Stop Hardcoding Secrets: Scan Your .env Files in 1 Command
In 2025, GitGuardian found 12.8 million hardcoded secrets in public GitHub repos. API keys, private keys, passwords — all sitting in plain text for anyone to find. Don't be part of that statistic. The Problem
In 2025, GitGuardian found 12.8 million hardcoded secrets in public GitHub repos. API keys, private keys, passwords — all sitting in plain text for anyone to find.
Don't be part of that statistic.
The Problem
You create a .env file. You add API_KEY=sk-live-abc123.... You commit. You push. You're screwed.
# .env — DO NOT COMMIT THIS FILE
DATABASE_URL=postgres://user:password@localhost:5432/db
STRIPE_SECRET=sk_live_abc123def456
AWS_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE
Even if you add .env to .gitignore, what about .env.production, .env.local, env.backup?
The 1-Command Fix
npx @wuchunjie/dotguard /your/project
Output:
🔍 Scanning: /your/project
📄 .env (3 issues)
⚠️ L2 | Hardcoded password
DATABASE_URL=postgres://user:password@localhost...
⚠️ L3 | API key
STRIPE_SECRET=sk_live_abc123def456
⚠️ L4 | Access token
AWS_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE
─────────────────────────────
⚠️ 3 potential secrets exposed!
💡 Add .env to .gitignore & use .env.example instead.
That's it. Zero config. Zero dependencies. Pure Node.js.
What It Scans For
-
API keys — anything matching
api_key=...,token=... -
Private keys —
BEGIN RSA PRIVATE KEY,BEGIN OPENSSH PRIVATE KEY -
Hardcoded passwords —
password=something -
Database URLs —
mysql://,postgres://,mongodb://with credentials - Long random strings — likely tokens or secrets
Integrate Into Your Workflow
# Pre-commit hook
npx @wuchunjie/dotguard . || exit 1
# CI pipeline
npx @wuchunjie/dotguard . && echo "✅ No secrets found"
# Check before every push
alias pushsafe='npx @wuchunjie/dotguard . && git push'
Bonus: What's Missing?
dotguard also checks for commonly recommended but missing env vars:
ℹ️ L0 | Missing NODE_ENV
Consider adding: NODE_ENV=production
ℹ️ L0 | Missing PORT
Consider adding: PORT=3000
Try It Now
npx @wuchunjie/dotguard .
Found this useful? Buy me a coffee ☕ — building open-source security tools
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.