diff --git a/pkg/provider/state.go b/pkg/provider/state.go index 17e469ec..1a04842d 100644 --- a/pkg/provider/state.go +++ b/pkg/provider/state.go @@ -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 diff --git a/pkg/provider/state_test.go b/pkg/provider/state_test.go index bf04fd32..7544860c 100644 --- a/pkg/provider/state_test.go +++ b/pkg/provider/state_test.go @@ -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),