Case study
Security CI Pipeline
Automatic security checks on every change to this site, including a custom gitleaks rule that found a leaked credential the default rules missed.
The problem
An old version of this site’s code had a Gmail app password in its git history. gitleaks with its default rules reported nothing; a manual review found it.1
A Google app password is 16 lowercase letters with no fixed prefix, so the default rules cannot match it. Until then, checks like this were done by hand. I replaced them with automatic checks that run on every change.
# Run 1: default rules $ gitleaks git -v --redact INF no leaks found # Run 2: same command, after adding the custom rule $ gitleaks git -v --redact Secret: [REDACTED] RuleID: gmail-app-password WRN leaks found: 1
Requirements
- Free tools only, and no secrets in CI.
- The pipeline must not become a supply-chain risk itself.
- A release ships only when every check passes.
What I built
- Secret scan: gitleaks over the full history of every branch, on every push and daily, with the default rules plus two custom rules.1
- Dependency audit: npm audit fails on critical vulnerabilities. Dependabot proposes updates every week.
- Code scan: Semgrep with JavaScript, TypeScript, React and secrets rules fails on any finding. ESLint and the unit tests run in the same workflow.2
- Live site checks: After every production deploy and daily: all eight security headers and the key CSP directives, the HSTS lifetime, the redirect to the canonical host, a security.txt that is present and not about to expire, and a published CV file that matches its SHA-256 hash in the repository.23
- Pre-commit hook: gitleaks on the staged changes blocks a commit that contains a secret. It also blocks the commit if gitleaks is not installed.
How it works
- Commitpre-commit secret scan
- Pushsecret scan, dependency audit, code scan
- Gateevery check passes
- Deployproduction
- Live checksheaders, CSP, security.txt, CV hash
Security decisions
- Every GitHub Action is pinned to a full commit SHA; the Semgrep container is pinned by digest.1
- Workflows get read-only access to the repository and need no secrets.1
- The gitleaks binary is checked against its published checksum before it runs.1
- A new package version is installed only after 7 days on the npm registry, and Dependabot uses the same cooldown. Security fixes are not delayed.4
- A CI job checks that my private statistics dashboard is never in the build output.4
- The custom rule: It matches 16 lowercase letters only when they are assigned to a password-like setting, in quotes or in .env and YAML style. Normal text does not match. A test script checks samples that must be found and samples that must not.1
Results
- On the original commit, the default rules found nothing and the custom rule found the leak, with no false positives in the repository.1
- The credential was revoked and the git history rebuilt.
- Every release of this site runs the security workflows and ships only when all of them pass.
- The custom rule now runs in CI and in the pre-commit hook.
What I’d do next
- A nonce-based CSP would earn an A+ on securityheaders.com. Today the site keeps static pages and accepts 'unsafe-inline' for scripts as a known trade-off.2
- Dev-only tooling has documented accepted risks that wait for upstream fixes. Dependabot will open the updates.
Evidence
- 1Security journal: “My Secret Scanner Missed a Real Password, So I Wrote a Rule That Catches It” (opens in a new tab)
- 2How this site is secured: “Secure development pipeline” and “HTTP security headers”
- 3Security journal: “From One Security Header to an A: Hardening My Portfolio” (opens in a new tab)
- 4Workflows, Dependabot settings and the dashboard check. Private repository, available on request.