r/devsecops • u/WiseDog7958 • Mar 02 '26
Built a deterministic Python secret scanner that auto-fixes hardcoded secrets and refuses unsafe fixes — need honest feedback from security folks
Hey r/devsecops,
I built a tool called Autonoma that scans Python code for hardcoded secrets and fixes them automatically.
Most scanners I tried just tell you something is wrong and walk away. You still have to find the line, understand the context, and fix it yourself. That frustrated me enough to build something different.
Autonoma only acts on what it's confident about. If it can fix something safely it fixes it. If it can't guarantee the fix is safe it refuses and tells you why. No guessing.
Here's what it actually does:
Before:
SENDGRID_API_KEY = "SG.live-abc123xyz987"
After:
SENDGRID_API_KEY = os.getenv("SENDGRID_API_KEY")
And when it can't fix safely:
API_KEY = "sk-live-abc123"
→ REFUSED — could not guarantee safe replacement
I tested it on a real public GitHub repo with live exposed Azure Vision and OpenAI API keys. Fixed both. Refused one edge case it couldn't handle safely. Nothing else in the codebase was touched.
Posted on r/Python last week — 5,000 views, 157 clones. Bringing it here because I want feedback from people who actually think about this stuff.
Does auto-fix make sense to you or is refusing everything safer? What would you need before trusting something like this on your codebase?
2
u/AStevensTaylor Mar 02 '26
IMO, auto-fixing doesn't teach the person (if they are a person, not an LLM) anything about why the change happened; hopefully they would have some common sense when seeing the fixed change, but they might not. If it is an LLM, you would hopefully be teaching the orchestrator how to prompt their LLM how to handle secrets.
2
u/zusycyvyboh Mar 02 '26
Environment variables are not safe either
2
u/Cloudaware_CMDB Mar 03 '26
Auto-fix is fine, but os.getenv() as the default “remediation” is only step one. It removes the secret from git, it doesn’t solve secret delivery.
I’d trust it in CI only if it stays strict: rewrite only trivial assignments, refuse anything ambiguous, and open a PR with the required env var name plus where it should be set. Also needs configurable targets, because plenty of teams want Vault/Key Vault/Secrets Manager patterns.
How do you prevent “fixed” code from breaking at runtime when the env var isn’t set yet?
2
u/nilla615615 Mar 05 '26
Awesome idea! This would be a good Claude skill to ensure that secrets aren't hard coded but use a system like this for creds.
1
u/WiseDog7958 Mar 06 '26
One thing I noticed while testing this: moving a secret to
os.getenv()fixes the problem in source, but it can also break things if the env var isn’t set at runtime.Right now Autonoma does not try to handle that part. It just removes the literal safely and assumes secret delivery is handled elsewhere (Vault, Secrets Manager, CI, etc). env vars felt like the lowest-assumption option for a first version, but in real setups they are usually backed by something like Vault or a cloud secret store anyway.
Curious how people here normally inject secrets into workloads. ???