Skip to content

Commit b854621

Browse files
committed
fix(adv): extend event max age from 3 to 30 days
Per discussion with Josh P and Amber A, this should be more accommodating of legitimate cases where advisory PRs are open for longer, without allowing knowably bad data to get added. Signed-off-by: Dan Luhring <[email protected]>
1 parent 98736c0 commit b854621

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

pkg/advisory/testdata/diff/added-event-with-non-recent-timestamp/a/ko.advisories.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package:
44
name: ko
55

66
advisories:
7-
- id: CVE-2023-11111
7+
- id: CGA-2222-2222-2222
88
events:
99
- timestamp: 1970-01-01T00:00:00Z
1010
type: true-positive-determination

pkg/advisory/testdata/diff/added-event-with-non-recent-timestamp/b/ko.advisories.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ package:
44
name: ko
55

66
advisories:
7-
- id: CVE-2023-11111
7+
- id: CGA-2222-2222-2222
88
events:
99
- timestamp: 1970-01-01T00:00:00Z
1010
type: true-positive-determination
11-
- timestamp: 2023-11-02T00:00:00Z # Not recent enough!
11+
- timestamp: 2023-10-10T00:00:00Z # Not recent enough!
1212
type: true-positive-determination

pkg/advisory/validate.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
"github.com/wolfi-dev/wolfictl/pkg/internal/errorhelpers"
1818
)
1919

20+
const eventMaxValidAgeInDays = 30
21+
2022
type ValidateOptions struct {
2123
// AdvisoryDocs is the Index of advisories on which to operate.
2224
AdvisoryDocs *configs.Index[v2.Document]
@@ -449,8 +451,6 @@ func (opts ValidateOptions) validateIndexDiffForAddedEvents(events []v2.Event, p
449451
return errors.Join(errs...)
450452
}
451453

452-
const eventMaxValidAgeInDays = 3
453-
454454
func (opts ValidateOptions) isRecent(t time.Time) bool {
455455
const maxAge = eventMaxValidAgeInDays * 24 * time.Hour // 3 days
456456
return opts.Now.Sub(t) < maxAge

0 commit comments

Comments
 (0)