Skip to content
huyvv533Public

About

Zero-dependency .env & config secret scanner, Shannon entropy analyzer, OASIS SARIF 2.1.0 exporter, and safe .env.example generator (CLI + TypeScript SDK + Local-First Web Auditor)

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🛡️ envshield

CI & GitHub Pages License: MIT Zero Dependencies

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/


Why 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:

  1. 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.
  2. 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, passwordless localhost URLs, and <YOUR_API_KEY> templates.
  3. Lints .env Footguns: Detects duplicate keys overriding earlier lines, unquoted whitespace / inline # comments, unclosed quotes, and invalid variable names.
  4. Generates Safe .env.example Files 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).
  5. Integrates Natively with GitHub Code Scanning (--format sarif): Emits valid OASIS SARIF 2.1.0 reports with masked previews so raw secrets never appear in CI logs.

Quick Start (CLI)

# 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.example

Programmatic TypeScript / ESM API

import {
  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);
}

GitHub Actions Integration Example

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

Contributing & License

Contributions, 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).

About

Zero-dependency .env & config secret scanner, Shannon entropy analyzer, OASIS SARIF 2.1.0 exporter, and safe .env.example generator (CLI + TypeScript SDK + Local-First Web Auditor)

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages