Skip to content

Commit

Permalink
port fix from #445
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Dec 2, 2024
1 parent 492726d commit 25d1b8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/provider/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ func (s States) EarliestTimestamp() (time.Time, error) {
if len(s) == 0 {
return time.Time{}, fmt.Errorf("cannot find earliest timestamp: no states provided")
}

// special case when there is exactly 1 state, return its timestamp even
// if it is nvd, because otherwise quality gates that pull only nvd deterministically fail.
if len(s) == 1 {
return s[0].Timestamp, nil
}

var earliest time.Time
for _, curState := range s {
// the NVD api is constantly down, so we don't want to consider it for the earliest timestamp
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Test_earliestTimestamp(t *testing.T) {
},
{
name: "single state, but it's nvd",
states: []provider.State{
states: []State{
{
Provider: "nvd",
Timestamp: time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC),
Expand Down

0 comments on commit 25d1b8a

Please sign in to comment.