Tech Interview RoomStudy guides

CI/CD

What quality and security gates belong in a pipeline?

Intermediate · 2 min read · Lesson 3 of 6 in CI/CD

Code quality

  • Unit and integration tests must pass; coverage tracked as a trend and a floor on new code (for example 80% in SonarQube's "clean as you code"), not a vanity target.
  • Static analysis: SonarQube quality gate (bugs, code smells, duplication), SpotBugs, Error Prone, Checkstyle or Spotless formatting.
  • Mutation testing (PIT) on critical modules to check that tests actually assert.

Security (shift left)

  • SAST: static application security testing (Sonar, Semgrep, CodeQL).
  • SCA: known-vulnerable dependencies (OWASP Dependency-Check, Snyk, Dependabot, Renovate for automated upgrades), and licence compliance.
  • Secret scanning: gitleaks or GitHub push protection.
  • Container scanning: Trivy or Grype on the built image; fail on fixable critical and high CVEs.
  • IaC scanning: Checkov or tfsec for Terraform and Kubernetes manifests.
  • DAST: OWASP ZAP against a deployed staging environment.
  • SBOM and signing: CycloneDX or SPDX SBOM, cosign signatures, SLSA provenance.

Gate design

Fail fast on high-signal checks (compilation, tests, critical vulnerabilities, leaked secrets); report lower-signal findings as warnings with a triage process, otherwise teams learn to ignore the pipeline.

Follow-up questions interviewers ask

Try answering each one before you open it.

How do you deal with flaky tests?

Track flakiness (tests that fail and pass on retry) automatically, quarantine flaky tests out of the blocking suite with an owner and a deadline, and fix root causes: shared state between tests, time and ordering assumptions, real network calls, Thread.sleep instead of awaiting conditions (use Awaitility), and non-deterministic test data. Never "fix" them by blanket retries in the merge gate.

A critical CVE appears in a transitive dependency in production. What do you do?

Assess exploitability (is the vulnerable code path used? is it reachable from untrusted input?), then patch: upgrade the direct dependency or pin the transitive version (Maven dependencyManagement), rebuild, and roll out through the normal pipeline. If no fix exists, mitigate (WAF rule, disable the feature, configuration change). Use the SBOMs of deployed images to find every affected service quickly, which is exactly what they were for during Log4Shell.