Created
July 15, 2020 09:41
-
-
Save thomsh/4f33a90bacb155fbba78d1be8b0d954c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/chef-workstation/embedded/bin/ruby | |
require "chef/encrypted_data_bag_item" | |
require "json" | |
if ARGV.length != 2 | |
puts "usage: decrypt_databag.rb /path/to/cipher_json_data_bag KEY" | |
abort | |
end | |
cipherdata_path = ARGV[0] | |
secret = ARGV[1] | |
#secret = Chef::EncryptedDataBagItem.load_secret(ARGV[1]) | |
encrypted_data = JSON.parse(File.read(cipherdata_path)) | |
plain_data = Chef::EncryptedDataBagItem.new(encrypted_data, secret).to_hash | |
puts JSON.pretty_generate(plain_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment