Skip to content

Commit 6945820

Browse files
NR-405078 : update go.mod version from go1.22 to go1.24 (#2042)
* NR-405078 : update go.mod version from go1.22 to go1.24 * fix version * fix version in dockerfiles * linter test * fix os.Lstat() changes to identify junction or symlink * fix windows setpriority * update comments
1 parent ac83457 commit 6945820

File tree

19 files changed

+54
-70
lines changed

19 files changed

+54
-70
lines changed

.golangci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ run:
88

99
# # all available settings of specific linters
1010
linters-settings:
11-
govet:
12-
# report about shadowed variables
13-
check-shadowing: true
11+
# Use shadow linter instead of govet check-shadowing
12+
shadow: true
13+
1414
misspell:
1515
ignore-words:
1616
- newrelic

Makefile.Common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ALL_SRC := $(shell find . -name '*.go' -not -path '*/vendor/*' -type f)
22

33
GOTOOLS ?=
4-
GOTOOLS += " github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.0"
4+
GOTOOLS += " github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8"
55
GOTOOLS += " go.elastic.co/go-licence-detector@v0.5.0"
66
GOTOOLS += " github.com/google/addlicense@04bfe4ee9ca5764577b029acc6a1957fd1997153"
77

build/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
FROM ubuntu:16.04
33

44
# Define Go version
5-
ARG GO_VERSION=1.22.10
5+
ARG GO_VERSION=1.24.2
66
# Define build-time arguments for the GitHub CLI version and architecture
77
ARG GH_VERSION='2.0.0'
88
ARG GH_ARCH='amd64'
@@ -33,7 +33,7 @@ RUN apt-get update && apt-get install -y \
3333
# RUN apt-get install -y \
3434
# gcc-5-multilib-mips-linux-gnu
3535

36-
# Install Go 1.22.0
36+
# Install Go 1.24.2
3737
RUN curl -sSL https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz -o go${GO_VERSION}.linux-amd64.tar.gz && \
3838
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
3939
rm go${GO_VERSION}.linux-amd64.tar.gz

go.mod

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/newrelic/infrastructure-agent
22

3-
go 1.22
3+
go 1.24
44

55
require (
66
github.com/Microsoft/go-winio v0.6.1
@@ -45,7 +45,6 @@ require (
4545
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
4646
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect
4747
github.com/Microsoft/hcsshim v0.11.4 // indirect
48-
github.com/andybalholm/brotli v1.0.5 // indirect
4948
github.com/containerd/cgroups v1.1.0 // indirect
5049
github.com/containerd/continuity v0.4.2 // indirect
5150
github.com/containerd/fifo v1.1.0 // indirect
@@ -62,7 +61,6 @@ require (
6261
github.com/go-ole/go-ole v1.2.6 // indirect
6362
github.com/godbus/dbus/v5 v5.1.0 // indirect
6463
github.com/gogo/protobuf v1.3.2 // indirect
65-
github.com/golang/protobuf v1.5.4 // indirect
6664
github.com/google/go-cmp v0.6.0 // indirect
6765
github.com/google/uuid v1.6.0 // indirect
6866
github.com/jmespath/go-jmespath v0.4.0 // indirect
@@ -85,8 +83,6 @@ require (
8583
github.com/stretchr/objx v0.5.2 // indirect
8684
github.com/tklauser/go-sysconf v0.3.12 // indirect
8785
github.com/tklauser/numcpus v0.6.1 // indirect
88-
github.com/valyala/bytebufferpool v1.0.0 // indirect
89-
github.com/valyala/fasthttp v1.49.0 // indirect
9086
github.com/yusufpapurcu/wmi v1.2.4 // indirect
9187
go.opencensus.io v0.24.0 // indirect
9288
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
@@ -99,7 +95,6 @@ require (
9995
golang.org/x/sync v0.10.0 // indirect
10096
golang.org/x/text v0.21.0 // indirect
10197
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
102-
google.golang.org/appengine v1.6.7 // indirect
10398
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect
10499
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
105100
google.golang.org/grpc v1.65.0 // indirect

go.sum

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7
1313
github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w=
1414
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
1515
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
16-
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
17-
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
1816
github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=
1917
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
2018
github.com/aws/aws-sdk-go v1.44.69 h1:3A3DEizrCK6dAbBoRGh8KmoZij7She9snclG1ixY/xQ=
@@ -86,7 +84,6 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l
8684
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
8785
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
8886
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
89-
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
9087
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
9188
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
9289
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
@@ -97,9 +94,6 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
9794
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
9895
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
9996
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
100-
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
101-
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
102-
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
10397
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
10498
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
10599
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@@ -115,8 +109,6 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
115109
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
116110
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
117111
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
118-
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
119-
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
120112
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
121113
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
122114
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
@@ -159,8 +151,6 @@ github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
159151
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
160152
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
161153
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
162-
github.com/newrelic/go-agent/v3 v3.27.0 h1:Z3XB49d8FKjRcGzCyViCO9itBxiLPSpwjY1HlMvgamQ=
163-
github.com/newrelic/go-agent/v3 v3.27.0/go.mod h1:TUzePinDc0BMH4Sui66rl4SBe6yOKJ5X/bRJekwuAtM=
164154
github.com/newrelic/go-agent/v3 v3.36.0 h1:PdvJZiUu45qg2qrOeia0gYr1vaZ2Ro6QIlqlgHObHXo=
165155
github.com/newrelic/go-agent/v3 v3.36.0/go.mod h1:GNTda53CohAhkgsc7/gqSsJhDZjj8vaky5u+vKz7wqM=
166156
github.com/newrelic/infra-identity-client-go v1.0.2 h1:RxkHAFOqeiBkW/fXvzkp3uORPl6crFt4I/zf4dCUFKM=
@@ -216,10 +206,6 @@ github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFA
216206
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
217207
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
218208
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
219-
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
220-
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
221-
github.com/valyala/fasthttp v1.49.0 h1:9FdvCpmxB74LH4dPb7IJ1cOSsluR07XG3I1txXWwJpE=
222-
github.com/valyala/fasthttp v1.49.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA=
223209
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
224210
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
225211
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
@@ -263,7 +249,6 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r
263249
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
264250
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
265251
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
266-
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
267252
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
268253
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
269254
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
@@ -273,8 +258,6 @@ golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
273258
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
274259
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
275260
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
276-
golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8=
277-
golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI=
278261
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
279262
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
280263
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -309,7 +292,6 @@ golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
309292
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
310293
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
311294
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
312-
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
313295
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
314296
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
315297
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
@@ -332,18 +314,14 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
332314
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
333315
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
334316
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
335-
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
336-
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
337317
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
338318
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
339319
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
340320
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
341321
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g=
342322
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0=
343-
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw=
344-
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
345-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
346-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
323+
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
324+
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
347325
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8=
348326
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
349327
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
@@ -352,8 +330,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
352330
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
353331
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
354332
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
355-
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
356-
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
357333
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
358334
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
359335
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
@@ -366,10 +342,7 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
366342
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
367343
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
368344
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
369-
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
370345
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
371-
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
372-
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
373346
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
374347
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
375348
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

internal/agent/delta/last_entityId_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ package delta
55

66
import (
77
"fmt"
8-
"github.com/newrelic/infrastructure-agent/pkg/entity"
9-
"github.com/stretchr/testify/assert"
10-
"github.com/stretchr/testify/require"
118
"io/ioutil"
129
"os"
1310
"path/filepath"
1411
"testing"
12+
13+
"github.com/newrelic/infrastructure-agent/pkg/entity"
14+
"github.com/stretchr/testify/assert"
15+
"github.com/stretchr/testify/require"
1516
)
1617

1718
func TestEntityIDFilePersist_RetrieveStoredValue(t *testing.T) {
@@ -50,7 +51,7 @@ func TestEntityIDFilePersist_ErrWhenReadingFile(t *testing.T) {
5051

5152
le := &EntityIDFilePersist{
5253
readFile: func(path string) (entity.ID, error) {
53-
return entity.EmptyID, fmt.Errorf(expectedMessage)
54+
return entity.EmptyID, fmt.Errorf("%v", expectedMessage)
5455
},
5556
}
5657

@@ -81,7 +82,7 @@ func TestEntityIDFilePersist_ErrWhenWritingFile(t *testing.T) {
8182

8283
le := &EntityIDFilePersist{
8384
writeFile: func(id entity.ID, filePath string) error {
84-
return fmt.Errorf(expectedErrMessage)
85+
return fmt.Errorf("%v", expectedErrMessage)
8586
},
8687
}
8788

internal/integrations/v4/executor/executor_windows.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ package executor
55
import (
66
"context"
77
"fmt"
8-
"golang.org/x/sys/windows"
98
"os/exec"
10-
"unsafe"
9+
10+
"golang.org/x/sys/windows"
1111
)
1212

1313
// userAwareCmd returns a cancellable Cmd struct to execute the given command with the provided
@@ -22,6 +22,7 @@ func startProcess(cmd *exec.Cmd) error {
2222
if err != nil {
2323
return err
2424
}
25+
2526
err = setPriorityClass(cmd)
2627
if err != nil {
2728
illog.WithError(err).WithField("command", cmd.String()).Error("cannot set priority class to process")
@@ -52,11 +53,13 @@ func processHandle(cmd *exec.Cmd) (windows.Handle, error) {
5253
return handle, fmt.Errorf("process cannot be nil pointer")
5354
}
5455

55-
// Using unsafe operation we are using the handle inside os.Process.
56-
handle = (*struct {
57-
pid int
58-
handle windows.Handle
59-
})(unsafe.Pointer(cmd.Process)).handle
56+
// Avoid Unsafe handle access to obtain a fresh, valid handle for the process
57+
// Add nolint to avoid G115 false positive (the tool has flagged a potential integer overflow issue when it actually doesn't exist)
58+
handle, err := windows.OpenProcess(windows.PROCESS_SET_INFORMATION|windows.PROCESS_QUERY_INFORMATION, false, uint32(cmd.Process.Pid)) //nolint:gosec
59+
60+
if err != nil {
61+
return 0, fmt.Errorf("open process failed : %w", err) //nolint:wrapcheck
62+
}
6063

6164
return handle, nil
6265
}

internal/integrations/v4/executor/executor_windows_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ package executor
99

1010
import (
1111
"context"
12+
"testing"
13+
1214
"github.com/newrelic/infrastructure-agent/internal/integrations/v4/fixtures"
1315
"github.com/newrelic/infrastructure-agent/internal/integrations/v4/testhelp"
1416
"github.com/stretchr/testify/assert"
1517
"golang.org/x/sys/windows"
16-
"testing"
1718
)
1819

1920
const (

pkg/disk/disk_windows.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"os"
1010
"path/filepath"
1111
"syscall"
12+
13+
"golang.org/x/sys/windows"
1214
)
1315

1416
// WriteFile writes data to a file named by filename. For more info, see ioutil.Writefile.
@@ -114,11 +116,18 @@ func checkSafeDir(dirPath string) error {
114116
}
115117

116118
for folder != child { // While we don't reach the drive letter
117-
stat, err := os.Lstat(folder)
119+
_, err := os.Lstat(folder)
118120
if err != nil {
119121
return err
120122
}
121-
if stat.Mode()&os.ModeSymlink != 0 {
123+
124+
attrs, err := windows.GetFileAttributes(windows.StringToUTF16Ptr(folder))
125+
126+
if err != nil {
127+
return err
128+
}
129+
130+
if attrs&windows.FILE_ATTRIBUTE_REPARSE_POINT != 0 {
122131
return fmt.Errorf("junctions and symlinks are not allowed: %s", folder)
123132
}
124133
child = folder

pkg/entity/register/worker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (w *worker) send(ctx context.Context, batch map[entity.Key]fwrequest.Entity
130130
for _, resp := range responses {
131131
if resp.ErrorMsg != "" {
132132
if w.config.VerboseLogLevel > 0 {
133-
wlog.WithError(fmt.Errorf(resp.ErrorMsg)).
133+
wlog.WithError(fmt.Errorf("%v", resp.ErrorMsg)).
134134
WithField("entityName", resp.Name).
135135
Errorf("failed to register entity")
136136
}
@@ -140,7 +140,7 @@ func (w *worker) send(ctx context.Context, batch map[entity.Key]fwrequest.Entity
140140

141141
if w.config.VerboseLogLevel > 0 && len(resp.Warnings) > 0 {
142142
for _, warn := range resp.Warnings {
143-
wlog.WithError(fmt.Errorf(warn)).
143+
wlog.WithError(fmt.Errorf("%v", warn)).
144144
WithField("entityName", resp.Name).
145145
WithField("entityID", resp.ID).
146146
Warn("entity registered with warnings")

0 commit comments

Comments
 (0)