Skip to content

Commit

Permalink
Change the default configuration for rule E3012 to not be strict (#2103)
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Sep 2, 2021
1 parent c686892 commit 56e8440
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self):
self.property_specs = []
self.config_definition = {
'strict': {
'default': True,
'default': False,
'type': 'boolean'
}
}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/test_quickstart_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@ class TestQuickStartTemplates(BaseCliTestCase):
def test_templates(self):
""" Test same templates using integration approach"""
rules = cfnlint.core.get_rules(
[], [], ['I', 'E', 'W'], {}, True)
[], [], ['I', 'E', 'W'], {
'E3012': {
'strict': True
}
}, True)
self.run_module_integration_scenarios(rules)
6 changes: 3 additions & 3 deletions test/unit/module/cfn_json/test_cfn_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setUp(self):
self.filenames = {
"config_rule": {
"filename": 'test/fixtures/templates/quickstart/config-rules.json',
"failures": 6
"failures": 4
},
"iam": {
"filename": 'test/fixtures/templates/quickstart/iam.json',
Expand All @@ -36,11 +36,11 @@ def setUp(self):
},
"vpc_management": {
"filename": 'test/fixtures/templates/quickstart/vpc-management.json',
"failures": 23
"failures": 8
},
"vpc": {
"filename": 'test/fixtures/templates/quickstart/vpc.json',
"failures": 40
"failures": 0
},
"poller": {
"filename": 'test/fixtures/templates/public/lambda-poller.json',
Expand Down
2 changes: 1 addition & 1 deletion test/unit/module/cfn_yaml/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUp(self):
},
"generic_bad": {
"filename": 'test/fixtures/templates/bad/generic.yaml',
"failures": 35
"failures": 29
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/module/formatters/test_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_json_formatter(self):
# Run a broken template
filename = 'test/fixtures/templates/bad/formatters.yaml'
(args, filenames, formatter) = cfnlint.core.get_args_filenames([
'--template', filename, '--format', 'json', '--include-checks', 'I'])
'--template', filename, '--format', 'json', '--include-checks', 'I', '--configure-rule', 'E3012:strict=true'])

results = []
for filename in filenames:
Expand Down
4 changes: 2 additions & 2 deletions test/unit/module/test_rules_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_fail_run(self):
filename = 'test/fixtures/templates/bad/generic.yaml'
template = cfnlint.decode.cfn_yaml.load(filename)
cfn = Template(filename, template, ['us-east-1'])
expected_err_count = 36
expected_err_count = 30
matches = []
matches.extend(self.rules.run(filename, cfn))
assert len(matches) == expected_err_count, 'Expected {} failures, got {}'.format(
Expand All @@ -63,7 +63,7 @@ def test_fail_sub_properties_run(self):

matches = []
matches.extend(self.rules.run(filename, cfn))
self.assertEqual(5, len(matches), 'Expected {} failures, got {}'.format(5, len(matches)))
self.assertEqual(4, len(matches), 'Expected {} failures, got {}'.format(4, len(matches)))

def test_success_filtering_of_rules_default(self):
"""Test extend function"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ def test_template_config(self):

def test_file_negative_nist_high_main(self):
"""Generic Test failure"""
self.helper_file_negative('test/fixtures/templates/quickstart/nist_high_main.yaml', 6)
self.helper_file_rule_config('test/fixtures/templates/quickstart/nist_high_main.yaml',
{'strict': True}, 6)

def test_file_negative_nist_high_app(self):
"""Generic Test failure"""
self.helper_file_negative('test/fixtures/templates/quickstart/nist_application.yaml', 53)
self.helper_file_rule_config('test/fixtures/templates/quickstart/nist_application.yaml',
{'strict': True}, 53)

def test_file_negative_nist_config_rules(self):
"""Generic Test failure"""
self.helper_file_negative('test/fixtures/templates/quickstart/nist_config_rules.yaml', 2)
self.helper_file_rule_config('test/fixtures/templates/quickstart/nist_config_rules.yaml',
{'strict': True}, 2)

def test_file_negative_generic(self):
"""Generic Test failure"""
self.helper_file_negative('test/fixtures/templates/bad/generic.yaml', 7)
self.helper_file_rule_config('test/fixtures/templates/bad/generic.yaml',
{'strict': True}, 7)


class TestResourceValuePrimitiveTypeNonStrict(BaseRuleTestCase):
Expand Down

0 comments on commit 56e8440

Please sign in to comment.