From ad1851874b756b36e2f7cd74ffb9efba382343ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Farias?= Date: Fri, 9 Aug 2024 15:57:05 +0200 Subject: [PATCH] Add default cli values of --pkg-relationships Package relationship has been introduced on https://github.com/aquasecurity/trivy/pull/7237 and using CLI there are default relationship values (all). Using the library directly there is no default value and having 0 relationships and retrieving 0 finginds. Therefore on this commit we added the default value with all relationships --- internal/vulnerability/runner.go | 4 +++- internal/vulnerability/scanner.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/vulnerability/runner.go b/internal/vulnerability/runner.go index b7d37837ff..a86b30d15c 100644 --- a/internal/vulnerability/runner.go +++ b/internal/vulnerability/runner.go @@ -23,6 +23,7 @@ import ( "time" "github.com/aquasecurity/trivy/pkg/commands/artifact" + ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" "github.com/aquasecurity/trivy/pkg/flag" trivy_types "github.com/aquasecurity/trivy/pkg/types" "github.com/elastic/elastic-agent-libs/logp" @@ -50,7 +51,8 @@ func NewVulnerabilityRunner(log *logp.Logger) (VulnerabilityRunner, error) { Debug: true, }, PackageOptions: flag.PackageOptions{ - PkgTypes: []string{trivy_types.PkgTypeOS, trivy_types.PkgTypeLibrary}, + PkgTypes: []string{trivy_types.PkgTypeOS, trivy_types.PkgTypeLibrary}, + PkgRelationships: ftypes.Relationships, }, ScanOptions: flag.ScanOptions{ Scanners: []trivy_types.Scanner{trivy_types.VulnerabilityScanner}, diff --git a/internal/vulnerability/scanner.go b/internal/vulnerability/scanner.go index 57f42bcb66..f235450f0a 100644 --- a/internal/vulnerability/scanner.go +++ b/internal/vulnerability/scanner.go @@ -26,6 +26,7 @@ import ( "time" db_types "github.com/aquasecurity/trivy-db/pkg/types" + ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" "github.com/aquasecurity/trivy/pkg/flag" trivy_types "github.com/aquasecurity/trivy/pkg/types" "github.com/elastic/elastic-agent-libs/logp" @@ -118,7 +119,8 @@ func (f VulnerabilityScanner) scan(ctx context.Context, snap ec2.EBSSnapshot) { Debug: true, }, PackageOptions: flag.PackageOptions{ - PkgTypes: []string{trivy_types.PkgTypeOS, trivy_types.PkgTypeLibrary}, + PkgTypes: []string{trivy_types.PkgTypeOS, trivy_types.PkgTypeLibrary}, + PkgRelationships: ftypes.Relationships, }, ScanOptions: flag.ScanOptions{ Target: fmt.Sprint("ebs:", snap.SnapshotId),