semgrep: Enforce no loop vars in goroutines (#17145)

This commit is contained in:
Mike Palmiotto 2022-09-15 10:13:51 -04:00 committed by GitHub
parent 2152a933ff
commit d23b57ea4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 0 deletions

View 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