super_top_secret 0.1.6 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9ed2b2e800813e1439cd9fc93f5aa50177b2474
4
- data.tar.gz: 24e39b751fde5488fa2bb9f3acbb66fded3199b4
3
+ metadata.gz: 02c43bd4c3d8138ac3924000e9f4f9cf8a3d24c9
4
+ data.tar.gz: b561a558a03f7497cb9ce751fe6770a93562cf50
5
5
  SHA512:
6
- metadata.gz: 4caf194d1d6bbd502044864580d59662ceb386e4b0bfa763665f9984648ec0fc2ab3a0a0c85d01b27ca6af3916aa4edfee508e5b5ccc5d213ba18f69e4897359
7
- data.tar.gz: e6d63a7a5b94a96e924820ef949777730a7afc29c36c88a7d8c399b6eea2df48ab257ce5530c56003296d97e909dc4ac55ab63b8993914393a9f7f9ab76b1773
6
+ metadata.gz: 62b15cb51a0c53981c7bd47fde9cd15b1ef5a9b285c392285f6fb315715cefb656e0b2fb316d24d9bcb35212a3655ab07322e40de27b2edede2de6b335c3baa6
7
+ data.tar.gz: 7b180f316f722c08e86e835bf9900d82a7c03891062014c6d140119264fb5c9e0a93e44225296f0c6ea228c6ea9b7ce468c0a95cd68f4487b53b64d20c457b2f
@@ -0,0 +1,27 @@
1
+ module SuperTopSecret
2
+
3
+ class Injector
4
+ def self.generate_config(app_file, secret_file)
5
+ app_hash = YAML.load(File.read(app_file))
6
+ secret_hash = YAML.load(File.read(secret_file))
7
+
8
+ injected_hash = {}
9
+
10
+ app_hash.each do |key, val|
11
+ if val.class == Hash # inside inner hash
12
+ val.each do |nested_key, nested_val|
13
+ nested_val = secret_hash[key][nested_val] if nested_val.include?("53CR3T_")
14
+ injected_hash[key] = val
15
+ injected_hash[key][nested_key] = nested_val
16
+ end
17
+ else # top level hash
18
+ val = secret_hash[val] if val.include?("53CR3T_")
19
+ injected_hash[key] = val
20
+ end
21
+ end
22
+
23
+ File.open("config/application.yml", "w+"){|f| f.write(injected_hash.to_yaml)}
24
+ end
25
+ end
26
+
27
+ end
@@ -1,3 +1,3 @@
1
1
  module SuperTopSecret
2
- VERSION = '0.1.6'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,3 +1,4 @@
1
1
  module SuperTopSecret
2
- require 'super_top_secret/railtie' if defined?(Rails)
2
+ require 'super_top_secret/railtie'
3
+ require 'super_top_secret/injector'
3
4
  end
@@ -1,21 +1,29 @@
1
1
  namespace :secrets do
2
2
  desc "Decrypt your secrets rake secrets:decrypt"
3
3
  task :decrypt do
4
- puts "Decrypting your files, sir and/or madam. Whatever you are, your files are being worked on."
5
- %w(config/application.yml config/database.yml).each do |p|
6
- if File.file?("#{p}.enc")
7
- sh("aws kms decrypt --ciphertext-blob fileb://#{p}.enc --output text --query Plaintext | base64 --decode > #{p}")
8
- end
4
+ puts "Decrypting your file, sir and/or madam. Whatever you are, your file is being worked on."
5
+ if File.file?("config/application_secrets.yml.enc")
6
+ sh("aws kms decrypt --ciphertext-blob fileb://config/application_secrets.yml.enc --output text --query Plaintext | base64 --decode > config/application_secrets.yml")
9
7
  end
10
8
  end
11
9
 
12
10
  desc "Encrypt your secrets rake secrets:encrypt"
13
11
  task :encrypt do
14
- puts "Encrypting your files, sir and/or madam. Whatever you are, your files are being worked on."
15
- %w(config/application.yml config/database.yml).each do |p|
16
- if File.file?(p)
17
- sh("aws kms encrypt --key-id arn:aws:kms:us-west-2:155751353262:alias/properties --plaintext fileb://#{p} --output text --query CiphertextBlob | base64 --decode > #{p}.enc")
18
- end
12
+ puts "Encrypting your file, sir and/or madam. Whatever you are, your file is being worked on."
13
+ if File.file?("config/application_secrets.yml")
14
+ sh("aws kms encrypt --key-id arn:aws:kms:us-west-2:155751353262:alias/properties --plaintext fileb://config/application_secrets.yml --output text --query CiphertextBlob | base64 --decode > config/application_secrets.yml.enc")
19
15
  end
20
16
  end
17
+
18
+ desc "Inject your secrets into your application.yml"
19
+ task :inject do
20
+ if File.file?("config/application_keys.yml") && File.file?("config/application_secrets.yml")
21
+ puts "Injecting your files, sir and/or madam. Whatever you are, your files are being worked on."
22
+ SuperTopSecret::Injector.generate_config("config/application_keys.yml", "config/application_secrets.yml")
23
+ else
24
+ puts "File(s) missing. config/application_keys.yml && config/application_secrets.yml are both required."
25
+ return
26
+ end
27
+
28
+ end
21
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_top_secret
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Stringham
@@ -49,6 +49,7 @@ files:
49
49
  - README.md
50
50
  - Rakefile
51
51
  - lib/super_top_secret.rb
52
+ - lib/super_top_secret/Injector.rb
52
53
  - lib/super_top_secret/railtie.rb
53
54
  - lib/super_top_secret/version.rb
54
55
  - lib/tasks/super_top_secret_tasks.rake