Class: Sarif::Result
- Inherits:
-
Object
- Object
- Sarif::Result
- Defined in:
- lib/sarif/result.rb
Overview
A result produced by an analysis tool.
Instance Attribute Summary collapse
-
#analysis_target ⇒ Object
Returns the value of attribute analysis_target.
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#baseline_state ⇒ Object
Returns the value of attribute baseline_state.
-
#code_flows ⇒ Object
Returns the value of attribute code_flows.
-
#correlation_guid ⇒ Object
Returns the value of attribute correlation_guid.
-
#fingerprints ⇒ Object
Returns the value of attribute fingerprints.
-
#fixes ⇒ Object
Returns the value of attribute fixes.
-
#graph_traversals ⇒ Object
Returns the value of attribute graph_traversals.
-
#graphs ⇒ Object
Returns the value of attribute graphs.
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#hosted_viewer_uri ⇒ Object
Returns the value of attribute hosted_viewer_uri.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#level ⇒ Object
Returns the value of attribute level.
-
#locations ⇒ Object
Returns the value of attribute locations.
-
#message ⇒ Object
Returns the value of attribute message.
-
#occurrence_count ⇒ Object
Returns the value of attribute occurrence_count.
-
#partial_fingerprints ⇒ Object
Returns the value of attribute partial_fingerprints.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#provenance ⇒ Object
Returns the value of attribute provenance.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#related_locations ⇒ Object
Returns the value of attribute related_locations.
-
#rule ⇒ Object
Returns the value of attribute rule.
-
#rule_id ⇒ Object
Returns the value of attribute rule_id.
-
#rule_index ⇒ Object
Returns the value of attribute rule_index.
-
#stacks ⇒ Object
Returns the value of attribute stacks.
-
#suppressions ⇒ Object
Returns the value of attribute suppressions.
-
#taxa ⇒ Object
Returns the value of attribute taxa.
-
#web_request ⇒ Object
Returns the value of attribute web_request.
-
#web_response ⇒ Object
Returns the value of attribute web_response.
-
#work_item_uris ⇒ Object
Returns the value of attribute work_item_uris.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(rule_id: nil, rule_index: -1,, rule: nil, kind: "fail", level: "warning", message:, analysis_target: nil, locations: [], guid: nil, correlation_guid: nil, occurrence_count: nil, partial_fingerprints: nil, fingerprints: nil, stacks: [], code_flows: [], graphs: [], graph_traversals: [], related_locations: [], suppressions: nil, baseline_state: nil, rank: -1.0,, attachments: [], hosted_viewer_uri: nil, work_item_uris: nil, provenance: nil, fixes: [], taxa: [], web_request: nil, web_response: nil, properties: nil) ⇒ Result
constructor
A new instance of Result.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(rule_id: nil, rule_index: -1,, rule: nil, kind: "fail", level: "warning", message:, analysis_target: nil, locations: [], guid: nil, correlation_guid: nil, occurrence_count: nil, partial_fingerprints: nil, fingerprints: nil, stacks: [], code_flows: [], graphs: [], graph_traversals: [], related_locations: [], suppressions: nil, baseline_state: nil, rank: -1.0,, attachments: [], hosted_viewer_uri: nil, work_item_uris: nil, provenance: nil, fixes: [], taxa: [], web_request: nil, web_response: nil, properties: nil) ⇒ Result
Returns a new instance of Result.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sarif/result.rb', line 8 def initialize(rule_id: nil, rule_index: -1, rule: nil, kind: "fail", level: "warning", message:, analysis_target: nil, locations: [], guid: nil, correlation_guid: nil, occurrence_count: nil, partial_fingerprints: nil, fingerprints: nil, stacks: [], code_flows: [], graphs: [], graph_traversals: [], related_locations: [], suppressions: nil, baseline_state: nil, rank: -1.0, attachments: [], hosted_viewer_uri: nil, work_item_uris: nil, provenance: nil, fixes: [], taxa: [], web_request: nil, web_response: nil, properties: nil) @rule_id = rule_id @rule_index = rule_index @rule = rule @kind = kind @level = level @message = @analysis_target = analysis_target @locations = locations @guid = guid @correlation_guid = correlation_guid @occurrence_count = occurrence_count @partial_fingerprints = partial_fingerprints @fingerprints = fingerprints @stacks = stacks @code_flows = code_flows @graphs = graphs @graph_traversals = graph_traversals @related_locations = @suppressions = suppressions @baseline_state = baseline_state @rank = rank @attachments = @hosted_viewer_uri = hosted_viewer_uri @work_item_uris = work_item_uris @provenance = provenance @fixes = fixes @taxa = taxa @web_request = web_request @web_response = web_response @properties = properties end |
Instance Attribute Details
#analysis_target ⇒ Object
Returns the value of attribute analysis_target.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def analysis_target @analysis_target end |
#attachments ⇒ Object
Returns the value of attribute attachments.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def @attachments end |
#baseline_state ⇒ Object
Returns the value of attribute baseline_state.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def baseline_state @baseline_state end |
#code_flows ⇒ Object
Returns the value of attribute code_flows.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def code_flows @code_flows end |
#correlation_guid ⇒ Object
Returns the value of attribute correlation_guid.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def correlation_guid @correlation_guid end |
#fingerprints ⇒ Object
Returns the value of attribute fingerprints.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def fingerprints @fingerprints end |
#fixes ⇒ Object
Returns the value of attribute fixes.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def fixes @fixes end |
#graph_traversals ⇒ Object
Returns the value of attribute graph_traversals.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def graph_traversals @graph_traversals end |
#graphs ⇒ Object
Returns the value of attribute graphs.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def graphs @graphs end |
#guid ⇒ Object
Returns the value of attribute guid.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def guid @guid end |
#hosted_viewer_uri ⇒ Object
Returns the value of attribute hosted_viewer_uri.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def hosted_viewer_uri @hosted_viewer_uri end |
#kind ⇒ Object
Returns the value of attribute kind.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def kind @kind end |
#level ⇒ Object
Returns the value of attribute level.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def level @level end |
#locations ⇒ Object
Returns the value of attribute locations.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def locations @locations end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def @message end |
#occurrence_count ⇒ Object
Returns the value of attribute occurrence_count.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def occurrence_count @occurrence_count end |
#partial_fingerprints ⇒ Object
Returns the value of attribute partial_fingerprints.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def partial_fingerprints @partial_fingerprints end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def properties @properties end |
#provenance ⇒ Object
Returns the value of attribute provenance.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def provenance @provenance end |
#rank ⇒ Object
Returns the value of attribute rank.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def rank @rank end |
#related_locations ⇒ Object
Returns the value of attribute related_locations.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def @related_locations end |
#rule ⇒ Object
Returns the value of attribute rule.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def rule @rule end |
#rule_id ⇒ Object
Returns the value of attribute rule_id.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def rule_id @rule_id end |
#rule_index ⇒ Object
Returns the value of attribute rule_index.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def rule_index @rule_index end |
#stacks ⇒ Object
Returns the value of attribute stacks.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def stacks @stacks end |
#suppressions ⇒ Object
Returns the value of attribute suppressions.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def suppressions @suppressions end |
#taxa ⇒ Object
Returns the value of attribute taxa.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def taxa @taxa end |
#web_request ⇒ Object
Returns the value of attribute web_request.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def web_request @web_request end |
#web_response ⇒ Object
Returns the value of attribute web_response.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def web_response @web_response end |
#work_item_uris ⇒ Object
Returns the value of attribute work_item_uris.
6 7 8 |
# File 'lib/sarif/result.rb', line 6 def work_item_uris @work_item_uris end |
Class Method Details
.from_hash(h) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/sarif/result.rb', line 80 def self.from_hash(h) return nil if h.nil? new( rule_id: h["ruleId"], rule_index: h["ruleIndex"] || -1, rule: ReportingDescriptorReference.from_hash(h["rule"]), kind: h["kind"] || "fail", level: h["level"] || "warning", message: Message.from_hash(h["message"]), analysis_target: ArtifactLocation.from_hash(h["analysisTarget"]), locations: h["locations"]&.map { |v| Location.from_hash(v) } || [], guid: h["guid"], correlation_guid: h["correlationGuid"], occurrence_count: h["occurrenceCount"], partial_fingerprints: h["partialFingerprints"], fingerprints: h["fingerprints"], stacks: h["stacks"]&.map { |v| Stack.from_hash(v) } || [], code_flows: h["codeFlows"]&.map { |v| CodeFlow.from_hash(v) } || [], graphs: h["graphs"]&.map { |v| Graph.from_hash(v) } || [], graph_traversals: h["graphTraversals"]&.map { |v| GraphTraversal.from_hash(v) } || [], related_locations: h["relatedLocations"]&.map { |v| Location.from_hash(v) } || [], suppressions: h["suppressions"]&.map { |v| Suppression.from_hash(v) }, baseline_state: h["baselineState"], rank: h["rank"] || -1.0, attachments: h["attachments"]&.map { |v| Attachment.from_hash(v) } || [], hosted_viewer_uri: h["hostedViewerUri"], work_item_uris: h["workItemUris"], provenance: ResultProvenance.from_hash(h["provenance"]), fixes: h["fixes"]&.map { |v| Fix.from_hash(v) } || [], taxa: h["taxa"]&.map { |v| ReportingDescriptorReference.from_hash(v) } || [], 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?
116 117 118 119 |
# File 'lib/sarif/result.rb', line 116 def ==(other) return false unless other.is_a?(Result) @rule_id == other.rule_id && @rule_index == other.rule_index && @rule == other.rule && @kind == other.kind && @level == other.level && @message == other. && @analysis_target == other.analysis_target && @locations == other.locations && @guid == other.guid && @correlation_guid == other.correlation_guid && @occurrence_count == other.occurrence_count && @partial_fingerprints == other.partial_fingerprints && @fingerprints == other.fingerprints && @stacks == other.stacks && @code_flows == other.code_flows && @graphs == other.graphs && @graph_traversals == other.graph_traversals && @related_locations == other. && @suppressions == other.suppressions && @baseline_state == other.baseline_state && @rank == other.rank && @attachments == other. && @hosted_viewer_uri == other.hosted_viewer_uri && @work_item_uris == other.work_item_uris && @provenance == other.provenance && @fixes == other.fixes && @taxa == other.taxa && @web_request == other.web_request && @web_response == other.web_response && @properties == other.properties end |
#hash ⇒ Object
123 124 125 |
# File 'lib/sarif/result.rb', line 123 def hash [@rule_id, @rule_index, @rule, @kind, @level, @message, @analysis_target, @locations, @guid, @correlation_guid, @occurrence_count, @partial_fingerprints, @fingerprints, @stacks, @code_flows, @graphs, @graph_traversals, @related_locations, @suppressions, @baseline_state, @rank, @attachments, @hosted_viewer_uri, @work_item_uris, @provenance, @fixes, @taxa, @web_request, @web_response, @properties].hash end |
#to_h ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/sarif/result.rb', line 41 def to_h h = {} h["ruleId"] = @rule_id unless @rule_id.nil? h["ruleIndex"] = @rule_index if @rule_index && @rule_index != -1 h["rule"] = @rule&.to_h unless @rule.nil? h["kind"] = @kind&.to_s if @kind && @kind != "fail" h["level"] = @level&.to_s if @level && @level != "warning" h["message"] = @message&.to_h h["analysisTarget"] = @analysis_target&.to_h unless @analysis_target.nil? h["locations"] = @locations&.map(&:to_h) if @locations&.any? h["guid"] = @guid unless @guid.nil? h["correlationGuid"] = @correlation_guid unless @correlation_guid.nil? h["occurrenceCount"] = @occurrence_count unless @occurrence_count.nil? h["partialFingerprints"] = @partial_fingerprints unless @partial_fingerprints.nil? h["fingerprints"] = @fingerprints unless @fingerprints.nil? h["stacks"] = @stacks&.map(&:to_h) if @stacks&.any? h["codeFlows"] = @code_flows&.map(&:to_h) if @code_flows&.any? h["graphs"] = @graphs&.map(&:to_h) if @graphs&.any? h["graphTraversals"] = @graph_traversals&.map(&:to_h) if @graph_traversals&.any? h["relatedLocations"] = @related_locations&.map(&:to_h) if @related_locations&.any? h["suppressions"] = @suppressions&.map(&:to_h) if @suppressions&.any? h["baselineState"] = @baseline_state&.to_s unless @baseline_state.nil? h["rank"] = @rank if @rank && @rank != -1 h["attachments"] = @attachments&.map(&:to_h) if @attachments&.any? h["hostedViewerUri"] = @hosted_viewer_uri unless @hosted_viewer_uri.nil? h["workItemUris"] = @work_item_uris if @work_item_uris&.any? h["provenance"] = @provenance&.to_h unless @provenance.nil? h["fixes"] = @fixes&.map(&:to_h) if @fixes&.any? h["taxa"] = @taxa&.map(&:to_h) if @taxa&.any? 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
76 77 78 |
# File 'lib/sarif/result.rb', line 76 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |