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

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 36

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

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

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

Instance Method Details

#valueObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mihari/structs/virustotal_intelligence.rb', line 23

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