Exemple #1
0
def test_failures_are_raised(bad_template):
    rule = S3BucketPublicReadWriteAclRule(Config())
    result = rule.invoke(bad_template)

    assert not result.valid
    assert len(result.failed_rules) == 1
    assert len(result.failed_monitored_rules) == 0
    assert result.failed_rules[0].rule == "S3BucketPublicReadWriteAclRule"
    assert result.failed_rules[0].reason == "S3 Bucket S3Bucket should not have a public read-write acl"
Exemple #2
0
def test_failures_are_raised(bad_template):
    rule = S3BucketPublicReadWriteAclRule(Config())
    result = rule.invoke(bad_template)

    assert not result.valid
    assert compare_lists_of_failures(
        result.failures,
        [
            Failure(
                granularity=RuleGranularity.RESOURCE,
                reason=
                "S3 Bucket S3Bucket should not have a public read-write acl",
                risk_value=RuleRisk.HIGH,
                rule="S3BucketPublicReadWriteAclRule",
                rule_mode=RuleMode.BLOCKING,
                actions=None,
                resource_ids={"S3Bucket"},
            )
        ],
    )
Exemple #3
0
def test_rule_supports_filter_config(bad_template, default_allow_all_config):
    rule = S3BucketPublicReadWriteAclRule(default_allow_all_config)
    result = rule.invoke(bad_template)

    assert result.valid
    assert compare_lists_of_failures(result.failures, [])