Skip to content

Commit

Permalink
fix(misconf): skip broken scans (#2396)
Browse files Browse the repository at this point in the history
  • Loading branch information
afdesk authored Jun 29, 2022
1 parent c36a373 commit 7111301
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/fanal/handler/misconf/misconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"path/filepath"
"strings"

"github.com/aquasecurity/defsec/pkg/scanners/rbac"

"github.com/liamg/memoryfs"
"github.com/samber/lo"
"golang.org/x/xerrors"
Expand All @@ -20,15 +18,18 @@ import (
"github.com/aquasecurity/defsec/pkg/scan"
"github.com/aquasecurity/defsec/pkg/scanners"
cfscanner "github.com/aquasecurity/defsec/pkg/scanners/cloudformation"
cfparser "github.com/aquasecurity/defsec/pkg/scanners/cloudformation/parser"
dfscanner "github.com/aquasecurity/defsec/pkg/scanners/dockerfile"
"github.com/aquasecurity/defsec/pkg/scanners/helm"
k8sscanner "github.com/aquasecurity/defsec/pkg/scanners/kubernetes"
"github.com/aquasecurity/defsec/pkg/scanners/options"
"github.com/aquasecurity/defsec/pkg/scanners/rbac"
tfscanner "github.com/aquasecurity/defsec/pkg/scanners/terraform"
"github.com/aquasecurity/trivy/pkg/fanal/analyzer"
"github.com/aquasecurity/trivy/pkg/fanal/artifact"
"github.com/aquasecurity/trivy/pkg/fanal/handler"
"github.com/aquasecurity/trivy/pkg/fanal/types"
"github.com/aquasecurity/trivy/pkg/log"
)

func init() {
Expand Down Expand Up @@ -236,6 +237,10 @@ func (h misconfPostHandler) Handle(ctx context.Context, result *analyzer.Analysi
for t, scanner := range h.scanners {
results, err := scanner.ScanFS(ctx, mapMemoryFS[t], ".")
if err != nil {
if _, ok := err.(*cfparser.InvalidContentError); ok {
log.Logger.Errorf("scan %q was broken with InvalidContentError: %v", scanner.Name(), err)
continue
}
return xerrors.Errorf("scan config error: %w", err)
}

Expand Down

0 comments on commit 7111301

Please sign in to comment.