Class: Mihari::Structs::VirusTotalIntelligence::Datum

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/mihari/structs/virustotal_intelligence.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#context_attributesContextAttributes? (readonly)

Returns:



33
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 33

attribute :context_attributes, ContextAttributes.optional

#idString (readonly)

Returns:

  • (String)


29
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 29

attribute :id, Types::String

#metadataHash (readonly)

Returns:

  • (Hash)


37
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 37

attribute :metadata, Types::Hash

#typeString (readonly)

Returns:

  • (String)


25
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 25

attribute :type, Types::String

Class Method Details

.from_dynamic!(d) ⇒ Object

Parameters:

  • d (Hash)


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 66

def from_dynamic!(d)
  d = Types::Hash[d]

  context_attributes = nil
  if d.key?("context_attributes")
    context_attributes = ContextAttributes.from_dynamic!(d.fetch("context_attributes"))
  end

  new(
    type: d.fetch("type"),
    id: d.fetch("id"),
    context_attributes:,
    metadata: d
  )
end

Instance Method Details

#artifactMihari::Models::Artifact



58
59
60
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 58

def artifact
  Models::Artifact.new(data: value, metadata:)
end

#valueString?

Returns:

  • (String, nil)


42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 42

def value
  case type
  when "file"
    id
  when "url"
    context_attributes&.url
  when "domain"
    id
  when "ip_address"
    id
  end
end