Zero-dependency .env & config secret scanner, Shannon entropy analyzer, secret redactor (mask), .env syntax linter, OASIS SARIF 2.1.0 exporter, and safe .env.example generator (v1.1.0).
👉 Try the 100% Local-First Browser Playground (Zero Network Calls): https://huyvv533.github.io/envshield/
Accidental .env commits, inline database URI passwords, and out-of-date .env.example files remain one of the most common security incidents in modern repositories—especially in fast AI-assisted development workflows.
envshield provides a tiny, zero-runtime-dependency TypeScript engine + Node CLI that:
- Catches 20+ High-Signal Credential Families + High-Entropy Secrets: AWS (
AKIA/ASIA), GitHub (ghp_/github_pat_), GitLab (glpat-), Stripe Live (sk_live_/rk_live_), OpenAI (sk-proj-), Anthropic (sk-ant-), Google Cloud/Gemini (AIza...), Hugging Face (hf_), Linear (lin_api_), Supabase (sbp_), signed JWTs, Slack & Discord webhooks, npm (npm_), PyPI (pypi-), SendGrid, Telegram Bot tokens, PEM/OpenSSH private keys, and PostgreSQL / MySQL / MongoDB / Redis connection URIs with embedded passwords. - Inline Suppression Directives & Zero-Noise Filtering: Supports
# envshield-ignore,# envshield-ignore-next-line, and# pragma: allowlist secret, while automatically ignoring UUIDv4 identifiers, 40/64-char hex Git commit SHAs, passwordlesslocalhostURLs, and<YOUR_API_KEY>templates. - Lints
.envFootguns: Detects duplicate keys overriding earlier lines, unquoted whitespace / inline#comments, unclosed quotes, and invalid variable names. - Generates Safe
.env.exampleFiles Automatically: Preserves comments and safe defaults (PORT=8080,ENABLE_METRICS=true) while redacting credentials and rewriting database URIs to safe local placeholders (postgresql://user:<PASSWORD>@localhost:5432/dbname). - Integrates Natively with GitHub Code Scanning (
--format sarif): Emits valid OASIS SARIF2.1.0reports with masked previews so raw secrets never appear in CI logs.
# Scan current repository (.env*, *.json, *.yaml, *.toml) and exit 1 if secrets are found
node ./bin/envshield.mjs scan .
# Export SARIF 2.1.0 for GitHub Code Scanning
node ./bin/envshield.mjs scan . --format sarif > envshield.sarif.json
# Redact leaked values in-place or to a sanitized copy for safe sharing
node ./bin/envshield.mjs mask .env --out .env.redacted
# Generate a clean, secret-free .env.example from your local .env
node ./bin/envshield.mjs example .env --out .env.example
# Lint .env syntax & check drift between .env and .env.example
node ./bin/envshield.mjs lint .env
node ./bin/envshield.mjs diff .env .env.exampleimport {
scanTextForSecrets,
lintDotenvSyntax,
generateSafeEnvExample,
diffEnvKeys,
computeShannonEntropy,
toSarifReport,
} from "envshield-oss";
const report = scanTextForSecrets(processEnvFileText, ".env.local");
if (report.findings.length > 0) {
console.error("Blocked commit:", report.findings);
}- name: Audit repository configs with envshield
run: |
git clone --depth 1 https://github.com/huyvv533/envshield.git /tmp/envshield
cd /tmp/envshield && npm ci && npm run build:lib && cd -
node /tmp/envshield/bin/envshield.mjs scan . --format sarif > results.sarifContributions, new token patterns, and false-positive test cases are welcome! Please read CONTRIBUTING.md and SECURITY.md.
Released under the MIT License by Huy Vu (@huyvv533).