Scan Python code for ten AST security issues: eval/exec, shell=True, pickle, unsafe yaml, weak hashes, disabled TLS, hardcoded secrets, SQL built from strings, mktemp, debug=True. Use when the user asks for a security scan or SARIF.
92%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Medium
Suggest reviewing before use
Static security scan for Python source using the standard-library ast module. Ten rules
(PY001-PY010) plus PY000 for files that cannot be parsed. Import aliases are resolved
(import subprocess as sp is still caught). Output is text or SARIF 2.1.0.
It analyses Python only and does not follow data flow across functions or files. For other languages or deep taint analysis, say so instead of claiming coverage.
Run the scanner on the paths in scope (no installation needed, Python 3.10+):
python3 scripts/sast_scan.py src/ app.py
python3 scripts/sast_scan.py . --format sarif --output scan.sarif
python3 scripts/sast_scan.py src/ --min-severity highRead each finding as path:line:column: [SEVERITY] RULE: message. Open the line and decide
whether it is a real risk in context.
Fix real findings with the safe alternative listed in references/rules.md. Prefer changing
the code over suppressing the finding.
Re-run the same command and confirm the finding is gone and no new one appeared.
If a finding is a justified false positive, add # nosast: PY00X on that line with a reason
in the commit message or a neighbouring comment. A bare # nosast silences every rule on the
line, so name the rule id.
| Code | Meaning |
|---|---|
| 0 | No findings |
| 1 | At least one finding was detected (counted before --min-severity filtering) |
| 2 | Usage error, missing path, or file limit exceeded |
| Id | Severity | Detects |
|---|---|---|
| PY000 | low | File could not be parsed, read or is too large |
| PY001 | high | eval / exec |
| PY002 | high | shell=True in subprocess calls, os.system, os.popen |
| PY003 | high | pickle, marshal, shelve loading |
| PY004 | high | yaml.load without a safe Loader= keyword |
| PY005 | medium | MD5 / SHA-1 unless usedforsecurity=False |
| PY006 | high | verify=False in requests, ssl._create_unverified_context |
| PY007 | medium | Non-empty string assigned to a password, secret, token or api_key name |
| PY008 | high | SQL built with f-string, .format, % or + passed to execute |
| PY009 | medium | tempfile.mktemp |
| PY010 | medium | .run(debug=True) |
Details, vulnerable and safe examples: references/rules.md.
Options, suppression syntax, SARIF notes and limits: references/usage.md.
Summarise by severity, list each finding with file and line, state what was fixed and what was suppressed and why, and note the scope limits above. Never paste a secret value into the report: PY007 findings name the variable, not its content.