← All scars

scar-003 · scar

Hardcoded secret

A key or password was written directly in source code and ended up in version control.

criticalcaptured Oct 7from commit b54a887never repeated

Before and after

Before · the mistake
1const API_KEY = "sk_live_abcdef123456"
After · the rule
1Read it from the environment: const API_KEY = process.env.API_KEY

How it’s detected

/(api_?key|secret|token|password)\w*\s*=\s*["'][A-Za-z0-9_\-]{12,}["']/i

Times it came back

This mistake has not been repeated. The rule is working.