Class: Sarif::ExternalProperties

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

Overview

The top-level element of an external property file.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema: nil, version: nil, guid: nil, run_guid: nil, conversion: nil, graphs: [], externalized_properties: nil, artifacts: nil, invocations: [], logical_locations: [], thread_flow_locations: [], results: [], taxonomies: [], driver: nil, extensions: [], policies: [], translations: [], addresses: [], web_requests: [], web_responses: [], properties: nil) ⇒ ExternalProperties

Returns a new instance of ExternalProperties.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sarif/external_properties.rb', line 8

def initialize(schema: nil, version: nil, guid: nil, run_guid: nil, conversion: nil, graphs: [], externalized_properties: nil, artifacts: nil, invocations: [], logical_locations: [], thread_flow_locations: [], results: [], taxonomies: [], driver: nil, extensions: [], policies: [], translations: [], addresses: [], web_requests: [], web_responses: [], properties: nil)
  @schema = schema
  @version = version
  @guid = guid
  @run_guid = run_guid
  @conversion = conversion
  @graphs = graphs
  @externalized_properties = externalized_properties
  @artifacts = artifacts
  @invocations = invocations
  @logical_locations = logical_locations
  @thread_flow_locations = thread_flow_locations
  @results = results
  @taxonomies = taxonomies
  @driver = driver
  @extensions = extensions
  @policies = policies
  @translations = translations
  @addresses = addresses
  @web_requests = web_requests
  @web_responses = web_responses
  @properties = properties
end

Instance Attribute Details

#addressesObject

Returns the value of attribute addresses.



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

def addresses
  @addresses
end

#artifactsObject

Returns the value of attribute artifacts.



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

def artifacts
  @artifacts
end

#conversionObject

Returns the value of attribute conversion.



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

def conversion
  @conversion
end

#driverObject

Returns the value of attribute driver.



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

def driver
  @driver
end

#extensionsObject

Returns the value of attribute extensions.



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

def extensions
  @extensions
end

#externalized_propertiesObject

Returns the value of attribute externalized_properties.



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

def externalized_properties
  @externalized_properties
end

#graphsObject

Returns the value of attribute graphs.



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

def graphs
  @graphs
end

#guidObject

Returns the value of attribute guid.



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

def guid
  @guid
end

#invocationsObject

Returns the value of attribute invocations.



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

def invocations
  @invocations
end

#logical_locationsObject

Returns the value of attribute logical_locations.



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

def logical_locations
  @logical_locations
end

#policiesObject

Returns the value of attribute policies.



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

def policies
  @policies
end

#propertiesObject

Returns the value of attribute properties.



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

def properties
  @properties
end

#resultsObject

Returns the value of attribute results.



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

def results
  @results
end

#run_guidObject

Returns the value of attribute run_guid.



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

def run_guid
  @run_guid
end

#schemaObject

Returns the value of attribute schema.



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

def schema
  @schema
end

#taxonomiesObject

Returns the value of attribute taxonomies.



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

def taxonomies
  @taxonomies
end

#thread_flow_locationsObject

Returns the value of attribute thread_flow_locations.



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

def thread_flow_locations
  @thread_flow_locations
end

#translationsObject

Returns the value of attribute translations.



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

def translations
  @translations
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

#web_requestsObject

Returns the value of attribute web_requests.



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

def web_requests
  @web_requests
end

#web_responsesObject

Returns the value of attribute web_responses.



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

def web_responses
  @web_responses
end

Class Method Details

.from_hash(h) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/sarif/external_properties.rb', line 62

def self.from_hash(h)
  return nil if h.nil?
  new(
    schema: h["schema"],
    version: h["version"],
    guid: h["guid"],
    run_guid: h["runGuid"],
    conversion: Conversion.from_hash(h["conversion"]),
    graphs: h["graphs"]&.map { |v| Graph.from_hash(v) } || [],
    externalized_properties: h["externalizedProperties"],
    artifacts: h["artifacts"]&.map { |v| Artifact.from_hash(v) },
    invocations: h["invocations"]&.map { |v| Invocation.from_hash(v) } || [],
    logical_locations: h["logicalLocations"]&.map { |v| LogicalLocation.from_hash(v) } || [],
    thread_flow_locations: h["threadFlowLocations"]&.map { |v| ThreadFlowLocation.from_hash(v) } || [],
    results: h["results"]&.map { |v| Result.from_hash(v) } || [],
    taxonomies: h["taxonomies"]&.map { |v| ToolComponent.from_hash(v) } || [],
    driver: ToolComponent.from_hash(h["driver"]),
    extensions: h["extensions"]&.map { |v| ToolComponent.from_hash(v) } || [],
    policies: h["policies"]&.map { |v| ToolComponent.from_hash(v) } || [],
    translations: h["translations"]&.map { |v| ToolComponent.from_hash(v) } || [],
    addresses: h["addresses"]&.map { |v| Address.from_hash(v) } || [],
    web_requests: h["webRequests"]&.map { |v| WebRequest.from_hash(v) } || [],
    web_responses: h["webResponses"]&.map { |v| WebResponse.from_hash(v) } || [],
    properties: h["properties"]
  )
end

Instance Method Details

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



89
90
91
92
# File 'lib/sarif/external_properties.rb', line 89

def ==(other)
  return false unless other.is_a?(ExternalProperties)
  @schema == other.schema && @version == other.version && @guid == other.guid && @run_guid == other.run_guid && @conversion == other.conversion && @graphs == other.graphs && @externalized_properties == other.externalized_properties && @artifacts == other.artifacts && @invocations == other.invocations && @logical_locations == other.logical_locations && @thread_flow_locations == other.thread_flow_locations && @results == other.results && @taxonomies == other.taxonomies && @driver == other.driver && @extensions == other.extensions && @policies == other.policies && @translations == other.translations && @addresses == other.addresses && @web_requests == other.web_requests && @web_responses == other.web_responses && @properties == other.properties
end

#hashObject



96
97
98
# File 'lib/sarif/external_properties.rb', line 96

def hash
  [@schema, @version, @guid, @run_guid, @conversion, @graphs, @externalized_properties, @artifacts, @invocations, @logical_locations, @thread_flow_locations, @results, @taxonomies, @driver, @extensions, @policies, @translations, @addresses, @web_requests, @web_responses, @properties].hash
end

#to_hObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/sarif/external_properties.rb', line 32

def to_h
  h = {}
  h["schema"] = @schema unless @schema.nil?
  h["version"] = @version&.to_s unless @version.nil?
  h["guid"] = @guid unless @guid.nil?
  h["runGuid"] = @run_guid unless @run_guid.nil?
  h["conversion"] = @conversion&.to_h unless @conversion.nil?
  h["graphs"] = @graphs&.map(&:to_h) if @graphs&.any?
  h["externalizedProperties"] = @externalized_properties unless @externalized_properties.nil?
  h["artifacts"] = @artifacts&.map(&:to_h) if @artifacts&.any?
  h["invocations"] = @invocations&.map(&:to_h) if @invocations&.any?
  h["logicalLocations"] = @logical_locations&.map(&:to_h) if @logical_locations&.any?
  h["threadFlowLocations"] = @thread_flow_locations&.map(&:to_h) if @thread_flow_locations&.any?
  h["results"] = @results&.map(&:to_h) if @results&.any?
  h["taxonomies"] = @taxonomies&.map(&:to_h) if @taxonomies&.any?
  h["driver"] = @driver&.to_h unless @driver.nil?
  h["extensions"] = @extensions&.map(&:to_h) if @extensions&.any?
  h["policies"] = @policies&.map(&:to_h) if @policies&.any?
  h["translations"] = @translations&.map(&:to_h) if @translations&.any?
  h["addresses"] = @addresses&.map(&:to_h) if @addresses&.any?
  h["webRequests"] = @web_requests&.map(&:to_h) if @web_requests&.any?
  h["webResponses"] = @web_responses&.map(&:to_h) if @web_responses&.any?
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



58
59
60
# File 'lib/sarif/external_properties.rb', line 58

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