Class: Ironment::Truster
- Inherits:
-
Object
show all
- Defined in:
- lib/ironment/truster.rb
Defined Under Namespace
Classes: Modified, NotTrusted, RuncomError
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Truster
Returns a new instance of Truster.
16
17
18
|
# File 'lib/ironment/truster.rb', line 16
def initialize(options = {})
@config = options[:config] || Config.new
end
|
Instance Method Details
#trust(runcom) ⇒ Object
36
37
38
|
# File 'lib/ironment/truster.rb', line 36
def trust(runcom)
@config[runcom.file] = runcom.sha1sum
end
|
#untrust(runcom) ⇒ Object
40
41
42
|
# File 'lib/ironment/truster.rb', line 40
def untrust(runcom)
@config[runcom.file] = nil
end
|
#validate(runcom) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/ironment/truster.rb', line 20
def validate(runcom)
expected_sha1sum = @config[runcom.file]
if expected_sha1sum.nil?
raise NotTrusted, runcom
end
real_sha1sum = runcom.sha1sum
unless expected_sha1sum == real_sha1sum
raise Modified, runcom
end
true
end
|