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.
More on SAST, SCA and secrets scanning in CI
gitleaks fails the PR on `tests/fixtures/fake_rsa.pem` and `testdata/aws_creds.json`, which only contain dummy valuesBeginner`fatal: ambiguous argument 'origin/main..HEAD': unknown revision` in the secrets-scan stepBeginnerSemgrep flags `subprocess.run(cmd, shell=True)` in a script where `cmd` is a hard-coded constantBeginnerSemgrep in CI reports findings in `node_modules/`, `vendor/` and minified `dist/*.js`BeginnerSemgrep job takes 35 minutes and gets killed with `exit code 137`IntermediateSonarQube Quality Gate fails on "Security Hotspots Reviewed is less than 100%" but there are no vulnerabilitiesBeginner