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:



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

attribute :autonomous_system, AutonomousSystem.optional

#ipString (readonly)

Returns:

  • (String)


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

attribute :ip, Types::String

#locationLocation (readonly)

Returns:



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

attribute :location, Location

#metadataHash (readonly)

Returns:

  • (Hash)


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

attribute :metadata, Types::Hash

#servicesArray<Service> (readonly)

Returns:



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

attribute :services, Types.Array(Service)

Class Method Details

.from_dynamic!(d) ⇒ Object

Parameters:

  • d (Hash)


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

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["autonomous_system"]),
    metadata: d,
    services: d.fetch("services", []).map { |x| Service.from_dynamic!(x) }
  )
end

Instance Method Details

#artifactMihari::Models::Artifact



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

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>)


121
122
123
# File 'lib/mihari/structs/censys.rb', line 121

def ports
  services.map(&:_port)
end