Class: Mihari::Structs::Censys::Hit

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#autonomous_systemAutonomousSystem (readonly)

Returns:



106
# File 'lib/mihari/structs/censys.rb', line 106

attribute :autonomous_system, AutonomousSystem

#ipString (readonly)

Returns:

  • (String)


98
# File 'lib/mihari/structs/censys.rb', line 98

attribute :ip, Types::String

#locationLocation (readonly)

Returns:



102
# File 'lib/mihari/structs/censys.rb', line 102

attribute :location, Location

#metadataHash (readonly)

Returns:

  • (Hash)


110
# File 'lib/mihari/structs/censys.rb', line 110

attribute :metadata, Types::Hash

#servicesArray<Service> (readonly)

Returns:



114
# File 'lib/mihari/structs/censys.rb', line 114

attribute :services, Types.Array(Service)

Class Method Details

.from_dynamic!(d) ⇒ Object

Parameters:

  • d (Hash)


140
141
142
143
144
145
146
147
148
149
# File 'lib/mihari/structs/censys.rb', line 140

def from_dynamic!(d)
  d = Types::Hash[d]
  new(
    ip: d.fetch("ip"),
    location: Location.from_dynamic!(d.fetch("location")),
    autonomous_system: AutonomousSystem.from_dynamic!(d.fetch("autonomous_system")),
    metadata: d,
    services: d.fetch("services", []).map { |x| Service.from_dynamic!(x) }
  )
end

Instance Method Details

#artifactMihari::Models::Artifact



126
127
128
129
130
131
132
133
134
# File 'lib/mihari/structs/censys.rb', line 126

def artifact
  Models::Artifact.new(
    data: ip,
    metadata:,
    autonomous_system: autonomous_system.as,
    geolocation: location.geolocation,
    ports:
  )
end

#portsArray<Mihari::Port>

Returns:

  • (Array<Mihari::Port>)


119
120
121
# File 'lib/mihari/structs/censys.rb', line 119

def ports
  services.map(&:_port)
end