Skip to content

Lesson 9 of 13 · 20m

Scanning in the Pipeline: Secrets, Deps, Code, Images

Four scanners earn a pipeline slot — gitleaks, the dependency audit, CodeQL, and an image scan — each gated on the severity you'll actually act on.

The pipeline is the one place scanning can't be skipped, which makes it the only place scanning reliably happens. Four scanners earn a slot — secrets, dependencies, static analysis, and the built image — and each has a noise profile that decides whether it gates or reports.

Secrets: scan before they land

Committed secrets are a git-history problem: push a .env once and it lives in the object graph forever, cloned by everyone who ever fetched. gitleaks (gitleaks git --redact) and trufflehog scan the repo for high-entropy and known-format credentials; trufflehog's --only-verified flag is the important one — it makes the API call to check whether a candidate key is live, which separates "string that looks like a token" from "token that works." GitHub's push protection blocks pushes containing recognized token formats on public repos for free — confirm it's on.

Placement: a fast secrets scan early in the pipeline catches the .env before it fans out into every log and artifact the run produces.

Dependencies: the lockfile is the input

npm audit reads package-lock.json against the GitHub Advisory Database and reports known CVEs. As a hard gate it's contentious — npm audit --audit-level=high fails builds on advisories you can't fix yet or that don't apply to your usage, and the noise teaches skipping. The better pattern: osv-scanner (Google's multi-ecosystem scanner against osv.dev) or audit in report mode, with the actual gate carried by Dependabot or Renovate opening bump PRs that run the whole suite — an update that breaks tests never merges. npm audit signatures adds the integrity layer the registry added after the fact, verifying packages' sigstore provenance where attestations exist.

SAST: CodeQL, with expectations set

github/codeql-action runs CodeQL analysis — JavaScript, TypeScript, Python, Go, and friends — and uploads SARIF results to the Security tab. It catches pattern-shaped bug classes: injection sinks, unsafe deserialization, path traversal. It does not catch logic bugs, and the default query suite produces false positives you tune away; the security-extended suite widens coverage at a noise cost. Gate on the severities you act on — high and up — or SAST gets disabled in month two.

Image scanning: after the build, before the deploy

The image you built is what actually runs, so scan that: aquasecurity/trivy-action scans the image filesystem for OS-package and language CVEs, and trivy image --severity CRITICAL --exit-code 1 fails the job on criticals. The meaningful gate is "no unfixed criticals in the base image or dependencies" — base images carry dozens of low and medium findings that are noise by design, and a scanner that red-lines on them is a scanner that gets its threshold raised until it means nothing.

Scan results land in two places: the job log, and SARIF uploaded to the repo's Security tab via codeql-action/upload-sarif. The SARIF route is the one reviewers can filter, dismiss, and track over time — the log route is where findings go to scroll past.

The model that survives contact

Scanning is not security — it's signal. Every scanner gates only at the severity you act on; everything below goes to a report nobody reads but an auditor can grep. The failure mode is alert fatigue, and the countermeasure is a gate that means something: it fails rarely and is never bypassed. A scanner configured to pass spends the gate's credibility on nothing.

Field notes

  • gitleaks on the PR diff (--log-opts) takes seconds; full-history scans are nightly work.
  • Dependabot alerts and Dependabot version updates are different features — the first reports CVEs, the second ships bumps on a schedule. You want both.
  • Scan reports uploaded as artifacts get exfiltrated with everything else in a compromised run — a Trivy report on your image is an attacker's shopping list. Keep them private or short-lived.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.