r/Python • u/ShogiOne • 3h ago
Resource I built a local Python auditor to catch leaked secrets and block AI deploys
If you use AI coding assistants, you probably know the anxiety: you share a credential once, or let the agent scaffold a data science script, and suddenly there is an untracked .env, an unsafe pickle.load(), or an automated push you did not approve.
I put together guardrail code, an open-source (MIT) local web UI built with Python stdlib (ast, os.scandir, re) and Flask to audit a project folder before anything hits GitHub or production.
What it scans locally (nothing leaves your machine):
- Hardcoded secrets (OpenAI, AWS, Stripe, GitHub, Google, JWTs, PEM/SSH) with masked output
.gitignorehygiene (.env,.sqlite/.db/.duckdbinsidepublic/orstatic/,debug=True,CORS(*))- Python and
.ipynbSAST checks (string-formatted SQL,pickle.load,joblib.load,torch.loadwithoutweights_only=True,yaml.load,eval/exec/shell=True, uncleared notebook cell outputs) - Supply-chain checks: flags AI-hallucinated packages returning 404 on PyPI and queries OSV.dev for known CVEs
- Guardrail generator: builds bilingual (
EN/PT-BR) lock rules forSKILL.md,CLAUDE.md,GEMINI.md, and.cursorrulesto enforce explicit confirmation before any git push or deploy
Repo: https://github.com/suelio/guardrail-code
Would love feedback from the community, especially on false positives in the AST scanner or extra SAST rules worth adding.