Skip to content

fix(scanners): skip osv with no sources, ignore Dockerfile stage names - #97

Merged
danieloceno merged 2 commits into
mainfrom
fix/osv-skip-and-docker-stage-images
Nov 16, 2026
Merged

danieloceno merged 2 commits into
mainfrom
fix/osv-skip-and-docker-stage-images

Conversation

@danieloceno

Copy link
Copy Markdown
Collaborator

No issue to close: both problems came from a demo rehearsal of SecGate 0.3.1 on public repositories.

What changed

  • osv-scanner that scans nothing is skipped, not clean (lib/scanners.mjs, runOsvScanner).
    • When osv-scanner finds no lockfile or manifest it can read, it exits 128 with "No package sources found". SecGate reported that as clean and scored it 100.
    • It is now skipped with the reason no package sources found, and it gets no tool score.
    • Seen on juice-shop/juice-shop at 266448a: the repository commits no lockfile (.npmrc sets package-lock=false).
  • A Dockerfile stage name is not scanned as an image (lib/scanners.mjs, extractBaseImages).
    • A FROM that names an earlier stage of the same Dockerfile (FROM node:20 AS base ... FROM base AS production) is no longer passed to trivy image.
    • Before, trivy image base failed, the image scan ended error, and Trivy counted as not run.
    • Seen on juice-shop infrastructure/Dockerfile:14 and documenso/documenso docker/Dockerfile:13,34,98.
  • no package sources found is not a coverage gap (secgate.js, NOT_A_GAP). Like no package.json in target for npm audit, there was nothing for the scanner to read. A run whose only skip is this reason can still PASS, as it did when osv-scanner said clean; the console, JSON and HTML now show the skip and its reason. The alternative, a gap, would make such a run INCOMPLETE (exit 2), so a repository with no dependencies at all would stop passing.
  • Release prep 0.3.2:
    • package.json and package-lock.json;
    • CHANGELOG ## [0.3.2] - 2026-11-15 and compare links;
    • README status line;
    • docs/tuning.md version line.

Proof

test/smoke.mjs. "On main" means the branch's test file run against 81d61ad: 53 passed, 2 failed.

Test Branch On main
a Dockerfile stage name (FROM base AS production) is not scanned as an image pass fails: image scan status: expected clean, got error
osv-scanner exit 128 (no package sources found) is skipped with the reason, never clean pass fails: osv status: expected skipped, got clean

Gate

npm ci && npm run check:deps && npm run lint && npm test on Node 22.23.4 at 10d16d7, exit 0:

  • dependency guard passed, eslint clean;
  • engine 59, score 22, walk ok, smoke 55, schema 6, SARIF 11, trivy-image 9, no-lockfile 6, config 15, baseline 7, suppression 8, confidence 28, timeout ok, determinism 13, golden 8, action-exit ok; 0 failed.

Not changed

  • A FROM ${ARG} image reference, and Dockerfiles with CRLF line endings, are handled as before.
  • The other rehearsal findings are not part of this change.

@danieloceno danieloceno added bug Something isn't working security Security-relevant labels Nov 16, 2026
@danieloceno

Copy link
Copy Markdown
Collaborator Author

Second-model review

Scope: the whole branch (81d61ad..10d16d7), checked against the two rehearsal fixes, the failing-on-main tests and the 0.3.2 release prep.

No blocking finding. Checked:

  1. osv-scanner with nothing to scan (lib/scanners.mjs, runOsvScanner). Exit 128, or the "No package sources found" message, now gives skipped with the reason no package sources found, and the scanner gets no tool score. That separates "nothing was scanned" from "no vulnerabilities found".
  2. Coverage choice (secgate.js, NOT_A_GAP). Keeping no package sources found out of coverage gaps matches the existing npm audit rule for a target with no package.json. The report still shows the skip and its reason, and a workflow that passes --require osv still exits 2, because required scanners must be in coverage.ran. Allowing the other scanners to decide PASS keeps the gate outcome from before, without calling the osv-scanner result clean.
  3. Dockerfile stages (lib/scanners.mjs, extractBaseImages). A stage name is recorded only after the FROM ... AS <name> that defines it, and compared case-insensitively. A later FROM <name> is no longer pulled as an image. scratch and real base images are handled as before.
  4. Tests (test/smoke.mjs). The stage test fails the image stub if base is pulled; at 81d61ad it fails with image scan status: expected clean, got error. The osv-scanner test checks the state, the reason and the missing score; at 81d61ad it fails with osv status: expected skipped, got clean. Both pass on the branch.
  5. Release metadata. package.json, package-lock.json, the CHANGELOG (an empty [Unreleased] above 0.3.2, and the v0.3.1...v0.3.2 compare link), the README status line and docs/tuning.md all say 0.3.2. release.yml checks that the tag equals the package.json version, so a v0.3.2 tag passes that check.
  6. Gate: the full gate exits 0 (smoke 55 passed, 0 failed), and lint passes.

Leftovers: none.

Verdict: approve

In plain English

SecGate called its dependency scanner "clean" on a project where that scanner had found nothing it could read, which hid the fact that nothing was checked; it now says "skipped" and why. It also tried to download a Docker image named after a build step inside the project's own Dockerfile, failed, and then reported the container scan as broken; it now skips those internal names. Nothing else changes, and version 0.3.2 is ready to tag. The remaining risk is small: unusual Dockerfile forms, such as image names built from variables, are handled as before.

@danieloceno
danieloceno merged commit 2e50cc2 into main Nov 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security Security-relevant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant