Case · CLI tool · Go
envguard: a linter and a safe for .env files
A Go CLI with no external modules: check compares .env with a schema, scan looks for secrets in the tree and git history, diff and doctor check environments and git hygiene, seal and unseal encrypt .env into .env.sealed (AES-256-GCM, PBKDF2 with 600k iterations), run starts a command with a clean environment, report and serve build a report. A secret value never reaches the output, the log or the HTML. A side project.
- Go
- stdlib only
- CLI
- AES-256-GCM
- PBKDF2
- fuzzing
- govulncheck
- gitleaks
- GitHub Actions
- Docker
01 · How it looks
Screenshots


02 · About
What it is and why
envguard is a Go console utility for .env files: it checks them against a schema, looks for secrets in the working tree and git history, encrypts .env into .env.sealed and runs commands with a clean environment. A side project.
One binary and only the Go standard library (there is no go.sum). The main rule of the project: a secret value never reaches the output, the log, an error, the HTML or the JSON. What is printed is the finding type, file, line and a four-character mask (for values of 12 characters and more); for short values only the length. Tests with canary values over the output of every command check this.
Limitations
There is no live version: it is a console utility.
In Go a secret cannot be reliably wiped from memory: passphrase and key buffers are zeroed, but variable values live in strings until garbage collection. Memory dumps and swap stay in the attacker model.
The scanner finds known formats and suspicious values; a secret of an arbitrary shape, encoded or inside a binary file, is missed, and the heuristics give false positives. Git history is checked in a limited way: the last N commits.
PBKDF2 is weaker against GPUs than scrypt and Argon2: that is the price of having no external modules. The -race check runs only in CI, file permissions are not checked on Windows.
What is inside
- check: compares .env with .env.example and the envguard.schema schema (types int, bool, url, duration, enum, port, secret, string, ranges, duplicates, quotes, CRLF and BOM)
- scan: secrets in known formats (AWS, GitHub, Cloudflare, Stripe, Slack, Google, PEM keys, JWT, a password in a URL) and two heuristics; exclusions through envguard:ignore and .envguardignore
- diff compares environments in constant time and prints only the fact of a change and the length; doctor checks .gitignore, git tracking, file permissions and history
- seal and unseal: AES-256-GCM, a key from a passphrase via PBKDF2 (600k iterations), the header as AAD; run starts a command with the decrypted environment without writing to disk, with a block list and output masking
- report and serve: an HTML report, also on 127.0.0.1, without variable values, a strict CSP, Host and Origin checks
- Tests: tables, golden files, canaries, seal property tests, 4 fuzz targets of 20 seconds each without crashes; govulncheck and gitleaks are clean
- Cross-builds for windows, linux and darwin with a script, CI in GitHub Actions and a Dockerfile
03 · How to run
Run it locally
git clone <repository on request> envguard
cd envguard
go build -o envguard ./cmd/envguard
./envguard check # .env against .env.example and the schema04 · Code
The repository is private
The source is in a private repository. Message me on Telegram and I will open access.
Request the code