Skip to content

Commit

Permalink
fix: logic of handling *.tf and *.tf.json in Terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
zdtsw committed Aug 1, 2022
1 parent ccd6f1b commit 477450c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/fanal/analyzer/config/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"

"golang.org/x/exp/slices"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -49,7 +50,17 @@ func (a ConfigAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInput)
}

func (a ConfigAnalyzer) Required(filePath string, _ os.FileInfo) bool {
return slices.Contains(requiredExts, filepath.Ext(filePath))
// with --file-patterns
if a.filePattern != nil && a.filePattern.MatchString(filePath) {
return true
}

for _, acceptable := range requiredExts {
if strings.HasSuffix(strings.ToLower(filePath), acceptable) {
return true
}
}
return false
}

func (ConfigAnalyzer) Type() analyzer.Type {
Expand Down

0 comments on commit 477450c

Please sign in to comment.