SAST, Dependency Scanning, Secret Detection, Container Scanning, DAST, IaC Scanning, and Security Gates: Configuration, Design Choices, and Tradeoffs
Choose deliberately between GitLab-managed and external scanners, advisory and enforced gates, stable and latest templates/components, and broad coverage versus feedback latency while preserving auditability and least privilege.
Learning objectives
- Choose between GitLab-managed scanners and external scanners based on report integration, portability, trust, and maintenance cost.
- Design advisory and blocking security gates as explicit policies rather than accidental scanner exit behavior.
- Choose Stable versus Latest templates/components with a documented update strategy.
- Design a reviewable false-positive/exception lifecycle with owner, rationale, scope, and expiry.
- Balance scan breadth and latency while preserving complete evidence and correct runner/network boundaries.
1. Built-in GitLab scanners versus external tools
Whatever scanner ownership model you choose, the evidence contract
still begins with CI_PIPELINE_SOURCE and
CI_COMMIT_SHA; template/component choice must not break
source provenance.
| Choice | Advantages | Tradeoffs | Observable evidence |
|---|---|---|---|
| GitLab-managed scanner/template | Native report schema; documented variables; easier GitLab UI integration. | Analyzer/runtime constraints and GitLab-version coupling; some workflows require Ultimate. | Included template/component, analyzer image/version, GitLab security report, job trace. |
| External OSS scanner | Portable; can run locally; independent release cadence. | You own versioning, report storage, schema adaptation, and gate logic. | Pinned tool image/binary, raw report checksum, adapter/gate version. |
| Custom organization scanner | Exact domain rules and workflow integration. | Highest maintenance burden; schema and false-positive quality are your responsibility. | Scanner release, ruleset commit, report schema tests, ownership record. |
2. Advisory scan versus enforced gate
An advisory scan produces evidence and keeps development moving. A gate blocks when a documented condition is met. Neither is universally correct. Early rollout often starts advisory to measure noise and coverage, then graduates to a gate with known ownership and exception handling.
| Policy style | Best fit | Failure risk | Safer design |
|---|---|---|---|
| Advisory | New scanner/ruleset, high uncertainty, discovery phase | Teams ignore findings indefinitely. | Define owner, SLA, metrics, and planned gate transition. |
| Block on any finding | Small trusted rule set with near-zero noise | One false positive halts all delivery. | Use severity/confidence/scope plus exception workflow. |
| Block new findings only | Mature baseline with legacy debt | Baseline drift or wrong comparison hides issues. | Bind baseline and current scan to exact SHAs and preserve both reports. |
| Central policy enforcement | Large organization needing consistent controls | Misconfigured policy can break many projects. | Canary rollout, policy versioning, emergency evidence path, explicit scope. |
3. Stable versus Latest templates and components
Current GitLab guidance recommends Stable security templates for production workflows because breaking changes are constrained to major GitLab versions. Latest templates deliver newer behavior faster and can change between minor releases. Mixing Stable and Latest security templates in the same project can create duplicate branch/MR pipelines.
GitLab increasingly publishes official CI/CD components for security
scanners. Treat component references as software dependencies: use a
reviewed release/update policy. Examples in GitLab docs sometimes
show @main for discovery, but a mutable branch is not
an immutable production dependency.
4. Dependency Scanning migration: do not build new workflows around the deprecated path
Current GitLab Dependency Scanning is Ultimate and is moving to the
SBOM-based analyzer. The migration guide says the legacy
Gemnasium-based scanning feature was deprecated in 17.9 and is
proposed for removal in GitLab 20.0. Stable/latest template users
should migrate to
Jobs/Dependency-Scanning.v2.gitlab-ci.yml; component
users should use major version 2 of the main dependency-scanning
component.
For this course's Free mandatory path, Chapter 26 will build supply-chain evidence directly from SBOM/dependency artifacts and local tooling. That preserves the mental model without pretending the paid GitLab workflow is available.
5. False positives and exceptions are governed evidence
A false positive is not “a finding somebody dislikes.” Triage should capture the finding identity, source/report SHA, technical rationale, reviewer/owner, scope, and expiry/review date. If the finding is accepted risk rather than false positive, say so explicitly. Suppression files should be version controlled and narrowly scoped.
{
"finding_id": "synthetic-secret:8b2f6d4e",
"classification": "training_marker_false_positive",
"scope": "src/app.py:LAB_SECRET_EXAMPLE_NOT_CREDENTIAL",
"owner": "lab-security-reviewer",
"rationale": "Synthetic marker contains no credential material.",
"expires": "2026-09-30"
}
6. Broad scan coverage versus feedback latency
Run fast source/secret/IaC scans in merge-request feedback when they fit runner capacity. More expensive dependency resolution, container scans, or DAST may use staged pipelines or scheduled/release checks depending on risk. Do not improve latency by silently dropping scanner classes. Record which checks were omitted and why.
Chapter 17's fan-out lesson applies: parallelize independent scans only within runner capacity. Chapter 18's cancellation lesson also applies: safe read-only scans can often be interruptible; deployment or external active-scanning side effects need different treatment.
7. Identity design: CI_JOB_TOKEN, registry credentials, cloud identity, and scanner data
The scanner should receive only the identity needed to read its input. Source scanners usually need repository checkout, not cloud-admin access. Container scanners need pull access to the exact image, not push/delete permission. DAST should authenticate to a disposable test account if authentication is required. Cloud/IaC validation that requires live access should prefer short-lived federated identity rather than long-lived static secrets, and only when the scan scope genuinely requires provider access.
8. Decision table
| Scenario | Choice | Tier/trust prerequisite | Prediction and evidence |
|---|---|---|---|
| Python MR needs fast source checks | GitLab Free SAST or pinned Semgrep OSS | Linux supported runner; untrusted MR must not receive protected secrets | Source SHA + scanner version + SAST/raw report + explicit gate. |
| Need known-vulnerable dependency management inside GitLab UI | Current GitLab Dependency Scanning | Ultimate; supported v2 template/component | SBOM/dependency report, finding state, exact template/component version. |
| Need unauthenticated web smoke security check | DAST only against disposable test target | Ultimate for GitLab DAST; network access to authorized test service | Target URL/build identity + DAST profile + report + post-scan target state. |
| Terraform policy check in Free project | GitLab IaC basic scan or local KICS/other OSS | Supported runner or local tool | IaC file SHA + scanner/ruleset + raw report; richer GitLab finding management is optional. |
| Organization wants mandatory scan across projects | Security/pipeline execution policy | Ultimate + policy project ownership | Policy version/scope + injected jobs + project pipeline evidence + exception process. |
Knowledge check
Why are Stable templates usually preferred for production security scanning?
GitLab documents Stable templates as changing less frequently, with breaking changes constrained more predictably than Latest templates.
What should a security exception record contain?
Finding identity, scope/source evidence, classification/rationale, owner/reviewer, and expiry or review date. Accepted risk and false positive should not be conflated.
Why is a mutable component reference such as
@main risky in production?
The referenced configuration can change without a repository change, weakening reproducibility and reviewability.
What is the current migration direction for GitLab Dependency Scanning?
Move from deprecated legacy Gemnasium-based scanning to SBOM-based v2 template/component workflows.
When should a scanner get cloud or production credentials?
Only when its explicitly authorized scan scope genuinely requires them; most source/secret/IaC static scans do not. Prefer least privilege and short-lived identity.
Version and compatibility note
GitLab and GitLab Runner evolve continuously. Treat version-sensitive YAML, runner/executor behavior, APIs, security features, policy controls, tiers, and deprecations as assumptions to verify against the current official GitLab documentation before production use. Preserve the exact project/ref/SHA, compiled configuration, pipeline/job IDs, runner/tool versions, and external target evidence used for any reproducible lab or incident record.
Official references and version notes
Documentation verification date: 2026-09-12. Basic
GitLab SAST, pipeline Secret Detection, Container Scanning, and IaC
scanning are documented for Free/Premium/Ultimate. Current GitLab
Dependency Scanning and DAST are Ultimate. Security policy
enforcement is Ultimate. GitLab's current Dependency Scanning
direction is SBOM-based; the legacy Gemnasium-based implementation
was deprecated in GitLab 17.9 and is proposed for removal in GitLab
20.0. Stable security templates are recommended for production
workflows; Latest templates change more frequently.
AST_ENABLE_MR_PIPELINES="true" is the current
recommended switch for supported application-security scans in
merge-request pipelines. GitLab documents Stable and Latest security
template editions and warns against mixing editions. Current
Dependency Scanning migration guidance specifically moves projects
to the v2 SBOM-based analyzer/template/component path.
- SAST — official reference.
- SAST analyzers — official reference.
- Secret detection — official reference.
- Secret detection configuration — official reference.
- Container scanning — official reference.
- Dependency scanning — official reference.
- Dependency scanning migration to SBOM — official reference.
- DAST — official reference.
- DAST browser analyzer — official reference.
- IaC scanning — official reference.
- Security configuration — official reference.
- Security policies — official reference.
- Security scanner integration and report schemas — official reference.
- CI/CD YAML syntax — official reference.
Current assumptions used in this chapter: Version-sensitive YAML, Runner/executor behavior, APIs, security features, policy controls, tiers, and deprecations must be verified against the exact GitLab, GitLab Runner, tool, and external-system versions used in production. Preserve the exact project/ref/SHA, compiled configuration, pipeline/job IDs, runner/tool versions, and external target evidence used for reproducible work.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0
Send only Ethereum/ERC-20 compatible assets to this
address.