Security testing works best as a set of fast, specific checks in the same pipeline that builds the code, each catching a different kind of flaw: secret detection (keys committed by mistake), SAST (static analysis of your code), SCA (known vulnerabilities and licences in dependencies), IaC scanning (misconfigured Terraform and Kubernetes), container scanning (vulnerable packages in images), and DAST (attacking the running app). The hard part is not running scanners; it is prioritising thousands of findings so engineers fix what is exploitable and reachable first, using exploit data (CISA KEV, EPSS) and context. This lesson follows one pull request through the security checks, and shows the two failures that make scanning useless: a scanner wall nobody reads, and a severity score treated as a priority.
Difficulty: Advanced · Know this first: Lesson 241, Lesson 244
By the end of this lesson you can work at four levels:
This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.
This bar adds up minutes the security checks add to a pull request, including the fixes. It is a worked example, not a measurement. The prioritisation hop decides whether the checks protect anything.
Pick how findings are prioritised, what blocks a merge, and whether scanners are deduplicated. The readouts show what an engineer sees and what ships.
Three questions. No score is saved anywhere — this is just you against the material.
Application security testing grows in four levels: reading findings, running the checks, prioritising by risk, and running a vulnerability management programme.
At the basic level you can read a finding and fix it.
Where it breaks: suppressing a finding without a reason.
Try it: Basic
SAST flags a query built with string formatting. What is the fix?
Now do it: Find a string-built query in a codebase you know.
At the intermediate level you wire the checks into the pipeline.
Try it: Intermediate
Why run IaC scanning on the Terraform plan rather than the source files only?
Now do it: Run Checkov on a plan file.
At the advanced level findings are ranked by likelihood and impact.
Try it: Advanced
What does EPSS estimate?
Now do it: Look up the EPSS score of a CVE in your dependencies.
At the master level vulnerabilities are managed as a measured programme.
Trade-off: strict gates slow some merges; a short, real blocking list keeps them respected.
Try it: Master
The vulnerability backlog grows every month. What reduces it most sustainably?
Now do it: Turn on automated dependency updates for one service.
The checks as pipeline steps (GitHub Actions syntax; the same tools run in any CI). Pin action and tool versions you have reviewed.
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0}
- name: Secrets (whole history of the pull request)
run: gitleaks git --log-opts="origin/main..HEAD" --redact --exit-code 1
- name: SAST on the diff
run: semgrep scan --config p/default --baseline-commit origin/main --error
- name: SCA from the lock files
run: osv-scanner scan --lockfile package-lock.json --lockfile go.sum
- name: IaC on the Terraform plan
run: terraform -chdir=infra plan -out tfplan && terraform -chdir=infra show -json tfplan > plan.json && checkov -f plan.json --framework terraform_plan
- name: Image scan and SBOM
run: |
docker build -t app:pr .
trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 0 --format json -o trivy.json app:pr
syft app:pr -o cyclonedx-json > sbom.json
A risk score for triage, in words: start with must-fix if the CVE is on the CISA KEV list and the code is reachable; otherwise rank by EPSS probability, raised for internet exposure and sensitive data, lowered when the vulnerable code is not reachable or only in test dependencies; use CVSS to break ties. Deduplicate findings for the same CVE and package across scanners before ranking.
DAST against staging: docker run -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t https://staging.example.com runs a passive baseline scan; full active scans and API scans from an OpenAPI spec need an environment you own and are allowed to attack.
This is a composite of a failure pattern that keeps repeating; the details are illustrative. The warning among four thousand.
Findings are deduplicated and ranked by KEV, EPSS, reachability, and exposure; the merge gate blocks on a short list of real risks; everything else gets a deadline by tier; and automated dependency updates keep most libraries current.
Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.
Before you start: A virtual environment for Python packages: python3 -m venv ~/sec && . ~/sec/bin/activate. Then pip install pip-audit, and Git. The key below is a made-up example in the documented AWS example format, not a real credential.
Type each one, read what it prints, and compare it with the note above it.
Commit a fake key, then "remove" it in the next commit.
mkdir -p ~/labs/sec && cd ~/labs/sec && git init -q
echo "aws_access_key_id = AKIAIOSFODNN7EXAMPLE" > config.ini && git add . && git commit -qm "add config"
echo "aws_access_key_id = ${AWS_KEY}" > config.ini && git commit -qam "remove key"
cat config.iniSearch the whole history the way a secret scanner does: the key is still there.
git log -p --all | grep -nE "AKIA[0-9A-Z]{16}"Scan pinned dependencies for known vulnerabilities (SCA).
printf "requests==2.19.0\njinja2==2.10\n" > requirements.txt pip-audit -r requirements.txt --no-deps 2>/dev/null | head -12
triage.pyThis program merges findings from three scanners, removes duplicates, and ranks them two ways: by CVSS score alone, and by risk (known exploitation on the CISA KEV list, EPSS probability, reachability, and internet exposure, with CVSS only breaking ties). It then applies a short blocking list for the merge gate. Save it as triage.py, then run it.
# triage.py
FINDINGS = [ # (scanner, cve, package, cvss, kev, epss, reachable, internet_facing, fix_available)
("sca", "CVE-2026-1101", "csvparse", 7.5, True, 0.71, True, True, True),
("trivy", "CVE-2026-1101", "csvparse", 7.5, True, 0.71, True, True, True),
("sca", "CVE-2026-2202", "testfaker", 9.8, False, 0.02, False, False, True),
("trivy", "CVE-2026-3303", "libxml", 8.1, False, 0.04, True, False, True),
("sca", "CVE-2026-4404", "imagekit", 6.5, False, 0.33, True, True, True),
("semgrep","SQLI-new-code", "exports.py", 8.0, False, 0.00, True, True, True),
("trivy", "CVE-2026-5505", "zlib", 5.3, False, 0.01, False, False, False),
]
unique = {}
for f in FINDINGS:
unique.setdefault((f[1], f[2]), f)
print(f"{len(FINDINGS)} findings from 3 scanners -> {len(unique)} after deduplication\n")
def risk(f):
_, cve, pkg, cvss, kev, epss, reach, internet, fix = f
score = epss * 10 + (5 if reach else -5) + (3 if internet else 0)
if kev and reach:
score += 100
if cve.startswith("SQLI"):
score += 50 # high-confidence SAST finding in new, internet-facing code
return (score, cvss)
def blocks(f):
_, cve, _, cvss, kev, _, reach, _, fix = f
return (kev and reach and fix) or cve.startswith("SQLI") or (cvss >= 9 and reach and fix)
for name, key in (("by CVSS only", lambda f: f[3]), ("by risk", risk)):
order = sorted(unique.values(), key=key, reverse=True)
print(name + ":")
for f in order:
tag = "BLOCK" if name == "by risk" and blocks(f) else ""
print(f" {f[1]:<14} {f[2]:<11} CVSS {f[3]:>4} KEV {'yes' if f[4] else 'no ':<3} EPSS {f[5]:.2f} reachable {'yes' if f[6] else 'no '} {tag}".rstrip())
print()
Run it, and you should see this output:
$ python3 triage.py 7 findings from 3 scanners -> 6 after deduplication by CVSS only: CVE-2026-2202 testfaker CVSS 9.8 KEV no EPSS 0.02 reachable no CVE-2026-3303 libxml CVSS 8.1 KEV no EPSS 0.04 reachable yes SQLI-new-code exports.py CVSS 8.0 KEV no EPSS 0.00 reachable yes CVE-2026-1101 csvparse CVSS 7.5 KEV yes EPSS 0.71 reachable yes CVE-2026-4404 imagekit CVSS 6.5 KEV no EPSS 0.33 reachable yes CVE-2026-5505 zlib CVSS 5.3 KEV no EPSS 0.01 reachable no by risk: CVE-2026-1101 csvparse CVSS 7.5 KEV yes EPSS 0.71 reachable yes BLOCK SQLI-new-code exports.py CVSS 8.0 KEV no EPSS 0.00 reachable yes BLOCK CVE-2026-4404 imagekit CVSS 6.5 KEV no EPSS 0.33 reachable yes CVE-2026-3303 libxml CVSS 8.1 KEV no EPSS 0.04 reachable yes CVE-2026-2202 testfaker CVSS 9.8 KEV no EPSS 0.02 reachable no CVE-2026-5505 zlib CVSS 5.3 KEV no EPSS 0.01 reachable no
The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/application-security-testing-sast-dast-sca-and-iac-scanning && cd ~/labs/application-security-testing-sast-dast-sca-and-iac-scanning) and save this as lab.sh.
#!/usr/bin/env bash
# The Linux steps of "Application Security Testing in the Pipeline: SAST, SCA, Secrets, IaC, Containers, DAST, and Prioritisation", as one script (save it as lab.sh).
#
# ./lab.sh run every step, in order
# ./lab.sh 2 4 run only steps 2 and 4
# ./lab.sh --list list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.
STEPS=(
'Commit a fake key, then "remove" it in the next commit.'
'Search the whole history the way a secret scanner does: the key is still there.'
'Scan pinned dependencies for known vulnerabilities (SCA).'
)
step_1() {
mkdir -p ~/labs/sec && cd ~/labs/sec && git init -q
echo "aws_access_key_id = AKIAIOSFODNN7EXAMPLE" > config.ini && git add . && git commit -qm "add config"
echo "aws_access_key_id = ${AWS_KEY}" > config.ini && git commit -qam "remove key"
cat config.ini
}
step_2() {
git log -p --all | grep -nE "AKIA[0-9A-Z]{16}"
}
step_3() {
printf "requests==2.19.0\njinja2==2.10\n" > requirements.txt
pip-audit -r requirements.txt --no-deps 2>/dev/null | head -12
}
# print a step that has to be run by hand, instead of running it
by_hand() {
echo " (run this one yourself: $1)"
sed 's/^/ /'
}
RESULTS=()
run_step() {
local n=$1 start=$SECONDS code
printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
"step_$n"
code=$?
RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}
summary() {
echo
echo "== summary"
local r
for r in "${RESULTS[@]}"; do echo " $r"; done
}
case "${1:-}" in
-h|--help) sed -n '2,6p' "$0"; exit 0 ;;
--list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac
[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
echo "there is no step '$n'; try --list" >&2
exit 2
fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done
Then make it executable and run it:
chmod +x lab.sh ./lab.sh --list # the steps ./lab.sh # every step, then a summary of exit codes and times ./lab.sh 2 3 # only steps 2 and 3
New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.
grep, head, mkdir, cat, echo, cd, Pipes, Redirection, If...Else.Your 40 services produce 60,000 open scanner findings and engineers ignore them. Design the application security testing and vulnerability management process.
Which checks run where, and how fast? How are findings deduplicated and ranked? What blocks a merge? What deadlines apply by tier? How do you shrink the backlog sustainably? How do you measure progress?
Say 40 services, 5 scanners, 60,000 open findings, 300 merges a week, and a security team of 4.
Push protection for secrets; SAST on the diff with tuned rules; SCA from lock files with reachability where available; IaC scanning on plans; image scanning and SBOMs; nightly DAST on staging; all findings into one platform with deduplication; ranking by KEV, EPSS, reachability, exposure, then CVSS; a gate that blocks only secrets, KEV or critical reachable with fixes, new high-confidence SAST, and IaC policy; deadlines by tier (KEV 7 days, high 30, medium 90); Renovate on every repository; security champions per team; monthly trend reports.
A short blocking list accepts some lower risks for a while and keeps the gate respected; reachability analysis is incomplete for some languages; automated updates need good tests to merge confidently.
Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.
| Scenario | Where | Effect | What goes wrong |
|---|---|---|---|
| Scanner wall | Hop 8: Prioritisation | Breaks | Every scanner's output goes into the build log: 4,200 findings per build, most low or duplicated, all labelled "warning". Engineers stop reading. The CSV library flaw, on the KEV list and reachable from the new internet-facing endpoint, ships. |
| CVSS as priority | Hop 8: Prioritisation | Breaks | Priority is the CVSS base score. The team spends five weeks on CVSS 9.8 findings in test-only dependencies that never ship. |
The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.
Last updated . Next review due by November 2027. Found something out of date? Tell me.