Created
July 15, 2020 09:41
-
-
Save thomsh/4f33a90bacb155fbba78d1be8b0d954c to your computer and use it in GitHub Desktop.
Revisions
-
thomsh created this gist
Jul 15, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ #!/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)