CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

trysac/sast-rules-mini

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.

Quality

92%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Medium

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

SKILL.md

name:
sast-rules-mini
description:
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.

sast-rules-mini

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.

When to use

  • The user asks for a security review, a SAST pass or a "quick scan" of Python files or a repository.
  • The user wants SARIF output for a code scanning upload.
  • Before merging Python changes that touch subprocess calls, deserialisation, SQL, TLS or credentials.

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.

Workflow

  1. 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 high
  2. Read each finding as path:line:column: [SEVERITY] RULE: message. Open the line and decide whether it is a real risk in context.

  3. Fix real findings with the safe alternative listed in references/rules.md. Prefer changing the code over suppressing the finding.

  4. Re-run the same command and confirm the finding is gone and no new one appeared.

  5. 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.

Exit codes

CodeMeaning
0No findings
1At least one finding was detected (counted before --min-severity filtering)
2Usage error, missing path, or file limit exceeded

Rules at a glance

IdSeverityDetects
PY000lowFile could not be parsed, read or is too large
PY001higheval / exec
PY002highshell=True in subprocess calls, os.system, os.popen
PY003highpickle, marshal, shelve loading
PY004highyaml.load without a safe Loader= keyword
PY005mediumMD5 / SHA-1 unless usedforsecurity=False
PY006highverify=False in requests, ssl._create_unverified_context
PY007mediumNon-empty string assigned to a password, secret, token or api_key name
PY008highSQL built with f-string, .format, % or + passed to execute
PY009mediumtempfile.mktemp
PY010medium.run(debug=True)

Details, vulnerable and safe examples: references/rules.md. Options, suppression syntax, SARIF notes and limits: references/usage.md.

Reporting

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.

SKILL.md

tile.json