Security scans pass on PRs from forks without reporting anything, but fail on main
AdvancedTroubleshootingSAST, SCA and secrets scanning in CI
Answer
Likely causes → Fork PRs get no secrets, so SonarQube/Snyk tokens are empty and the step is skipped or continue-on-error swallows the auth failure.
Diagnose → Look for empty tokens or 401 in fork run logs; check if: conditions and continue-on-error: true.
Fix → Run token-free scanners (Semgrep OSS, gitleaks, Trivy fs) on pull_request, and token-based ones in a workflow_run job that checks out the PR code read-only. Never use pull_request_target with a checkout of PR code and secrets.
Prevent → Make a missing token a hard failure on trusted branches, and audit for silent continue-on-error.
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 valuesBeginnergitleaks passes locally but the CI job reports 40 old leaks nobody touched in this PRIntermediate`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`Intermediate