A DevSecOps pipeline is a CI/CD pipeline in which security checks run as ordinary automated steps next to your tests. Secrets are scanned before code leaves a laptop, every pull request gets static analysis plus dependency and infrastructure-code checks, every container image is scanned before it ships, and a dynamic scanner probes staging. Each check comes with a written rule for what fails the build and what goes on a list someone reads every week. If you're starting from zero, add secret and dependency scanning first and dynamic scanning last.
Why these checks, in this order
Two numbers explain most of the priorities. In Verizon's 2026 Data Breach Investigations Report, exploiting a software vulnerability was how 31% of breaches started, which made it a more common way in than stolen credentials. GitGuardian's State of Secrets Sprawl 2026 counted 28,649,024 new secrets in public GitHub commits during 2025, and of the valid secrets it had found in 2022, 64% still worked four years later.
Known-vulnerable packages and keys sitting in commits are exactly what automated scanners are good at. Most of the tools are free, they run on every change, and a finding usually comes with an obvious fix: upgrade the package, rotate the key.
What a pipeline is bad at is your business logic. Broken access control is at the top of the OWASP Top 10, and no scanner knows that a staff user shouldn't be able to approve their own import. That part belongs to requirements, design reviews and tests written for your rules, which our secure SDLC post covers. This post is about the automated part.
What runs at each stage
Stage | Check | Tools (free unless noted) | Blocks when |
|---|---|---|---|
Developer's machine | Secrets in staged changes | gitleaks as a pre-commit hook | A secret is staged |
Push | Secret push protection | GitHub push protection (paid on private repos) | A known key format is pushed |
Pull request | Secrets in the new commits | TruffleHog | A secret is confirmed live, or can't be checked |
Pull request | Static analysis (SAST) | Semgrep CE, Opengrep, CodeQL (paid on private repos) | A new high-severity finding appears |
Pull request | Dependencies (SCA) and infrastructure code | Trivy, npm audit, Checkov | A high or critical CVE has a fixed version; a high-severity misconfiguration |
Build | Container image | Trivy | A high or critical CVE in the image has a fixed version |
Release | Software bill of materials (SBOM) | Trivy, Syft | Never; it's a record |
Staging | Dynamic scan (DAST) | ZAP | Not on pull requests; findings become tickets |
Production | New CVEs in what's already deployed | Dependabot alerts, the stored SBOMs | Not a build step; your patch deadlines apply |
On cost: push protection and CodeQL are free on public GitHub repositories. For private ones, GitHub sells them as add-ons, Secret Protection at $19 and Code Security at $30 per active committer per month. Everything else in the table is open source.
The pre-commit hook is a convenience for the developer. Anyone can skip it with SKIP=gitleaks git commit, so CI checks again. It takes one file, .pre-commit-config.yaml, and a pre-commit install:
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.1
hooks:
- id: gitleaksA working pipeline for GitHub Actions
This workflow runs four jobs in parallel on every pull request, with tool versions current as of October 2026. It assumes a Node.js app with a committed package-lock.json and a Dockerfile at the repository root. Trivy also checks Terraform, Kubernetes manifests and other infrastructure code if they're in the repo. Save it as .github/workflows/security.yml:
name: security
on:
pull_request:
permissions:
contents: read
env:
TRIVY: ghcr.io/aquasecurity/trivy:0.76.0@sha256:2416d1f74045b57274df1a340eee6b510cacd73c66a6ccb8da092b117eb7d222
jobs:
secrets:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Live secrets in this PR's commits (TruffleHog)
env:
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.event.pull_request.head.sha }}
run: |
docker run --rm -v "$PWD:/repo" \
ghcr.io/trufflesecurity/trufflehog:3.99.2@sha256:47a84bc18a0d04a165498bbbd3bacfd84176661cbc91f8e0f85467f6a771e99a \
git file:///repo --since-commit "$BASE" --branch "$HEAD" \
--results=verified,unknown --fail --no-update
sast:
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- run: pipx install semgrep==1.181.0
- name: New findings only (Semgrep)
env:
BASE: ${{ github.event.pull_request.base.sha }}
run: semgrep scan --config p/default --error --baseline-commit "$BASE"
dependencies-and-config:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Vulnerable dependencies and misconfigurations (Trivy)
run: |
docker run --rm -v "$PWD:/src" -w /src "$TRIVY" \
fs --scanners vuln,misconfig --severity HIGH,CRITICAL \
--ignore-unfixed --exit-code 1 .
image:
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- run: docker build -t "app:$GITHUB_SHA" .
- name: Vulnerabilities in the built image (Trivy)
run: |
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
-v "$PWD:/src" -w /src "$TRIVY" \
image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 \
"app:$GITHUB_SHA"Why it's written this way
TruffleHog and Trivy run as container images pinned by digest, Semgrep is installed at a fixed version, and the only actions in the file are GitHub's own, pinned to a commit SHA. The reason is recent. On 19 March 2026, attackers with stolen credentials published a malicious Trivy release and force-pushed 76 of the 77 version tags of the trivy-action GitHub Action to code that stole credentials from the runner (Aqua's advisory). Pipelines that referenced the action by tag ran the stealer before the real scan; Trivy images referenced by digest were not affected. Security tools run with access to your code and often your secrets, so treat them with the same suspicion as any other dependency. Our GitHub Actions post goes deeper into SHA pinning and token permissions.
The secrets job scans only the commits in the pull request. With --results=verified,unknown, TruffleHog reports a secret only if it confirmed the credential works by calling the provider's API, or if it couldn't finish that check. Treat both as real. By the time this job runs the commit is already on GitHub, so the fix is to rotate the key. Deleting the commit from the branch leaves it in clones and forks.
The sast job uses --baseline-commit, so Semgrep reports only findings that don't already exist on the target branch. Without it, the first run fails on every old finding in the codebase, and a check that is red on day one tends to get switched off. p/default is Semgrep's general ruleset. The rules Semgrep maintains have been under the Semgrep Rules License since December 2024, which allows internal use but not use in a competing product; the engine itself is still LGPL 2.1. If that license is a problem for you, Opengrep is an LGPL fork that a group of security vendors started in January 2025.
The dependencies-and-config job reads lockfiles for known CVEs and checks Dockerfiles, Terraform, Kubernetes manifests and similar files for misconfigurations. For npm, Trivy leaves out development dependencies unless you pass --include-dev-deps. For a gate that's usually right: a CVE in your test runner matters less than one in your web framework. Expect the first run to fail on something like a Dockerfile with no USER line, which Trivy rates high because the container then runs as root.
The image job builds the image and scans it, including the operating-system packages that came with the base image. --ignore-unfixed hides CVEs that have no fixed version yet. Without it, a base image can block every build over something nobody can fix. Those CVEs still deserve attention, so run the same scan without the flag as part of the weekly triage.
When you decide to live with a finding, record that where the scanner reads it. A .trivyignore file at the repository root takes one ID per line, with an optional expiry date after which the finding blocks again. Put a comment line (starting with #) above each entry with the reason and the owner:
#reason: not reachable from the public API, fixed by the framework upgrade; owner: @maria
CVE-YYYY-NNNNN exp:2026-12-31For Semgrep, a // nosemgrep: rule-id comment on the flagged line does the same. Ask for a one-line reason next to it in code review.
Two more pieces live outside this file. In the release build, generate an SBOM for the image, for example with trivy image --format cyclonedx --output sbom.cdx.json app:1.4.2, and store it with the release. When the next widely used library gets a critical CVE, you can answer "are we affected, and in which release?" by searching those files instead of rebuilding old versions. And let Dependabot propose updates, with a .github/dependabot.yml like this one:
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
- package-ecosystem: docker
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: weeklyDependabot already waits three days before proposing a new version. Seven days for npm gives the registry more time to pull a malicious release: the Shai-Hulud worm in September 2025 stole maintainers' npm credentials and used them to publish infected versions of more than 500 packages. The cooldown doesn't delay security updates. Commit the lockfile and install with npm ci in CI, so the build gets exactly the versions someone reviewed. One gap to know about: Dependabot doesn't update image references written into workflow steps (env:, run: or an action's inputs), so the image digests in these workflows need a manual bump every month or so, or a custom regex manager in Renovate.
What should fail the build
Block only on findings you'd stop a release for every single time. Everything else goes to a triage list that a named person reads once a week. If the pipeline fails on every medium finding, people start dismissing findings without reading them, or an admin starts merging past the check.
A blocking list that works for most teams:
- A live secret, or one TruffleHog couldn't verify.
- A new high-severity SAST finding, once the rules are tuned (see the rollout below).
- A high or critical CVE in a runtime dependency or the image, when a fixed version exists.
- A high-severity misconfiguration: a storage bucket open to the internet, a database port open to
0.0.0.0/0, a container running as root.
For the triage list, CVSS alone is a poor sort order. The CVSS base score describes how bad a vulnerability is by its nature (7.0 to 8.9 is high, 9.0 and above critical), and says nothing about whether anyone is exploiting it. Two free sources fill that gap. CISA's Known Exploited Vulnerabilities catalog lists CVEs with confirmed exploitation in the wild, and FIRST's EPSS gives every published CVE a daily probability of being exploited in the next 30 days. Sort by "in KEV" first, then EPSS, then CVSS.
Then write down patch deadlines you can keep. A reasonable start for a small team: anything in KEV or rated critical within two working days, high within two weeks, the rest with the next scheduled upgrade. Name the person who reads the alerts, because an unread Dependabot queue protects nobody.
When a scanner finds a live secret
How much one string is worth depends on the system. The Finland property-search platform we build for a client runs on Supabase, where a secret key (or the older service_role key) bypasses every row-level security policy, so one of those in a repository means full access to the project's data. A hospital rostering platform we build for a client receives staff leave records from hospitals' HR systems, sick leave included. A leaked database credential in a system like that can turn into a reportable breach quickly, and under Turkey's data protection law (KVKK), as under the GDPR, the data controller has 72 hours from learning of a breach to notify the regulator.
The order matters:
- Revoke or rotate the key at the provider, and deploy the replacement.
- Check the provider's logs for any use of the old key since the commit date.
- Move the value into the CI secret store or a secret manager. For cloud deploys, OIDC lets the pipeline request short-lived credentials, so there is no stored cloud key to leak.
- Rewrite git history only if you have a reason to, and don't count on it: clones, forks and CI caches keep the old commits.
When you first add secret scanning, also run TruffleHog once over the full history of each repository. Without --branch it scans every branch in the clone:
docker run --rm -v "$PWD:/repo" \
ghcr.io/trufflesecurity/trufflehog:3.99.2@sha256:47a84bc18a0d04a165498bbbd3bacfd84176661cbc91f8e0f85467f6a771e99a \
git file:///repo --results=verified,unknownThe pull request job only looks at new commits, and old keys are the ones most likely to have been forgotten.
Dynamic scanning against staging
ZAP, now branded ZAP by Checkmarx, has two modes worth knowing. The baseline scan spiders the site for one minute by default and only inspects the responses: missing security headers, cookies without the right flags, information leaks. It sends no attacks, so it's safe to run after every staging deploy (zaproxy/action-baseline takes the same inputs as the full-scan action below). The full scan does attack. It submits forms and fuzzes parameters, which can create junk records or send emails, so run it against staging at night and never against production. Saved as .github/workflows/dast-nightly.yml:
name: dast-nightly
on:
schedule:
- cron: "30 1 * * *"
workflow_dispatch:
permissions:
contents: read
jobs:
zap-full-scan:
runs-on: ubuntu-24.04
timeout-minutes: 90
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: zaproxy/action-full-scan@3c58388149901b9a03b7718852c5ba889646c27c # v0.13.0
with:
target: https://staging.example.com
docker_name: ghcr.io/zaproxy/zaproxy:2.17.0@sha256:5ccfff9a411743ab2615136a2edd7416bec9ce41572fa94e935df38c14adb2b6
allow_issue_writing: falsedocker_name pins the ZAP image, which the action would otherwise pull by its stable tag. The report lands in the run's artifacts as zap_scan. Read it for a couple of weeks before you gate anything on it. Once you know which alerts matter for your app, list those as FAIL in a rules file (rules_file_name), add cmd_options: "-i" so every rule you didn't list is reported as INFO, and set fail_action: true. Without -i, an ordinary warning fails the job too.
Two caveats. An unauthenticated scan sees what an anonymous visitor sees, and in most business apps that's little more than the login page. Teaching ZAP to log in is where the real effort goes, so do it after the rest of the pipeline is running. And if your product is mostly an API, ZAP's API scan (zaproxy/action-api-scan) reads an OpenAPI, SOAP or GraphQL definition instead of crawling pages.
Rolling it out in a small team
Adding everything at once produces a wall of red builds and a team that stops trusting the checks. One step a week works better:
- Turn on push protection where you have it, add the pre-commit hook and the
dependabot.ymlabove, and run TruffleHog over the full history of every repository. Rotate whatever it finds. - Add the
secretsanddependencies-and-configjobs, blocking from the first day. On an older project, expect to spend a day upgrading packages and writing the first.trivyignoreentries. - Add the
sastjob without--errorand leave it reporting for two weeks. Read every finding, switch off the rules that don't fit your codebase, then add--error. - Add the
imagejob, and the SBOM step in the release build. - Then ZAP: the baseline scan after each staging deploy, the nightly full scan, and an authenticated setup if most of the app sits behind a login.
In the first month, watch two things: how many minutes the security jobs add to a pull request, and how many findings get dismissed rather than fixed. If people dismiss most of what a rule reports, the rule is wrong for your codebase. Turn it off instead of training everyone to ignore the tool.
Where the pipeline stops
Scanners find known patterns. Your permission model, approval flows and tenant boundaries need threat modeling, code review and tests written for your own rules, and before a major launch, or for a system holding sensitive data, an external penetration test is worth paying for. Hand the testers your scan reports so they spend their days on what the tools can't see. Agent-based tools such as IAST and RASP can come later, once everything above is running.
The pipeline also leaves evidence behind. Customer security questionnaires ask how you handle vulnerabilities, and ISO 27001:2022 has Annex A controls for exactly that: 8.8 for technical vulnerabilities and 8.25 to 8.29 for secure development and testing. We are working toward ISO 27001 and preparing for SOC 2 ourselves. Scan history, exception files with dates and owners, and triage notes are the trail an auditor asks to see, so keep them.
Frequently asked questions
What's the difference between DevOps and DevSecOps?
The pipeline and the habits are the same. DevSecOps adds security checks to that pipeline and makes developers responsible for fixing what the checks find, while security specialists write the rules and handle what tools can't. The name joins Development, Security and Operations.
Are free tools enough?
For a small team, mostly yes. The scanners in the workflows above are free, and running them costs only CI minutes. Paid platforms add a dashboard across repositories, deduplication, prioritization and support. They start to pay off when several teams share the findings, or when a customer contract names a product.
How much does this slow down pull requests?
The four jobs run in parallel, so the wait is set by the slowest one, often the image build. Measure it in the first week. If one job is slow, fix that job (cache the build, exclude generated files) rather than dropping the check.
If you'd like help adding these checks to a project you already run, get in touch.
Related Articles
Secure SDLC: What Each Phase Should Produce
What a secure SDLC adds to each phase of development: requirements you can test, a worked threat model for a CSV import, and where a small team should start.
Read More: Secure SDLC: What Each Phase Should ProduceOWASP Top 10 2025: What Changed and How to Fix Each Risk
OWASP's 2025 list adds two categories and folds SSRF into access control. What each risk looks like in a real web app or API, and what to fix first.
Read More: OWASP Top 10 2025: What Changed and How to Fix Each RiskBuying a Penetration Test: Scope, Cost Drivers and Preparation
A buyer's and developer's guide to penetration testing: what you pay for, how to scope and prepare, and what to do when the report arrives.
Read More: Buying a Penetration Test: Scope, Cost Drivers and Preparation
