MCPcopy
hub / github.com/aquasecurity/tfsec / evalMatchSpecAttr

Function evalMatchSpecAttr

internal/pkg/custom/processing.go:333–356  ·  view source on GitHub ↗
(a *terraform.Attribute, spec *MatchSpec, customCtx *customContext)

Source from the content-addressed store, hash-verified

331}
332
333func evalMatchSpecAttr(a *terraform.Attribute, spec *MatchSpec, customCtx *customContext) bool {
334 for _, preCondition := range spec.PreConditions {
335 clone := preCondition
336 if !evalMatchSpecAttr(a, &clone, customCtx) {
337 // precondition not met
338 return true
339 }
340 }
341
342 switch spec.Action {
343 case Not:
344 return notifyPredicateAttr(a, spec, customCtx)
345 case And:
346 return processAndPredicateAttr(a, spec, customCtx)
347 case Or:
348 return processOrPredicateAttr(a, spec, customCtx)
349 default:
350 if matchFunction, ok := AttrMatchFunctions[spec.Action]; ok {
351 return matchFunction(a, spec, customCtx)
352 } else {
353 return false
354 }
355 }
356}
357
358func notifyPredicate(b *terraform.Block, spec *MatchSpec, customCtx *customContext) bool {
359 return !evalMatchSpec(b, &spec.PredicateMatchSpec[0], customCtx)

Callers 4

notifyPredicateAttrFunction · 0.85
processOrPredicateAttrFunction · 0.85
processAndPredicateAttrFunction · 0.85
processSubMatchesFunction · 0.85

Calls 3

notifyPredicateAttrFunction · 0.85
processAndPredicateAttrFunction · 0.85
processOrPredicateAttrFunction · 0.85

Tested by

no test coverage detected