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 →
- Rotate the credential first and confirm the old one is dead.
- Search access logs for use of the old credential during its exposure window.
- Decide on rewriting: for an internal repo with a rotated secret, I usually do not rewrite, because it breaks 400 clones and open PRs.
- 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. - 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".
More on Pipeline Security Scanning
You are asked to add security to an existing CI pipeline. Where do SAST, SCA, secrets scanning and DAST each go?BeginnerGitleaks flags an AWS access key in a pull request. The developer says it is a test key. What do you do?BeginnerDevelopers fear security scans will slow the pipeline from 6 to 20 minutes. How do you roll them out?BeginnerA SAST tool reports 2,000 findings on a legacy repo the first time you run it. How do you introduce it without freezing delivery?IntermediateA developer insists a scanner finding is a false positive. What is your process?BeginnerSCA flags a critical CVE in a transitive dependency and no patched version exists. What are your options?Intermediate