Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
simar7 committed Aug 8, 2024
1 parent 36bc496 commit 116f122
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pkg/compliance/spec/compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/compliance/spec/compliance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/flag/report_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 116f122

Please sign in to comment.