Skip to content

Commit

Permalink
fix(server): pass license categories to options (aquasecurity#7203)
Browse files Browse the repository at this point in the history
Signed-off-by: nikpivkin <[email protected]>
  • Loading branch information
nikpivkin authored and skahn007gl committed Jul 23, 2024
1 parent 2e5ed9c commit 998255d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/rpc/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 998255d

Please sign in to comment.