SemGrep rule to identify direct uses of crypto/rand.Reader and recommend the use of the SecureRandomReader instead (#6330)

* semgrep rules for crypto/rand added

* error fixed

* semgrep rules for crypto/rand added

* error fixed

* requested changes updated

* requested changes added

* Ent exclude files added
pull/6391/head
Abhishek Manjegowda 3 months ago committed by GitHub
parent 429247f407
commit 81c9ef0204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,33 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
rules:
- id: avoid-crypto-rand-use-secure-reader
languages:
- go
severity: WARNING
message: |
The 'crypto/rand' package is being used directly.
To ensure consistent security patterns across our codebase,
please use 'SecureRandomReader' instead.
patterns:
- pattern: |
rand.Reader
- pattern-inside: |
import "crypto/rand"
...
paths:
exclude:
- "*_test.go"
- "**/website/*"
- "**/testing/*"
- "options.go"
- "testing.go"
- "controller.go"
- "servers.go"
- "worker.go"
- "repository_scope.go"
- "keys.go"
- "testing_ent.go"
- "options_ent.go"
fix: Use SecureRandomReader instead of crypto/rand.Reader directly.
Loading…
Cancel
Save