semgrep: Enforce no loop vars in goroutines (#17145)
This commit is contained in:
parent
2152a933ff
commit
d23b57ea4c
|
@ -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