semgrep: Enforce no loop vars in goroutines (#17145)
This commit is contained in:
parent
f4fa806489
commit
9cb852d099
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
|
Loading…
Reference in New Issue
Block a user