14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/hiera/backend/eyaml/actions/decrypt_action.rb', line 14
def self.execute
output_data = case Eyaml::Options[:source]
when :eyaml
encryptions = []
output = Eyaml::Options[:input_data].gsub( REGEX_ENCRYPTED_BLOCK ) { |match|
indentation = $1
encryption_scheme = parse_encryption_scheme( $2 )
decryptor = Encryptor.find encryption_scheme
ciphertext = $3.gsub(/[ \n]/, '')
plaintext = decryptor.decrypt( decryptor.decode ciphertext )
">\n" + indentation + "DEC::#{decryptor.tag}[" + plaintext + "]!"
}
output.gsub!( REGEX_ENCRYPTED_STRING ) { |match|
encryption_scheme = parse_encryption_scheme( $1 )
decryptor = Encryptor.find encryption_scheme
plaintext = decryptor.decrypt( decryptor.decode $2 )
"DEC::#{decryptor.tag}[" + plaintext + "]!"
}
output
else
output = Eyaml::Options[:input_data].gsub( REGEX_ENCRYPTED_STRING ) { |match|
encryption_scheme = parse_encryption_scheme( $1 )
decryptor = Encryptor.find encryption_scheme
decryptor.decrypt( decryptor.decode $2 )
}
output
end
output_data
end
|