Interview Prep/GitHub Actions/Security Hardening & Supply Chain

You want to detect secrets accidentally committed in PRs within CI. How?

BeginnerScenarioSecurity Hardening & Supply Chain
Answer

Situation read → Secret scanning at PR time.

What I'd do →

  1. Enable GitHub secret scanning with push protection (blocks pushes containing known token formats).
  2. Add gitleaks in CI for custom patterns:
    - uses: actions/checkout@v4
      with: { fetch-depth: 0 }
    - run: docker run --rm -v "$PWD:/repo" zricethezav/gitleaks:v8.21.2 detect --source /repo --log-opts "origin/main..HEAD"
    

Why → Push protection prevents the leak; CI scanning catches custom formats.

Interview tip → Remember that a committed secret must be rotated even if the commit is removed.

All GitHub Actions questions Roadmap: GitHub Actions

More on Security Hardening & Supply Chain