Skip to content

Commit 2907593

Browse files
authored
Remove gosec from test linting (#4471)
1 parent eb2358a commit 2907593

File tree

22 files changed

+78
-78
lines changed

22 files changed

+78
-78
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ linters:
238238
# 4. Exclude any file suffixed with _test.go.
239239
- path: "(^tests/)|(^(.*/)*test_[^/]*\\.go$)|(.*test/.*)|(.*_test\\.go$)"
240240
linters:
241+
- gosec
241242
- prealloc
242243
formatters:
243244
enable:

snow/networking/sender/sender_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func TestReliableMessages(t *testing.T) {
457457
vdrIDs := set.Of(ids.BuildTestNodeID([]byte{1}))
458458

459459
sender.SendPullQuery(t.Context(), vdrIDs, uint32(i), ids.Empty, 0)
460-
time.Sleep(time.Duration(rand.Float64() * float64(time.Microsecond))) // #nosec G404
460+
time.Sleep(time.Duration(rand.Float64() * float64(time.Microsecond)))
461461
}
462462
}()
463463

tests/fixture/tmpnet/process_runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (p *ProcessRuntime) Start(ctx context.Context) error {
121121
}
122122

123123
// All arguments are provided in the flags file
124-
cmd := exec.Command(runtimeConfig.AvalancheGoPath, "--config-file", p.node.GetFlagsPath()) // #nosec G204
124+
cmd := exec.Command(runtimeConfig.AvalancheGoPath, "--config-file", p.node.GetFlagsPath())
125125
// Ensure process is detached from the parent process so that an error in the parent will not affect the child
126126
configureDetachedProcess(cmd)
127127

utils/bag/bag_benchmark_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func BenchmarkBagListSmall(b *testing.B) {
1313
smallLen := 5
1414
bag := Bag[int]{}
1515
for i := 0; i < smallLen; i++ {
16-
bag.Add(rand.Int()) // #nosec G404
16+
bag.Add(rand.Int())
1717
}
1818
b.ResetTimer()
1919
for n := 0; n < b.N; n++ {
@@ -26,7 +26,7 @@ func BenchmarkBagListMedium(b *testing.B) {
2626
mediumLen := 25
2727
bag := Bag[int]{}
2828
for i := 0; i < mediumLen; i++ {
29-
bag.Add(rand.Int()) // #nosec G404
29+
bag.Add(rand.Int())
3030
}
3131
b.ResetTimer()
3232

@@ -40,7 +40,7 @@ func BenchmarkBagListLarge(b *testing.B) {
4040
largeLen := 100000
4141
bag := Bag[int]{}
4242
for i := 0; i < largeLen; i++ {
43-
bag.Add(rand.Int()) // #nosec G404
43+
bag.Add(rand.Int())
4444
}
4545
b.ResetTimer()
4646
for n := 0; n < b.N; n++ {

utils/formatting/encoding_benchmark_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func BenchmarkEncodings(b *testing.B) {
5757
}
5858
for _, benchmark := range benchmarks {
5959
bytes := make([]byte, benchmark.size)
60-
_, _ = rand.Read(bytes) // #nosec G404
60+
_, _ = rand.Read(bytes)
6161
b.Run(fmt.Sprintf("%s-%d bytes", benchmark.encoding, benchmark.size), func(b *testing.B) {
6262
for n := 0; n < b.N; n++ {
6363
_, err := Encode(benchmark.encoding, bytes)

vms/platformvm/state/l1_validator_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ func TestL1Validator_immutableFieldsAreUnmodified(t *testing.T) {
8080
var (
8181
randomizeL1Validator = func(l1Validator L1Validator) L1Validator {
8282
// Randomize unrelated fields
83-
l1Validator.Weight = rand.Uint64() // #nosec G404
84-
l1Validator.MinNonce = rand.Uint64() // #nosec G404
85-
l1Validator.EndAccumulatedFee = rand.Uint64() // #nosec G404
83+
l1Validator.Weight = rand.Uint64()
84+
l1Validator.MinNonce = rand.Uint64()
85+
l1Validator.EndAccumulatedFee = rand.Uint64()
8686
return l1Validator
8787
}
8888
l1Validator = newL1Validator()
@@ -123,7 +123,7 @@ func TestL1Validator_immutableFieldsAreUnmodified(t *testing.T) {
123123
})
124124
t.Run("different startTime", func(t *testing.T) {
125125
v := randomizeL1Validator(l1Validator)
126-
v.StartTime = rand.Uint64() // #nosec G404
126+
v.StartTime = rand.Uint64()
127127
require.False(t, l1Validator.immutableFieldsAreUnmodified(v))
128128
})
129129
}
@@ -239,9 +239,9 @@ func newL1Validator() L1Validator {
239239
PublicKey: utils.RandomBytes(bls.PublicKeyLen),
240240
RemainingBalanceOwner: utils.RandomBytes(32),
241241
DeactivationOwner: utils.RandomBytes(32),
242-
StartTime: rand.Uint64(), // #nosec G404
243-
Weight: rand.Uint64(), // #nosec G404
244-
MinNonce: rand.Uint64(), // #nosec G404
245-
EndAccumulatedFee: rand.Uint64(), // #nosec G404
242+
StartTime: rand.Uint64(),
243+
Weight: rand.Uint64(),
244+
MinNonce: rand.Uint64(),
245+
EndAccumulatedFee: rand.Uint64(),
246246
}
247247
}

vms/platformvm/state/state_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,6 @@ func TestPutAndGetFeeState(t *testing.T) {
14631463
require.NoError(err)
14641464
require.Equal(gas.State{}, defaultFeeState)
14651465

1466-
//nolint:gosec // This does not require a secure random number generator
14671466
expectedFeeState := gas.State{
14681467
Capacity: gas.Gas(rand.Uint64()),
14691468
Excess: gas.Gas(rand.Uint64()),

vms/proposervm/proposer/windower_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func TestDelayChangeByChain(t *testing.T) {
143143
require := require.New(t)
144144

145145
source := rand.NewSource(int64(0))
146-
rng := rand.New(source) // #nosec G404
146+
rng := rand.New(source)
147147

148148
chainID0 := ids.Empty
149149
_, err := rng.Read(chainID0[:])
@@ -216,7 +216,7 @@ func TestExpectedProposerChangeByChain(t *testing.T) {
216216
require := require.New(t)
217217

218218
source := rand.NewSource(int64(0))
219-
rng := rand.New(source) // #nosec G404
219+
rng := rand.New(source)
220220

221221
chainID0 := ids.Empty
222222
_, err := rng.Read(chainID0[:])

wallet/chain/p/builder/builder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func generateUTXOs(random *rand.Rand, assetID ids.ID, locktime uint64) []*avax.U
5252
func TestSplitByLocktime(t *testing.T) {
5353
seed := time.Now().UnixNano()
5454
t.Logf("Seed: %d", seed)
55-
random := rand.New(rand.NewSource(seed)) // #nosec G404
55+
random := rand.New(rand.NewSource(seed))
5656

5757
var (
5858
require = require.New(t)
@@ -84,7 +84,7 @@ func TestSplitByLocktime(t *testing.T) {
8484
func TestByAssetID(t *testing.T) {
8585
seed := time.Now().UnixNano()
8686
t.Logf("Seed: %d", seed)
87-
random := rand.New(rand.NewSource(seed)) // #nosec G404
87+
random := rand.New(rand.NewSource(seed))
8888

8989
var (
9090
require = require.New(t)

x/merkledb/codec_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,22 +489,22 @@ func FuzzCodecDBNodeDeterministic(f *testing.F) {
489489
) {
490490
require := require.New(t)
491491
for _, bf := range validBranchFactors {
492-
r := rand.New(rand.NewSource(int64(randSeed))) // #nosec G404
492+
r := rand.New(rand.NewSource(int64(randSeed)))
493493

494494
value := maybe.Nothing[[]byte]()
495495
if hasValue {
496496
value = maybe.Some(valueBytes)
497497
}
498498

499-
numChildren := r.Intn(int(bf)) // #nosec G404
499+
numChildren := r.Intn(int(bf))
500500

501501
children := map[byte]*child{}
502502
for i := 0; i < numChildren; i++ {
503503
var childID ids.ID
504-
_, _ = r.Read(childID[:]) // #nosec G404
504+
_, _ = r.Read(childID[:])
505505

506-
childKeyBytes := make([]byte, r.Intn(32)) // #nosec G404
507-
_, _ = r.Read(childKeyBytes) // #nosec G404
506+
childKeyBytes := make([]byte, r.Intn(32))
507+
_, _ = r.Read(childKeyBytes)
508508

509509
children[byte(i)] = &child{
510510
compressedKey: ToKey(childKeyBytes),

0 commit comments

Comments
 (0)