Interview Prep/DevSecOps/SAST, SCA and secrets scanning in CI

gitleaks passes locally but the CI job reports 40 old leaks nobody touched in this PR

IntermediateTroubleshootingSAST, SCA and secrets scanning in CI
Answer

Likely causes → CI runs gitleaks detect over the full history while local runs use protect --staged (or git mode on a shallow clone). Old commits contain historical secrets.

Diagnose →

git rev-list --count HEAD           # shallow vs full clone
gitleaks detect --log-opts="origin/main..HEAD" -v   # only PR commits

Fix → Scan only the PR range in CI (--log-opts="$BASE_SHA..$HEAD_SHA"), and handle the historical findings separately: rotate them, then baseline with --baseline-path gl-baseline.json.

Prevent → Run a full-history scan on a schedule, not on every PR, and track legacy findings as tickets until each is rotated.

All DevSecOps questions Roadmap: Security in the pipeline

More on SAST, SCA and secrets scanning in CI