From cce38ba6f303191b1b1820134dff9d3b20c62383 Mon Sep 17 00:00:00 2001 From: Matt Schuchard Date: Thu, 7 Dec 2023 16:33:28 -0500 Subject: [PATCH] iterate on eyaml validation functionality --- lib/puppet-check/data_parser.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/puppet-check/data_parser.rb b/lib/puppet-check/data_parser.rb index 1f5e428..79d529a 100644 --- a/lib/puppet-check/data_parser.rb +++ b/lib/puppet-check/data_parser.rb @@ -39,20 +39,24 @@ def self.eyaml(files, public, private) end # setup decryption - # rsa = OpenSSL::PKey::RSA.new(File.read(private)) - # x509 = OpenSSL::X509::Certificate.new(File.read(public)) + rsa = OpenSSL::PKey::RSA.new(File.read(private)) + x509 = OpenSSL::X509::Certificate.new(File.read(public)) files.each do |file| - # grab all encoded portions of the eyaml + # check encoded yaml syntax + parsed = YAML.load_file(file) + + # extract encoded values + # ENC[PKCS7] - # decrypt the encoded portions + # decrypt the encoded yaml # decrypted = OpenSSL::PKCS7.new(File.read(file)).decrypt(rsa, x509) - # insert decrypted portions back into eyaml (pass into loader below) + # check decoded eyaml syntax + # decoded = YAML.safe_load(decrypted) - # check yaml syntax - # parsed = YAML.load_file(decrypted) - parsed = YAML.load_file(file) + # merge data hashes + # parsed = merge(parsed, decoded) rescue StandardError => err PuppetCheck.files[:errors][file] = err.to_s.gsub("(#{file}): ", '').split("\n") else