@@ -3,6 +3,8 @@ package pkg_test
33import (
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