Skip to content

Commit

Permalink
Fix an issue when scanning metadata (#3596)
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong authored Aug 13, 2024
1 parent c6d3252 commit 69fbdff
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/cfnlint/data/schemas/other/metadata/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@
}
},
"properties": {
"AWS::CloudFormation::Interface": {},
"cfn-lint": {}
"AWS::CloudFormation::Interface": {
"cfnLint": [
"Metadata/AWS::CloudFormation::Interface"
]
},
"cfn-lint": {
"cfnLint": [
"Metadata/cfn-lint"
]
}
},
"type": "object"
}
89 changes: 89 additions & 0 deletions test/fixtures/results/integration/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[
{
"Filename": "test/fixtures/templates/integration/metdata.yaml",
"Id": "e020b5ec-4ab1-0eb4-b917-7729e96af1d2",
"Level": "Warning",
"Location": {
"End": {
"ColumnNumber": 16,
"LineNumber": 9
},
"Path": [
"Metadata",
"AWS::CloudFormation::Interface",
"ParameterGroups",
0,
"Parameters",
0
],
"Start": {
"ColumnNumber": 13,
"LineNumber": 9
}
},
"Message": "'Vpc' is not one of ['VpcId']",
"ParentId": null,
"Rule": {
"Description": "Metadata Interface parameters actually exist",
"Id": "W4001",
"ShortDescription": "Metadata Interface parameters exist",
"Source": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-interface.html"
}
},
{
"Filename": "test/fixtures/templates/integration/metdata.yaml",
"Id": "a29b7c20-4cf5-0a50-3291-2606201bcde4",
"Level": "Warning",
"Location": {
"End": {
"ColumnNumber": 17,
"LineNumber": 12
},
"Path": [
"Metadata",
"cfn-lint",
"config",
"bad_checks"
],
"Start": {
"ColumnNumber": 7,
"LineNumber": 12
}
},
"Message": "Additional properties are not allowed ('bad_checks' was unexpected)",
"ParentId": null,
"Rule": {
"Description": "Metadata cfn-lint configuration has many values and we want to validate that",
"Id": "W4005",
"ShortDescription": "Validate cfnlint configuration in the Metadata",
"Source": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-interface.html"
}
},
{
"Filename": "test/fixtures/templates/integration/metdata.yaml",
"Id": "98830d26-133b-bdd8-e52a-f5a4d6a15cd8",
"Level": "Warning",
"Location": {
"End": {
"ColumnNumber": 8,
"LineNumber": 17
},
"Path": [
"Parameters",
"VpcId"
],
"Start": {
"ColumnNumber": 3,
"LineNumber": 17
}
},
"Message": "Parameter VpcId not used.",
"ParentId": null,
"Rule": {
"Description": "Making sure the parameters defined are used",
"Id": "W2001",
"ShortDescription": "Check if Parameters are Used",
"Source": "https://github.com/aws-cloudformation/cfn-lint"
}
}
]
21 changes: 21 additions & 0 deletions test/fixtures/templates/integration/metdata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
AWSTemplateFormatVersion: 2010-09-09

Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: 'Vpc Parameters'
Parameters:
- Vpc
cfn-lint:
config:
bad_checks:
- E3002

Parameters:
# Vpc Parameters
VpcId:
Description: VPC To Create Stack In
Type: String

Resources: {}
5 changes: 5 additions & 0 deletions test/integration/test_integration_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class TestQuickStartTemplates(BaseCliTestCase):
"results_filename": ("test/fixtures/results/integration/ref-no-value.json"),
"exit_code": 2,
},
{
"filename": ("test/fixtures/templates/integration/metdata.yaml"),
"results_filename": ("test/fixtures/results/integration/metadata.json"),
"exit_code": 2,
},
]

def test_templates(self):
Expand Down

0 comments on commit 69fbdff

Please sign in to comment.