Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
PatMyron authored Nov 23, 2020
2 parents a42b9dc + 620d14e commit e76485a
Show file tree
Hide file tree
Showing 22 changed files with 637 additions and 151 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ Lint all `yaml` files in `path` and all subdirectories (recursive):

*Note*: Glob in Python 3.5 supports recursive searching `**/*.yaml`. If you are using an earlier version of Python you will have to handle this manually (`folder1/*.yaml`, `folder2/*.yaml`, etc).

##### Exit Codes
`cfn-lint` will return a non zero exit if there are any issues with your template. The value is dependent on the sevirity of the issues found. For each level of discovered error `cfn-lint` will use bitwise OR to determine the final exit code. This will result in these possibilities.

- 0 is no issue was found
- 2 is an error
- 4 is a warning
- 6 is an error and a warning
- 8 is an informational
- 10 is an error and informational
- 12 is an warning and informational
- 14 is an error and a warning and an informational

##### Specifying the template as an input stream

The template to be linted can also be passed using standard input:
Expand Down Expand Up @@ -138,7 +150,7 @@ Optional parameters:
| ------------- | ------------- | ------------- | ------------- |
| -h, --help | | | Get description of cfn-lint |
| -t, --template | | filename | Alternative way to specify Template file path to the file that needs to be tested by cfn-lint |
| -f, --format | format | quiet, parseable, json, junit | Output format |
| -f, --format | format | quiet, parseable, json, junit, pretty | Output format |
| -l, --list-rules | | | List all the rules |
| -r, --regions | regions | [REGIONS [REGIONS ...]], ALL_REGIONS | Test the template against many regions. [Supported regions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html) |
| -b, --ignore-bad-template | ignore_bad_template | | Ignores bad template errors |
Expand Down
9 changes: 1 addition & 8 deletions scripts/update_specs_from_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,9 @@
'South America (Sao Paulo)': 'sa-east-1',
'US East (N. Virginia)': 'us-east-1',
'US East (Ohio)': 'us-east-2',
'US East (Verizon) - Atlanta': 'us-east-1',
'US East (Verizon) - Boston': 'us-east-1',
'US East (Verizon) - New York': 'us-east-1',
'US East (Verizon) - Washington DC': 'us-east-1',
'US West (N. California)': 'us-west-1',
'US West (Oregon)': 'us-west-2',
'US West (Los Angeles)': 'us-west-2',
'US West (Verizon) - San Francisco Bay Area': 'us-west-2',
'US East (Verizon) - Miami': 'us-east-1',
'US East (Verizon) - Dallas': 'us-east-1',
}

session = boto3.session.Session()
Expand Down Expand Up @@ -206,7 +199,7 @@ def get_results(service, product_families):
products = json.loads(price_item)
product = products.get('product', {})
if product:
if product.get('productFamily') in product_families:
if product.get('productFamily') in product_families and 'Verizon' not in product.get('attributes').get('location'):
if not results.get(region_map[product.get('attributes').get('location')]):
results[region_map[product.get('attributes').get('location')]] = set()
results[region_map[product.get('attributes').get('location')]].add(
Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main():
matches.extend(errors)
LOGGER.debug('Completed linting of file: %s', str(filename))

matches_output = formatter.print_matches(matches, rules)
matches_output = formatter.print_matches(matches, rules, filenames)

if matches_output:
if args.output_file:
Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def __call__(self, parser, namespace, values, option_string=None):
'-I', '--info', help='Enable information logging', action='store_true'
)
standard.add_argument(
'-f', '--format', help='Output Format', choices=['quiet', 'parseable', 'json', 'junit']
'-f', '--format', help='Output Format', choices=['quiet', 'parseable', 'json', 'junit', 'pretty']
)

standard.add_argument(
Expand Down
8 changes: 5 additions & 3 deletions src/cfnlint/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def get_exit_code(matches):
""" Determine exit code """
exit_code = 0
for match in matches:
if match.rule.id[0] == 'I':
if match.rule.severity == 'informational':
exit_code = exit_code | 8
elif match.rule.id[0] == 'W':
elif match.rule.severity == 'warning':
exit_code = exit_code | 4
elif match.rule.id[0] == 'E':
elif match.rule.severity == 'error':
exit_code = exit_code | 2

return exit_code
Expand All @@ -79,6 +79,8 @@ def get_formatter(fmt):
formatter = cfnlint.formatters.JsonFormatter()
elif fmt == 'junit':
formatter = cfnlint.formatters.JUnitFormatter()
elif fmt == 'pretty':
formatter = cfnlint.formatters.PrettyFormatter()
else:
formatter = cfnlint.formatters.Formatter()

Expand Down
173 changes: 173 additions & 0 deletions src/cfnlint/data/AdditionalSpecs/SubNeededExcludes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"ResourceTypes": {
"AWS::ApiGateway::Method": {
"ExcludeRegex": "stageVariables\\..*"
},
"AWS::AppSync::FunctionConfiguration": {
"Properties": {
"RequestMappingTemplate": {
"ExcludeAll": true
},
"ResponseMappingTemplate": {
"ExcludeAll": true
}
}
},
"AWS::AppSync::Resolver": {
"Properties": {
"RequestMappingTemplate": {
"ExcludeAll": true
},
"ResponseMappingTemplate": {
"ExcludeAll": true
}
}
},
"AWS::AutoScaling::LaunchConfiguration": {
"Properties": {
"UserData": {
"ExcludeAll": true
}
}
},
"AWS::CloudFormation::StackSet": {
"Properties": {
"TemplateBody": {
"ExcludeAll": true
}
}
},
"AWS::CodeBuild::Project": {
"Properties": {
"BuildSpec": {
"ExcludeAll": true
}
}
},
"AWS::EC2::FlowLog": {
"Properties": {
"LogFormat": {
"ExcludeAll": true
}
}
},
"AWS::EC2::Instance": {
"Metadata": {
"AWS::CloudFormation::Init": {
"ExcludeAll": true
}
},
"Properties": {
"UserData": {
"ExcludeAll": true
}
}
},
"AWS::EMR::InstanceGroupConfig": {
"Properties": {
"AutoScalingPolicy": {
"Properties": {
"ScalingRule": {
"Properties": {
"ScalingTrigger": {
"Properties": {
"CloudWatchAlarmDefinition": {
"ExcludeAll": true
}
}
}
}
}
}
}
}
},
"AWS::IAM::Policy": {
"Properties": {
"PolicyDocument": {
"ExcludeValues": [
"aws:CurrentTime",
"aws:EpochTime",
"aws:TokenIssueTime",
"aws:principaltype",
"aws:SecureTransport",
"aws:SourceIp",
"aws:UserAgent",
"aws:userid",
"aws:username",
"ec2:SourceInstanceARN",
"iot:Connection.Thing.ThingName",
"iot:Connection.Thing.ThingTypeName",
"iot:Connection.Thing.IsAttached",
"iot:ClientId",
"transfer:HomeBucket",
"transfer:HomeDirectory",
"transfer:HomeFolder",
"transfer:UserName",
"redshift:DbUser",
"cognito-identity.amazonaws.com:aud",
"cognito-identity.amazonaws.com:sub",
"cognito-identity.amazonaws.com:amr"
]
}
}
},
"AWS::IoT::Policy": {
"Properties": {
"PolicyDocument": {
"ExcludeValues": [
"aws:CurrentTime",
"aws:EpochTime",
"aws:TokenIssueTime",
"aws:principaltype",
"aws:SecureTransport",
"aws:SourceIp",
"aws:UserAgent",
"aws:userid",
"aws:username",
"ec2:SourceInstanceARN",
"iot:Connection.Thing.ThingName",
"iot:Connection.Thing.ThingTypeName",
"iot:Connection.Thing.IsAttached",
"iot:ClientId",
"transfer:HomeBucket",
"transfer:HomeDirectory",
"transfer:HomeFolder",
"transfer:UserName",
"redshift:DbUser",
"cognito-identity.amazonaws.com:aud",
"cognito-identity.amazonaws.com:sub",
"cognito-identity.amazonaws.com:amr"
]
}
}
},
"AWS::IoT::TopicRule": {
"Properties": {
"TopicRulePayload": {
"ExcludeAll": true
}
}
},
"AWS::Lambda::Function": {
"Properties": {
"Code": {
"Properties": {
"ZipFile": {
"ExcludeAll": true
}
}
}
}
},
"AWS::StepFunctions::StateMachine": {
"Properties": {
"DefinitionString": {
"ExcludeBasedOnProperties": [
"AWS::StepFunctions::StateMachine.DefinitionSubstitutions"
]
}
}
}
}
}
15 changes: 1 addition & 14 deletions src/cfnlint/data/CloudSpecs/us-east-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -14316,19 +14316,6 @@
}
}
},
"AWS::EC2::CarrierGateway.Tags": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-carriergateway-tags.html",
"Properties": {
"Tags": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-carriergateway-tags.html#cfn-ec2-carriergateway-tags-tags",
"DuplicatesAllowed": false,
"ItemType": "Tag",
"Required": false,
"Type": "List",
"UpdateType": "Mutable"
}
}
},
"AWS::EC2::ClientVpnEndpoint.CertificateAuthenticationRequest": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-clientvpnendpoint-certificateauthenticationrequest.html",
"Properties": {
Expand Down Expand Up @@ -54621,7 +54608,7 @@
"Tags": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-carriergateway.html#cfn-ec2-carriergateway-tags",
"Required": false,
"Type": "Tags",
"Type": "Tag",
"UpdateType": "Mutable"
},
"VpcId": {
Expand Down
15 changes: 1 addition & 14 deletions src/cfnlint/data/CloudSpecs/us-west-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -14147,19 +14147,6 @@
}
}
},
"AWS::EC2::CarrierGateway.Tags": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-carriergateway-tags.html",
"Properties": {
"Tags": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-carriergateway-tags.html#cfn-ec2-carriergateway-tags-tags",
"DuplicatesAllowed": false,
"ItemType": "Tag",
"Required": false,
"Type": "List",
"UpdateType": "Mutable"
}
}
},
"AWS::EC2::ClientVpnEndpoint.CertificateAuthenticationRequest": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-clientvpnendpoint-certificateauthenticationrequest.html",
"Properties": {
Expand Down Expand Up @@ -54382,7 +54369,7 @@
"Tags": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-carriergateway.html#cfn-ec2-carriergateway-tags",
"Required": false,
"Type": "Tags",
"Type": "Tag",
"UpdateType": "Mutable"
},
"VpcId": {
Expand Down
9 changes: 9 additions & 0 deletions src/cfnlint/data/ExtendedSpecs/all/01_spec_patch.json
Original file line number Diff line number Diff line change
Expand Up @@ -417,5 +417,14 @@
"op": "replace",
"path": "/ResourceTypes/AWS::IoT::DomainConfiguration/Properties/Tags/Type",
"value": "Tag"
},
{
"op": "remove",
"path": "/PropertyTypes/AWS::EC2::CarrierGateway.Tags"
},
{
"op": "replace",
"path": "/ResourceTypes/AWS::EC2::CarrierGateway/Properties/Tags/Type",
"value": "Tag"
}
]
40 changes: 40 additions & 0 deletions src/cfnlint/data/ExtendedSpecs/all/03_value_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,46 @@
]
}
},
"AvailabilityZoneWithAll": {
"AllowedValues": [
"all", "af-south-1a", "af-south-1b", "af-south-1c",
"ap-east-1a", "ap-east-1b", "ap-east-1c",
"ap-northeast-1a", "ap-northeast-1b", "ap-northeast-1c", "ap-northeast-1d",
"ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c", "ap-northeast-2d",
"ap-northeast-3a",
"ap-south-1a", "ap-south-1b", "ap-south-1c",
"ap-southeast-1a", "ap-southeast-1b", "ap-southeast-1c",
"ap-southeast-2a", "ap-southeast-2b", "ap-southeast-2c",
"ca-central-1a", "ca-central-1b", "ca-central-1d",
"cn-north-1a", "cn-north-1b",
"cn-northwest-1a", "cn-northwest-1b", "cn-northwest-1c",
"eu-central-1a", "eu-central-1b", "eu-central-1c",
"eu-north-1a", "eu-north-1b", "eu-north-1c",
"eu-south-1a", "eu-south-1b", "eu-south-1c",
"eu-west-1a", "eu-west-1b", "eu-west-1c",
"eu-west-2a", "eu-west-2b", "eu-west-2c",
"eu-west-3a", "eu-west-3b", "eu-west-3c",
"me-south-1a", "me-south-1b", "me-south-1c",
"sa-east-1a", "sa-east-1b", "sa-east-1c",
"us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e", "us-east-1f",
"us-east-2a", "us-east-2b", "us-east-2c",
"us-gov-east-1a", "us-gov-east-1b", "us-gov-east-1c",
"us-gov-west-1a", "us-gov-west-1b", "us-gov-west-1c",
"us-west-1a", "us-west-1b", "us-west-1c",
"us-west-2a", "us-west-2b", "us-west-2c", "us-west-2d", "us-west-2-lax-1a", "us-west-2-lax-1b"
],
"GetAtt": {
"AWS::EC2::Instance": "AvailabilityZone",
"AWS::EC2::Subnet": "AvailabilityZone",
"AWS::OpsWorks::Instance": "AvailabilityZone"
},
"Ref": {
"Parameters": [
"String",
"AvailabilityZone"
]
}
},
"CertificateValidationMethod": {
"botocore": "acm/2015-12-08/ValidationMethod"
},
Expand Down
Loading

0 comments on commit e76485a

Please sign in to comment.