Skip to content
keyparityPublic

About

Check that every env var your code uses is in .env.example and GitHub Secrets. Reads names only, never values.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

keyparity

OpenSSF Best Practices OpenSSF Scorecard

Your code reads STRIPE_KEY. Your .env.example forgot it, and so did the repo's GitHub Secrets. You find out when the deploy fails at 2 a.m.

keyparity checks that every environment variable your code uses is listed in .env.example and set as a GitHub Secret, and flags the ones nobody uses any more. It reads secret names only, never values.

Install

With Node 20 or later, run it without installing:

npx keyparity audit

Or download a single-file binary for your system from the latest release. On an Apple Silicon Mac:

curl -fsSLo keyparity https://github.com/keyparity/keyparity/releases/download/v0.1.2/keyparity-darwin-arm64
gh attestation verify keyparity --repo keyparity/keyparity
chmod +x keyparity && mv keyparity /usr/local/bin/

There are also builds for Intel Macs, Linux (x64 and arm64) and Windows. Each file is listed in SHA256SUMS and has a build attestation. Checking secrets needs the GitHub CLI, signed in.

Use it

keyparity audit                    # check this repo against .env.example and its GitHub secrets
keyparity audit --strict           # exit 1 if anything is missing: put this in CI
keyparity generate-template        # print a .env.example built from your code

Here's keyparity audit --skip-secrets on a small example project:

Local missing (1)
  API_KEY  src/index.ts:2  missing from .env.example

Unused (1)
  OLD_FLAG  not referenced

Synced, as far as checked (2)
  DB_URL        src/index.ts:1
  DEPLOY_TOKEN  .github/workflows/deploy.yml:5

2 synced, 0 CI missing, 1 local missing, 1 unused
GitHub secrets weren't checked.

It reads env vars from JavaScript and TypeScript (process.env, Bun.env, import.meta.env), Python (os.environ, os.getenv), Go (os.Getenv, os.LookupEnv), Rust (env::var), Ruby (ENV[], ENV.fetch) and GitHub Actions workflows (${{ secrets.NAME }}). Test files and fixtures are skipped unless you pass --include-tests. Run keyparity audit --help for every flag.

Contributing

Issues and ideas are welcome. See CONTRIBUTING.md. To work on it locally, you need Bun:

bun install
bun test

License

MIT

About

Check that every env var your code uses is in .env.example and GitHub Secrets. Reads names only, never values.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages