Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cfnlint v1 compatibility upgrade #192

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
87a93a0
chore: updated gitignore
sliedig Sep 10, 2024
824abc5
chore: minor formatting and spelling mistakes in readme
sliedig Sep 10, 2024
5203a47
chore: minor formatting corrections
sliedig Sep 10, 2024
bfcf93b
chore(ci): testing against supported versions of python
sliedig Sep 10, 2024
f136e70
feat: modified Lambda message to more easily identify the Lambda prop…
sliedig Sep 10, 2024
15228a8
chore: minor refactorings
sliedig Sep 10, 2024
1ccaf82
feat: upgrading cfnlint to version 1.12.4 and min python version to 3…
sliedig Sep 10, 2024
a0059b6
fix: build config
sliedig Sep 10, 2024
92b506b
Removing python 3.6 and 3.7
leandrodamascena Nov 22, 2024
9f4d7d3
Removing python 3.6 and 3.7
leandrodamascena Nov 22, 2024
44e1280
chore(deps): bump setuptools in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
7c0e8b8
chore(deps): bump urllib3 from 1.26.7 to 1.26.19 in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
37b277b
chore(deps-dev): bump certifi in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
4af8bc3
chore(deps-dev): bump future in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
a4af269
chore(deps-dev): bump requests in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
0416acb
chore(deps-dev): bump black in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
9ce8363
chore(deps-dev): bump idna from 3.3 to 3.7 in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
19e637f
chore(deps-dev): bump bandit in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
952ca6a
chore(deps): bump actions/setup-go from 3 to 5
dependabot[bot] Nov 22, 2024
b9a1dbc
chore(deps-dev): bump flake8-bugbear in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
4c4de1e
chore(deps-dev): bump radon from 5.1.0 to 6.0.1 in /cfn-lint-serverless
dependabot[bot] Nov 22, 2024
0565b35
fix: updated python runtime version for templates and docs
sliedig Nov 30, 2024
3000590
fix: python test
sliedig Nov 30, 2024
214dbce
chore(deps): bumping min python version
sliedig Nov 30, 2024
c58e633
chore(ci): updating gh actions
sliedig Nov 30, 2024
f54983f
chore(deps): updating go runtime and dependencies
sliedig Nov 30, 2024
595138c
Merge remote-tracking branch 'upstream/main' into sliedig-patch
sliedig Nov 30, 2024
071417b
chore(deps): bumping cfn-lint
sliedig Nov 30, 2024
8c703d6
chore(deps): update pytest and related dependencies to latest versions
sliedig Nov 30, 2024
6ac0943
fix: resolved issue cause cfnlint E3601 failure
sliedig Dec 1, 2024
94305dc
chore: bump version to 0.3.3 in pyproject.toml
sliedig Dec 1, 2024
47481dc
chore(ci): updating publishing token
sliedig Dec 1, 2024
d3b1553
chore: fix formatting
sliedig Dec 1, 2024
25e75f8
chore: updated gitignore
sliedig Dec 31, 2024
0d914c1
chore(deps): update dependencies in go.mod and go.sum, and bump versi…
sliedig Dec 31, 2024
a827551
refactor: improve AwsSqsQueueRedrivePolicyRule implementation and upd…
sliedig Dec 31, 2024
3426505
refactor: update severity return type to tflint.Severity and improve …
sliedig Dec 31, 2024
ecdf7a0
refactor: standardize rule implementations and improve resource checks
sliedig Dec 31, 2024
f676cd8
chore(ci): update workflow configurations and dependencies
sliedig Dec 31, 2024
2558e5c
Merge remote-tracking branch 'upstream/main' into sliedig-patch
sliedig Dec 31, 2024
bf6569e
chore(ci): update Python version in workflows to 3.13
sliedig Dec 31, 2024
39f1f09
chore: updated lock file and minor template changes
sliedig Jan 2, 2025
59ad73a
Merge branch main into sliedig-patch
sliedig Jan 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ jobs:
run: make -C $FOLDER lint
- name: Tests
run: make -C $FOLDER test

44 changes: 44 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"yaml.schemas": {
"file:///Users/sliedig/Library/Application%20Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/sam.schema.json": [
"resources/templates/lambda.yaml",
"resources/templates/sns.yaml",
"resources/templates/cognito-user-pool.yaml",
"example/template.yaml",
"examples/SimpleLambda/template.yaml",
"benchmark/template.yaml",
"blog/account-a-web-store/template.yaml",
"blog/account-c-invoice-processing/template.yaml",
"patterns/multi-bus-multi-account-pattern/blue-service-account/blue-service-app/template.yaml",
"patterns/multi-bus-multi-account-pattern/orange-service-account/orange-service-app/template.yaml",
"patterns/single-bus-multi-account-pattern/orange-service-account/orange-service-app/template.yaml",
"patterns/multi-bus-multi-account-pattern/purple-service-account/purple-service-app/template.yaml",
"patterns/single-bus-multi-account-pattern/purple-service-account/purple-service-app/template.yaml",
"patterns/single-bus-multi-account-pattern/blue-service-account/blue-service-app/template.yaml",
"src/backend/template.yaml",
"sam-app/template.yaml",
"sam-app-github/template.yaml",
"sam-pipelines-demo-rakuten/template.yaml",
"sam/app-control-concurrency-with-dynamodb/template.yaml",
"sam/app-decompose-for-parallelism/template.yaml",
"sam/app-s3-athena-dataprocessing/template.yaml",
"sam/app-order-management/template.yaml",
"backend/template.yaml",
"packaged.yaml",
"template.yaml",
"src/property-contract/template.yaml",
"src/unicorn-property/template.yaml",
"src/unicorn-properties-sam/unicorn-properties/template.yaml",
"src/unicorn-properties-sam/unicorn-contracts/template.yaml",
"src/unicorn-properties-sam/unicorn-properties-web/template.yaml"
],
"file:/Users/sliedig/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/sam.schema.json": [
"example/template.yaml",
"benchmark/template.yaml",
"resources/templates/lambda.yaml",
"resources/templates/sns.yaml",
"resources/templates/cognito-user-pool.yaml"
],
"https://www.artillery.io/schema.json": []
}
}
2 changes: 1 addition & 1 deletion cfn-lint-serverless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Usage

```bash
cfn-lint template.yaml -a cfn_lint_serverless.rules
```
```
2 changes: 1 addition & 1 deletion cfn-lint-serverless/cfn_lint_serverless/rules/lambda_.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LambdaTracingRule(CloudFormationLintRule):
source_url = "https://awslabs.github.io/serverless-rules/rules/lambda/tracing/"
tags = ["lambda"]

_message = "Lambda function {} should have TracingConfig.Mode set to 'Active'."
_message = "Lambda function {} should have Tracing property set to 'Active'."

def match(self, cfn):
"""
Expand Down
29 changes: 9 additions & 20 deletions cfn-lint-serverless/cfn_lint_serverless/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ class Value:
def __new__(cls, value: Union[None, dict, str]) -> Union[None, TValue]:
"""
Create a new Value object

If the 'value' passed is None, this will return None instead of a class object
"""

if value is None:
return None

return super(Value, cls).__new__(cls)
return None if value is None else super(Value, cls).__new__(cls)

def __init__(self, value: Union[dict, str]):
"""
Expand All @@ -44,7 +40,7 @@ def __init__(self, value: Union[dict, str]):

# Not a dict - return an error here
elif not isinstance(value, dict):
raise ValueError("'value' should be of type str or dict, got '%s'" % type(value))
raise ValueError(f"'value' should be of type str or dict, got '{type(value)}'")

# 'Ref' intrinsic function
elif "Ref" in value:
Expand All @@ -54,11 +50,11 @@ def __init__(self, value: Union[dict, str]):
elif "Fn::GetAtt" in value:
self.id, self.references = self._get_from_getatt(value["Fn::GetAtt"])

# 'Fn::Join' intrisic function
# 'Fn::Join' intrinsic function
elif "Fn::Join" in value:
self.id, self.references = self._get_from_join(value["Fn::Join"])

# 'Fn::Sub' intrisic function
# 'Fn::Sub' intrinsic function
elif "Fn::Sub" in value:
self.id, self.references = self._get_from_sub(value["Fn::Sub"])

Expand Down Expand Up @@ -100,27 +96,20 @@ def _get_from_sub(self, value: Union[str, list]) -> Tuple[str, List[str]]:
Return the name and references from a 'Fn::Sub' intrinsic function
"""

pattern = value
variables = {}

if isinstance(value, list):
pattern = value[0]
# Using Value() here to get nested references
variables = {k: Value(v) for k, v in value[1].items()}
pattern, variables = value[0], {k: Value(v) for k, v in value[1].items()}
else:
pattern, variables = value, {}

references = []

for match in SUB_PATTERN.findall(pattern):
if match in variables:
# Variable with reference(s)
if len(variables[match].references) > 0:
if variables[match].references:
references.extend(variables[match].references)
# Hard-coded variable
else:
# Replace with hard-coded value in value ID
pattern = pattern.replace(f"${{{match}}}", variables[match].id)
# No matching variable
else:
references.append(match)

return (pattern, references)
return pattern, references
6 changes: 3 additions & 3 deletions cfn-lint-serverless/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def test_rule_with_templates(rules):
"""

# Retrieve all serverless rule IDs
rule_ids = set([r.id for r in rules if r.id[1] == "S"])
rule_ids = {r.id for r in rules if r.id[1] == "S"}

# Retrieve all rule IDs for tests
test_rule_ids = set([t[1] for t in templates])
test_rule_ids = {t[1] for t in templates}

assert rule_ids == test_rule_ids

Expand All @@ -70,7 +70,7 @@ def test_template(filename, rule, mode, rules):
match_ids = [match.rule.id for match in matches]

# No non-serverless errors
assert len([m for m in match_ids if m[1] != "S"]) == 0
assert not [m for m in match_ids if m[1] != "S"]

if mode == "fail":
assert rule in match_ids
Expand Down
2 changes: 1 addition & 1 deletion docs/cfn-lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If the template fulfills the requirements for all rules, `cfn-lint` will return
ES4000 EventBridge rule ConsumerFunctionTrigger should have a DeadLetterConfig.Arn property for all its Targets.
template.yaml:5:1

WS1000 Lambda function ConsumerFunction should have TracingConfig.Mode set to 'Active'.
WS1000 Lambda function ConsumerFunction should have Tracing property set to 'Active'.
template.yaml:7:3

WS1004 Lambda function ConsumerFunction does not have a corresponding log group with a Retention property
Expand Down
2 changes: 1 addition & 1 deletion examples/cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
CDK Example
===========

xample on how to use cfn-lint-serverless with [AWS CDK](https://docs.aws.amazon.com/cdk/latest/guide/home.html).
Example on how to use cfn-lint-serverless with [AWS CDK](https://docs.aws.amazon.com/cdk/latest/guide/home.html).

Usage
-----
Expand Down
9 changes: 5 additions & 4 deletions examples/cdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
packages=setuptools.find_packages(where="cdk"),

install_requires=[
"aws-cdk.core==1.106.1",
"aws-cdk.core==1.204.0",
],

python_requires=">=3.6",
python_requires=">=3.8",

classifiers=[
"Development Status :: 4 - Beta",
Expand All @@ -31,9 +31,10 @@

"Programming Language :: JavaScript",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",

"Topic :: Software Development :: Code Generators",
"Topic :: Utilities",
Expand Down
35 changes: 32 additions & 3 deletions tflint-ruleset-aws-serverless/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
module github.com/awslabs/serverless-rules/tflint-ruleset-aws-serverless

go 1.15
go 1.23

require (
github.com/hashicorp/hcl/v2 v2.12.0
github.com/terraform-linters/tflint-plugin-sdk v0.9.1
github.com/hashicorp/hcl/v2 v2.23.0
github.com/terraform-linters/tflint-plugin-sdk v0.21.0
)

require (
github.com/agext/levenshtein v1.2.1 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)
Loading
Loading