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

`fatal: ambiguous argument 'origin/main..HEAD': unknown revision` in the secrets-scan step

BeginnerTroubleshootingSAST, SCA and secrets scanning in CI
Answer

Likely causes → actions/checkout defaults to fetch-depth: 1, so the base branch ref does not exist in the runner.

Diagnose →

git branch -a
git log --oneline | wc -l

Fix →

- uses: actions/checkout@v4
  with:
    fetch-depth: 0

Or fetch just the base: git fetch origin main --depth=50.

Prevent → Any tool that diffs against a base (gitleaks, Semgrep diff-aware, SonarQube new-code) needs history; set fetch-depth: 0 in the shared workflow template.

All DevSecOps questions Roadmap: Security in the pipeline

More on SAST, SCA and secrets scanning in CI