Skip to content

Commit b0828f2

Browse files
faddatPantani
andauthoredAug 5, 2024··
chore: enable gosec linter (#4161)
* gosec * gosec * secure use of tar files * fix lint issues * fix tests --------- Co-authored-by: Danilo Pantani <[email protected]>
1 parent 3152cf5 commit b0828f2

File tree

31 files changed

+123
-85
lines changed

31 files changed

+123
-85
lines changed
 

‎.golangci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ linters:
2020
- godot
2121
- gofumpt
2222
- revive
23+
- gosec
2324
- gosimple
2425
- govet
2526
- grouper

‎ignite/cmd/account_export.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func accountExportHandler(cmd *cobra.Command, args []string) error {
6161
return err
6262
}
6363

64-
if err := os.WriteFile(path, []byte(armored), 0o644); err != nil {
64+
if err := os.WriteFile(path, []byte(armored), 0o600); err != nil {
6565
return err
6666
}
6767

‎ignite/cmd/chain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func toolsMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, app
187187
return err
188188
}
189189

190-
return os.WriteFile(toolsFilename, buf.Bytes(), 0o644)
190+
return os.WriteFile(toolsFilename, buf.Bytes(), 0o600)
191191
}
192192

193193
func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath, protoDir string) error {

‎ignite/internal/analytics/analytics.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func checkDNT() (anonIdentity, error) {
151151
return i, err
152152
}
153153

154-
return i, os.WriteFile(identityPath, data, 0o700)
154+
return i, os.WriteFile(identityPath, data, 0o600)
155155
}
156156

157157
func getIsCI() bool {

‎ignite/internal/plugin/testdata/execute_fail/go.mod

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
2525
github.com/cockroachdb/redact v1.1.5 // indirect
2626
github.com/cosmos/btcutil v1.0.5 // indirect
27-
github.com/cosmos/cosmos-sdk v0.50.7 // indirect
27+
github.com/cosmos/cosmos-sdk v0.50.8 // indirect
2828
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
2929
github.com/emirpasic/gods v1.18.1 // indirect
3030
github.com/fatih/color v1.16.0 // indirect
@@ -81,17 +81,17 @@ require (
8181
github.com/spf13/pflag v1.0.5 // indirect
8282
github.com/xanzy/ssh-agent v0.3.3 // indirect
8383
go.etcd.io/bbolt v1.3.9 // indirect
84-
golang.org/x/crypto v0.23.0 // indirect
84+
golang.org/x/crypto v0.24.0 // indirect
8585
golang.org/x/mod v0.17.0 // indirect
86-
golang.org/x/net v0.25.0 // indirect
86+
golang.org/x/net v0.26.0 // indirect
8787
golang.org/x/sync v0.7.0 // indirect
88-
golang.org/x/sys v0.20.0 // indirect
89-
golang.org/x/term v0.20.0 // indirect
90-
golang.org/x/text v0.15.0 // indirect
91-
golang.org/x/tools v0.21.0 // indirect
88+
golang.org/x/sys v0.21.0 // indirect
89+
golang.org/x/term v0.21.0 // indirect
90+
golang.org/x/text v0.16.0 // indirect
91+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
9292
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
9393
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
94-
google.golang.org/grpc v1.64.0 // indirect
94+
google.golang.org/grpc v1.64.1 // indirect
9595
google.golang.org/protobuf v1.34.1 // indirect
9696
gopkg.in/warnings.v0 v0.1.2 // indirect
9797
gopkg.in/yaml.v3 v3.0.1 // indirect

‎ignite/internal/plugin/testdata/execute_ok/go.mod

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
2525
github.com/cockroachdb/redact v1.1.5 // indirect
2626
github.com/cosmos/btcutil v1.0.5 // indirect
27-
github.com/cosmos/cosmos-sdk v0.50.7 // indirect
27+
github.com/cosmos/cosmos-sdk v0.50.8 // indirect
2828
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
2929
github.com/emirpasic/gods v1.18.1 // indirect
3030
github.com/fatih/color v1.16.0 // indirect
@@ -81,17 +81,17 @@ require (
8181
github.com/spf13/pflag v1.0.5 // indirect
8282
github.com/xanzy/ssh-agent v0.3.3 // indirect
8383
go.etcd.io/bbolt v1.3.9 // indirect
84-
golang.org/x/crypto v0.23.0 // indirect
84+
golang.org/x/crypto v0.24.0 // indirect
8585
golang.org/x/mod v0.17.0 // indirect
86-
golang.org/x/net v0.25.0 // indirect
86+
golang.org/x/net v0.26.0 // indirect
8787
golang.org/x/sync v0.7.0 // indirect
88-
golang.org/x/sys v0.20.0 // indirect
89-
golang.org/x/term v0.20.0 // indirect
90-
golang.org/x/text v0.15.0 // indirect
91-
golang.org/x/tools v0.21.0 // indirect
88+
golang.org/x/sys v0.21.0 // indirect
89+
golang.org/x/term v0.21.0 // indirect
90+
golang.org/x/text v0.16.0 // indirect
91+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
9292
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
9393
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
94-
google.golang.org/grpc v1.64.0 // indirect
94+
google.golang.org/grpc v1.64.1 // indirect
9595
google.golang.org/protobuf v1.34.1 // indirect
9696
gopkg.in/warnings.v0 v0.1.2 // indirect
9797
gopkg.in/yaml.v3 v3.0.1 // indirect

‎ignite/internal/tools/gen-config-doc/go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ require (
6161
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d // indirect
6262
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e // indirect
6363
github.com/spf13/pflag v1.0.5 // indirect
64-
golang.org/x/net v0.25.0 // indirect
65-
golang.org/x/sys v0.20.0 // indirect
66-
golang.org/x/term v0.20.0 // indirect
67-
golang.org/x/text v0.15.0 // indirect
64+
golang.org/x/net v0.26.0 // indirect
65+
golang.org/x/sys v0.21.0 // indirect
66+
golang.org/x/term v0.21.0 // indirect
67+
golang.org/x/text v0.16.0 // indirect
6868
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
6969
gopkg.in/yaml.v3 v3.0.1 // indirect
7070
)

‎ignite/internal/tools/gen-config-doc/go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfS
195195
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
196196
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
197197
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
198+
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
198199
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
199200
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
200201
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -220,19 +221,22 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
220221
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
221222
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
222223
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
224+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
223225
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
224226
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
225227
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
226228
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
227229
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
228230
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
231+
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
229232
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
230233
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
231234
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
232235
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
233236
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
234237
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
235238
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
239+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
236240
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
237241
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
238242
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=

‎ignite/internal/tools/gen-mig-diffs/go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ require (
7979
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e // indirect
8080
github.com/spf13/pflag v1.0.5 // indirect
8181
github.com/xanzy/ssh-agent v0.3.3 // indirect
82-
golang.org/x/crypto v0.23.0 // indirect
82+
golang.org/x/crypto v0.24.0 // indirect
8383
golang.org/x/mod v0.17.0 // indirect
84-
golang.org/x/net v0.25.0 // indirect
84+
golang.org/x/net v0.26.0 // indirect
8585
golang.org/x/sync v0.7.0 // indirect
86-
golang.org/x/sys v0.20.0 // indirect
87-
golang.org/x/term v0.20.0 // indirect
88-
golang.org/x/text v0.15.0 // indirect
89-
golang.org/x/tools v0.21.0 // indirect
86+
golang.org/x/sys v0.21.0 // indirect
87+
golang.org/x/term v0.21.0 // indirect
88+
golang.org/x/text v0.16.0 // indirect
89+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
9090
gopkg.in/warnings.v0 v0.1.2 // indirect
9191
gopkg.in/yaml.v3 v3.0.1 // indirect
9292
)

‎ignite/internal/tools/gen-mig-diffs/go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
226226
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
227227
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
228228
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
229+
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
229230
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
230231
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
231232
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@@ -247,6 +248,7 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
247248
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
248249
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
249250
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
251+
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
250252
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
251253
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
252254
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -278,6 +280,7 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
278280
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
279281
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
280282
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
283+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
281284
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
282285
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
283286
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -286,6 +289,7 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
286289
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
287290
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
288291
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
292+
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
289293
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
290294
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
291295
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -295,6 +299,7 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
295299
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
296300
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
297301
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
302+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
298303
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
299304
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
300305
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -303,6 +308,7 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
303308
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
304309
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
305310
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
311+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
306312
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
307313
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
308314
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

‎ignite/pkg/availableport/availableport.go

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
package availableport
22

33
import (
4+
"crypto/rand"
45
"fmt"
5-
"math/rand"
6+
"math/big"
67
"net"
7-
"time"
88

99
"github.com/ignite/cli/v29/ignite/pkg/errors"
1010
)
1111

1212
type availablePortOptions struct {
13-
randomizer *rand.Rand
14-
minPort uint
15-
maxPort uint
13+
minPort uint
14+
maxPort uint
1615
}
1716

1817
type Options func(o *availablePortOptions)
1918

20-
func WithRandomizer(r *rand.Rand) Options {
21-
return func(o *availablePortOptions) {
22-
o.randomizer = r
23-
}
24-
}
25-
2619
func WithMaxPort(maxPort uint) Options {
2720
return func(o *availablePortOptions) {
2821
o.maxPort = maxPort
@@ -41,9 +34,8 @@ func WithMinPort(minPort uint) Options {
4134
func Find(n uint, options ...Options) (ports []uint, err error) {
4235
// Defining them before so we can set a value depending on the AvailablePortOptions
4336
opts := availablePortOptions{
44-
minPort: 44000,
45-
maxPort: 55000,
46-
randomizer: rand.New(rand.NewSource(time.Now().UnixNano())),
37+
minPort: 44000,
38+
maxPort: 55000,
4739
}
4840

4941
for _, apply := range options {
@@ -64,8 +56,9 @@ func Find(n uint, options ...Options) (ports []uint, err error) {
6456
for len(registered) < int(n) {
6557
// Greater or equal to min and lower than max
6658
totalPorts := opts.maxPort - opts.minPort + 1
67-
randomPort := opts.randomizer.Intn(int(totalPorts))
68-
port := uint(randomPort) + opts.minPort
59+
60+
randomPort, _ := rand.Int(rand.Reader, big.NewInt(int64(totalPorts)))
61+
port := uint(randomPort.Uint64()) + opts.minPort
6962

7063
conn, err := net.Dial("tcp", fmt.Sprintf(":%d", port))
7164
// if there is an error, this might mean that no one is listening from this port

‎ignite/pkg/availableport/availableport_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package availableport_test
22

33
import (
4-
"math/rand"
54
"testing"
65

76
"github.com/stretchr/testify/require"
@@ -51,7 +50,6 @@ func TestFind(t *testing.T) {
5150
name: "with randomizer",
5251
n: 100,
5352
options: []availableport.Options{
54-
availableport.WithRandomizer(rand.New(rand.NewSource(2023))),
5553
availableport.WithMinPort(100),
5654
availableport.WithMaxPort(200),
5755
},

‎ignite/pkg/chaincmd/runner/chain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (r Runner) Export(ctx context.Context, exportedFile string) error {
240240
}
241241

242242
// Save the new state
243-
return os.WriteFile(exportedFile, exportedState, 0o644)
243+
return os.WriteFile(exportedFile, exportedState, 0o600)
244244
}
245245

246246
// EventSelector is used to query events.

‎ignite/pkg/checksum/checksum.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func Sum(dirPath, outPath string) error {
4242
}
4343
}
4444

45-
return os.WriteFile(outPath, b.Bytes(), 0o666)
45+
return os.WriteFile(outPath, b.Bytes(), 0o600)
4646
}
4747

4848
// Binary returns SHA256 hash of executable file, file is searched by name in PATH.

‎ignite/pkg/cmdrunner/cmdrunner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func (r *Runner) newCommand(step *step.Step) Executor {
233233
}
234234

235235
// Initialize command
236-
command := exec.Command(step.Exec.Command, step.Exec.Args...)
236+
command := exec.Command(step.Exec.Command, step.Exec.Args...) //nolint:gosec
237237
command.Stdout = stdout
238238
command.Stderr = stderr
239239
command.Dir = dir

‎ignite/pkg/cosmosgen/generate_openapi.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (g *generator) generateOpenAPISpec(ctx context.Context) error {
6565

6666
if !errors.Is(err, cache.ErrorNotFound) {
6767
specPath := filepath.Join(dir, specFilename)
68-
if err := os.WriteFile(specPath, existingSpec, 0o644); err != nil {
68+
if err := os.WriteFile(specPath, existingSpec, 0o600); err != nil {
6969
return err
7070
}
7171
return conf.AddSpec(name, specPath, true)

‎ignite/pkg/cosmosgen/sta.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ return createCustomOperationId(method, route, moduleName);
5454
// generateRouteNameFile generates the `route-name.eta` file.
5555
func generateRouteNameFile(outPath string) error {
5656
outTemplate := filepath.Join(outPath, "route-name.eta")
57-
return os.WriteFile(outTemplate, []byte(routeNameTemplate), 0o644)
57+
return os.WriteFile(outTemplate, []byte(routeNameTemplate), 0o600)
5858
}

‎ignite/pkg/dircache/cache_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,39 @@ func Test_cacheKey(t *testing.T) {
3030
args: args{
3131
src: wd,
3232
},
33-
want: "78f544d2184b8076ac527ba4728822de1a7fc77bf2d6a77e44d0193cb63ed26e",
33+
want: "4cf0539ac24f8ebc9ee17b81d0ea880e55d2ba98a4e355affe3c3f8a0cdb01ee",
3434
},
3535
{
3636
name: "one key",
3737
args: args{
3838
src: wd,
3939
keys: []string{"test"},
4040
},
41-
want: "5701099a1fcc67cd8b694295fbdecf537edcc8733bcc3adae0bdd7e65e28c8e5",
41+
want: "dc7b4e68b7b9d827b3833845202818a11a1105542a3551052c012d815a64e7ae",
4242
},
4343
{
4444
name: "two keys",
4545
args: args{
4646
src: wd,
4747
keys: []string{"test1", "test2"},
4848
},
49-
want: "6299c9bd405a1c073fa711006f8aadf6420cf522ef446e36fc01586354726095",
49+
want: "a017b975dd0a30efc7fbc515af9b3c37657c20a509fd5771111d4c0e43d373b0",
5050
},
5151
{
5252
name: "duplicated keys",
5353
args: args{
5454
src: wd,
5555
keys: []string{"test", "test"},
5656
},
57-
want: "b9eb1b01931deccc44a354ab5aeb52337a465e5559069eb35b71ea0cbfe3c87f",
57+
want: "26ce20a6c4563963fd646121948cd62137a143317c970a52a3ec8ed9979c868d",
5858
},
5959
{
6060
name: "many keys",
6161
args: args{
6262
src: wd,
6363
keys: []string{"test1", "test2", "test3", "test4", "test5", "test6", "test6"},
6464
},
65-
want: "bbe74cfd33ba4d1244e8d0ea3e430081d06ed55be12c7772d345d3117a4dfc90",
65+
want: "f9cd1468363ff902bdd5a93c9c7c43c83c9074796486306a7da046a082314121",
6666
},
6767
{
6868
name: "invalid source",

‎ignite/pkg/dirchange/dirchange.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dirchange
22

33
import (
44
"bytes"
5-
"crypto/md5"
5+
"crypto/sha256"
66
"os"
77
"path/filepath"
88

@@ -60,7 +60,7 @@ func HasDirChecksumChanged(checksumCache cache.Cache[[]byte], cacheKey string, w
6060
// ChecksumFromPaths computes the md5 checksum from the provided paths.
6161
// Relative paths to the workdir are used. If workdir is empty, string paths are absolute.
6262
func ChecksumFromPaths(workdir string, paths ...string) ([]byte, error) {
63-
hash := md5.New()
63+
hash := sha256.New()
6464

6565
// Can't compute hash if no file present
6666
noFile := true

0 commit comments

Comments
 (0)
Please sign in to comment.