diff --git a/pkg/compliance/spec/compliance.go b/pkg/compliance/spec/compliance.go index 584168c4c043..95ed4ea44177 100644 --- a/pkg/compliance/spec/compliance.go +++ b/pkg/compliance/spec/compliance.go @@ -74,7 +74,7 @@ func scannerByCheckID(checkID string) types.Scanner { } // GetComplianceSpec accept compliance flag name/path and return builtin or file system loaded spec -func GetComplianceSpec(specNameOrPath string, cache cache.TrivyCache) (ComplianceSpec, error) { +func GetComplianceSpec(specNameOrPath string, c cache.TrivyCache) (ComplianceSpec, error) { if specNameOrPath == "" { return ComplianceSpec{}, nil } @@ -87,13 +87,13 @@ func GetComplianceSpec(specNameOrPath string, cache cache.TrivyCache) (Complianc return ComplianceSpec{}, fmt.Errorf("error retrieving compliance spec from specified path: %w", err) } } else { - _, err := os.ReadFile(filepath.Join(cache.GetChecksDir(), "metadata.json")) + _, err := os.ReadFile(filepath.Join(c.GetChecksDir(), "metadata.json")) if err != nil { // cache corrupt or bundle does not exist, load embedded version b = []byte(sp.NewSpecLoader().GetSpecByName(specNameOrPath)) log.Debug("Compliance spec loaded from embedded library", log.String("spec", specNameOrPath)) } else { // load from bundle on disk - b, err = LoadFromBundle(cache, specNameOrPath) + b, err = LoadFromBundle(c, specNameOrPath) if err != nil { return ComplianceSpec{}, err } @@ -109,8 +109,8 @@ func GetComplianceSpec(specNameOrPath string, cache cache.TrivyCache) (Complianc } -func LoadFromBundle(cache cache.TrivyCache, specNameOrPath string) ([]byte, error) { - b, err := os.ReadFile(filepath.Join(cache.GetComplianceSpecsDir(), specNameOrPath+".yaml")) +func LoadFromBundle(c cache.TrivyCache, specNameOrPath string) ([]byte, error) { + b, err := os.ReadFile(filepath.Join(c.GetComplianceSpecsDir(), specNameOrPath+".yaml")) if err != nil { return nil, fmt.Errorf("error retrieving compliance spec from bundle %s: %w", specNameOrPath, err) } diff --git a/pkg/compliance/spec/compliance_test.go b/pkg/compliance/spec/compliance_test.go index df2387abdba6..901d5db099c6 100644 --- a/pkg/compliance/spec/compliance_test.go +++ b/pkg/compliance/spec/compliance_test.go @@ -5,10 +5,10 @@ import ( "sort" "testing" - "github.com/aquasecurity/trivy/pkg/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/aquasecurity/trivy/pkg/cache" "github.com/aquasecurity/trivy/pkg/compliance/spec" iacTypes "github.com/aquasecurity/trivy/pkg/iac/types" "github.com/aquasecurity/trivy/pkg/types" diff --git a/pkg/flag/report_flags.go b/pkg/flag/report_flags.go index 268f5d9f858b..2e86402c6d44 100644 --- a/pkg/flag/report_flags.go +++ b/pkg/flag/report_flags.go @@ -4,12 +4,12 @@ import ( "slices" "strings" - "github.com/aquasecurity/trivy/pkg/cache" "github.com/mattn/go-shellwords" "github.com/samber/lo" "golang.org/x/xerrors" dbTypes "github.com/aquasecurity/trivy-db/pkg/types" + "github.com/aquasecurity/trivy/pkg/cache" "github.com/aquasecurity/trivy/pkg/compliance/spec" "github.com/aquasecurity/trivy/pkg/log" "github.com/aquasecurity/trivy/pkg/result"