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 +4 -4
- data/lib/super_top_secret/Injector.rb +27 -0
- data/lib/super_top_secret/version.rb +1 -1
- data/lib/super_top_secret.rb +2 -1
- data/lib/tasks/super_top_secret_tasks.rake +18 -10
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02c43bd4c3d8138ac3924000e9f4f9cf8a3d24c9
|
4
|
+
data.tar.gz: b561a558a03f7497cb9ce751fe6770a93562cf50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/super_top_secret.rb
CHANGED
@@ -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
|
5
|
-
|
6
|
-
|
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
|
15
|
-
|
16
|
-
|
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.
|
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
|