mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
semgrep: Enforce no loop vars in goroutines (#17145)
This commit is contained in:
28
tools/semgrep/ci/loopclosure.yml
Normal file
28
tools/semgrep/ci/loopclosure.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
rules:
|
||||
- id: loopclosure
|
||||
patterns:
|
||||
- pattern-inside: |
|
||||
for $A, $B := range $C {
|
||||
...
|
||||
}
|
||||
- pattern-inside: |
|
||||
go func() {
|
||||
...
|
||||
}()
|
||||
- pattern-not-inside: |
|
||||
go func(..., $B, ...) {
|
||||
...
|
||||
}(..., $B, ...)
|
||||
- pattern-not-inside: |
|
||||
go func() {
|
||||
...
|
||||
for ... {
|
||||
...
|
||||
}
|
||||
...
|
||||
}()
|
||||
- pattern: $B
|
||||
message: Loop variable $B used inside goroutine
|
||||
languages:
|
||||
- go
|
||||
severity: WARNING
|
||||
Reference in New Issue
Block a user