Skip to content

Commit d3e5edb

Browse files
committed
add disclaimer
1 parent f988786 commit d3e5edb

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

contrib/trivy/pkg/converter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ func Convert(results types.Results, artifactType ftypes.ArtifactType, artifactNa
206206
dupPkgs[p.Name] = append(versions, pv)
207207
}
208208
}
209+
// >= (not >) so that the Arch-bearing entry from Packages
210+
// overwrites the Arch-less one written by the Vulnerabilities
211+
// loop above, even when the version is identical.
209212
if compareVersions(trivyResult.Type, pv, existing.Version) >= 0 {
210213
pkgs[p.Name] = models.Package{
211214
Name: p.Name,
@@ -231,6 +234,7 @@ func Convert(results types.Results, artifactType ftypes.ArtifactType, artifactNa
231234

232235
if existing, ok := srcPkgs[p.SrcName]; ok {
233236
existing.AddBinaryName(p.Name)
237+
// >= for consistency with pkgs above.
234238
if compareVersions(trivyResult.Type, sv, existing.Version) >= 0 {
235239
srcPkgs[p.SrcName] = models.SrcPackage{
236240
Name: p.SrcName,

contrib/trivy/pkg/converter_test.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package pkg_test
33
import (
44
"testing"
55

6+
trivydbTypes "github.com/aquasecurity/trivy-db/pkg/types"
7+
"github.com/aquasecurity/trivy-db/pkg/vulnsrc/vulnerability"
68
gocmp "github.com/google/go-cmp/cmp"
79
gocmpopts "github.com/google/go-cmp/cmp/cmpopts"
810

@@ -804,6 +806,83 @@ func TestConvert(t *testing.T) {
804806
},
805807
},
806808
},
809+
{
810+
// The Vulnerabilities loop writes pkgs entries without Arch.
811+
// The ClassOSPkg Packages loop must overwrite with same version
812+
// to add Arch (hence >= not > in compareVersions).
813+
name: "vuln entry without Arch is augmented by Packages entry",
814+
args: args{
815+
results: types.Results{
816+
{
817+
Target: "debian 13.3",
818+
Class: types.ClassOSPkg,
819+
Type: ftypes.Debian,
820+
Vulnerabilities: []types.DetectedVulnerability{
821+
{
822+
VulnerabilityID: "CVE-2025-99999",
823+
PkgName: "libssl3t64",
824+
InstalledVersion: "3.5.5-1~deb13u1",
825+
Vulnerability: trivydbTypes.Vulnerability{
826+
VendorSeverity: trivydbTypes.VendorSeverity{
827+
vulnerability.Debian: trivydbTypes.SeverityLow,
828+
},
829+
},
830+
},
831+
},
832+
Packages: []ftypes.Package{
833+
{
834+
Name: "libssl3t64",
835+
Version: "3.5.5",
836+
Release: "1~deb13u1",
837+
SrcName: "openssl",
838+
SrcVersion: "3.5.5",
839+
SrcRelease: "1~deb13u1",
840+
Arch: "amd64",
841+
},
842+
},
843+
},
844+
},
845+
artifactType: ftypes.TypeContainerImage,
846+
artifactName: "test:latest",
847+
},
848+
want: &models.ScanResult{
849+
JSONVersion: models.JSONVersion,
850+
ScannedCves: models.VulnInfos{
851+
"CVE-2025-99999": {
852+
CveID: "CVE-2025-99999",
853+
Confidences: models.Confidences{
854+
{Score: 100, DetectionMethod: models.TrivyMatchStr},
855+
},
856+
AffectedPackages: models.PackageFixStatuses{
857+
{Name: "libssl3t64", NotFixedYet: true, FixState: "Affected"},
858+
},
859+
CveContents: models.CveContents{
860+
"trivy:debian": []models.CveContent{{
861+
Type: "trivy:debian",
862+
CveID: "CVE-2025-99999",
863+
Cvss3Severity: "LOW",
864+
}},
865+
},
866+
LibraryFixedIns: models.LibraryFixedIns{},
867+
},
868+
},
869+
LibraryScanners: models.LibraryScanners{},
870+
Packages: models.Packages{
871+
"libssl3t64": {
872+
Name: "libssl3t64",
873+
Version: "3.5.5-1~deb13u1",
874+
Arch: "amd64",
875+
},
876+
},
877+
SrcPackages: models.SrcPackages{
878+
"openssl": {
879+
Name: "openssl",
880+
Version: "3.5.5-1~deb13u1",
881+
BinaryNames: []string{"libssl3t64"},
882+
},
883+
},
884+
},
885+
},
807886
}
808887

809888
for _, tt := range tests {

0 commit comments

Comments
 (0)