88 "google.golang.org/protobuf/types/known/structpb"
99
1010 ftypes "github.com/aquasecurity/fanal/types"
11- deptypes "github.com/aquasecurity/go-dep-parser/pkg/types"
1211 dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
1312 "github.com/aquasecurity/trivy/pkg/log"
1413 "github.com/aquasecurity/trivy/pkg/types"
@@ -33,6 +32,7 @@ func ConvertToRPCPkgs(pkgs []ftypes.Package) []*common.Package {
3332 SrcEpoch : int32 (pkg .SrcEpoch ),
3433 License : pkg .License ,
3534 Layer : ConvertToRPCLayer (pkg .Layer ),
35+ FilePath : pkg .FilePath ,
3636 })
3737 }
3838 return rpcPkgs
@@ -54,37 +54,12 @@ func ConvertFromRPCPkgs(rpcPkgs []*common.Package) []ftypes.Package {
5454 SrcEpoch : int (pkg .SrcEpoch ),
5555 License : pkg .License ,
5656 Layer : ConvertFromRPCLayer (pkg .Layer ),
57+ FilePath : pkg .FilePath ,
5758 })
5859 }
5960 return pkgs
6061}
6162
62- // ConvertFromRPCLibraries returns list of Fanal library
63- func ConvertFromRPCLibraries (rpcLibs []* common.Library ) []ftypes.Package {
64- var pkgs []ftypes.Package
65- for _ , l := range rpcLibs {
66- pkgs = append (pkgs , ftypes.Package {
67- Name : l .Name ,
68- Version : l .Version ,
69- License : l .License ,
70- })
71- }
72- return pkgs
73- }
74-
75- // ConvertToRPCLibraries returns list of libraries
76- func ConvertToRPCLibraries (libs []deptypes.Library ) []* common.Library {
77- var rpcLibs []* common.Library
78- for _ , l := range libs {
79- rpcLibs = append (rpcLibs , & common.Library {
80- Name : l .Name ,
81- Version : l .Version ,
82- License : l .License ,
83- })
84- }
85- return rpcLibs
86- }
87-
8863// ConvertToRPCVulns returns common.Vulnerability
8964func ConvertToRPCVulns (vulns []types.DetectedVulnerability ) []* common.Vulnerability {
9065 var rpcVulns []* common.Vulnerability
@@ -128,6 +103,7 @@ func ConvertToRPCVulns(vulns []types.DetectedVulnerability) []*common.Vulnerabil
128103 VulnerabilityId : vuln .VulnerabilityID ,
129104 VendorIds : vuln .VendorIDs ,
130105 PkgName : vuln .PkgName ,
106+ PkgPath : vuln .PkgPath ,
131107 InstalledVersion : vuln .InstalledVersion ,
132108 FixedVersion : vuln .FixedVersion ,
133109 Title : vuln .Title ,
@@ -264,6 +240,7 @@ func ConvertFromRPCVulns(rpcVulns []*common.Vulnerability) []types.DetectedVulne
264240 VulnerabilityID : vuln .VulnerabilityId ,
265241 VendorIDs : vuln .VendorIds ,
266242 PkgName : vuln .PkgName ,
243+ PkgPath : vuln .PkgPath ,
267244 InstalledVersion : vuln .InstalledVersion ,
268245 FixedVersion : vuln .FixedVersion ,
269246 Vulnerability : dbTypes.Vulnerability {
@@ -364,7 +341,7 @@ func ConvertFromRPCApplications(rpcApps []*common.Application) []ftypes.Applicat
364341 apps = append (apps , ftypes.Application {
365342 Type : rpcApp .Type ,
366343 FilePath : rpcApp .FilePath ,
367- Libraries : ConvertFromRPCLibraries (rpcApp .Libraries ),
344+ Libraries : ConvertFromRPCPkgs (rpcApp .Libraries ),
368345 })
369346 }
370347 return apps
@@ -478,18 +455,10 @@ func ConvertToRPCBlobInfo(diffID string, blobInfo ftypes.BlobInfo) *cache.PutBlo
478455
479456 var applications []* common.Application
480457 for _ , app := range blobInfo .Applications {
481- var libs []* common.Library
482- for _ , lib := range app .Libraries {
483- libs = append (libs , & common.Library {
484- Name : lib .Name ,
485- Version : lib .Version ,
486- License : lib .License ,
487- })
488- }
489458 applications = append (applications , & common.Application {
490459 Type : app .Type ,
491460 FilePath : app .FilePath ,
492- Libraries : libs ,
461+ Libraries : ConvertToRPCPkgs ( app . Libraries ) ,
493462 })
494463 }
495464
0 commit comments