Skip to content

secrets

Environment files and their examples, and credentials in staged changes and pushed commits. Guide: Security.

Always.

Scans the staged change for keys, tokens, and passwords.

Runs at the commit stage, once for the repository.

A secret that reaches a commit stays in history after you delete the line, and every clone holds it.

Remove the value and load it from the environment.

Load a staged credential from an environment variable instead, and rotate it if it already leaked.

gspot ignore secrets/gitleaks-staged --paths "<path>" --reason "<why>"
gspot ignore secrets/gitleaks-staged --rule <rule> --reason "<why>"

Scans every commit about to be pushed for keys, tokens, and passwords.

Runs at the push stage.

A commit made past the hook still reaches the shared branch unless the push checks it.

Rewrite the commit that holds the value and rotate the secret. To accept a finding, this check needs its own [[ignore]] record, because one for secrets/gitleaks-staged does not cover it.

A credential in an earlier commit still reports after you delete it from the working tree. Rotate it, then remove it from history, and coordinate any rewrite of shared commits.

gspot ignore secrets/gitleaks-pushed --paths "<path>" --reason "<why>"
gspot ignore secrets/gitleaks-pushed --rule <rule> --reason "<why>"

Checks every tracked environment file: key format, duplicates, quoting, ordering, and trailing spaces.

Runs at the commit stage.

Other people copy a tracked environment file, so a malformed line in it spreads to every machine.

Fix the line that dotenv-linter names.

A dotenv file that defines one key twice reports a duplicate. Keep one line, and delete the other.

gspot ignore secrets/dotenv-linter --paths "<path>" --reason "<why>"
gspot ignore secrets/dotenv-linter --rule <rule> --reason "<why>"

Reports a read of a variable named like a token, secret, key, or password with a literal fallback, in JavaScript, TypeScript, and Python.

Runs at the push stage, once per scope.

A secret with a default runs in production with a value that a repository reader knows.

Delete the fallback, and fail with a clear message when the variable is missing.

process.env.API_TOKEN ?? 'dev-token' reports environment-default. Read the variable with no fallback, and fail when it is missing.

gspot ignore secrets/environment-defaults --paths "<path>" --reason "<why>"

Checks that an existing env example lists each static uppercase key that code reads through process.env, import.meta.env, Bun.env, Deno.env.get, the Python os module, or an environment function.

Runs at the push stage, once per scope.

A variable missing from the env example breaks the first run on a new machine.

Add the key to .env.example or a file under secrets.environment_examples, or stop reading it.

Code that reads API_URL while .env.example lacks that key reports a finding. Add API_URL= to .env.example with a note on the value, and no credential.

gspot ignore secrets/environment-examples --paths "<path>" --reason "<why>"
Setting What it sets
secrets.environment_examples The example environment files to search for environment keys; a key may appear in any one of them.
secrets.environment_functions Functions of this project that read environment variables, such as read_env. secrets/environment-examples reads the keys they take.
Rule file Installed when
.gspot/rules/SECRETS.md Always
Tool Version
gitleaks 8.30.1
dotenv-linter 4.0.0

.gspot/configurations/secrets/gitleaks.toml

**/.env, **/.env.*, **/.dev.vars, and **/.dev.vars.*. repository/local-files reports a tracked file at these paths.