Skip to content

Commit

Permalink
add check if links are not set in keyvalue backend
Browse files Browse the repository at this point in the history
Signed-off-by: pxp928 <parth.psu@gmail.com>
  • Loading branch information
pxp928 committed Oct 1, 2024
1 parent 4bd4ace commit dd044f2
Showing 1 changed file with 48 additions and 30 deletions.
78 changes: 48 additions & 30 deletions pkg/assembler/backends/keyvalue/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,40 +313,58 @@ func (c *demoClient) QueryPackagesListForType(ctx context.Context, pkgSpec model
continue
}
if queryType == model.QueryTypeVulnerability {
for _, certVulnID := range pkgVer.CertifyVulnLinks {
link, err := byIDkv[*certifyVulnerabilityLink](ctx, certVulnID, c)
if err != nil {
continue
}
now := time.Now().UTC()
scanInterval := now.Add(time.Duration(-24) * time.Hour).UTC()
lastIntervalTime := now.Add(time.Duration(-*lastScan) * time.Hour).UTC()
if lastIntervalTime.After(link.TimeScanned) && scanInterval.Before(link.TimeScanned) {
pvs = append(pvs, &model.PackageVersion{
ID: pkgVer.ThisID,
Version: pkgVer.Version,
Subpath: pkgVer.Subpath,
Qualifiers: getCollectedPackageQualifiers(pkgVer.Qualifiers),
})
if len(pkgVer.CertifyVulnLinks) > 0 {
for _, certVulnID := range pkgVer.CertifyVulnLinks {
link, err := byIDkv[*certifyVulnerabilityLink](ctx, certVulnID, c)
if err != nil {
continue
}
now := time.Now().UTC()
scanInterval := now.Add(time.Duration(-24) * time.Hour).UTC()
lastIntervalTime := now.Add(time.Duration(-*lastScan) * time.Hour).UTC()
if lastIntervalTime.After(link.TimeScanned) && scanInterval.Before(link.TimeScanned) {
pvs = append(pvs, &model.PackageVersion{
ID: pkgVer.ThisID,
Version: pkgVer.Version,
Subpath: pkgVer.Subpath,
Qualifiers: getCollectedPackageQualifiers(pkgVer.Qualifiers),
})
}
}
} else {
pvs = append(pvs, &model.PackageVersion{
ID: pkgVer.ThisID,
Version: pkgVer.Version,
Subpath: pkgVer.Subpath,
Qualifiers: getCollectedPackageQualifiers(pkgVer.Qualifiers),
})
}
} else {
for _, certLegalID := range pkgVer.CertifyLegals {
link, err := byIDkv[*certifyLegalStruct](ctx, certLegalID, c)
if err != nil {
continue
}
now := time.Now().UTC()
scanInterval := now.Add(time.Duration(-24) * time.Hour).UTC()
lastIntervalTime := now.Add(time.Duration(-*lastScan) * time.Hour).UTC()
if lastIntervalTime.After(link.TimeScanned) && scanInterval.Before(link.TimeScanned) {
pvs = append(pvs, &model.PackageVersion{
ID: pkgVer.ThisID,
Version: pkgVer.Version,
Subpath: pkgVer.Subpath,
Qualifiers: getCollectedPackageQualifiers(pkgVer.Qualifiers),
})
if len(pkgVer.CertifyLegals) > 0 {
for _, certLegalID := range pkgVer.CertifyLegals {
link, err := byIDkv[*certifyLegalStruct](ctx, certLegalID, c)
if err != nil {
continue
}
now := time.Now().UTC()
scanInterval := now.Add(time.Duration(-24) * time.Hour).UTC()
lastIntervalTime := now.Add(time.Duration(-*lastScan) * time.Hour).UTC()
if lastIntervalTime.After(link.TimeScanned) && scanInterval.Before(link.TimeScanned) {
pvs = append(pvs, &model.PackageVersion{
ID: pkgVer.ThisID,
Version: pkgVer.Version,
Subpath: pkgVer.Subpath,
Qualifiers: getCollectedPackageQualifiers(pkgVer.Qualifiers),
})
}
}
} else {
pvs = append(pvs, &model.PackageVersion{
ID: pkgVer.ThisID,
Version: pkgVer.Version,
Subpath: pkgVer.Subpath,
Qualifiers: getCollectedPackageQualifiers(pkgVer.Qualifiers),
})
}
}
}
Expand Down

0 comments on commit dd044f2

Please sign in to comment.