Lesson 7 of 9 · 27m
Security Scanning Integrated Into the Pipeline
Run SAST, dependency, container, and secret scanning as decision-grade controls instead of noisy decorative jobs.
Security scanning fails in two opposite ways. Either it is so noisy that everyone ignores it, or it is so strict that teams route around it. Professional integration means deciding which findings block, which findings inform, where results appear, and how exceptions expire. The scanner is the easy part; governance is the work.
Put scanner output where reviewers already look
include:
- template: Jobs/SAST.gitlab-ci.yml
- template: Jobs/Secret-Detection.gitlab-ci.yml
- template: Jobs/Dependency-Scanning.gitlab-ci.ymlGitLab templates generate report artifacts that surface in merge request security widgets. That placement matters. A scanner that only writes to job logs will be read only after a breach retrospective.
Tune the analyzer rather than forking the world:
sast:
variables:
SAST_EXCLUDED_PATHS: "spec,tmp,vendor"
SCAN_KUBERNETES_MANIFESTS: "false"Blocking policy must be explicit
allow_failure: true is not neutral. It means a scanner can fail or report serious findings without stopping delivery. Sometimes that is correct while tuning. Sometimes it is compliance theater.
A pragmatic progression:
- Run in report-only mode and measure false positives.
- Block only high-confidence critical findings.
- Expand enforcement as remediation capacity catches up.
- Require dated exceptions with an owner.
secret_detection:
allow_failure: falseSecret detection is usually a hard blocker because a leaked credential is not a theoretical future risk. SAST often needs more tuning before blocking.
Scans need the right context
Dependency scanning requires lockfiles or package manager metadata. Container scanning needs the image you will actually ship, not a convenient base image. Infrastructure scanning needs the rendered manifest or Terraform plan, not just source files that templating will transform.
container_scanning:
variables:
CS_IMAGE: "$CI_REGISTRY_IMAGE/app:$CI_COMMIT_SHA"If the scanned artifact is not the deployed artifact, the result is decorative.
Triage is an engineering workflow
Every scanner needs an answer to: who triages, how fast, and what happens when a finding is disputed? Suppression files without ownership turn into permanent denial. Make exceptions visible, narrow, and time-bound.
Field notes
- Put findings in merge request reports, not just logs.
allow_failureis a policy decision; write down why it is set.- Scan the artifact you deploy, especially for containers.
- Hard-block leaked secrets before tuning anything else.
- Exceptions need owners, scope, and expiry dates.
Was this lesson helpful?