bulwark 0.0.1
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 +7 -0
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/bin/bulwark +4 -0
- data/bulwark.gemspec +27 -0
- data/lib/bulwark/s3_file_permittor.rb +55 -0
- data/lib/bulwark/version.rb +3 -0
- data/lib/bulwark.rb +10 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16b2ac9dda99f1f9cf917812c9359f477f464cce
|
4
|
+
data.tar.gz: 08f84a5ee1a381c5f76b1bf9944ed4974985e8e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a432fcc98b5b425ae1fd97768320df67faa0063aacbc81d77e33e52d2781d092b5068362985250b244cccb232945f19cbb5c0600486a4b9850cd3b5e276dfc3
|
7
|
+
data.tar.gz: d8f69128861702919347d2a3499f181a24ba70f0391523664062c216c05febc9c1c45c47c0fd9f30c6a44afb74b08215054277d9bb6c16e11bc6972cce50e013
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Joshua Plicque
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Bulwark [](https://codeclimate.com/repos/571a2d7e5bd56f13060002a9/feed) [ ](https://codeship.com/projects/148019)
|
2
|
+
|
3
|
+
Mass update your S3 file permissions.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
* Ruby 2.0 or greater
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
Install from Rubygems:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem install bulwark
|
13
|
+
```
|
14
|
+
|
15
|
+
Or add it to your Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'bulwark'
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
Create a `.env` file. Populate it with your S3 Bucket credentials:
|
23
|
+
```ruby
|
24
|
+
S3_ACCESS_KEY_ID=foobar
|
25
|
+
S3_BUCKET=foobar
|
26
|
+
S3_REGION=foobar
|
27
|
+
S3_SECRET_ACCESS_KEY=foobar
|
28
|
+
```
|
29
|
+
***If your S3 region is US Standard, set S3_REGION=us-east-1***
|
30
|
+
|
31
|
+
|
32
|
+
Make all your S3 files private:
|
33
|
+
```sh
|
34
|
+
$ bulwark privatize_files
|
35
|
+
```
|
36
|
+
|
37
|
+
Or make all your S3 files public-read:
|
38
|
+
```sh
|
39
|
+
$ bulwark publicize_files
|
40
|
+
```
|
41
|
+
|
42
|
+
## License
|
43
|
+
Bulwark is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/bulwark
ADDED
data/bulwark.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'bulwark/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'bulwark'
|
7
|
+
gem.version = Bulwark::VERSION
|
8
|
+
gem.authors = ['Joshua Plicque']
|
9
|
+
gem.summary = 'Mass update your S3 file permissions.'
|
10
|
+
gem.email = 'plicjo@gmail.com'
|
11
|
+
gem.homepage = 'https://github.com/plicjo/bulwark'
|
12
|
+
gem.license = 'MIT'
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.required_ruby_version = '>= 2.0.0'
|
17
|
+
gem.bindir = 'bin'
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(spec)/}) { |f| File.basename(f) }
|
20
|
+
|
21
|
+
gem.add_development_dependency 'bundler', '~> 1.10'
|
22
|
+
gem.add_development_dependency 'rake' , '~> 10.0'
|
23
|
+
gem.add_development_dependency 'rspec' , '~> 3.4'
|
24
|
+
gem.add_development_dependency 'pry' , '~> 0.10.3'
|
25
|
+
gem.add_dependency 'dotenv' , '~> 2.1' , '>= 2.1.1'
|
26
|
+
gem.add_dependency 'aws-sdk', '~> 2'
|
27
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Bulwark
|
2
|
+
class S3FilePermittor
|
3
|
+
attr_reader :client, :permission
|
4
|
+
|
5
|
+
def initialize(command)
|
6
|
+
@permission = set_permission(command.first)
|
7
|
+
end
|
8
|
+
|
9
|
+
def set_permission(command)
|
10
|
+
command_to_permission(command)
|
11
|
+
rescue KeyError => e
|
12
|
+
puts "#{e} is not a valid Bulwark command. Try these:\n\nbulwark publicize_files\nbulwark privatize_file\n\n"
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def files
|
17
|
+
client.list_objects(bucket: bucket).contents
|
18
|
+
end
|
19
|
+
|
20
|
+
def file_keys
|
21
|
+
files.map { |file| file.key }
|
22
|
+
end
|
23
|
+
|
24
|
+
def change_permissions
|
25
|
+
file_keys.each do |key|
|
26
|
+
Aws::S3::ObjectAcl.new(bucket, key, client: client).put({ acl: permission })
|
27
|
+
puts "#{key} is now #{permission}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def bucket
|
32
|
+
ENV['S3_BUCKET']
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def command_to_permission(command)
|
38
|
+
{ 'privatize' => 'private',
|
39
|
+
'privatize_files' => 'private',
|
40
|
+
'publicize' => 'public-read',
|
41
|
+
'publicize_files' => 'public-read'
|
42
|
+
}.fetch(command)
|
43
|
+
end
|
44
|
+
|
45
|
+
def client
|
46
|
+
@client ||= begin
|
47
|
+
Aws::S3::Client.new(
|
48
|
+
access_key_id: ENV['S3_ACCESS_KEY_ID'],
|
49
|
+
secret_access_key: ENV['S3_SECRET_ACCESS_KEY'],
|
50
|
+
region: ENV['S3_REGION']
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/bulwark.rb
ADDED
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bulwark
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joshua Plicque
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dotenv
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.1'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.1.1
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.1'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.1.1
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: aws-sdk
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2'
|
103
|
+
description:
|
104
|
+
email: plicjo@gmail.com
|
105
|
+
executables:
|
106
|
+
- bulwark
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- Gemfile
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- bin/bulwark
|
116
|
+
- bulwark.gemspec
|
117
|
+
- lib/bulwark.rb
|
118
|
+
- lib/bulwark/s3_file_permittor.rb
|
119
|
+
- lib/bulwark/version.rb
|
120
|
+
homepage: https://github.com/plicjo/bulwark
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 2.0.0
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.5.1
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Mass update your S3 file permissions.
|
144
|
+
test_files: []
|
145
|
+
has_rdoc:
|