mcp-server-semgrep
Version:
MCP Server for Semgrep Integration - static code analysis with AI
30 lines (29 loc) • 919 B
YAML
rules:
- id: exported_loop_pointer
message: >-
`$VALUE` is a loop pointer that may be exported from the loop. This pointer is
shared between loop iterations, so the exported reference will always point to
the last loop value, which is likely unintentional. To fix, copy the pointer to
a new pointer within the loop.
metadata:
references:
- https://github.com/kyoh86/looppointer
category: correctness
technology:
- go
severity: WARNING
languages:
- go
pattern-either:
- pattern: |
for _, $VALUE := range $SOURCE {
<... &($VALUE) ...>
}
- pattern: |
for _, $VALUE := range $SOURCE {
<... func() { <... &$VALUE ...> } ...>
}
- pattern: |
for _, $VALUE := range $SOURCE {
<... $ANYTHING(..., <... &$VALUE ...>, ...) ...>
}