Skip to content

Commit

Permalink
removed redundant comments from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kristyko committed Feb 15, 2024
1 parent 9a5b940 commit c6d8461
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 6 additions & 5 deletions pkg/result/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func FilterResult(ctx context.Context, result *types.Result, ignoreConf IgnoreCo
filterLicenses(result, severities, opt.IgnoreLicenses, ignoreConf)

if opt.PolicyFile != "" {
if err := applyPolicy(ctx, result, opt.PolicyFile); err != nil {
return xerrors.Errorf("failed to apply the policy: %w", err)
}
}
Expand Down Expand Up @@ -287,9 +288,9 @@ func applyPolicy(ctx context.Context, result *types.Result, policyFile string) e
}
result.Misconfigurations = filteredMisconfs

// Secrets
var filteredSecrets []ftypes.SecretFinding
for _, scrt := range scrts {
// Secrets
var filteredSecrets []types.DetectedSecret
for _, scrt := range result.Secrets {
ignored, err := evaluate(ctx, query, scrt)
if err != nil {
return err
Expand All @@ -303,7 +304,7 @@ func applyPolicy(ctx context.Context, result *types.Result, policyFile string) e

// Licenses
var filteredLicenses []types.DetectedLicense
for _, lic := range lics {
for _, lic := range result.Licenses {
ignored, err := evaluate(ctx, query, lic)
if err != nil {
return err
Expand All @@ -315,7 +316,7 @@ func applyPolicy(ctx context.Context, result *types.Result, policyFile string) e
}
result.Licenses = filteredLicenses

return nil
return nil
}

func evaluate(ctx context.Context, query rego.PreparedEvalQuery, input interface{}) (bool, error) {
Expand Down
6 changes: 2 additions & 4 deletions pkg/result/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ func TestFilter(t *testing.T) {
{
Licenses: []types.DetectedLicense{
{
// this license is ignored
Name: "GPL-3.0",
Severity: dbTypes.SeverityLow.String(),
FilePath: "usr/share/gcc/python/libstdcxx/v6/__init__.py",
Expand All @@ -638,7 +637,7 @@ func TestFilter(t *testing.T) {
Confidence: 1,
},
},
Secrets: []ftypes.SecretFinding{
Secrets: []types.DetectedSecret{
{
RuleID: "generic-passed-rule",
Severity: dbTypes.SeverityLow.String(),
Expand Down Expand Up @@ -667,15 +666,14 @@ func TestFilter(t *testing.T) {
{
Licenses: []types.DetectedLicense{
{
// this license is ignored
Name: "GPL-3.0",
Severity: dbTypes.SeverityLow.String(),
FilePath: "usr/share/gcc/python/libstdcxx/v6/__init__.py",
Category: "restricted",
Confidence: 1,
},
},
Secrets: []ftypes.SecretFinding{
Secrets: []types.DetectedSecret{
{
RuleID: "generic-passed-rule",
Severity: dbTypes.SeverityLow.String(),
Expand Down

0 comments on commit c6d8461

Please sign in to comment.