osv-scanner icon indicating copy to clipboard operation
osv-scanner copied to clipboard

Config-driven vulnerability suppression leaves no trace in machine-readable output

Open herdiyana256 opened this issue 3 months ago • 4 comments

Manager.Get loads an osv-scanner.toml from each scanned manifest's directory and applies its IgnoredVulns/PackageOverrides ignore directives to that directory's results. During a recursive scan this can reach directories the person running the scan didn't author (vendored deps, submodules, extracted archives, a folder added by a PR). A config placed there suppresses findings silently — currently only logged at info level, so under --verbosity warn or JSON/SARIF output the scan can print "no issues found" / exit 0 with no trace that anything was suppressed.

Proposal:

  • Raise config-driven suppression logging to warning level (loaded config path, each suppressed vuln/package, filtered count).
  • Add a --no-config-ignore flag that drops suppressing directives (IgnoredVulns, ignore flags on PackageOverrides) from auto-discovered configs, while leaving license overrides intact. Configs passed explicitly via --config stay trusted/unaffected.

Happy to submit a PR for this once discussed/assigned — closing #2997 per contributing guide since it was opened without an issue first.

herdiyana256 avatar Aug 17 '26 16:08 herdiyana256

Per the contributing guide I opened this issue first and closed #2997. Could a maintainer take a look and assign it if the direction sounds right? The change raises config-driven suppression to warning level (loaded config path, each suppressed vuln/package, filtered count) and adds --no-config-ignore that drops suppressing directives from auto-discovered configs while leaving --config and license overrides trusted. Patch and tests are ready, I'll send the PR once it's assigned. cc @G-Rath

herdiyana256 avatar Aug 25 '26 17:08 herdiyana256

You say it's silent at default verbosity, but isn't the default verbosity info?

another-rex avatar Sep 08 '26 03:09 another-rex

You're right, info is the default and those lines do print. The title overstates it and I'll retitle. The body did say "only logged at info level, so under --verbosity warn or JSON/SARIF output", but the title should have matched that.

Where I think it still holds up is the machine-readable output, which is what CI actually reads.

docs/output.md describes JSON as giving you "all the information osv-scanner found in a machine-readable format". It doesn't include this. Scanning a tree with a config that suppresses everything:

$ osv-scanner scan source --recursive --format json --output-file res.json ./root
$ cat res.json
{
  "results": [],
  "experimental_config": {
    "licenses": {
      "summary": false,
      "allowlist": null
    }
  }
}

No config path, no suppressed package, no count, at any verbosity including info. It's identical to a genuinely clean scan. Without the config the same tree is 54 vulnerabilities, 8 critical, exit 1.

That matters because the reusable workflow this repo scans itself with pins the format and gates on the file, not on stdout. osv-scanner-unified-action.yml calls google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml, which runs:

--output=${{ inputs.matrix-property }}results.json
--format=json
${{ inputs.scan-args }}

then osv-reporter reads results.json with --fail-on-vuln to decide whether the job fails. The info lines are printed, but they go to the step log of a continue-on-error: true step while the thing deciding pass/fail sees an empty result. No --verbosity change needed for that.

The verbosity part is the smaller half, but the reason I called it silent is that every suppression signal is Infof, so it's in the same tier as Scanning dir, Starting filesystem walk and End status: 2 dirs visited, 4 inodes visited. Turning that chatter down with --verbosity warn takes the suppression with it:

$ osv-scanner scan source --recursive --verbosity warn ./root

No issues found
$ echo $?
0

One more thing worth noting: the config doesn't need to be crafted. This is the whole file, copied from the "ignore everything in the current directory" example in docs/configuration.md:

[[PackageOverrides]]
ignore = true

Dropped in root/vendored_dep/, it suppresses that whole subtree and logs (no reason given). And the untrusted-project warning in the docs is only on fix and guided remediation, so nothing tells you that pointing scan at a directory also means trusting configs found inside it. --config is the only lever today and it disables auto-discovery everywhere, which isn't usable if you have legitimate per-directory configs.

So the narrow ask is to record the suppression where it survives both the verbosity setting and the machine-readable output: the config path and the filtered count in the JSON result, and warn level in the log. The --no-config-ignore half is separable and I'm happy to drop it if only the reporting half is worth doing.

herdiyana256 avatar Sep 08 '26 12:09 herdiyana256

+1 on treating machine-readable output as the real contract

In CI the JSON/SARIF file is what gates the job (same pattern as this repo's reusable workflow: write results.json, then fail-on-vuln from that file). Info-level lines in the step log don't help when the artifact that decides pass/fail looks identical to a clean scan.

If you're open to a minimal first cut, I'd prioritize:

  1. config path + suppressed count in the JSON result (so consumers can assert "zero findings AND zero suppressions", or at least surface the suppressions)
  2. warn-level log for each auto-discovered suppression

--no-config-ignore is nice for untrusted trees, but even without it the reporting half closes the trust gap for normal pipelines.

Chris0Jeky avatar Sep 17 '26 11:09 Chris0Jeky