8000 Remove experimental from W3037 (#3680) · aws-cloudformation/cfn-lint@cf5aad3 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf5aad3

Browse files
authored
Remove experimental from W3037 (#3680)
1 parent 3cc4012 commit cf5aad3

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class Permissions(CfnLintKeyword):
2121
description = "Check for valid IAM Permissions"
2222
source_url = "https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_action.html"
2323
tags = ["properties", "iam", "permissions"]
24-
experimental = True
2524

2625
def __init__(self):
2726
"""Init"""
@@ -33,6 +32,11 @@ def __init__(self):
3332
def validate(
3433
self, validator: Validator, _, instance: Any, schema: dict[str, Any]
3534
) -> ValidationResult:
35+
# Escape validation when using SAM transforms as a result of
36+
# https://github.com/aws/serverless-application-model/issues/3633
37+
if validator.context.transforms.has_sam_transform():
38+
return
39+
3640
actions = ensure_list(instance)
3741

3842
for action in actions:
@@ -41,7 +45,7 @@ def validate(
4145
if ":" not in action:
4246
yield ValidationError(
4347
(
44-
f"{action!r} is not a valid action."
48+
f"{action!r} is not a valid action. "
4549
"Must be of the form service:action or '*'"
4650
),
4751
rule=self,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
import pytest
7+
8+
from cfnlint.rules.resources.iam.Permissions import Permissions
9+
10+
11+
@pytest.fixture(scope="module")
12+
def rule():
13+
rule = Permissions()
14+
yield rule
15+
16+
17+
@pytest.fixture
18+
def template():
19+
return {
20+
"Transform": "AWS::Serverless-2016-10-31",
21+
}
22+
23+
24+
@pytest.mark.para 6212 metrize(
25+
"name,instance,err_count",
26+
[
27+
("Empty string", "", 0),
28+
],
29+
)
30+
def test_permissions(name, instance, err_count, rule, validator):
31+
errors = list(rule.validate(validator, {}, instance, {}))
32+
assert len(errors) == err_count, f"Test {name!r} got {errors!r}"

0 commit comments

Comments
 (0)
0