secrets
Environment files and their examples, and credentials in staged changes and pushed commits. Guide: Security.
Selected when
Section titled “Selected when”Always.
Checks
Section titled “Checks”gitleaks-staged
Section titled “gitleaks-staged”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.
What to do
Section titled “What to do”Remove the value and load it from the environment.
Example
Section titled “Example”Load a staged credential from an environment variable instead, and rotate it if it already leaked.
Turn it off
Section titled “Turn it off”gspot ignore secrets/gitleaks-staged --paths "<path>" --reason "<why>"gspot ignore secrets/gitleaks-staged --rule <rule> --reason "<why>"gitleaks-pushed
Section titled “gitleaks-pushed”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.
What to do
Section titled “What to do”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.
Example
Section titled “Example”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.
Turn it off
Section titled “Turn it off”gspot ignore secrets/gitleaks-pushed --paths "<path>" --reason "<why>"gspot ignore secrets/gitleaks-pushed --rule <rule> --reason "<why>"dotenv-linter
Section titled “dotenv-linter”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.
What to do
Section titled “What to do”Fix the line that dotenv-linter names.
Example
Section titled “Example”A dotenv file that defines one key twice reports a duplicate. Keep one line, and delete the other.
Turn it off
Section titled “Turn it off”gspot ignore secrets/dotenv-linter --paths "<path>" --reason "<why>"gspot ignore secrets/dotenv-linter --rule <rule> --reason "<why>"environment-defaults
Section titled “environment-defaults”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.
What to do
Section titled “What to do”Delete the fallback, and fail with a clear message when the variable is missing.
Example
Section titled “Example”process.env.API_TOKEN ?? 'dev-token' reports environment-default. Read the variable with no fallback, and fail when it is missing.
Turn it off
Section titled “Turn it off”gspot ignore secrets/environment-defaults --paths "<path>" --reason "<why>"environment-examples
Section titled “environment-examples”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.
What to do
Section titled “What to do”Add the key to .env.example or a file under secrets.environment_examples, or stop reading it.
Example
Section titled “Example”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.
Turn it off
Section titled “Turn it off”gspot ignore secrets/environment-examples --paths "<path>" --reason "<why>"Settings
Section titled “Settings”| 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. |
Rules for coding agents
Section titled “Rules for coding agents”| Rule file | Installed when |
|---|---|
.gspot/rules/SECRETS.md |
Always |
Tools and versions
Section titled “Tools and versions”| Tool | Version |
|---|---|
| gitleaks | 8.30.1 |
| dotenv-linter | 4.0.0 |
Files gspot writes
Section titled “Files gspot writes”.gspot/configurations/secrets/gitleaks.toml
Paths that must stay out of Git
Section titled “Paths that must stay out of Git”**/.env, **/.env.*, **/.dev.vars, and **/.dev.vars.*. repository/local-files reports a tracked file at these paths.