Skip to main content
SAST, DAST & SCA Integration Without Breaking Velocity
Lesson 14 of 15

SAST, DAST & SCA Integration Without Breaking Velocity

Integrate static analysis (SAST), software composition analysis (SCA), and dynamic testing (DAST) into CI/CD pipelines using diff-aware scanning, SBOM/VEX triage, and asynchronous staging checks so security gates catch real flaws without stalling delivery.

Advanced 26 min AppSec

Learning objectives

  • Differentiate what SAST, SCA, and DAST detect and match each scanner to the right CI/CD stage
  • Configure diff-aware Semgrep rules with exclusions to eliminate false positives on pull requests
  • Implement continuous SCA monitoring by feeding CycloneDX SBOMs and VEX triage decisions into Dependency-Track
  • Run non-blocking baseline DAST scans against authorised staging targets and isolate active fuzzing to scheduled jobs

Recommended first: CI/CD Pipeline Hardening & Secrets Management (OIDC/Vault)Software Supply Chain Security: Dependencies, SBOM & SLSA

#Why this matters

Adding security scanners to a CI/CD pipeline is easy; keeping them enabled six months later is hard. When teams drop default SAST, SCA, and DAST tools into a pull-request workflow in blocking mode, builds that used to finish in four minutes suddenly take thirty minutes and fail on hundreds of legacy or non-exploitable findings. Developers respond by disabling checks, adding blanket suppressions, or pushing hotfixes around the pipeline.

Effective DevSecOps treats developer velocity as a security requirement. Building on hardened runners and SBOM generation, the goal is to place each scanner at the pipeline stage where its signal-to-noise ratio and runtime budget fit, tune rules to your codebase, and separate fast PR feedback from deeper asynchronous verification.

#Matching scanner type to pipeline stage

SAST, SCA, and DAST examine different representations of the same system, so none replaces the others:

Scanner What it inspects Typical runtime Primary blind spot Best pipeline stage
SAST (Semgrep) Source code and ASTs Seconds to 3 min Runtime headers, auth state, infra Synchronous PR gate (diff-aware)
SCA (Dependency-Track) Lockfiles and CycloneDX SBOMs Seconds (upload) Whether vulnerable function is reachable PR lockfile check + continuous monitoring
DAST (OWASP ZAP) Live HTTP/API responses 2 to 45+ min Unreached routes, dead code paths Passive baseline on staging; active nightly

The core design principle is simple: synchronous pull-request gates must be fast (under a few minutes) and high-confidence. Longer or noisier checks run asynchronously after merge or on a schedule, feeding triaged tickets into the team's backlog rather than blocking unrelated feature commits.

  1. Pull RequestDiff-aware Semgrep + lockfile SCA
  2. Merge to mainBuild once, emit CycloneDX SBOM
  3. Dependency-TrackContinuous CVE + VEX evaluation
  4. Staging DeployZAP baseline passive scan
  5. Nightly ScheduleZAP active scan on isolated target

#Keeping pull requests fast with diff-aware SAST

Traditional regex-based linters drown teams in false positives because they cannot distinguish a comment, a test fixture, or a safe wrapper function from real execution. Modern tools such as Semgrep parse code into an Abstract Syntax Tree (AST), letting you match structural patterns and exclude safe idioms cleanly.

Two practices keep SAST fast and credible on pull requests:

  1. Scan the diff, not the whole history. Use --baseline-commit so a pull request only blocks on new findings introduced by the branch. Existing findings are tracked in a backlog rather than holding an unrelated bugfix hostage.
  2. Write narrow, local rules. If your codebase uses an internal sanitisation helper or passes fixed argument lists instead of shell strings, encode that knowledge directly in the rule using pattern-not and paths.

Consider a Python service where calling subprocess.run with shell=True risks command injection, whereas passing an argument list with shell=False (the default) is safe. A naive rule matching subprocess.run(...) flags every call. Tightening the rule isolates genuine risk:

yaml
rules:
  - id: python-subprocess-shell-true
    languages: [python]
    severity: ERROR
    message: Avoid shell=True in subprocess.run; pass an argument list instead.
    patterns:
      - pattern: subprocess.run(..., shell=True, ...)
      - pattern-not: subprocess.run("...", shell=True, ...)
    paths:
      exclude:
        - "tests/**"

In this rule, pattern-not suppresses static string literals (where no variable is interpolated), and paths.exclude skips test suites. Running Semgrep in CI against changed files takes seconds:

Running a diff-aware Semgrep scan
$ semgrep scan --config rules/python-cmd.yaml --baseline-commit origin/main --error
Scanning 4 changed files with 1 rule.
Ran 1 rule on 4 files: 1 finding.
app/exporter.py:42 [python-subprocess-shell-true] Avoid shell=True in subprocess.run

#Continuous SCA with SBOMs and VEX triage

Dependency vulnerabilities behave differently from source bugs: code that passed every check on Tuesday can become vulnerable on Wednesday when a new CVE is disclosed. Running an SCA CLI only during pull requests misses stale services that have not been rebuilt in weeks.

A cleaner architecture separates SBOM generation from vulnerability evaluation:

  1. During the build on main, generate a CycloneDX SBOM alongside the artifact and upload it to OWASP Dependency-Track.
  2. Dependency-Track stores the component inventory and continuously re-evaluates it whenever advisory feeds update, eliminating redundant CI scans.
  3. On pull requests, only check whether newly added or upgraded dependencies introduce critical, fixable vulnerabilities or forbidden licenses.

Blocking every build on raw CVSS scores still causes gridlock because many CVEs reside in transitive libraries whose vulnerable function is never invoked. VEX (Vulnerability Exploitability eXchange) solves this by letting security engineers record an auditable assessment in Dependency-Track, such as not_affected (with a justification like code_not_reachable) or false_positive. Once triaged, Dependency-Track suppresses repeat alerts for that component version across pipelines until a new version changes the dependency graph.

#Integrating DAST without stalling merges

Full active DAST crawls a running application and fuzzes every form, header, and JSON parameter with injection payloads. Running that inside a pull-request job adds 20 to 45 minutes and often fails due to ephemeral test environment flakiness.

Split DAST into two tiers aligned with OWASP ZAP:

  • PR or post-merge baseline (passive only): Spin up the built container against an isolated mock backend and run zap-baseline.py. It spiders reachable endpoints and inspects responses passively for missing security headers, insecure cookies, stack traces, and CORS issues in roughly one to two minutes without sending attack payloads.
  • Nightly active scan: Run full active scanning against a dedicated, seeded staging environment (http://lab.local:8080) with authentication configured, routing confirmed findings to the security triage queue.
Running a fast ZAP baseline scan against a lab preview container
$ docker run --rm --network host ghcr.io/zaproxy/zaproxy:stable \
  zap-baseline.py -t http://lab.local:8080 -I -r zap-baseline.html
PASS: Directory Browsing [10033]
WARN-NEW: Content Security Policy (CSP) Header Not Set [10038] x 3
FAIL-NEW: 0  FAIL-INPROG: 0  WARN-NEW: 1  IGNORE: 0  PASS: 58

Notice the -I flag: by default, zap-baseline.py exits with code 2 on warnings, which would fail a pipeline over informational headers. Using -I lets warnings surface in the HTML report while failing the job only on high-confidence FAIL-NEW alerts or explicit rule overrides.

#Common mistakes

  • Enabling every community ruleset in blocking mode on day one: High false-positive rates destroy developer trust faster than having no scanner at all. Start new rules in audit/comment mode, measure precision, and promote only high-signal rules to blocking.
  • Unreviewed inline suppressions: Letting # nosemgrep comments silence findings without CODEOWNERS or security review turns suppressions into a quiet bypass path.
  • Scanning shared or production databases with active DAST: Active payloads can submit thousands of forms, trigger account lockouts, or corrupt shared test data. Keep active DAST on disposable, seeded environments.
  • Treating scanner output as one-way noise: Whenever DAST or a manual pentest finds a flaw, add a regression rule in Semgrep or a policy check so the same class never re-enters the codebase.

#Summary

Integrating SAST, SCA, and DAST without breaking velocity depends on matching each tool's cost and signal quality to the right pipeline stage. Keep pull-request checks fast and high-confidence through diff-aware, AST-tuned Semgrep rules and passive ZAP baselines. Move heavy active DAST to scheduled staging runs and offload continuous CVE tracking to Dependency-Track with CycloneDX SBOMs and VEX triage so teams fix real risks instead of chasing stale alerts.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in