Skip to content

Commit

Permalink
added fix for local-exec found outside of a provisioner
Browse files Browse the repository at this point in the history
  • Loading branch information
bradegler authored and verbanicm committed Oct 21, 2022
1 parent eb5be1b commit e5478d5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/lint-terraform/linter/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ func (tfl *TerraformLinter) FindViolations(content []byte, path string) ([]*lint
}

var instances []*lint.ViolationInstance
inProvisioner := false
for _, token := range tokens {
if token.Bytes != nil && token.Type == hclsyntax.TokenQuotedLit {
if token.Bytes == nil {
continue
}

// Each Ident token starts a new object, we are only looking for provisioner
// type objects with specific types, local-exec and remote-exec
if token.Type == hclsyntax.TokenIdent {
inProvisioner = string(token.Bytes) == "provisioner"
}
if inProvisioner && token.Type == hclsyntax.TokenQuotedLit {
if string(token.Bytes) == tokenLocalExec {
instances = append(instances, &lint.ViolationInstance{ViolationType: tokenLocalExec, Path: path, Line: token.Range.Start.Line})
}
Expand Down

0 comments on commit e5478d5

Please sign in to comment.