← All articles
DevSecOps8 min read

Secure CI/CD Gates That Don’t Slow Your Team Down

SAST, SCA, secrets scanning, and container checks belong in the pipeline—here’s how to make them fast and actionable.

Security gates in CI/CD usually fail in one of two ways. Either they are so noisy that developers learn to ignore or bypass them, or they are so slow that teams batch changes to avoid them—which makes releases riskier. The goal is gates that are fast, accurate, and placed where they catch problems cheapest, with a clear path for the rare legitimate exception.

Where each security check belongs

  1. Pre-commitSecret scanning on the developer's machine
  2. Pull requestSAST, dependency, and IaC scans in parallel
  3. BuildImage scan, SBOM, signing
  4. DeployPolicy checks, approvals for production
  5. RuntimePosture and threat detection feed back into the backlog
Fast checks early and on every change; heavier checks in parallel or before promotion.

Principles for gates developers will keep

  • Block only on findings that are real, fixable, and important; report everything else.
  • Run checks in parallel so the pipeline is as fast as its slowest single job.
  • Scan only what changed on pull requests, and the whole repository on a schedule.
  • Show results where developers already look—pull request comments, not a separate portal.
  • Make exceptions explicit, owned, and time-limited.

1. Stop secrets before they are committed

A secret pushed to a shared repository should be treated as compromised, even if the commit is later removed. Catch secrets on the developer's machine with a pre-commit hook, again in CI as a safety net, and enable push protection in your Git platform. Pair this with short-lived credentials everywhere so a leaked value has limited use.

.pre-commit-config.yamlyaml
repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.21.2
    hooks:
      - id: gitleaks

2. Fast pull request checks, in parallel

Static analysis, dependency scanning, and infrastructure-as-code scanning are independent, so run them as separate jobs. Configure each to fail only on high-severity, high-confidence findings in changed code, and to post the rest as annotations.

.github/workflows/security.ymlyaml
name: security
on: [pull_request]

permissions:
  contents: read
  security-events: write

jobs:
  secrets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - uses: gitleaks/gitleaks-action@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  sast:
    runs-on: ubuntu-latest
    container: semgrep/semgrep
    steps:
      - uses: actions/checkout@v4
      - run: semgrep scan --config p/default --severity ERROR --error

  dependencies-and-iac:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: aquasecurity/trivy-action@0.28.0
        with:
          scan-type: fs
          scanners: vuln,misconfig
          severity: HIGH,CRITICAL
          ignore-unfixed: true
          exit-code: "1"

How does your cloud measure up?

Score your setup across foundation, delivery, reliability, security, and cost in 3 minutes—instant results, no email needed.

Take the free scorecard

3. Build-time checks on artefacts

Scan the built container image, not just the source, because base images bring their own vulnerabilities. Generate a software bill of materials and sign the image so later stages—and your cluster's admission controller—can verify exactly what was built and checked. Rebuild images regularly so base-image fixes reach production even when application code is unchanged.

4. Deploy-time gates

Before production, check policy rather than code: is the image signed, does the deployment meet security requirements, is the change approved where required? Use protected deployment environments with required reviewers for production, and an admission policy in Kubernetes that rejects unsigned images or privileged pods. These gates are quick because the expensive scanning already happened earlier.

5. Handle exceptions without breaking trust

Sometimes a finding cannot be fixed immediately—no patched version exists, or the vulnerable code path is not reachable. Record the exception in the repository with a reason, an owner, and an expiry date, so it is reviewed rather than forgotten.

security-exceptions.yamlyaml
- id: CVE-2026-12345
  package: libexample
  reason: "Vulnerable function not called; upstream fix pending"
  owner: payments-team
  approved_by: security-lead
  expires: 2026-12-31

A small script in CI can fail the build when an exception has expired, turning “we'll fix it later” into a scheduled task.

6. Measure the gates themselves

  • Pipeline duration added by security jobs—aim to keep it in low single-digit minutes.
  • False-positive rate: how often developers mark findings as not applicable.
  • Time to fix high-severity findings once reported.
  • Number of active exceptions and how many have expired.

A worked example: one pull request through the gates

A developer adds a new payment webhook handler. The pre-commit hook catches a test API key pasted into a fixture before it ever leaves the laptop. In the pull request, three jobs start in parallel: static analysis flags an unsanitised value passed to a SQL query in the new handler and posts the line as a review comment; the dependency scan reports a medium-severity issue in a transitive package with no fix available, which is shown but does not block; the IaC scan confirms the new queue is encrypted. The developer fixes the query, the jobs re-run in about three minutes, and the change merges. At build, the image scan passes, an SBOM is generated, and the image is signed. The production deploy waits for an approver in the protected environment, and the cluster's admission policy verifies the signature. Nobody opened a separate security portal, and the only blocking finding was a real one.

Tuning rules so the signal stays high

Out-of-the-box rule sets are written for everyone, so they are noisy for anyone in particular. Start with a curated default set, then review the findings developers mark as false positives each month and disable or tune the rules that generate them. Add custom rules for patterns specific to your codebase—an internal HTTP client that must always set timeouts, or a logging helper that must never receive raw request bodies. For dependency scanning, prefer reachability-aware tools where available, and treat findings in development-only dependencies differently from those that ship to production.

Secure the pipeline itself

Attackers increasingly target CI systems because they hold deployment credentials. The pipeline needs the same controls as production:

  • Pin third-party actions and plugins to full commit SHAs, and review updates.
  • Set the default GITHUB_TOKEN permissions to read-only and grant write scopes per job.
  • Use OIDC federation to cloud providers instead of stored keys.
  • Run untrusted pull requests from forks without access to secrets or deployment roles.
  • Protect the default branch: required reviews, required status checks, and no force pushes.
  • Use ephemeral, isolated runners for jobs that touch production.

A 30-day rollout plan

  1. Week 1: enable secret scanning and push protection; add the pre-commit hook to repository templates.
  2. Week 2: add SAST, dependency, and IaC scans in report-only mode and measure the noise.
  3. Week 3: tune rules, agree severity thresholds with team leads, and switch high-severity findings to blocking.
  4. Week 4: add image scanning, SBOMs, signing, protected environments, and the exceptions file with expiry checks.

Automate the fixes as well as the findings. Dependency update bots such as Dependabot or Renovate open small, frequent pull requests for vulnerable and outdated packages, which keeps upgrades routine instead of turning them into quarterly projects that nobody wants to start.

Share the results upward too: a monthly view of blocked issues, time to fix, and exceptions gives leadership evidence that security work is reducing risk rather than just adding steps.

Checklist

  1. Secret scanning in pre-commit, CI, and Git push protection.
  2. SAST, dependency, and IaC scans as parallel pull request jobs, blocking only on high-confidence, high-severity findings.
  3. Image scanning, SBOMs, and signing at build time.
  4. Protected production environments and admission policies at deploy time.
  5. Expiring, owned exceptions stored in the repository.
  6. Metrics on gate speed, noise, and time to fix.

Good gates make the secure path the fast path. That is the design goal of our Secure Delivery Pipeline module.

Key takeaways

  • Fail builds on severity the security team owns—not every scanner finding.
  • Prefer fast, high-signal checks on changed paths before slow full-repo scans.
  • Use short-lived OIDC credentials; never store long-lived cloud keys in runners.

FAQ

Which gates should be mandatory on every PR?

Secrets detection, dependency vulnerability checks with clear fix paths, and SAST on changed code. Heavier container or IaC scans can run on merge or nightly if PR latency matters.

How do we stop teams bypassing gates?

Keep signal high, publish ownership of false positives, and measure time-to-green. Noisy gates create shadow pipelines; trusted gates get adopted.

Need help putting this into practice?

Our engineers do this every week. Get a fixed-scope plan for secure delivery pipeline module—free scoping call, written price before you commit.

Get a free scoping call