Add support for expiry date in ignore - #3481
Conversation
Signed-off-by: lauren_tb <lauren.taylor-brown@justice.gov.uk>
c3191f0 to
55771f6
Compare
noqt
left a comment
There was a problem hiding this comment.
I’m reviewing this for NOQT. I think this needs one safety fix before merge.
IgnoreRule.Validate() is added, but nothing in the production config/load path calls it. On the runtime path, isExpiresAfterInPast() catches a parse error and returns false, so a typo such as expires-after: 2026/12/31 silently leaves the ignore rule active indefinitely. That’s the opposite of the clear startup error promised by the new validation comment, and it’s risky for vulnerability suppressions.
Please wire this validation into config loading and add an end-to-end invalid-config test, or propagate the parse error through the application path. I checked exact head 55771f63b294e6ba2073177754d1622606b2a1de; it merges cleanly with current main. Hosted static analysis is also red on formatting, but the unreachable validation path is the blocker here.
Summary
This pull request adds support for an
expires-afterfield to ignore rules, allowing users to specify a date after which an ignore rule will no longer apply. It includes validation, logic changes, and tests to ensure correct handling of the new field.Motivation
Currently the .grype.yml file does does not support the inclusion of an expiry date for vulnerabilities that are intentionally ignored.
Changes
expires-afterfield to theIgnoreRulestruct, allowing users to set an expiration date for ignore rules. The rule will be ignored if the current date is after the specified date. [1] [2]parseExpiresAfterandisExpiresAfterInPastto parse and evaluate the expiration date, handling empty and malformed values gracefully.IgnoreRule.IgnoreMatchmethod to skip rules whose expiration date has passed.Validation and Testing
Validatemethod toIgnoreRuleto check for malformedexpires-aftervalues at config load time, providing early feedback to users.ignore_test.goto cover various scenarios for theexpires-afterfield, including valid, empty, past, future, and malformed dates.Miscellaneous
Type of change
Checklist