cfn-nag 0.3.42 → 0.3.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfn-nag/cfn_nag.rb +1 -1
- data/lib/cfn-nag/custom_rule_loader.rb +0 -2
- data/lib/cfn-nag/custom_rules/EbsVolumeHasSseRule.rb +1 -1
- data/lib/cfn-nag/custom_rules/IamManagedPolicyNotActionRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamManagedPolicyNotResourceRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamManagedPolicyWildcardActionRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamManagedPolicyWildcardResourceRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamPolicyNotActionRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamPolicyNotResourceRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamPolicyWildcardActionRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamPolicyWildcardResourceRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamRoleNotActionOnPermissionsPolicyRule.rb +4 -4
- data/lib/cfn-nag/custom_rules/IamRoleNotActionOnTrustPolicyRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamRoleNotPrincipalOnTrustPolicyRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamRoleNotResourceOnPermissionsPolicyRule.rb +4 -4
- data/lib/cfn-nag/custom_rules/IamRoleWildcardActionOnPermissionsPolicyRule.rb +4 -4
- data/lib/cfn-nag/custom_rules/IamRoleWildcardActionOnTrustPolicyRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/IamRoleWildcardResourceOnPermissionsPolicyRule.rb +4 -4
- data/lib/cfn-nag/custom_rules/LambdaPermissionInvokeFunctionActionRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/ManagedPolicyOnUserRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/PolicyOnUserRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/RDSInstanceMasterUserPasswordRule.rb +1 -5
- data/lib/cfn-nag/custom_rules/RDSInstancePubliclyAccessibleRule.rb +1 -1
- data/lib/cfn-nag/custom_rules/S3BucketPolicyNotActionRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/S3BucketPolicyNotPrincipalRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/S3BucketPolicyWildcardActionRule.rb +1 -1
- data/lib/cfn-nag/custom_rules/S3BucketPolicyWildcardPrincipalRule.rb +1 -1
- data/lib/cfn-nag/custom_rules/S3BucketPublicReadAclRule.rb +1 -3
- data/lib/cfn-nag/custom_rules/S3BucketPublicReadWriteAclRule.rb +1 -3
- data/lib/cfn-nag/custom_rules/SecurityGroupEgressOpenToWorldRule.rb +1 -3
- data/lib/cfn-nag/custom_rules/SecurityGroupEgressPortRangeRule.rb +5 -7
- data/lib/cfn-nag/custom_rules/SecurityGroupIngressCidrNon32Rule.rb +1 -3
- data/lib/cfn-nag/custom_rules/SecurityGroupIngressOpenToWorldRule.rb +1 -3
- data/lib/cfn-nag/custom_rules/SecurityGroupIngressPortRangeRule.rb +5 -7
- data/lib/cfn-nag/custom_rules/SecurityGroupMissingEgressRule.rb +1 -3
- data/lib/cfn-nag/custom_rules/SnsTopicPolicyNotActionRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/SnsTopicPolicyNotPrincipalRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/SnsTopicPolicyWildcardPrincipalRule.rb +1 -1
- data/lib/cfn-nag/custom_rules/SqsQueuePolicyNotActionRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/SqsQueuePolicyNotPrincipalRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/SqsQueuePolicyWildcardActionRule.rb +1 -1
- data/lib/cfn-nag/custom_rules/SqsQueuePolicyWildcardPrincipalRule.rb +1 -1
- data/lib/cfn-nag/custom_rules/UserHasInlinePolicyRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/UserMissingGroupRule.rb +1 -3
- data/lib/cfn-nag/custom_rules/base.rb +1 -3
- data/lib/cfn-nag/ip_addr.rb +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 431c10516146893563f42ae5a75a3fdb9019b03ae6feb03dcd16e5cb804a4b99
|
4
|
+
data.tar.gz: c0f24c8a080c368ea450344b3f981797d72b3c696ab8b1fd66c99060dfb822ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 615aa2c6fae2c0b3b1b951812fb68953cf2c7700926314c5f8babc03286b0bf1d8b7e209cf925b481f475b19ba30f46a4ef2d4315762de7bab091f2fbf3d486f
|
7
|
+
data.tar.gz: 41002ed03b0a00deb1a1d40bceb8fa02ce5d25fd723d9c90c356a64060ccdb4a02583c74681afbe3c580363ca311b3de37d0b94c9f03cd11520cd4696c5011d7
|
data/lib/cfn-nag/cfn_nag.rb
CHANGED
@@ -17,7 +17,7 @@ class EbsVolumeHasSseRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
violating_volumes = \
|
19
19
|
cfn_model.resources_by_type('AWS::EC2::Volume').select do |volume|
|
20
|
-
volume.encrypted.nil? || volume.encrypted.to_s.
|
20
|
+
volume.encrypted.nil? || volume.encrypted.to_s.casecmp('false').zero?
|
21
21
|
end
|
22
22
|
|
23
23
|
violating_volumes.map(&:logical_resource_id)
|
@@ -17,8 +17,8 @@ class IamManagedPolicyNotActionRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
violating_policies = \
|
19
19
|
cfn_model.resources_by_type('AWS::IAM::ManagedPolicy')
|
20
|
-
.
|
21
|
-
|
20
|
+
.reject do |policy|
|
21
|
+
policy.policy_document.allows_not_action.empty?
|
22
22
|
end
|
23
23
|
|
24
24
|
violating_policies.map(&:logical_resource_id)
|
@@ -17,8 +17,8 @@ class IamManagedPolicyNotResourceRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
violating_policies = \
|
19
19
|
cfn_model.resources_by_type('AWS::IAM::ManagedPolicy')
|
20
|
-
.
|
21
|
-
|
20
|
+
.reject do |policy|
|
21
|
+
policy.policy_document.allows_not_resource.empty?
|
22
22
|
end
|
23
23
|
|
24
24
|
violating_policies.map(&:logical_resource_id)
|
@@ -17,8 +17,8 @@ class IamManagedPolicyWildcardActionRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
violating_policies = \
|
19
19
|
cfn_model.resources_by_type('AWS::IAM::ManagedPolicy')
|
20
|
-
.
|
21
|
-
|
20
|
+
.reject do |policy|
|
21
|
+
policy.policy_document.wildcard_allowed_actions.empty?
|
22
22
|
end
|
23
23
|
|
24
24
|
violating_policies.map(&:logical_resource_id)
|
@@ -17,8 +17,8 @@ class IamManagedPolicyWildcardResourceRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
violating_policies = \
|
19
19
|
cfn_model.resources_by_type('AWS::IAM::ManagedPolicy')
|
20
|
-
.
|
21
|
-
|
20
|
+
.reject do |policy|
|
21
|
+
policy.policy_document.wildcard_allowed_resources.empty?
|
22
22
|
end
|
23
23
|
|
24
24
|
violating_policies.map(&:logical_resource_id)
|
@@ -17,8 +17,8 @@ class IamPolicyNotActionRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
violating_policies = \
|
19
19
|
cfn_model.resources_by_type('AWS::IAM::Policy')
|
20
|
-
.
|
21
|
-
|
20
|
+
.reject do |policy|
|
21
|
+
policy.policy_document.allows_not_action.empty?
|
22
22
|
end
|
23
23
|
|
24
24
|
violating_policies.map(&:logical_resource_id)
|
@@ -17,8 +17,8 @@ class IamPolicyNotResourceRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
violating_policies = \
|
19
19
|
cfn_model.resources_by_type('AWS::IAM::Policy')
|
20
|
-
.
|
21
|
-
|
20
|
+
.reject do |policy|
|
21
|
+
policy.policy_document.allows_not_resource.empty?
|
22
22
|
end
|
23
23
|
|
24
24
|
violating_policies.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class IamPolicyWildcardActionRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::IAM::Policy').
|
19
|
-
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::IAM::Policy').reject do |policy|
|
19
|
+
policy.policy_document.wildcard_allowed_actions.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class IamPolicyWildcardResourceRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::IAM::Policy').
|
19
|
-
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::IAM::Policy').reject do |policy|
|
19
|
+
policy.policy_document.wildcard_allowed_resources.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -15,11 +15,11 @@ class IamRoleNotActionOnPermissionsPolicyRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').
|
19
|
-
violating_policies = role.policy_objects.
|
20
|
-
|
18
|
+
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').reject do |role|
|
19
|
+
violating_policies = role.policy_objects.reject do |policy|
|
20
|
+
policy.policy_document.allows_not_action.empty?
|
21
21
|
end
|
22
|
-
|
22
|
+
violating_policies.empty?
|
23
23
|
end
|
24
24
|
|
25
25
|
violating_roles.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class IamRoleNotActionOnTrustPolicyRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').
|
19
|
-
|
18
|
+
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').reject do |role|
|
19
|
+
role.assume_role_policy_document.allows_not_action.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_roles.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class IamRoleNotPrincipalOnTrustPolicyRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').
|
19
|
-
|
18
|
+
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').reject do |role|
|
19
|
+
role.assume_role_policy_document.allows_not_principal.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_roles.map(&:logical_resource_id)
|
@@ -15,11 +15,11 @@ class IamRoleNotResourceOnPermissionsPolicyRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').
|
19
|
-
violating_policies = role.policy_objects.
|
20
|
-
|
18
|
+
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').reject do |role|
|
19
|
+
violating_policies = role.policy_objects.reject do |policy|
|
20
|
+
policy.policy_document.allows_not_resource.empty?
|
21
21
|
end
|
22
|
-
|
22
|
+
violating_policies.empty?
|
23
23
|
end
|
24
24
|
|
25
25
|
violating_roles.map(&:logical_resource_id)
|
@@ -15,11 +15,11 @@ class IamRoleWildcardActionOnPermissionsPolicyRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').
|
19
|
-
violating_policies = role.policy_objects.
|
20
|
-
|
18
|
+
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').reject do |role|
|
19
|
+
violating_policies = role.policy_objects.reject do |policy|
|
20
|
+
policy.policy_document.wildcard_allowed_actions.empty?
|
21
21
|
end
|
22
|
-
|
22
|
+
violating_policies.empty?
|
23
23
|
end
|
24
24
|
|
25
25
|
violating_roles.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class IamRoleWildcardActionOnTrustPolicyRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').
|
19
|
-
|
18
|
+
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').reject do |role|
|
19
|
+
role.assume_role_policy_document.wildcard_allowed_actions.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_roles.map(&:logical_resource_id)
|
@@ -15,11 +15,11 @@ class IamRoleWildcardResourceOnPermissionsPolicyRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').
|
19
|
-
violating_policies = role.policy_objects.
|
20
|
-
|
18
|
+
violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').reject do |role|
|
19
|
+
violating_policies = role.policy_objects.reject do |policy|
|
20
|
+
policy.policy_document.wildcard_allowed_resources.empty?
|
21
21
|
end
|
22
|
-
|
22
|
+
violating_policies.empty?
|
23
23
|
end
|
24
24
|
|
25
25
|
violating_roles.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class LambdaPermissionInvokeFunctionActionRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_lambdas = cfn_model.resources_by_type('AWS::Lambda::Permission').
|
19
|
-
lambda_permission.action
|
18
|
+
violating_lambdas = cfn_model.resources_by_type('AWS::Lambda::Permission').reject do |lambda_permission|
|
19
|
+
lambda_permission.action == 'lambda:InvokeFunction'
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_lambdas.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class ManagedPolicyOnUserRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::IAM::ManagedPolicy').
|
19
|
-
policy.users.
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::IAM::ManagedPolicy').reject do |policy|
|
19
|
+
policy.users.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class PolicyOnUserRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::IAM::Policy').
|
19
|
-
policy.users.
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::IAM::Policy').reject do |policy|
|
19
|
+
policy.users.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -32,11 +32,7 @@ class RDSInstanceMasterUserPasswordRule < BaseRule
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def to_boolean(string)
|
35
|
-
|
36
|
-
true
|
37
|
-
else
|
38
|
-
false
|
39
|
-
end
|
35
|
+
string.to_s.casecmp('true').zero?
|
40
36
|
end
|
41
37
|
|
42
38
|
def references_no_echo_parameter_without_default?(cfn_model, master_user_password)
|
@@ -16,7 +16,7 @@ class RDSInstancePubliclyAccessibleRule < BaseRule
|
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
violating_rdsinstances = cfn_model.resources_by_type('AWS::RDS::DBInstance').select do |instance|
|
19
|
-
instance.publiclyAccessible.nil? || instance.publiclyAccessible.to_s.
|
19
|
+
instance.publiclyAccessible.nil? || instance.publiclyAccessible.to_s.casecmp('true').zero?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_rdsinstances.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class S3BucketPolicyNotActionRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::S3::BucketPolicy').
|
19
|
-
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::S3::BucketPolicy').reject do |policy|
|
19
|
+
policy.policy_document.allows_not_action.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class S3BucketPolicyNotPrincipalRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::S3::BucketPolicy').
|
19
|
-
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::S3::BucketPolicy').reject do |policy|
|
19
|
+
policy.policy_document.allows_not_principal.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -18,7 +18,7 @@ class S3BucketPolicyWildcardActionRule < BaseRule
|
|
18
18
|
logical_resource_ids = []
|
19
19
|
|
20
20
|
cfn_model.resources_by_type('AWS::S3::BucketPolicy').each do |bucket_policy|
|
21
|
-
|
21
|
+
unless bucket_policy.policy_document.wildcard_allowed_actions.empty?
|
22
22
|
logical_resource_ids << bucket_policy.logical_resource_id
|
23
23
|
end
|
24
24
|
end
|
@@ -18,7 +18,7 @@ class S3BucketPolicyWildcardPrincipalRule < BaseRule
|
|
18
18
|
logical_resource_ids = []
|
19
19
|
|
20
20
|
cfn_model.resources_by_type('AWS::S3::BucketPolicy').each do |topic_policy|
|
21
|
-
|
21
|
+
unless topic_policy.policy_document.wildcard_allowed_principals.empty?
|
22
22
|
logical_resource_ids << topic_policy.logical_resource_id
|
23
23
|
end
|
24
24
|
end
|
@@ -18,9 +18,7 @@ class S3BucketPublicReadAclRule < BaseRule
|
|
18
18
|
logical_resource_ids = []
|
19
19
|
|
20
20
|
cfn_model.resources_by_type('AWS::S3::Bucket').each do |bucket|
|
21
|
-
if bucket.accessControl == 'PublicRead'
|
22
|
-
logical_resource_ids << bucket.logical_resource_id
|
23
|
-
end
|
21
|
+
logical_resource_ids << bucket.logical_resource_id if bucket.accessControl == 'PublicRead'
|
24
22
|
end
|
25
23
|
|
26
24
|
logical_resource_ids
|
@@ -18,9 +18,7 @@ class S3BucketPublicReadWriteAclRule < BaseRule
|
|
18
18
|
logical_resource_ids = []
|
19
19
|
|
20
20
|
cfn_model.resources_by_type('AWS::S3::Bucket').each do |bucket|
|
21
|
-
if bucket.accessControl == 'PublicReadWrite'
|
22
|
-
logical_resource_ids << bucket.logical_resource_id
|
23
|
-
end
|
21
|
+
logical_resource_ids << bucket.logical_resource_id if bucket.accessControl == 'PublicReadWrite'
|
24
22
|
end
|
25
23
|
|
26
24
|
logical_resource_ids
|
@@ -26,9 +26,7 @@ class SecurityGroupEgressOpenToWorldRule < BaseRule
|
|
26
26
|
ip4_open?(egress) || ip6_open?(egress)
|
27
27
|
end
|
28
28
|
|
29
|
-
unless violating_egresses.empty?
|
30
|
-
logical_resource_ids << security_group.logical_resource_id
|
31
|
-
end
|
29
|
+
logical_resource_ids << security_group.logical_resource_id unless violating_egresses.empty?
|
32
30
|
end
|
33
31
|
|
34
32
|
violating_egresses = cfn_model.standalone_egress.select do |standalone_egress|
|
@@ -19,17 +19,15 @@ class SecurityGroupEgressPortRangeRule < BaseRule
|
|
19
19
|
def audit_impl(cfn_model)
|
20
20
|
logical_resource_ids = []
|
21
21
|
cfn_model.security_groups.each do |security_group|
|
22
|
-
violating_egresses = security_group.egresses.
|
23
|
-
egress.fromPort
|
22
|
+
violating_egresses = security_group.egresses.reject do |egress|
|
23
|
+
egress.fromPort == egress.toPort
|
24
24
|
end
|
25
25
|
|
26
|
-
unless violating_egresses.empty?
|
27
|
-
logical_resource_ids << security_group.logical_resource_id
|
28
|
-
end
|
26
|
+
logical_resource_ids << security_group.logical_resource_id unless violating_egresses.empty?
|
29
27
|
end
|
30
28
|
|
31
|
-
violating_egresses = cfn_model.standalone_egress.
|
32
|
-
standalone_egress.fromPort
|
29
|
+
violating_egresses = cfn_model.standalone_egress.reject do |standalone_egress|
|
30
|
+
standalone_egress.fromPort == standalone_egress.toPort
|
33
31
|
end
|
34
32
|
|
35
33
|
logical_resource_ids + violating_egresses.map(&:logical_resource_id)
|
@@ -26,9 +26,7 @@ class SecurityGroupIngressCidrNon32Rule < BaseRule
|
|
26
26
|
ip4_cidr_range?(ingress) || ip6_cidr_range?(ingress)
|
27
27
|
end
|
28
28
|
|
29
|
-
unless violating_ingresses.empty?
|
30
|
-
logical_resource_ids << security_group.logical_resource_id
|
31
|
-
end
|
29
|
+
logical_resource_ids << security_group.logical_resource_id unless violating_ingresses.empty?
|
32
30
|
end
|
33
31
|
|
34
32
|
violating_ingresses = cfn_model.standalone_ingress.select do |standalone_ingress|
|
@@ -28,9 +28,7 @@ class SecurityGroupIngressOpenToWorldRule < BaseRule
|
|
28
28
|
ip4_open?(ingress) || ip6_open?(ingress)
|
29
29
|
end
|
30
30
|
|
31
|
-
unless violating_ingresses.empty?
|
32
|
-
logical_resource_ids << security_group.logical_resource_id
|
33
|
-
end
|
31
|
+
logical_resource_ids << security_group.logical_resource_id unless violating_ingresses.empty?
|
34
32
|
end
|
35
33
|
|
36
34
|
violating_ingresses = cfn_model.standalone_ingress.select do |standalone_ingress|
|
@@ -19,17 +19,15 @@ class SecurityGroupIngressPortRangeRule < BaseRule
|
|
19
19
|
def audit_impl(cfn_model)
|
20
20
|
logical_resource_ids = []
|
21
21
|
cfn_model.security_groups.each do |security_group|
|
22
|
-
violating_ingresses = security_group.ingresses.
|
23
|
-
ingress.fromPort
|
22
|
+
violating_ingresses = security_group.ingresses.reject do |ingress|
|
23
|
+
ingress.fromPort == ingress.toPort
|
24
24
|
end
|
25
25
|
|
26
|
-
unless violating_ingresses.empty?
|
27
|
-
logical_resource_ids << security_group.logical_resource_id
|
28
|
-
end
|
26
|
+
logical_resource_ids << security_group.logical_resource_id unless violating_ingresses.empty?
|
29
27
|
end
|
30
28
|
|
31
|
-
violating_ingresses = cfn_model.standalone_ingress.
|
32
|
-
standalone_ingress.fromPort
|
29
|
+
violating_ingresses = cfn_model.standalone_ingress.reject do |standalone_ingress|
|
30
|
+
standalone_ingress.fromPort == standalone_ingress.toPort
|
33
31
|
end
|
34
32
|
|
35
33
|
logical_resource_ids + violating_ingresses.map(&:logical_resource_id)
|
@@ -17,9 +17,7 @@ class SecurityGroupMissingEgressRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
logical_resource_ids = []
|
19
19
|
cfn_model.security_groups.each do |security_group|
|
20
|
-
if security_group.egresses.empty?
|
21
|
-
logical_resource_ids << security_group.logical_resource_id
|
22
|
-
end
|
20
|
+
logical_resource_ids << security_group.logical_resource_id if security_group.egresses.empty?
|
23
21
|
end
|
24
22
|
|
25
23
|
logical_resource_ids
|
@@ -15,8 +15,8 @@ class SnsTopicPolicyNotActionRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::SNS::TopicPolicy').
|
19
|
-
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::SNS::TopicPolicy').reject do |policy|
|
19
|
+
policy.policy_document.allows_not_action.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class SnsTopicPolicyNotPrincipalRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::SNS::TopicPolicy').
|
19
|
-
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::SNS::TopicPolicy').reject do |policy|
|
19
|
+
policy.policy_document.allows_not_principal.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -18,7 +18,7 @@ class SnsTopicPolicyWildcardPrincipalRule < BaseRule
|
|
18
18
|
logical_resource_ids = []
|
19
19
|
|
20
20
|
cfn_model.resources_by_type('AWS::SNS::TopicPolicy').each do |topic_policy|
|
21
|
-
|
21
|
+
unless topic_policy.policy_document.wildcard_allowed_principals.empty?
|
22
22
|
logical_resource_ids << topic_policy.logical_resource_id
|
23
23
|
end
|
24
24
|
end
|
@@ -15,8 +15,8 @@ class SqsQueuePolicyNotActionRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::SQS::QueuePolicy').
|
19
|
-
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::SQS::QueuePolicy').reject do |policy|
|
19
|
+
policy.policy_document.allows_not_action.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -15,8 +15,8 @@ class SqsQueuePolicyNotPrincipalRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_policies = cfn_model.resources_by_type('AWS::SQS::QueuePolicy').
|
19
|
-
|
18
|
+
violating_policies = cfn_model.resources_by_type('AWS::SQS::QueuePolicy').reject do |policy|
|
19
|
+
policy.policy_document.allows_not_principal.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_policies.map(&:logical_resource_id)
|
@@ -18,7 +18,7 @@ class SqsQueuePolicyWildcardActionRule < BaseRule
|
|
18
18
|
logical_resource_ids = []
|
19
19
|
|
20
20
|
cfn_model.resources_by_type('AWS::SQS::QueuePolicy').each do |queue_policy|
|
21
|
-
|
21
|
+
unless queue_policy.policy_document.wildcard_allowed_actions.empty?
|
22
22
|
logical_resource_ids << queue_policy.logical_resource_id
|
23
23
|
end
|
24
24
|
end
|
@@ -18,7 +18,7 @@ class SqsQueuePolicyWildcardPrincipalRule < BaseRule
|
|
18
18
|
logical_resource_ids = []
|
19
19
|
|
20
20
|
cfn_model.resources_by_type('AWS::SQS::QueuePolicy').each do |topic_policy|
|
21
|
-
|
21
|
+
unless topic_policy.policy_document.wildcard_allowed_principals.empty?
|
22
22
|
logical_resource_ids << topic_policy.logical_resource_id
|
23
23
|
end
|
24
24
|
end
|
@@ -15,8 +15,8 @@ class UserHasInlinePolicyRule < BaseRule
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def audit_impl(cfn_model)
|
18
|
-
violating_users = cfn_model.iam_users.
|
19
|
-
iam_user.policy_objects.
|
18
|
+
violating_users = cfn_model.iam_users.reject do |iam_user|
|
19
|
+
iam_user.policy_objects.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
violating_users.map(&:logical_resource_id)
|
@@ -17,9 +17,7 @@ class UserMissingGroupRule < BaseRule
|
|
17
17
|
def audit_impl(cfn_model)
|
18
18
|
logical_resource_ids = []
|
19
19
|
cfn_model.iam_users.each do |iam_user|
|
20
|
-
if iam_user.group_names.empty?
|
21
|
-
logical_resource_ids << iam_user.logical_resource_id
|
22
|
-
end
|
20
|
+
logical_resource_ids << iam_user.logical_resource_id if iam_user.group_names.empty?
|
23
21
|
end
|
24
22
|
|
25
23
|
logical_resource_ids
|
@@ -15,13 +15,11 @@ class BaseRule
|
|
15
15
|
def audit(cfn_model)
|
16
16
|
logical_resource_ids = audit_impl(cfn_model)
|
17
17
|
|
18
|
-
|
18
|
+
unless logical_resource_ids.empty?
|
19
19
|
Violation.new(id: rule_id,
|
20
20
|
type: rule_type,
|
21
21
|
message: rule_text,
|
22
22
|
logical_resource_ids: logical_resource_ids)
|
23
|
-
else
|
24
|
-
nil
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
data/lib/cfn-nag/ip_addr.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn-nag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|