Ignore Rules That Age Well
Every team that gates on scans eventually needs to say "we know about this one". Both scanners read an ignore file from the project, so the decision is versioned, reviewed and visible. The danger is the opposite of a red build: an ignore list that grows forever and silently hides real problems. This lesson shows the mechanics and the habits that keep ignore lists honest.
Grype: .grype.yaml
Grype reads .grype.yaml from the current directory (or --config FILE). Each ignore rule matches on any combination of the vulnerability id, the fix state and the package:
cp -r /opt/samples/node-app . && cd node-app
cat > .grype.yaml <<'YAML'
ignore:
# one advisory, everywhere, with the reason recorded next to it
- vulnerability: GHSA-xvch-5gv4-984h
reason: "minimist only parses our own build flags; tracked in SEC-142"
# every advisory for one exact package version
- package:
name: lodash
version: 4.17.15
type: npm
reason: "lodash 4.17.15 is replaced by 4.17.21 in SEC-150"
YAML
echo "--- reported"; grype . -q -o json | jq -r '.matches[] | .vulnerability.id'
echo "--- suppressed"; grype . -q -o json | jq -r '.ignoredMatches[] | "\(.vulnerability.id) (\(.artifact.name))"' | sort--- reported
--- suppressed
GHSA-29mw-wpgm-hmr9 (lodash)
GHSA-35jh-r3h4-6jhm (lodash)
GHSA-f23m-r3pf-42rh (lodash)
GHSA-p6mc-m468-83gw (lodash)
GHSA-r5fr-rjxr-66jc (lodash)
GHSA-xvch-5gv4-984h (minimist)
GHSA-xxjr-mmjv-4gpg (lodash)
Everything is ignored, so the build would pass, and that is exactly the problem with broad rules: the package rule also hides any future lodash 4.17.15 advisory nobody has looked at yet. Prefer rules that name one vulnerability, scoped to one package.
The JSON report keeps suppressed findings in ignoredMatches, and --show-suppressed adds them to the table, so ignoring never deletes evidence:
cp -r /opt/samples/node-app . && cd node-app
printf 'ignore:\n - vulnerability: GHSA-xvch-5gv4-984h\n package:\n name: minimist\n' > .grype.yaml
grype . -q --show-suppressed | grep -E 'NAME|minimist'NAME INSTALLED FIXED IN TYPE VULNERABILITY SEVERITY EPSS RISK
minimist 1.2.5 1.2.6 npm GHSA-xvch-5gv4-984h Critical 4.6% (91st) 4.3 (suppressed)
Ignoring by fix state
Some teams decide not to gate on vulnerabilities that can't be fixed yet, while still reporting them. Grype's fix states are fixed, not-fixed, wont-fix and unknown:
cat > .grype.yaml <<'YAML'
ignore:
- fix-state: not-fixed
- fix-state: unknown
YAML
img=/opt/samples/images/alpine-3.18.0.tar
echo "gated: $(grype $img -q -o json | jq '.matches | length') ignored: $(grype $img -q -o json | jq '.ignoredMatches | length')"gated: 49 ignored: 14
That's the same effect as --only-fixed, but written in the project's config instead of the pipeline's command line, where it is easier to review.
Trivy: .trivyignore and .trivyignore.yaml
Trivy reads .trivyignore (one id per line, # comments) from the current directory, or any file given with --ignorefile. The YAML form adds scoping by path or purl, a free-text statement, and an expiry date:
cp -r /opt/samples/node-app . && cd node-app
cat > .trivyignore.yaml <<'YAML'
vulnerabilities:
- id: CVE-2021-44906
purls:
- pkg:npm/minimist@1.2.5
statement: "only parses our own build flags; SEC-142"
- id: CVE-2020-8203
statement: "accepted until the lodash upgrade (SEC-150)"
expired_at: 2025-06-30
YAML
trivy fs . -q --ignorefile .trivyignore.yaml -f json | jq -r '[.Results[].Vulnerabilities[].VulnerabilityID] | sort | join(" ")'CVE-2020-28500 CVE-2020-8203 CVE-2021-23337 CVE-2025-13465 CVE-2026-2950 CVE-2026-4800 NSWG-ECO-516
CVE-2021-44906 is gone. CVE-2020-8203 is still reported: its exception expired on 30 June 2025, so Trivy ignores the rule. An expiry date turns "we'll fix it later" into a date on which the build goes red again and someone must decide afresh. Grype's ignore rules have no expiry; teams emulate it with a CI check over the config (a date in the reason and a script that fails on past dates).
A model: ignore rules with mandatory reasons and expiry
Whatever the scanner supports, you can enforce your own policy on the ignore file. This model applies rules to findings and refuses rules without a reason or an expiry, the two fields that keep an ignore list honest.
TODAY = "2026-10-24" # in CI: the build date
findings = [
("minimist", "1.2.5", "CVE-2021-44906"),
("lodash", "4.17.15", "CVE-2020-8203"),
("lodash", "4.17.15", "CVE-2021-23337"),
]
rules = [
{"id": "CVE-2021-44906", "package": "minimist", "reason": "build-time only, SEC-142", "expires": "2027-01-31"},
{"id": "CVE-2020-8203", "package": "lodash", "reason": "upgrade in SEC-150", "expires": "2025-06-30"},
{"id": "CVE-2021-23337", "package": "lodash", "reason": "", "expires": "2027-01-31"},
]
def lint(rule):
problems = []
if not rule.get("reason"):
problems.append("no reason")
if not rule.get("expires"):
problems.append("no expiry")
elif rule["expires"] < TODAY: # ISO dates compare correctly as strings
problems.append(f"expired {rule['expires']}")
return problems
active = []
for r in rules:
p = lint(r)
print(f"rule {r['id']:15} {'ok' if not p else 'REJECTED: ' + ', '.join(p)}")
if not p:
active.append(r)
for pkg, ver, vid in findings:
hit = any(r["id"] == vid and r["package"] == pkg for r in active)
print(f"{pkg}@{ver} {vid}: {'ignored' if hit else 'REPORTED'}")rule CVE-2021-44906 ok
rule CVE-2020-8203 REJECTED: expired 2025-06-30
rule CVE-2021-23337 REJECTED: no reason
minimist@1.2.5 CVE-2021-44906: ignored
lodash@4.17.15 CVE-2020-8203: REPORTED
lodash@4.17.15 CVE-2021-23337: REPORTED
The comment in the code is worth a second look: ISO 8601 dates (YYYY-MM-DD) are one of the few cases where string comparison is correct, because every field has a fixed width and the most significant field comes first.
Habits
- One vulnerability, one package, one reason, one expiry. Broad rules hide future findings.
- Link a ticket in the reason, so the exception has an owner.
- Review ignore-file changes like code: require a security reviewer in
CODEOWNERSfor.grype.yamland.trivyignore*. - Prefer VEX for "not affected". An ignore rule says "don't bother me"; a VEX statement says why the product isn't affected, in a format your customers' scanners can read too. That's the next lesson.
Test yourself
What is the risk of a Grype rule that ignores every advisory for lodash version 4.17.15?
- It is not valid YAML
- It also hides future advisories for that version that nobody has reviewed
- It slows the scan
- Grype ignores package rules
A .trivyignore.yaml entry has expired_at: 2025-06-30 and today is later. What does Trivy do?
- Ignores the finding forever
- Reports the finding again, because the exception expired
- Fails to parse the file
- Deletes the rule
Where does Grype keep findings suppressed by ignore rules in its JSON output?
- They are deleted
- In
ignoredMatches - In
matcheswith severity None - In a separate log file