Skip to content

Commit f43dacb

Browse files
Use time.Equal instead of UTC conversion + ==. (#875)
The `time.Equal` API compares across timezones, so it is better. For storage, we still convert to UTC. Signed-off-by: Mihai Maruseac <[email protected]>
1 parent 39afb15 commit f43dacb

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

pkg/assembler/backends/inmem/certifyScorecard.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (c *demoClient) certifyScorecard(ctx context.Context, source model.SourceIn
8585
return nil, gqlerror.Errorf("%v :: %s", funcName, err)
8686
}
8787
if sourceID == v.sourceID &&
88-
scorecard.TimeScanned.UTC() == v.timeScanned &&
88+
scorecard.TimeScanned.Equal(v.timeScanned) &&
8989
floatEqual(scorecard.AggregateScore, v.aggregateScore) &&
9090
scorecard.ScorecardVersion == v.scorecardVersion &&
9191
scorecard.ScorecardCommit == v.scorecardCommit &&

pkg/assembler/backends/inmem/certifyVEXStatement.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (c *demoClient) ingestVEXStatement(ctx context.Context, subject model.Packa
197197
if artifactID != 0 && artifactID == v.artifactID {
198198
subjectMatch = true
199199
}
200-
if vulnMatch && subjectMatch && vexStatement.KnownSince.UTC() == v.knownSince && vexStatement.VexJustification == v.justification &&
200+
if vulnMatch && subjectMatch && vexStatement.KnownSince.Equal(v.knownSince) && vexStatement.VexJustification == v.justification &&
201201
vexStatement.Status == v.status && vexStatement.Statement == v.statement && vexStatement.StatusNotes == v.statusNotes &&
202202
vexStatement.Origin == v.origin && vexStatement.Collector == v.collector {
203203

pkg/assembler/backends/inmem/certifyVuln.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func (c *demoClient) CertifyVuln(ctx context.Context, filter *model.CertifyVulnS
332332
func (c *demoClient) addCVIfMatch(out []*model.CertifyVuln,
333333
filter *model.CertifyVulnSpec,
334334
link *vulnerabilityLink) ([]*model.CertifyVuln, error) {
335-
if filter != nil && filter.TimeScanned != nil && filter.TimeScanned.UTC() == link.timeScanned {
335+
if filter != nil && filter.TimeScanned != nil && filter.TimeScanned.Equal(link.timeScanned) {
336336
return out, nil
337337
}
338338
if filter != nil && noMatch(filter.DbURI, link.dbURI) {

pkg/assembler/backends/inmem/hasSourceAt.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (c *demoClient) ingestHasSourceAt(ctx context.Context, packageArg model.Pkg
100100
return nil, gqlerror.Errorf("%v :: %s", funcName, err)
101101
}
102102
if packageID == v.packageID && sourceID == v.sourceID && hasSourceAt.Justification == v.justification &&
103-
hasSourceAt.Origin == v.origin && hasSourceAt.Collector == v.collector && hasSourceAt.KnownSince.UTC() == v.knownSince {
103+
hasSourceAt.Origin == v.origin && hasSourceAt.Collector == v.collector && hasSourceAt.KnownSince.Equal(v.knownSince) {
104104
collectedSrcMapLink = *v
105105
duplicate = true
106106
break

0 commit comments

Comments
 (0)