Secret with a fallback value
Secret with a fallback value. A secret falls back to a literal when the env var is missing (process.env.JWT_SECRET || ").
This is how the comment reads inline, under the flagged line.
Why it matters
If the variable is unset in production, the app quietly runs with a secret that's in the repo.
What to do
Fail at startup when a required secret is missing.
Examples
const secret = process.env.JWT_SECRET || "dev-secret";
const secret = required("JWT_SECRET");What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
const s = process.env.JWT_SECRET || "dev";
Left alone
const s = required('JWT_SECRET');Research
Credentials in source, and secrets read with a fallback default. A committed secret stays exposed, even after it is deleted.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"default-secret"
],
"severity": {
"default-secret": "low"
}
}
}