class EFIValidate::EFIValidator
Class that represents a single run of a validator against a firmware
Attributes
data[R]
errors[R]
parser[R]
Public Class Methods
new(parser, file)
click to toggle source
# File lib/efivalidate/efi_validator.rb, line 6 def initialize(parser, file) @parser = parser reader = File.open(file, mode: 'rb') @data = reader.read reader.close perform_core_sec_fixup if @parser.rows.any?(&:core_sec?) end
Public Instance Methods
get_region(offset, length)
click to toggle source
# File lib/efivalidate/efi_validator.rb, line 28 def get_region(offset, length) @data[offset, length] || '' end
perform_core_sec_fixup()
click to toggle source
# File lib/efivalidate/efi_validator.rb, line 32 def perform_core_sec_fixup # Apple zeros out what appears to be a hash and checksum before validating the SEC_CORE region @data[-0x100, 0x80] = "\0" * 0x80 @data[-0x04, 0x04] = "\0" * 0x04 end
valid?()
click to toggle source
# File lib/efivalidate/efi_validator.rb, line 43 def valid? validate errors.count.zero? end
validate()
click to toggle source
# File lib/efivalidate/efi_validator.rb, line 39 def validate validate! unless @errors end
validate!()
click to toggle source
# File lib/efivalidate/efi_validator.rb, line 16 def validate! @errors = [] @parser.rows.reject(&:privacy_row?).each do |row| section_data = get_region(row.ealf_offset, row.ealf_length) calculated_hash = @parser.header.create_hash.hexdigest section_data @errors << EFIValidationError.new(row, section_data, calculated_hash) unless calculated_hash == row.hash end end