@@ -32,49 +32,48 @@ def __init__(self):
32
32
def check (self , properties , exclusions , path , cfn ):
33
33
"""Check itself"""
34
34
matches = []
35
-
36
- property_sets = cfn .get_object_without_conditions (properties )
37
- for property_set in property_sets :
38
- obj = property_set ["Object" ].clean ()
39
- for prop in obj :
40
- if prop in exclusions :
41
- for excl_property in exclusions [prop ]:
42
- if excl_property in obj :
43
- if property_set ["Scenario" ] is None :
44
- message = (
45
- "Property {0} should NOT exist with {1} for {2}"
46
- )
47
- matches .append (
48
- RuleMatch (
49
- path + [prop ],
50
- message .format (
51
- excl_property ,
52
- prop ,
53
- "/" .join (map (str , path )),
54
- ),
55
- )
56
- )
57
- else :
58
- scenario_text = " and " .join (
59
- [
60
- f'when condition "{ k } " is { v } '
61
- for (k , v ) in property_set ["Scenario" ].items ()
62
- ]
63
- )
64
- message = (
65
- "Property {0} should NOT exist with {1} {2} for {3}"
66
- )
67
- matches .append (
68
- RuleMatch (
69
- path + [prop ],
70
- message .format (
71
- excl_property ,
72
- prop ,
73
- scenario_text ,
74
- "/" .join (map (str , path )),
75
- ),
76
- )
77
- )
35
+ for p_value , p_path in properties .items_safe (path [:]):
36
+ for k , v in exclusions .items ():
37
+ property_sets = cfn .get_object_without_conditions (p_value , [k ] + v )
38
+ for property_set in property_sets :
39
+ obj = property_set ["Object" ].clean ()
40
+ for prop in obj :
41
+ if prop in exclusions :
42
+ for excl_property in exclusions [prop ]:
43
+ if excl_property in obj :
44
+ if property_set ["Scenario" ] is None :
45
+ message = "Property {0} should NOT exist with {1} for {2}"
46
+ matches .append (
47
+ RuleMatch (
48
+ p_path + [prop ],
49
+ message .format (
50
+ excl_property ,
51
+ prop ,
52
+ "/" .join (map (str , p_path )),
53
+ ),
54
+ )
55
+ )
56
+ else :
57
+ scenario_text = " and " .join (
58
+ [
59
+ f'when condition "{ k } " is { v } '
60
+ for (k , v ) in property_set [
61
+ "Scenario"
62
+ ].items ()
63
+ ]
64
+ )
65
+ message = "Property {0} should NOT exist with {1} {2} for {3}"
66
+ matches .append (
67
+ RuleMatch (
68
+ p_path + [prop ],
69
+ message .format (
70
+ excl_property ,
71
+ prop ,
72
+ scenario_text ,
73
+ "/" .join (map (str , p_path )),
74
+ ),
75
+ )
76
+ )
78
77
79
78
return matches
80
79
0 commit comments