mcp-server-semgrep
Version:
MCP Server for Semgrep Integration - static code analysis with AI
34 lines (33 loc) • 1.04 kB
YAML
rules:
- id: dangerous-annotations-usage
patterns:
- pattern: |
$C.__annotations__[$NAME] = $X
- pattern-not: |
$C.__annotations__[$NAME] = "..."
- pattern-not: |
$C.__annotations__[$NAME] = typing.$Y
- metavariable-regex:
metavariable: $X
regex: (?!(int|float|complex|list|tuple|range|str|bytes|bytearray|memoryview|set|frozenset|dict))
message: Annotations passed to `typing.get_type_hints` are evaluated in `globals` and `locals` namespaces.
Make sure that no arbitrary value can be written as the annotation and passed to `typing.get_type_hints`
function.
severity: INFO
metadata:
cwe:
- "CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection')"
owasp:
- A03:2021 - Injection
category: security
references:
- https://docs.python.org/3/library/typing.html#typing.get_type_hints
technology:
- python
subcategory:
- audit
likelihood: LOW
impact: LOW
confidence: LOW
languages:
- python