Exception: Kotoshu::IntegrityError

Inherits:
Error
  • Object
show all
Defined in:
lib/kotoshu/core/exceptions.rb

Overview

Error raised when a downloaded resource fails integrity verification (SHA-256 mismatch against manifest, truncated content, etc.).

The downloaded bytes are never trusted until verified against a known manifest entry. Mismatch raises this error with both hashes so the caller can surface them in audit logs and CI output.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_id, expected:, actual:, url: nil) ⇒ IntegrityError

Returns a new instance of IntegrityError.



152
153
154
155
156
157
158
159
160
161
# File 'lib/kotoshu/core/exceptions.rb', line 152

def initialize(resource_id, expected:, actual:, url: nil)
  @resource_id = resource_id
  @expected = expected
  @actual = actual
  @url = url
  msg = +"Integrity verification failed for #{resource_id}: "
  msg << "expected sha256=#{expected}, got sha256=#{actual}"
  msg << " (url: #{url})" if url
  super(msg)
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



163
164
165
# File 'lib/kotoshu/core/exceptions.rb', line 163

def actual
  @actual
end

#expectedObject (readonly)

Returns the value of attribute expected.



163
164
165
# File 'lib/kotoshu/core/exceptions.rb', line 163

def expected
  @expected
end

#resource_idObject (readonly)

Returns the value of attribute resource_id.



163
164
165
# File 'lib/kotoshu/core/exceptions.rb', line 163

def resource_id
  @resource_id
end

#urlObject (readonly)

Returns the value of attribute url.



163
164
165
# File 'lib/kotoshu/core/exceptions.rb', line 163

def url
  @url
end