From 9d5201808da89607ae43570bdf1f335b482a6b79 Mon Sep 17 00:00:00 2001 From: Nikita Pivkin Date: Mon, 22 Jul 2024 14:01:45 +0700 Subject: [PATCH] fix(server): pass license categories to options (#7203) Signed-off-by: nikpivkin --- pkg/rpc/server/server.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 25b43b2afd92..b0e58f87c0e9 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -9,6 +9,7 @@ import ( "google.golang.org/protobuf/types/known/emptypb" "github.com/aquasecurity/trivy/pkg/cache" + ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" "github.com/aquasecurity/trivy/pkg/log" "github.com/aquasecurity/trivy/pkg/rpc" "github.com/aquasecurity/trivy/pkg/scanner" @@ -46,10 +47,17 @@ func (s *ScanServer) Scan(ctx context.Context, in *rpcScanner.ScanRequest) (*rpc scanners := lo.Map(in.Options.Scanners, func(s string, index int) types.Scanner { return types.Scanner(s) }) + + licenseCategories := lo.MapEntries(in.Options.LicenseCategories, + func(k string, v *rpcScanner.Licenses) (ftypes.LicenseCategory, []string) { + return ftypes.LicenseCategory(k), v.Names + }) + options := types.ScanOptions{ - PkgTypes: in.Options.PkgTypes, - Scanners: scanners, - IncludeDevDeps: in.Options.IncludeDevDeps, + PkgTypes: in.Options.PkgTypes, + Scanners: scanners, + IncludeDevDeps: in.Options.IncludeDevDeps, + LicenseCategories: licenseCategories, } results, os, err := s.localScanner.Scan(ctx, in.Target, in.ArtifactId, in.BlobIds, options) if err != nil {