@@ -78,6 +78,30 @@ def _variable_custom_excluded(self, value):
78
78
return re .match (custom_search , value )
79
79
return False
80
80
81
+ def _validate_step_functions (self , var , parameter_string_path , cfn ) -> bool :
82
+ # Step Function State Machine has a Definition Substitution
83
+ # that allows usage of special variables outside of a !Sub
84
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachine-definitionsubstitutions.html
85
+
86
+ for key in ["DefinitionString" , "Definition" ]:
87
+ if key in parameter_string_path :
88
+ modified_parameter_string_path = copy .copy (parameter_string_path )
89
+ index = parameter_string_path .index (key )
90
+ modified_parameter_string_path [index ] = "DefinitionSubstitutions"
91
+ modified_parameter_string_path = modified_parameter_string_path [
92
+ : index + 1
93
+ ]
94
+ modified_parameter_string_path .append (var [2 :- 1 ])
95
+
96
+ if reduce (
97
+ lambda c , k : c .get (k , {}),
98
+ modified_parameter_string_path ,
99
+ cfn .template ,
100
+ ):
101
+ return True
102
+
103
+ return False
104
+
81
105
def match (self , cfn : Template ) -> RuleMatches :
82
106
matches = []
83
107
@@ -93,24 +117,8 @@ def match(self, cfn: Template) -> RuleMatches:
93
117
# Get variable
94
118
var = parameter_string_path [- 1 ]
95
119
96
- # Step Function State Machine has a Definition Substitution
97
- # that allows usage of special variables outside of a !Sub
98
- # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachine-definitionsubstitutions.html
99
-
100
- if "DefinitionString" in parameter_string_path :
101
- modified_parameter_string_path = copy .copy (parameter_string_path )
102
- index = parameter_string_path .index ("DefinitionString" )
103
- modified_parameter_string_path [index ] = "DefinitionSubstitutions"
104
- modified_parameter_string_path = modified_parameter_string_path [
105
- : index + 1
106
- ]
107
- modified_parameter_string_path .append (var [2 :- 1 ])
108
- if reduce (
109
- lambda c , k : c .get (k , {}),
110
- modified_parameter_string_path ,
111
- cfn .template ,
112
- ):
113
- continue
120
+ if self ._validate_step_functions (var , parameter_string_path , cfn ):
121
+ continue
114
122
115
123
# Exclude variables that match custom exclude filters, if configured
116
124
# (for third-party tools that pre-process templates
0 commit comments