Skip to content

Commit 8ea6c9c

Browse files
authored
Not alert on asterisk resources (#4024)
1 parent 24a515d commit 8ea6c9c

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

src/cfnlint/rules/resources/iam/StatementResources.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import annotations
77

8+
import logging
89
from collections import deque
910
from typing import Any
1011

@@ -14,6 +15,8 @@
1415
from cfnlint.rules.helpers import get_value_from_path
1516
from cfnlint.rules.jsonschema.CfnLintKeyword import CfnLintKeyword
1617

18+
LOGGER = logging.getLogger(__name__)
19+
1720

1821
class _Arn:
1922

@@ -164,8 +167,9 @@ def validate(
164167
rule=self,
165168
)
166169
else:
167-
yield ValidationError(
168-
f"action {action!r} requires a resource of '*'",
169-
path=deque(["Resource"]),
170-
rule=self,
171-
)
170+
LOGGER.debug(f"action {action!r} requires a resource of '*'")
171+
# yield ValidationError(
172+
# f"action {action!r} requires a resource of '*'",
173+
# path=deque(["Resource"]),
174+
# rule=self,
175+
# )

test/unit/rules/resources/iam/test_statement_resources.py

+35-38
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ def template():
118118
"Resource": [{"Ref": "LogGroup"}],
119119
},
120120
[
121-
ValidationError(
122-
"action 'cloudformation:CreateStackSet' requires a resource of '*'",
123-
rule=StatementResources(),
124-
path=deque(["Resource"]),
125-
),
121+
# ValidationError(
122+
# "action 'cloudformation:CreateStackSet' requires a resource of '*'", # noqa: E501
123+
# rule=StatementResources(),
124+
# path=deque(["Resource"]),
125+
# ),
126126
],
127127
),
128128
(
@@ -131,11 +131,11 @@ def template():
131131
"Resource": [{"Foo": "Bar"}],
132132
},
133133
[
134-
ValidationError(
135-
"action 'cloudformation:CreateStackSet' requires a resource of '*'",
136-
rule=StatementResources(),
137-
path=deque(["Resource"]),
138-
),
134+
# ValidationError(
135+
# "action 'cloudformation:CreateStackSet' requires a resource of '*'", # noqa: E501
136+
# rule=StatementResources(),
137+
# path=deque(["Resource"]),
138+
# ),
139139
],
140140
),
141141
(
@@ -144,11 +144,11 @@ def template():
144144
"Resource": ["arn:aws:cloudformation:us-east-1:123456789012:*"],
145145
},
146146
[
147-
ValidationError(
148-
"action 'cloudformation:CreateStackSet' requires a resource of '*'",
149-
rule=StatementResources(),
150-
path=deque(["Resource"]),
151-
),
147+
# ValidationError(
148+
# "action 'cloudformation:CreateStackSet' requires a resource of '*'", # noqa: E501
149+
# rule=StatementResources(),
150+
# path=deque(["Resource"]),
151+
# ),
152152
],
153153
),
154154
(
@@ -160,11 +160,11 @@ def template():
160160
"Resource": ["arn:aws:cloudformation:us-east-1:123456789012:*"],
161161
},
162162
[
163-
ValidationError(
164-
"action 'cloudformation:CreateStackSet' requires a resource of '*'",
165-
rule=StatementResources(),
166-
path=deque(["Resource"]),
167-
),
163+
# ValidationError(
164+
# "action 'cloudformation:CreateStackSet' requires a resource of '*'", # noqa: E501
165+
# rule=StatementResources(),
166+
# path=deque(["Resource"]),
167+
# ),
168168
],
169169
),
170170
(
@@ -173,11 +173,11 @@ def template():
173173
"Resource": ["arn:aws:cloudformation:us-east-1:123456789012:*"],
174174
},
175175
[
176-
ValidationError(
177-
"action 'cloudformation:CreateStackSet' requires a resource of '*'",
178-
rule=StatementResources(),
179-
path=deque(["Resource"]),
180-
),
176+
# ValidationError(
177+
# "action 'cloudformation:CreateStackSet' requires a resource of '*'", # noqa: E501
178+
# rule=StatementResources(),
179+
# path=deque(["Resource"]),
180+
# ),
181181
],
182182
),
183183
(
@@ -196,11 +196,11 @@ def template():
196196
"Resource": ["arn:aws:cloudformation:*:*:stack/*"],
197197
},
198198
[
199-
ValidationError(
200-
"action 'cloudformation:CreateStackSet' requires a resource of '*'",
201-
rule=StatementResources(),
202-
path=deque(["Resource"]),
203-
),
199+
# ValidationError(
200+
# "action 'cloudformation:CreateStackSet' requires a resource of '*'", # noqa: E501
201+
# rule=StatementResources(),
202+
# path=deque(["Resource"]),
203+
# ),
204204
],
205205
),
206206
(
@@ -335,21 +335,18 @@ def template():
335335
"Resource": {"Fn::GetAtt": "LogGroup.Arn"},
336336
},
337337
[
338-
ValidationError(
339-
"action 'logs:DescribeLogGroups' requires a resource of '*'",
340-
rule=StatementResources(),
341-
path=deque(["Resource"]),
342-
),
338+
# ValidationError(
339+
# "action 'logs:DescribeLogGroups' requires a resource of '*'", # noqa: E501
340+
# rule=StatementResources(),
341+
# path=deque(["Resource"]),
342+
# ),
343343
],
344344
),
345345
],
346346
)
347347
def test_rule(instance, expected, rule, validator):
348348
errors = list(rule.validate(validator, {}, instance, {}))
349349

350-
for err in errors:
351-
print(err.message)
352-
print(err.path)
353350
assert errors == expected, f"Got {errors!r}"
354351

355352

0 commit comments

Comments
 (0)