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
|
||||
elsif version == INSPEC_PROFILE_VERSION_2
|
||||
header << version
|
||||
header << f.readline.strip!
|
||||
content = f.read
|
||||
f.close
|
||||
|
||||
|
@ -102,15 +103,15 @@ module Inspec
|
|||
valid = false
|
||||
end
|
||||
|
||||
@key_name = header[1]
|
||||
validation_key_path = Inspec::IafFile.find_validation_key(header[1])
|
||||
@key_name = header[2]
|
||||
validation_key_path = Inspec::IafFile.find_validation_key(@key_name)
|
||||
|
||||
unless valid_header?(header)
|
||||
valid = false
|
||||
end
|
||||
|
||||
verification_key = KEY_ALG.new File.read validation_key_path
|
||||
signature = Base64.decode64(header[3])
|
||||
signature = Base64.decode64(header[4])
|
||||
digest = ARTIFACT_DIGEST.new
|
||||
unless verification_key.verify digest, signature, content
|
||||
valid = false
|
||||
|
@ -120,7 +121,7 @@ module Inspec
|
|||
end
|
||||
|
||||
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
|
||||
|
|
|
@ -80,6 +80,7 @@ module InspecPlugins
|
|||
|
||||
File.open(artifact_filename, "wb") do |f|
|
||||
f.puts INSPEC_PROFILE_VERSION_2
|
||||
f.puts "Use \"inspec export\" to view this file"
|
||||
f.write(content)
|
||||
end
|
||||
puts "Successfully generated #{artifact_filename}"
|
||||
|
|
Loading…
Reference in a new issue