Class: Sarif::ThreadFlowLocation

Inherits:
Object
  • Object
show all
Defined in:
lib/sarif/thread_flow_location.rb

Overview

A location visited by an analysis tool while simulating or monitoring the execution of a program.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index: -1,, location: nil, stack: nil, kinds: [], taxa: [], module_name: nil, state: nil, nesting_level: nil, execution_order: -1,, execution_time_utc: nil, importance: "important", web_request: nil, web_response: nil, properties: nil) ⇒ ThreadFlowLocation

Returns a new instance of ThreadFlowLocation.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sarif/thread_flow_location.rb', line 8

def initialize(index: -1, location: nil, stack: nil, kinds: [], taxa: [], module_name: nil, state: nil, nesting_level: nil, execution_order: -1, execution_time_utc: nil, importance: "important", web_request: nil, web_response: nil, properties: nil)
  @index = index
  @location = location
  @stack = stack
  @kinds = kinds
  @taxa = taxa
  @module_name = module_name
  @state = state
  @nesting_level = nesting_level
  @execution_order = execution_order
  @execution_time_utc = execution_time_utc
  @importance = importance
  @web_request = web_request
  @web_response = web_response
  @properties = properties
end

Instance Attribute Details

#execution_orderObject

Returns the value of attribute execution_order.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def execution_order
  @execution_order
end

#execution_time_utcObject

Returns the value of attribute execution_time_utc.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def execution_time_utc
  @execution_time_utc
end

#importanceObject

Returns the value of attribute importance.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def importance
  @importance
end

#indexObject

Returns the value of attribute index.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def index
  @index
end

#kindsObject

Returns the value of attribute kinds.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def kinds
  @kinds
end

#locationObject

Returns the value of attribute location.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def location
  @location
end

#module_nameObject

Returns the value of attribute module_name.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def module_name
  @module_name
end

#nesting_levelObject

Returns the value of attribute nesting_level.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def nesting_level
  @nesting_level
end

#propertiesObject

Returns the value of attribute properties.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def properties
  @properties
end

#stackObject

Returns the value of attribute stack.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def stack
  @stack
end

#stateObject

Returns the value of attribute state.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def state
  @state
end

#taxaObject

Returns the value of attribute taxa.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def taxa
  @taxa
end

#web_requestObject

Returns the value of attribute web_request.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def web_request
  @web_request
end

#web_responseObject

Returns the value of attribute web_response.



6
7
8
# File 'lib/sarif/thread_flow_location.rb', line 6

def web_response
  @web_response
end

Class Method Details

.from_hash(h) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/sarif/thread_flow_location.rb', line 48

def self.from_hash(h)
  return nil if h.nil?
  new(
    index: h["index"] || -1,
    location: Location.from_hash(h["location"]),
    stack: Stack.from_hash(h["stack"]),
    kinds: h["kinds"] || [],
    taxa: h["taxa"]&.map { |v| ReportingDescriptorReference.from_hash(v) } || [],
    module_name: h["module"],
    state: h["state"],
    nesting_level: h["nestingLevel"],
    execution_order: h["executionOrder"] || -1,
    execution_time_utc: h["executionTimeUtc"],
    importance: h["importance"] || "important",
    web_request: WebRequest.from_hash(h["webRequest"]),
    web_response: WebResponse.from_hash(h["webResponse"]),
    properties: h["properties"]
  )
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



68
69
70
71
# File 'lib/sarif/thread_flow_location.rb', line 68

def ==(other)
  return false unless other.is_a?(ThreadFlowLocation)
  @index == other.index && @location == other.location && @stack == other.stack && @kinds == other.kinds && @taxa == other.taxa && @module_name == other.module_name && @state == other.state && @nesting_level == other.nesting_level && @execution_order == other.execution_order && @execution_time_utc == other.execution_time_utc && @importance == other.importance && @web_request == other.web_request && @web_response == other.web_response && @properties == other.properties
end

#hashObject



75
76
77
# File 'lib/sarif/thread_flow_location.rb', line 75

def hash
  [@index, @location, @stack, @kinds, @taxa, @module_name, @state, @nesting_level, @execution_order, @execution_time_utc, @importance, @web_request, @web_response, @properties].hash
end

#to_hObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sarif/thread_flow_location.rb', line 25

def to_h
  h = {}
  h["index"] = @index if @index && @index != -1
  h["location"] = @location&.to_h unless @location.nil?
  h["stack"] = @stack&.to_h unless @stack.nil?
  h["kinds"] = @kinds if @kinds&.any?
  h["taxa"] = @taxa&.map(&:to_h) if @taxa&.any?
  h["module"] = @module_name unless @module_name.nil?
  h["state"] = @state unless @state.nil?
  h["nestingLevel"] = @nesting_level unless @nesting_level.nil?
  h["executionOrder"] = @execution_order if @execution_order && @execution_order != -1
  h["executionTimeUtc"] = @execution_time_utc unless @execution_time_utc.nil?
  h["importance"] = @importance&.to_s if @importance && @importance != "important"
  h["webRequest"] = @web_request&.to_h unless @web_request.nil?
  h["webResponse"] = @web_response&.to_h unless @web_response.nil?
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



44
45
46
# File 'lib/sarif/thread_flow_location.rb', line 44

def to_json(pretty: false)
  pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h)
end