s3-secure 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/s3_secure/abstract_base.rb +2 -1
- data/lib/s3_secure/access_logs.rb +2 -0
- data/lib/s3_secure/access_logs/disable.rb +4 -4
- data/lib/s3_secure/access_logs/enable.rb +4 -4
- data/lib/s3_secure/access_logs/show.rb +2 -2
- data/lib/s3_secure/cli.rb +2 -2
- data/lib/s3_secure/encryption.rb +2 -0
- data/lib/s3_secure/encryption/disable.rb +2 -2
- data/lib/s3_secure/encryption/enable.rb +2 -4
- data/lib/s3_secure/encryption/show.rb +3 -3
- data/lib/s3_secure/lifecycle.rb +2 -0
- data/lib/s3_secure/lifecycle/add.rb +3 -3
- data/lib/s3_secure/lifecycle/remove.rb +2 -2
- data/lib/s3_secure/lifecycle/show.rb +3 -3
- data/lib/s3_secure/policy.rb +2 -0
- data/lib/s3_secure/policy/enforce.rb +3 -4
- data/lib/s3_secure/policy/show.rb +3 -4
- data/lib/s3_secure/policy/unforce.rb +3 -3
- data/lib/s3_secure/remediate_all.rb +6 -5
- data/lib/s3_secure/say.rb +7 -0
- data/lib/s3_secure/version.rb +1 -1
- data/lib/s3_secure/versioning.rb +2 -0
- data/lib/s3_secure/versioning/disable.rb +2 -2
- data/lib/s3_secure/versioning/enable.rb +2 -2
- data/lib/s3_secure/versioning/show.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fe4cf360f3085cd6d3a6432163e48446163b3fb4c873594198009a9eca48352
|
4
|
+
data.tar.gz: 74458fbc45b76b221c51dd75120f75c0122cd32aee9efc1a2516fcba8eaeaebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a657388018a9a0aac3b396e6d7480e210871cd2a0f6a7a85cc31a22f9b1caa7ef0e536bfe2dbbf7a921fc1c5f98366c36f388a36330b55cb9ca740fc0ffa56f
|
7
|
+
data.tar.gz: c52d3846e952af1438bb9f776d66e976a9645b5ec2c8ba8cfec18ae2ce9e24526d69f9c07951b25aaa26cc74c56da25585083c57f9d9775c2f0bd5f78ea89107
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.5.1]
|
7
|
+
- #3 add quiet option
|
8
|
+
|
6
9
|
## [0.5.0]
|
7
10
|
- add commands: access_logs, lifecycle, versioning, remediate_all
|
8
11
|
- s3 client is smarter and switches regions on a per-bucket basis
|
@@ -9,7 +9,7 @@ class S3Secure::AccessLogs
|
|
9
9
|
|
10
10
|
def remove_access_logging
|
11
11
|
unless @show.logging_enabled?
|
12
|
-
|
12
|
+
say "Bucket #{@bucket} is not configured with access logging. So nothing to remove."
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
@@ -17,12 +17,12 @@ class S3Secure::AccessLogs
|
|
17
17
|
bucket: @bucket, # source
|
18
18
|
bucket_logging_status: {}, # empty hash to remove
|
19
19
|
)
|
20
|
-
|
20
|
+
say "Bucket #{@bucket} access logging removed"
|
21
21
|
end
|
22
22
|
|
23
23
|
def remove_bucket_acl
|
24
24
|
unless @show.acl_enabled?
|
25
|
-
|
25
|
+
say "Bucket #{@bucket} is not configured the log delivery ACL. So nothing to remove."
|
26
26
|
return
|
27
27
|
end
|
28
28
|
|
@@ -31,7 +31,7 @@ class S3Secure::AccessLogs
|
|
31
31
|
bucket: @bucket,
|
32
32
|
access_control_policy: access_control_policy,
|
33
33
|
)
|
34
|
-
|
34
|
+
say "Bucket #{@bucket} ACL Log Delivery removed"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -9,7 +9,7 @@ class S3Secure::AccessLogs
|
|
9
9
|
# Bucket ACL applies on the target bucket only
|
10
10
|
def add_bucket_acl
|
11
11
|
if @show.acl_enabled?
|
12
|
-
|
12
|
+
say "Bucket acl already has log delivery ACL"
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
@@ -17,12 +17,12 @@ class S3Secure::AccessLogs
|
|
17
17
|
bucket: @bucket,
|
18
18
|
access_control_policy: @show.access_control_policy_with_log_delivery_permissions,
|
19
19
|
)
|
20
|
-
|
20
|
+
say "Added to bucket acl that grants log delivery"
|
21
21
|
end
|
22
22
|
|
23
23
|
def enable_access_logging
|
24
24
|
if @show.logging_enabled?
|
25
|
-
|
25
|
+
say "Bucket access logging already enabled"
|
26
26
|
return
|
27
27
|
end
|
28
28
|
|
@@ -35,7 +35,7 @@ class S3Secure::AccessLogs
|
|
35
35
|
},
|
36
36
|
},
|
37
37
|
)
|
38
|
-
|
38
|
+
say "Enabled access logging on the source bucket #{@bucket} to be delivered to the target bucket #{@show.target_bucket}"
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/lib/s3_secure/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module S3Secure
|
2
2
|
class CLI < Command
|
3
|
-
class_option :
|
3
|
+
class_option :quiet, type: :boolean
|
4
4
|
class_option :noop, type: :boolean
|
5
5
|
|
6
6
|
desc "access_logs SUBCOMMAND", "access_logs subcommands"
|
@@ -23,7 +23,7 @@ module S3Secure
|
|
23
23
|
long_desc Help.text(:lifecycle)
|
24
24
|
subcommand "lifecycle", Lifecycle
|
25
25
|
|
26
|
-
desc "remediate_all", "Remediate all. For more fine-grain control use each of the commands directly."
|
26
|
+
desc "remediate_all BUCKET", "Remediate all. For more fine-grain control use each of the commands directly."
|
27
27
|
long_desc Help.text("remediate_all")
|
28
28
|
def remediate_all(bucket)
|
29
29
|
RemediateAll.new(options.merge(bucket: bucket)).run
|
data/lib/s3_secure/encryption.rb
CHANGED
@@ -5,9 +5,9 @@ class S3Secure::Encryption
|
|
5
5
|
|
6
6
|
if show.enabled?
|
7
7
|
s3.delete_bucket_encryption(bucket: @bucket) # returns resp = #<struct Aws::EmptyStructure>
|
8
|
-
|
8
|
+
say "Bucket #{@bucket} encryption has been removed"
|
9
9
|
else
|
10
|
-
|
10
|
+
say "Bucket #{@bucket} is not configured with encryption at the bucket level"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -5,8 +5,7 @@ class S3Secure::Encryption
|
|
5
5
|
|
6
6
|
if show.enabled?
|
7
7
|
# check rules to see if encryption is already set of some sort
|
8
|
-
|
9
|
-
puts show.rules.map(&:to_h)
|
8
|
+
say "Bucket #{@bucket} already has encryption rules:"
|
10
9
|
else
|
11
10
|
# Set encryption rules
|
12
11
|
# Ruby docs: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Client.html#put_bucket_encryption-instance_method
|
@@ -18,8 +17,7 @@ class S3Secure::Encryption
|
|
18
17
|
bucket: @bucket,
|
19
18
|
server_side_encryption_configuration: {
|
20
19
|
rules: [rule]})
|
21
|
-
|
22
|
-
pp rule
|
20
|
+
say "Encyption enabled on bucket #{@bucket} with rules:"
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -2,10 +2,10 @@ class S3Secure::Encryption
|
|
2
2
|
class Show < Base
|
3
3
|
def run
|
4
4
|
if rules
|
5
|
-
|
6
|
-
|
5
|
+
say "Bucket #{@bucket} is configured with these encryption rules:"
|
6
|
+
say rules.map(&:to_h)
|
7
7
|
else
|
8
|
-
|
8
|
+
say "Bucket #{@bucket} is not configured with encryption at the bucket level"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
data/lib/s3_secure/lifecycle.rb
CHANGED
@@ -9,7 +9,7 @@ class S3Secure::Lifecycle
|
|
9
9
|
builder = Builder.new(current_rules)
|
10
10
|
rules = builder.rules_with_addition(@options[:prefix])
|
11
11
|
if current_rules.size == rules.size
|
12
|
-
|
12
|
+
say "WARN: rule wasnt added because a #{RULE_ID} already exists".color(:yellow)
|
13
13
|
else
|
14
14
|
s3.put_bucket_lifecycle_configuration(
|
15
15
|
bucket: @bucket, # required
|
@@ -17,7 +17,7 @@ class S3Secure::Lifecycle
|
|
17
17
|
)
|
18
18
|
end
|
19
19
|
elsif show.any?
|
20
|
-
|
20
|
+
say "Bucket #{@bucket} is has a lifecycle policy already."
|
21
21
|
return
|
22
22
|
else
|
23
23
|
options = {
|
@@ -27,7 +27,7 @@ class S3Secure::Lifecycle
|
|
27
27
|
s3.put_bucket_lifecycle_configuration(options)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
say "Added lifecycle policy to bucket #{@bucket}"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -5,7 +5,7 @@ class S3Secure::Lifecycle
|
|
5
5
|
def run
|
6
6
|
show = Show.new(@options)
|
7
7
|
unless show.has?(RULE_ID)
|
8
|
-
|
8
|
+
say "Bucket #{@bucket} already does not have the #{RULE_ID} lifecycle rule."
|
9
9
|
return
|
10
10
|
end
|
11
11
|
|
@@ -22,7 +22,7 @@ class S3Secure::Lifecycle
|
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
say "Removed the #{RULE_ID} lifecycle rule on bucket #{@bucket}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -4,13 +4,13 @@ class S3Secure::Lifecycle
|
|
4
4
|
|
5
5
|
def run
|
6
6
|
if any?
|
7
|
-
|
7
|
+
say "This S3 bucket has lifecycle rules"
|
8
8
|
else
|
9
|
-
|
9
|
+
say "This S3 bucket does not have lifecycle rules"
|
10
10
|
end
|
11
11
|
|
12
12
|
if any?
|
13
|
-
|
13
|
+
say "Bucket lifecycle details: "
|
14
14
|
pp get_lifecycle(@bucket).to_h
|
15
15
|
end
|
16
16
|
end
|
data/lib/s3_secure/policy.rb
CHANGED
@@ -11,8 +11,8 @@ class S3Secure::Policy
|
|
11
11
|
bucket_policy = show.policy
|
12
12
|
document = Document.new(@bucket, bucket_policy)
|
13
13
|
if document.has?(@sid)
|
14
|
-
|
15
|
-
|
14
|
+
say "Bucket policy for #{@bucket} has ForceSSLOnlyAccess policy statement already:"
|
15
|
+
say bucket_policy
|
16
16
|
else
|
17
17
|
# Set encryption rules
|
18
18
|
# Ruby docs: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Client.html#put_bucket_policy-instance_method
|
@@ -25,8 +25,7 @@ class S3Secure::Policy
|
|
25
25
|
bucket: @bucket,
|
26
26
|
policy: policy_document,
|
27
27
|
)
|
28
|
-
|
29
|
-
puts policy_document
|
28
|
+
say "Add bucket policy to bucket #{@bucket}:"
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -2,11 +2,10 @@ class S3Secure::Policy
|
|
2
2
|
class Show < Base
|
3
3
|
def run
|
4
4
|
if policy
|
5
|
-
|
6
|
-
|
7
|
-
# puts policy.map(&:to_h)
|
5
|
+
say "Bucket #{@bucket} is configured with this policy:"
|
6
|
+
say policy
|
8
7
|
else
|
9
|
-
|
8
|
+
say "Bucket #{@bucket} is not configured bucket policy"
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
@@ -28,10 +28,10 @@ class S3Secure::Policy
|
|
28
28
|
s3.delete_bucket_policy(bucket: @bucket)
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
say "Remove bucket policy statement from bucket #{@bucket}:"
|
32
|
+
say policy_document if policy_document
|
33
33
|
else
|
34
|
-
|
34
|
+
say "Bucket policy for #{@bucket} does not have ForceSSLOnlyAccess policy statement. Nothing to be done."
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module S3Secure
|
2
2
|
class RemediateAll < AbstractBase
|
3
3
|
def run
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
o = @options.merge(bucket: @bucket)
|
5
|
+
Encryption::Enable.new(o).run
|
6
|
+
Policy::Enforce.new(o.merge(sid: "ForceSSLOnlyAccess")).run
|
7
|
+
Versioning::Enable.new(o).run
|
8
|
+
Lifecycle::Add.new(o).run
|
9
|
+
AccessLogs::Enable.new(o).run
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
data/lib/s3_secure/version.rb
CHANGED
data/lib/s3_secure/versioning.rb
CHANGED
@@ -10,9 +10,9 @@ class S3Secure::Versioning
|
|
10
10
|
status: "Suspended",
|
11
11
|
},
|
12
12
|
)
|
13
|
-
|
13
|
+
say "Versioning Suspended on bucket #{@bucket}"
|
14
14
|
else
|
15
|
-
|
15
|
+
say "Bucket #{@bucket} is already has versioning already Suspended or not Enabled."
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -3,7 +3,7 @@ class S3Secure::Versioning
|
|
3
3
|
def run
|
4
4
|
show = Show.new(@options)
|
5
5
|
if show.enabled?
|
6
|
-
|
6
|
+
say "Bucket #{@bucket} is has versioning already enabled."
|
7
7
|
else
|
8
8
|
s3.put_bucket_versioning(
|
9
9
|
bucket: @bucket,
|
@@ -12,7 +12,7 @@ class S3Secure::Versioning
|
|
12
12
|
status: "Enabled",
|
13
13
|
},
|
14
14
|
)
|
15
|
-
|
15
|
+
say "Versioning enabled on bucket #{@bucket}"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -2,13 +2,13 @@ class S3Secure::Versioning
|
|
2
2
|
class Show < Base
|
3
3
|
def run
|
4
4
|
if enabled?
|
5
|
-
|
5
|
+
say "This S3 bucket has versioning enabled"
|
6
6
|
else
|
7
|
-
|
7
|
+
say "This S3 bucket does not have versioning enabled"
|
8
8
|
end
|
9
9
|
details = get_versioning(@bucket).to_h
|
10
10
|
unless details.empty?
|
11
|
-
|
11
|
+
say "Bucket versioning details: "
|
12
12
|
pp details
|
13
13
|
end
|
14
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3-secure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -267,6 +267,7 @@ files:
|
|
267
267
|
- lib/s3_secure/policy/show.rb
|
268
268
|
- lib/s3_secure/policy/unforce.rb
|
269
269
|
- lib/s3_secure/remediate_all.rb
|
270
|
+
- lib/s3_secure/say.rb
|
270
271
|
- lib/s3_secure/summary.rb
|
271
272
|
- lib/s3_secure/summary/item.rb
|
272
273
|
- lib/s3_secure/summary/items.rb
|