1
0

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 f4fa806489
commit 9cb852d099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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