cfn-nag 0.4.44 → 0.4.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cfn-nag/custom_rules/MissingBucketPolicyRule.rb +40 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c877e195fcb87784efd39e29b1bd1544f3915dc6f2a043c1eb31839b50e5f211
|
4
|
+
data.tar.gz: 2954e474c00a8b537dbe2813fe253c0609b7e33eb2e597a07a60315c2a98a444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38dc9fd4ca9f94ed23ffbb51181056d8ec82f2146047db30b1669716c390ee463c9023ea7ed87f8b18093d7e70016ac399f1104ea21c7bff90d951d4d01e987b
|
7
|
+
data.tar.gz: 9e7d7fedde37b2488be3dbc22f6cc5021d72c0c66d530ace5f2020eda6f3ffe90f094384a2ea2646b2f2c098e1df06f4abd847b45cfe3c9125946ed88d3c1925
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
class MissingBucketPolicyRule < BaseRule
|
7
|
+
def rule_text
|
8
|
+
'S3 bucket should likely have a bucket policy'
|
9
|
+
end
|
10
|
+
|
11
|
+
def rule_type
|
12
|
+
Violation::WARNING
|
13
|
+
end
|
14
|
+
|
15
|
+
def rule_id
|
16
|
+
'W51'
|
17
|
+
end
|
18
|
+
|
19
|
+
def audit_impl(cfn_model)
|
20
|
+
violating_buckets = cfn_model.resources_by_type('AWS::S3::Bucket').select do |bucket|
|
21
|
+
policy_for_bucket(cfn_model, bucket).nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
violating_buckets.map(&:logical_resource_id)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def policy_for_bucket(cfn_model, bucket)
|
30
|
+
cfn_model.resources_by_type('AWS::S3::BucketPolicy').find do |bucket_policy|
|
31
|
+
if bucket_policy.bucket.is_a? String
|
32
|
+
bucket.bucketName == bucket_policy.bucket
|
33
|
+
elsif bucket_policy.bucket.is_a? Hash
|
34
|
+
bucket_policy.bucket['Ref'] == bucket.logical_resource_id
|
35
|
+
else
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn-nag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
@@ -215,6 +215,7 @@ files:
|
|
215
215
|
- lib/cfn-nag/custom_rules/LambdaPermissionInvokeFunctionActionRule.rb
|
216
216
|
- lib/cfn-nag/custom_rules/LambdaPermissionWildcardPrincipalRule.rb
|
217
217
|
- lib/cfn-nag/custom_rules/ManagedPolicyOnUserRule.rb
|
218
|
+
- lib/cfn-nag/custom_rules/MissingBucketPolicyRule.rb
|
218
219
|
- lib/cfn-nag/custom_rules/NeptuneDBClusterStorageEncryptedRule.rb
|
219
220
|
- lib/cfn-nag/custom_rules/OpsWorksStackRdsDbInstancePasswordRule.rb
|
220
221
|
- lib/cfn-nag/custom_rules/PolicyOnUserRule.rb
|