mcp-server-semgrep
Version:
MCP Server for Semgrep Integration - static code analysis with AI
47 lines (46 loc) • 1.09 kB
YAML
rules:
- id: suppressed-exception-handling-finally-break
patterns:
- pattern-either:
- pattern: |
try:
...
except $EXCEPTION:
...
finally:
...
break
- pattern: |
try:
...
except $EXCEPTION:
...
finally:
...
continue
- pattern: |
try:
...
except $EXCEPTION:
...
finally:
...
return ...
- pattern: |
try:
...
return ...
finally:
...
return ...
message: >-
Having a `break`, `continue`, or `return` in a `finally` block will cause strange behaviors, like exceptions not being caught.
metadata:
references:
- https://docs.python.org/3/reference/compound_stmts.html#the-try-statement
- https://www.python.org/dev/peps/pep-0601/#rejection-note
category: 'correctness'
technology:
- python
languages: [python]
severity: WARNING