Class: Mihari::Structs::Onyphe::Result
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Mihari::Structs::Onyphe::Result
- Includes:
- Concerns::AutonomousSystemNormalizable
- Defined in:
- lib/mihari/structs/onyphe.rb
Instance Attribute Summary collapse
- #asn ⇒ String readonly
- #country_code ⇒ String, nll readonly
- #ip ⇒ String readonly
- #metadata ⇒ Hash readonly
Class Method Summary collapse
Instance Method Summary collapse
- #artifact ⇒ Mihari::Models::Artifact
- #as ⇒ Mihari::AutonomousSystem
- #geolocation ⇒ Mihari::Geolocation?
Methods included from Concerns::AutonomousSystemNormalizable
Instance Attribute Details
#asn ⇒ String (readonly)
11 |
# File 'lib/mihari/structs/onyphe.rb', line 11 attribute :asn, Types::String |
#country_code ⇒ String, nll (readonly)
15 |
# File 'lib/mihari/structs/onyphe.rb', line 15 attribute :country_code, Types::String.optional |
#ip ⇒ String (readonly)
20 |
# File 'lib/mihari/structs/onyphe.rb', line 20 attribute :ip, Types::String |
#metadata ⇒ Hash (readonly)
24 |
# File 'lib/mihari/structs/onyphe.rb', line 24 attribute :metadata, Types::Hash |
Class Method Details
.from_dynamic!(d) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/mihari/structs/onyphe.rb', line 61 def from_dynamic!(d) d = Types::Hash[d] new( asn: d.fetch("asn"), ip: d.fetch("ip"), # Onyphe's country = 2-letter country code country_code: d["country"], metadata: d ) end |
Instance Method Details
#artifact ⇒ Mihari::Models::Artifact
29 30 31 32 33 34 35 36 |
# File 'lib/mihari/structs/onyphe.rb', line 29 def artifact Mihari::Models::Artifact.new( data: ip, metadata: , autonomous_system: as, geolocation: geolocation ) end |
#as ⇒ Mihari::AutonomousSystem
53 54 55 |
# File 'lib/mihari/structs/onyphe.rb', line 53 def as Mihari::Models::AutonomousSystem.new(asn: normalize_asn(asn)) end |
#geolocation ⇒ Mihari::Geolocation?
41 42 43 44 45 46 47 48 |
# File 'lib/mihari/structs/onyphe.rb', line 41 def geolocation return nil if country_code.nil? Mihari::Models::Geolocation.new( country: NormalizeCountry(country_code, to: :short), country_code: country_code ) end |