heroku_vault 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/bin/heroku_vault +5 -0
- data/heroku_vault.gemspec +31 -0
- data/lib/heroku_vault/cli.rb +102 -0
- data/lib/heroku_vault/encrypter_factory.rb +10 -0
- data/lib/heroku_vault/heroku_commander.rb +17 -0
- data/lib/heroku_vault/main.rb +4 -0
- data/lib/heroku_vault/version.rb +3 -0
- data/lib/heroku_vault.rb +9 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eeb7502a3a104ec19ec437b24d391a9e815596e6c8062d404ce5c58127736cbf
|
4
|
+
data.tar.gz: cd7f7005110777289bc35e3204501aae21ed251c210b7b10e50e79dcb8130f97
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b814c1745c5469bc0b17f934d6294b15cf4cfb28d9bdf009f13ecbc9e2e6eccf56bd41961554edf0a302c88dcaa342afec53253a83f378aded787aed4ac4cdf
|
7
|
+
data.tar.gz: 0d9e1c370ff54a6de0b6a6e0e3d56bf6256c41b787949944275c520308f04586e8019fdb10630e4c83b4df4037133675fba4d1037958b781bbe7809e152ae981
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at tomato.wonder.life@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 nasum
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# HerokuVault
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/heroku_vault`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'heroku_vault'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install heroku_vault
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```bash
|
26
|
+
$ export HEROKU_TOKEN=hogehogehoge # export heroku token
|
27
|
+
$ heroku_vault fetch heroku_app_name -o law.json # fetch heroku_app config value to json
|
28
|
+
$ emacs law.json # edit config
|
29
|
+
$ heroku_vault enrypt law.json -o encrypted.json # config value encrypted
|
30
|
+
$ git push origin HEAD # push private ripository
|
31
|
+
$ heroku_valut apply heroku_app_name -f encrypted.json # apply config
|
32
|
+
```
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
37
|
+
|
38
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/heroku_vault. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
47
|
+
|
48
|
+
## Code of Conduct
|
49
|
+
|
50
|
+
Everyone interacting in the HerokuVault project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/heroku_vault/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/heroku_vault
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "heroku_vault/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "heroku_vault"
|
8
|
+
spec.version = HerokuVault::VERSION
|
9
|
+
spec.authors = ["nasum"]
|
10
|
+
spec.email = ["tomato.wonder.life@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{heroku config encrypt}
|
13
|
+
spec.description = %q{heroku config encrypt}
|
14
|
+
spec.homepage = "https://github.com/nasum/heroku_vault"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "bin"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "activesupport", "~> 5.2.0"
|
25
|
+
spec.add_runtime_dependency "platform-api", "~> 2.1.0"
|
26
|
+
spec.add_runtime_dependency "thor", "~> 0.20.0"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
29
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.7"
|
31
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module HerokuVault
|
5
|
+
class Cli < Thor
|
6
|
+
desc "encrypt config_file", "encrypt usage"
|
7
|
+
method_option :output, aliases: :o, required: true
|
8
|
+
def encrypt(file_name)
|
9
|
+
password = enter_password
|
10
|
+
encryptor = HerokuVault::EncrypterFactory.create(password)
|
11
|
+
|
12
|
+
config_data = open(file_name) do |io|
|
13
|
+
JSON.load(io)
|
14
|
+
end
|
15
|
+
|
16
|
+
encrypted = config_data.map do |key, val|
|
17
|
+
[key, encryptor.encrypt_and_sign(val)]
|
18
|
+
end
|
19
|
+
|
20
|
+
output_file(options[:output], JSON.parse(encrypted.to_h.to_json))
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "decrypt config_file", "decrypt usage"
|
24
|
+
def decrypt(file_name)
|
25
|
+
config_data = open(file_name) do |io|
|
26
|
+
JSON.load(io)
|
27
|
+
end
|
28
|
+
|
29
|
+
password = enter_password
|
30
|
+
encryptor = HerokuVault::EncrypterFactory.create(password)
|
31
|
+
|
32
|
+
decrypted = config_data.map do |key, val|
|
33
|
+
[key, encryptor.decrypt_and_verify(val)]
|
34
|
+
end
|
35
|
+
|
36
|
+
puts decrypted.to_h.to_json
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "fetch heroku_app_name", "fetch usage"
|
40
|
+
method_option :output, aliases: :o, required: true
|
41
|
+
def fetch(app_name)
|
42
|
+
heroku = HerokuVault::HerokuCommander.new
|
43
|
+
config_data = heroku.config_all(app_name)
|
44
|
+
file_name = options[:output]
|
45
|
+
output_file(file_name, JSON.parse(config_data))
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "create_encrypted_config heroku_app_name", "create encrypted heroku config"
|
49
|
+
method_option :output, aliases: :o, required: true
|
50
|
+
def create_encrypted_config(app_name)
|
51
|
+
password = enter_password
|
52
|
+
heroku = HerokuVault::HerokuCommander.new
|
53
|
+
config_data = heroku.config_all(app_name)
|
54
|
+
encryptor = HerokuVault::EncrypterFactory.create(password)
|
55
|
+
|
56
|
+
encrypted = JSON.parse(config_data).map do |key, val|
|
57
|
+
[key, encryptor.encrypt_and_sign(val)]
|
58
|
+
end
|
59
|
+
|
60
|
+
file_name = options[:output]
|
61
|
+
output_file(file_name, JSON.parse(encrypted.to_h.to_json))
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "apply heroku_app_name", "apply config"
|
65
|
+
method_option :file, aliases: :f, required: true
|
66
|
+
def apply(app_name)
|
67
|
+
password = enter_password
|
68
|
+
encryptor = HerokuVault::EncrypterFactory.create(password)
|
69
|
+
heroku = HerokuVault::HerokuCommander.new
|
70
|
+
|
71
|
+
File.open(options[:file]) do |file|
|
72
|
+
config_data = file.read
|
73
|
+
decrypted_config = JSON.parse(config_data).map do |key, val|
|
74
|
+
[key, encryptor.decrypt_and_verify(val)]
|
75
|
+
end
|
76
|
+
|
77
|
+
decrypted_config.each do |key, val|
|
78
|
+
obj = {}
|
79
|
+
obj[key] = val
|
80
|
+
heroku.apply_config(app_name, obj)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def enter_password
|
88
|
+
print 'enter paswword: '
|
89
|
+
password = STDIN.noecho(&:gets)
|
90
|
+
puts
|
91
|
+
return password
|
92
|
+
end
|
93
|
+
|
94
|
+
def output_file(file_name, json_hash)
|
95
|
+
File.open(file_name, 'w') do |file|
|
96
|
+
JSON.pretty_generate(json_hash).each_line do |line|
|
97
|
+
file.puts line
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
module HerokuVault
|
4
|
+
module EncrypterFactory
|
5
|
+
def self.create(password)
|
6
|
+
key = ActiveSupport::KeyGenerator.new(password).generate_key('salt', 32)
|
7
|
+
return ActiveSupport::MessageEncryptor.new(key, cipher: "aes-256-cbc")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'platform-api'
|
2
|
+
|
3
|
+
module HerokuVault
|
4
|
+
class HerokuCommander
|
5
|
+
def initialize
|
6
|
+
@heroku = PlatformAPI.connect_oauth(ENV['HEROKU_TOKEN'])
|
7
|
+
end
|
8
|
+
|
9
|
+
def config_all(app_name)
|
10
|
+
@heroku.config_var.info_for_app(app_name).to_json
|
11
|
+
end
|
12
|
+
|
13
|
+
def apply_config(app_name, body)
|
14
|
+
@heroku.config_var.update(app_name, body)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/heroku_vault.rb
ADDED
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku_vault
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nasum
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: platform-api
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.20.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.20.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.7'
|
97
|
+
description: heroku config encrypt
|
98
|
+
email:
|
99
|
+
- tomato.wonder.life@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- CODE_OF_CONDUCT.md
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/heroku_vault
|
112
|
+
- heroku_vault.gemspec
|
113
|
+
- lib/heroku_vault.rb
|
114
|
+
- lib/heroku_vault/cli.rb
|
115
|
+
- lib/heroku_vault/encrypter_factory.rb
|
116
|
+
- lib/heroku_vault/heroku_commander.rb
|
117
|
+
- lib/heroku_vault/main.rb
|
118
|
+
- lib/heroku_vault/version.rb
|
119
|
+
homepage: https://github.com/nasum/heroku_vault
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.7.6
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: heroku config encrypt
|
143
|
+
test_files: []
|