Skip to content

Commit

Permalink
epss: no new fingerprint when etag is missing
Browse files Browse the repository at this point in the history
Signed-off-by: daynewlee <[email protected]>
  • Loading branch information
daynewlee committed Dec 13, 2024
1 parent f93b034 commit fd434d8
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions enricher/epss/epss.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"strings"
"time"

"github.com/google/uuid"
"github.com/quay/zlog"

"github.com/quay/claircore"
Expand Down Expand Up @@ -129,24 +128,16 @@ func (e *Enricher) FetchEnrichment(ctx context.Context, prevFingerprint driver.F
if err = httputil.CheckResponse(resp, http.StatusOK); err != nil {
return nil, "", fmt.Errorf("unable to fetch file: %w", err)
}
var str string

var newFingerprint driver.Fingerprint
str = resp.Header.Get("etag")
if str == "" {
newUUID, err := uuid.NewRandom()
if err != nil {
return nil, "", fmt.Errorf("failed to generate UUID: %w", err)
if etag := resp.Header.Get("etag"); etag != "" {
newFingerprint = driver.Fingerprint(etag)
if prevFingerprint == newFingerprint {
zlog.Info(ctx).Str("fingerprint", string(newFingerprint)).Msg("file unchanged; skipping processing")
return nil, prevFingerprint, nil
}
// Generate a UUID for customized URL
str = newUUID.String()
zlog.Warn(ctx).Msg("ETag not found; generated UUID for fingerprint")
newFingerprint = driver.Fingerprint(etag)
}
newFingerprint = driver.Fingerprint(str)
if prevFingerprint == newFingerprint {
zlog.Info(ctx).Str("fingerprint", string(newFingerprint)).Msg("file unchanged; skipping processing")
return nil, prevFingerprint, nil
}

gzipReader, err := gzip.NewReader(resp.Body)
if err != nil {
return nil, "", fmt.Errorf("unable to decompress file: %w", err)
Expand Down

0 comments on commit fd434d8

Please sign in to comment.