Skip to content

Commit e3d8e93

Browse files
authored
Limit the amount of conditions that get processed (#2598)
1 parent bf334a2 commit e3d8e93

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/cfnlint/conditions.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ class Condition:
8686
Not = None
8787
Equals = None
8888
Influenced_Equals = None
89+
Name = None
8990

9091
def __init__(self, template, name=None, sub_condition=None):
9192
self.And = []
9293
self.Or = []
9394
self.Not = []
9495
self.Influenced_Equals = {}
96+
self.Name = name
9597
if name is not None:
9698
value = template.get("Conditions", {}).get(name, {})
9799
try:
@@ -106,6 +108,11 @@ def __init__(self, template, name=None, sub_condition=None):
106108
LOGGER.debug("Error parsing condition: %s", name)
107109
self.Equals = None
108110

111+
def __eq__(self, __o: object) -> bool:
112+
if self.Name is None:
113+
return False
114+
return self.Name == __o.Name
115+
109116
def test(self, scenarios):
110117
"""Test a condition based on a scenario"""
111118
if self.And:
@@ -441,9 +448,10 @@ def multiply_equals(currents, s_hash, sets, parameter_values):
441448
if matched_conditions:
442449
scenarios = []
443450
for con_hash, sets in matched_equals.items():
444-
scenarios = multiply_equals(
445-
scenarios, con_hash, sets, self.Parameters.get(con_hash)
446-
)
451+
if len(scenarios) < 20:
452+
scenarios = multiply_equals(
453+
scenarios, con_hash, sets, self.Parameters.get(con_hash)
454+
)
447455

448456
for scenario in scenarios:
449457
r_condition = {}

0 commit comments

Comments
 (0)