Class: Stratagem::Scan::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/stratagem/scan/result.rb

Overview

Each security check emits 1 or more result objects based on its findings Payload is an arbitrary piece of data that the check produces. It must be able to be encoded to JSON Unique is a value that identifies the check result within the namespace of the check

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Result

passed = true / false



11
12
13
# File 'lib/stratagem/scan/result.rb', line 11

def initialize(args)
  args.each {|key,value| self.send("#{key}=", value) }
end

Instance Attribute Details

#checkObject

Returns the value of attribute check.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def check
  @check
end

#codeObject

Returns the value of attribute code.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def code
  @code
end

#componentObject

Returns the value of attribute component.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def component
  @component
end

#concern_typeObject

Returns the value of attribute concern_type.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def concern_type
  @concern_type
end

#confirmedObject

Returns the value of attribute confirmed.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def confirmed
  @confirmed
end

#line_numberObject

Returns the value of attribute line_number.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def line_number
  @line_number
end

#passedObject

Returns the value of attribute passed.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def passed
  @passed
end

#payloadObject

Returns the value of attribute payload.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def payload
  @payload
end

#solution_payloadObject

Returns the value of attribute solution_payload.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def solution_payload
  @solution_payload
end

#specializationObject

Returns the value of attribute specialization.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def specialization
  @specialization
end

#uniqueObject

Returns the value of attribute unique.



8
9
10
# File 'lib/stratagem/scan/result.rb', line 8

def unique
  @unique
end

Instance Method Details

#check_nameObject



36
37
38
# File 'lib/stratagem/scan/result.rb', line 36

def check_name
  check ? check.name : nil
end

#component_nameObject



32
33
34
# File 'lib/stratagem/scan/result.rb', line 32

def component_name
  component ? component.name : nil
end

#exportObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/stratagem/scan/result.rb', line 15

def export
  h = {
    :guid => guid, 
    :check_name => check_name, 
    :specialization => specialization,
    :component => component_name, 
    :payload => payload, 
    :line_number => line_number, 
    :code => code,
    :concern_type => concern_type,
    :confirmed => confirmed || false,
    :solution_payload => solution_payload
  }
  h[:path] = component.path.gsub(RAILS_ROOT+'/', '') if component
  h
end

#guidObject



40
41
42
# File 'lib/stratagem/scan/result.rb', line 40

def guid
  "#{check_name.underscore}:#{(component_name || '').underscore}:#{unique.to_s.underscore}"
end