You are asked to add security to an existing CI pipeline. Where do SAST, SCA, secrets scanning and DAST each go?
BeginnerScenarioPipeline Security Scanning
Answer
Situation read → Classic "shift left" design question. Each scan type needs a different artifact, so each lands at a different stage.
What I'd do →
- Pre-commit and PR: secrets scan (
gitleaks) and fast SAST (semgrep) on the diff only. - Build stage: SCA against lockfiles (
trivy fs,osv-scanner) and IaC scan (checkov,trivy config). - After image build: image scan (
trivy image), SBOM generation, signing. - After deploy to staging: DAST (
ZAP baseline) against the running app. - Production: runtime detection and continuous re-scan of SBOMs.
Why → SAST and SCA need only source, so they run before anything is built. DAST needs a running target, so it can only run after deploy.
Interview tip → Say "cheap and fast scans block the PR, slow scans run nightly or post-deploy".
More on Pipeline Security Scanning
Gitleaks 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?IntermediateDevelopers bypass your pre-commit secret scan with `git commit --no-verify`. How do you close the gap?Intermediate