s3-secure 0.3.0 → 0.4.0
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/cli.rb +8 -0
- data/lib/s3_secure/help/summary.md +22 -0
- data/lib/s3_secure/summary.rb +13 -0
- data/lib/s3_secure/summary/item.rb +16 -0
- data/lib/s3_secure/summary/items.rb +67 -0
- data/lib/s3_secure/table.rb +18 -0
- data/lib/s3_secure/version.rb +1 -1
- data/s3-secure.gemspec +1 -0
- metadata +21 -3
- data/lib/s3_secure/help/hello.md +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 458984b9117afa2925e7b2f6d662d1d7d85f1db797443a8addde3e59162794d4
|
4
|
+
data.tar.gz: 9127363474746342e5af37bfd32a68e5fce29f6738902026fa00141720989f26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a318aa5bbf6d9a960d65e2f32a6ea18053b07532c6a19e8ce4c36d3e92252e6383344238ec372e98d0c8da970a3af6015af67b169f244af81b80b431ca518450
|
7
|
+
data.tar.gz: e098eea71ed734a3ad6664d293d476fcddad5a4c285542bf1dc634ef9833773c99b0a77637f5bcb9242e3e3d3ee9b3256b904c635e96c2806de936b230eba258
|
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.4.0]
|
7
|
+
- #1 summary command
|
8
|
+
|
6
9
|
## [0.3.0]
|
7
10
|
- clean up policy_document method interface
|
8
11
|
|
data/lib/s3_secure/cli.rb
CHANGED
@@ -11,6 +11,14 @@ module S3Secure
|
|
11
11
|
long_desc Help.text(:policy)
|
12
12
|
subcommand "policy", Policy
|
13
13
|
|
14
|
+
desc "summary", "Summarize buckets"
|
15
|
+
long_desc Help.text("summary")
|
16
|
+
option :ssl, default: "any", desc: "filter for ssl enforcement. Examples: any, yes, no"
|
17
|
+
option :encrypted, default: "any", desc: "filter for encryption enabled. Examples: any, yes, no"
|
18
|
+
def summary
|
19
|
+
Summary.new(options).run
|
20
|
+
end
|
21
|
+
|
14
22
|
desc "batch *PARAMS", "Batch wrapper method"
|
15
23
|
long_desc Help.text(:batch)
|
16
24
|
def batch(*params)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
## Examples
|
2
|
+
|
3
|
+
$ s3-secure summary
|
4
|
+
Determining bucket security-related settings...
|
5
|
+
+----------------------------+------+------------+
|
6
|
+
| Bucket | SSL? | Encrypted? |
|
7
|
+
+----------------------------+------+------------+
|
8
|
+
| a-test-bucket-in-us-east-1 | yes | no |
|
9
|
+
| a-test-bucket-in-us-west-1 | no | no |
|
10
|
+
+----------------------------+------+------------+
|
11
|
+
$
|
12
|
+
|
13
|
+
There are `--ssl no` and `--encrypted no` filtering options:
|
14
|
+
|
15
|
+
$ s3-secure summary --ssl no --encrypted no
|
16
|
+
Determining bucket security-related settings...
|
17
|
+
+----------------------------+------+------------+
|
18
|
+
| Bucket | SSL? | Encrypted? |
|
19
|
+
+----------------------------+------+------------+
|
20
|
+
| a-test-bucket-in-us-west-1 | no | no |
|
21
|
+
+----------------------------+------+------------+
|
22
|
+
$
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module S3Secure
|
2
|
+
class Summary < AbstractBase
|
3
|
+
def run
|
4
|
+
$stderr.puts("Determining bucket security-related settings...")
|
5
|
+
data = [%w[Bucket SSL? Encrypted?]]
|
6
|
+
items = Items.new(@options, buckets)
|
7
|
+
items.filtered_items.each do |i|
|
8
|
+
data << [i.bucket, i.ssl, i.encrypted]
|
9
|
+
end
|
10
|
+
S3Secure::Table.new(@options, data).display
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class S3Secure::Summary
|
2
|
+
class Item
|
3
|
+
attr_reader :bucket
|
4
|
+
def initialize(bucket, properties={})
|
5
|
+
@bucket, @properties = bucket, properties
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(name, *args, &block)
|
9
|
+
if @properties.key?(name)
|
10
|
+
@properties[name]
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class S3Secure::Summary
|
2
|
+
class Items < S3Secure::AbstractBase
|
3
|
+
extend Memoist
|
4
|
+
|
5
|
+
# override initialize
|
6
|
+
def initialize(options, buckets)
|
7
|
+
@options, @buckets = options, buckets
|
8
|
+
@ssl, @encrypted = @options[:ssl], @options[:encrypted]
|
9
|
+
end
|
10
|
+
|
11
|
+
def filtered_items
|
12
|
+
items = all_items.select do |item|
|
13
|
+
case @ssl
|
14
|
+
when "yes", "no"
|
15
|
+
@ssl == item.ssl
|
16
|
+
else # any or fallback
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
items.select do |item|
|
22
|
+
case @encrypted
|
23
|
+
when "yes", "no"
|
24
|
+
@encrypted == item.encrypted
|
25
|
+
else # any or fallback
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Triggers loading of items
|
32
|
+
def all_items
|
33
|
+
load_items!
|
34
|
+
end
|
35
|
+
|
36
|
+
def load_items!
|
37
|
+
@buckets.map do |bucket|
|
38
|
+
Item.new(bucket,
|
39
|
+
ssl: ssl?(bucket) ? "yes" : "no",
|
40
|
+
encrypted: encrypted?(bucket) ? "yes" : "no")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
memoize :load_items!
|
44
|
+
|
45
|
+
private
|
46
|
+
def ssl?(bucket)
|
47
|
+
s3 = s3_regional_client(bucket)
|
48
|
+
list = S3Secure::Policy::List.new(@options)
|
49
|
+
list.set_s3(s3)
|
50
|
+
|
51
|
+
bucket_policy = list.get_policy(bucket)
|
52
|
+
document = S3Secure::Policy::Document.new(bucket, bucket_policy)
|
53
|
+
document.has?("ForceSSLOnlyAccess")
|
54
|
+
end
|
55
|
+
memoize :ssl?
|
56
|
+
|
57
|
+
def encrypted?(bucket)
|
58
|
+
s3 = s3_regional_client(bucket)
|
59
|
+
list = S3Secure::Encryption::List.new(@options)
|
60
|
+
list.set_s3(s3)
|
61
|
+
|
62
|
+
rules = list.get_encryption_rules(bucket)
|
63
|
+
!!rules
|
64
|
+
end
|
65
|
+
memoize :encrypted?
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "text-table"
|
2
|
+
|
3
|
+
module S3Secure
|
4
|
+
class Table
|
5
|
+
attr_reader :data
|
6
|
+
def initialize(options, data)
|
7
|
+
@options = options
|
8
|
+
@data = data
|
9
|
+
end
|
10
|
+
|
11
|
+
def display
|
12
|
+
table = Text::Table.new
|
13
|
+
table.head = data.shift
|
14
|
+
table.rows = data
|
15
|
+
puts table
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/s3_secure/version.rb
CHANGED
data/s3-secure.gemspec
CHANGED
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: text-table
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: thor
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,7 +215,7 @@ files:
|
|
201
215
|
- lib/s3_secure/help.rb
|
202
216
|
- lib/s3_secure/help/completion.md
|
203
217
|
- lib/s3_secure/help/completion_script.md
|
204
|
-
- lib/s3_secure/help/
|
218
|
+
- lib/s3_secure/help/summary.md
|
205
219
|
- lib/s3_secure/policy.rb
|
206
220
|
- lib/s3_secure/policy/base.rb
|
207
221
|
- lib/s3_secure/policy/checker.rb
|
@@ -213,6 +227,10 @@ files:
|
|
213
227
|
- lib/s3_secure/policy/list.rb
|
214
228
|
- lib/s3_secure/policy/show.rb
|
215
229
|
- lib/s3_secure/policy/unforce.rb
|
230
|
+
- lib/s3_secure/summary.rb
|
231
|
+
- lib/s3_secure/summary/item.rb
|
232
|
+
- lib/s3_secure/summary/items.rb
|
233
|
+
- lib/s3_secure/table.rb
|
216
234
|
- lib/s3_secure/version.rb
|
217
235
|
- s3-secure.gemspec
|
218
236
|
- spec/lib/cli_spec.rb
|