Class: Sarif::ResultProvenance
- Inherits:
-
Object
- Object
- Sarif::ResultProvenance
- Defined in:
- lib/sarif/result_provenance.rb
Overview
Contains information about how and when a result was detected.
Instance Attribute Summary collapse
-
#conversion_sources ⇒ Object
Returns the value of attribute conversion_sources.
-
#first_detection_run_guid ⇒ Object
Returns the value of attribute first_detection_run_guid.
-
#first_detection_time_utc ⇒ Object
Returns the value of attribute first_detection_time_utc.
-
#invocation_index ⇒ Object
Returns the value of attribute invocation_index.
-
#last_detection_run_guid ⇒ Object
Returns the value of attribute last_detection_run_guid.
-
#last_detection_time_utc ⇒ Object
Returns the value of attribute last_detection_time_utc.
-
#properties ⇒ Object
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(first_detection_time_utc: nil, last_detection_time_utc: nil, first_detection_run_guid: nil, last_detection_run_guid: nil, invocation_index: -1,, conversion_sources: [], properties: nil) ⇒ ResultProvenance
constructor
A new instance of ResultProvenance.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(first_detection_time_utc: nil, last_detection_time_utc: nil, first_detection_run_guid: nil, last_detection_run_guid: nil, invocation_index: -1,, conversion_sources: [], properties: nil) ⇒ ResultProvenance
Returns a new instance of ResultProvenance.
8 9 10 11 12 13 14 15 16 |
# File 'lib/sarif/result_provenance.rb', line 8 def initialize(first_detection_time_utc: nil, last_detection_time_utc: nil, first_detection_run_guid: nil, last_detection_run_guid: nil, invocation_index: -1, conversion_sources: [], properties: nil) @first_detection_time_utc = first_detection_time_utc @last_detection_time_utc = last_detection_time_utc @first_detection_run_guid = first_detection_run_guid @last_detection_run_guid = last_detection_run_guid @invocation_index = invocation_index @conversion_sources = conversion_sources @properties = properties end |
Instance Attribute Details
#conversion_sources ⇒ Object
Returns the value of attribute conversion_sources.
6 7 8 |
# File 'lib/sarif/result_provenance.rb', line 6 def conversion_sources @conversion_sources end |
#first_detection_run_guid ⇒ Object
Returns the value of attribute first_detection_run_guid.
6 7 8 |
# File 'lib/sarif/result_provenance.rb', line 6 def first_detection_run_guid @first_detection_run_guid end |
#first_detection_time_utc ⇒ Object
Returns the value of attribute first_detection_time_utc.
6 7 8 |
# File 'lib/sarif/result_provenance.rb', line 6 def first_detection_time_utc @first_detection_time_utc end |
#invocation_index ⇒ Object
Returns the value of attribute invocation_index.
6 7 8 |
# File 'lib/sarif/result_provenance.rb', line 6 def invocation_index @invocation_index end |
#last_detection_run_guid ⇒ Object
Returns the value of attribute last_detection_run_guid.
6 7 8 |
# File 'lib/sarif/result_provenance.rb', line 6 def last_detection_run_guid @last_detection_run_guid end |
#last_detection_time_utc ⇒ Object
Returns the value of attribute last_detection_time_utc.
6 7 8 |
# File 'lib/sarif/result_provenance.rb', line 6 def last_detection_time_utc @last_detection_time_utc end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/result_provenance.rb', line 6 def properties @properties end |
Class Method Details
.from_hash(h) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sarif/result_provenance.rb', line 34 def self.from_hash(h) return nil if h.nil? new( first_detection_time_utc: h["firstDetectionTimeUtc"], last_detection_time_utc: h["lastDetectionTimeUtc"], first_detection_run_guid: h["firstDetectionRunGuid"], last_detection_run_guid: h["lastDetectionRunGuid"], invocation_index: h["invocationIndex"] || -1, conversion_sources: h["conversionSources"]&.map { |v| PhysicalLocation.from_hash(v) } || [], properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
47 48 49 50 |
# File 'lib/sarif/result_provenance.rb', line 47 def ==(other) return false unless other.is_a?(ResultProvenance) @first_detection_time_utc == other.first_detection_time_utc && @last_detection_time_utc == other.last_detection_time_utc && @first_detection_run_guid == other.first_detection_run_guid && @last_detection_run_guid == other.last_detection_run_guid && @invocation_index == other.invocation_index && @conversion_sources == other.conversion_sources && @properties == other.properties end |
#hash ⇒ Object
54 55 56 |
# File 'lib/sarif/result_provenance.rb', line 54 def hash [@first_detection_time_utc, @last_detection_time_utc, @first_detection_run_guid, @last_detection_run_guid, @invocation_index, @conversion_sources, @properties].hash end |
#to_h ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sarif/result_provenance.rb', line 18 def to_h h = {} h["firstDetectionTimeUtc"] = @first_detection_time_utc unless @first_detection_time_utc.nil? h["lastDetectionTimeUtc"] = @last_detection_time_utc unless @last_detection_time_utc.nil? h["firstDetectionRunGuid"] = @first_detection_run_guid unless @first_detection_run_guid.nil? h["lastDetectionRunGuid"] = @last_detection_run_guid unless @last_detection_run_guid.nil? h["invocationIndex"] = @invocation_index if @invocation_index && @invocation_index != -1 h["conversionSources"] = @conversion_sources&.map(&:to_h) if @conversion_sources&.any? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
30 31 32 |
# File 'lib/sarif/result_provenance.rb', line 30 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |