Interview Prep/DevSecOps/Pipeline Security Scanning

A secret exists in the git history of an 8-year-old monorepo with 400 contributors. Do you rewrite history?

AdvancedScenarioPipeline Security Scanning
Answer

Situation read → The secret is already compromised. Rewriting history is cleanup, not remediation.

What I'd do →

  1. Rotate the credential first and confirm the old one is dead.
  2. Search access logs for use of the old credential during its exposure window.
  3. Decide on rewriting: for an internal repo with a rotated secret, I usually do not rewrite, because it breaks 400 clones and open PRs.
  4. If the secret is highly sensitive or the repo is public, rewrite with git filter-repo --replace-text expressions.txt, force-push, ask GitHub to purge cached views, and have everyone re-clone.
  5. Add scanning to prevent recurrence.

Why → Rotation removes the risk. History rewriting reduces noise and future scanner alerts at a high coordination cost.

Interview tip → Lead with "rotate first".

All DevSecOps questions Roadmap: Security in the pipeline

More on Pipeline Security Scanning