Class: Mihari::Structs::Censys::V3::Hit
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Mihari::Structs::Censys::V3::Hit
- Includes:
- Concerns::AutonomousSystemNormalizable
- Defined in:
- lib/mihari/structs/censys.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Concerns::AutonomousSystemNormalizable
Class Method Details
.from_dynamic!(d) ⇒ Object
292 293 294 295 296 297 298 299 300 301 |
# File 'lib/mihari/structs/censys.rb', line 292 def from_dynamic!(d) res = d.dig("host_v1", "resource") || {} new( ip: res["ip"], autonomous_system: res["autonomous_system"], location: res["location"], services: res["services"], metadata: d ) end |
Instance Method Details
#artifact ⇒ Object
266 267 268 269 270 271 272 273 274 |
# File 'lib/mihari/structs/censys.rb', line 266 def artifact Mihari::Models::Artifact.new( data: ip, metadata: , autonomous_system: autonomous_system_model, geolocation: geolocation_model, ports: ports.map { |p| Mihari::Models::Port.new(number: p) } ) end |
#autonomous_system_model ⇒ Object
276 277 278 279 280 |
# File 'lib/mihari/structs/censys.rb', line 276 def autonomous_system_model return nil if autonomous_system.nil? Mihari::Models::AutonomousSystem.new(number: normalize_asn(autonomous_system["asn"])) end |
#geolocation_model ⇒ Object
282 283 284 285 286 287 288 289 |
# File 'lib/mihari/structs/censys.rb', line 282 def geolocation_model return nil if location.nil? Mihari::Models::Geolocation.new( country: location["country"], country_code: location["country_code"] ) end |
#ports ⇒ Object
262 263 264 |
# File 'lib/mihari/structs/censys.rb', line 262 def ports (services || []).filter_map { |svc| svc["port"] } end |