mirror of
https://github.com/inspec/inspec
synced 2024-11-22 12:43:07 +00:00
CFINSPEC-340 Adds usage header line in the signed profile
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
parent
078d1ce898
commit
04d93db068
2 changed files with 6 additions and 4 deletions
|
@ -90,6 +90,7 @@ module Inspec
|
||||||
f.close
|
f.close
|
||||||
elsif version == INSPEC_PROFILE_VERSION_2
|
elsif version == INSPEC_PROFILE_VERSION_2
|
||||||
header << version
|
header << version
|
||||||
|
header << f.readline.strip!
|
||||||
content = f.read
|
content = f.read
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
|
@ -102,15 +103,15 @@ module Inspec
|
||||||
valid = false
|
valid = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@key_name = header[1]
|
@key_name = header[2]
|
||||||
validation_key_path = Inspec::IafFile.find_validation_key(header[1])
|
validation_key_path = Inspec::IafFile.find_validation_key(@key_name)
|
||||||
|
|
||||||
unless valid_header?(header)
|
unless valid_header?(header)
|
||||||
valid = false
|
valid = false
|
||||||
end
|
end
|
||||||
|
|
||||||
verification_key = KEY_ALG.new File.read validation_key_path
|
verification_key = KEY_ALG.new File.read validation_key_path
|
||||||
signature = Base64.decode64(header[3])
|
signature = Base64.decode64(header[4])
|
||||||
digest = ARTIFACT_DIGEST.new
|
digest = ARTIFACT_DIGEST.new
|
||||||
unless verification_key.verify digest, signature, content
|
unless verification_key.verify digest, signature, content
|
||||||
valid = false
|
valid = false
|
||||||
|
@ -120,7 +121,7 @@ module Inspec
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_header?(header)
|
def valid_header?(header)
|
||||||
VALID_PROFILE_VERSIONS.member?(header[0]) && VALID_PROFILE_DIGESTS.member?(header[2])
|
VALID_PROFILE_VERSIONS.member?(header[0]) && VALID_PROFILE_DIGESTS.member?(header[3])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -80,6 +80,7 @@ module InspecPlugins
|
||||||
|
|
||||||
File.open(artifact_filename, "wb") do |f|
|
File.open(artifact_filename, "wb") do |f|
|
||||||
f.puts INSPEC_PROFILE_VERSION_2
|
f.puts INSPEC_PROFILE_VERSION_2
|
||||||
|
f.puts "Use \"inspec export\" to view this file"
|
||||||
f.write(content)
|
f.write(content)
|
||||||
end
|
end
|
||||||
puts "Successfully generated #{artifact_filename}"
|
puts "Successfully generated #{artifact_filename}"
|
||||||
|
|
Loading…
Reference in a new issue