Class: Mihari::Structs::Shodan::InternetDBResponse

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ InternetDBResponse

Parameters:

  • d (Hash)

Returns:



290
291
292
293
294
295
296
297
298
299
300
# File 'lib/mihari/structs/shodan.rb', line 290

def from_dynamic!(d)
  d = Types::Hash[d]
  new(
    ip: d.fetch("ip"),
    ports: d.fetch("ports"),
    cpes: d.fetch("cpes"),
    hostnames: d.fetch("hostnames"),
    tags: d.fetch("tags"),
    vulns: d.fetch("vulns")
  )
end

.from_json!(json) ⇒ InternetDBResponse

Parameters:

  • json (String)

Returns:



307
308
309
# File 'lib/mihari/structs/shodan.rb', line 307

def from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#cpesArray<String>

Returns:

  • (Array<String>)


259
260
261
# File 'lib/mihari/structs/shodan.rb', line 259

def cpes
  attributes[:cpes]
end

#hostnamesArray<String>

Returns:

  • (Array<String>)


266
267
268
# File 'lib/mihari/structs/shodan.rb', line 266

def hostnames
  attributes[:hostnames]
end

#ipString

Returns:

  • (String)


245
246
247
# File 'lib/mihari/structs/shodan.rb', line 245

def ip
  attributes[:ip]
end

#portsArray<Integer>

Returns:

  • (Array<Integer>)


252
253
254
# File 'lib/mihari/structs/shodan.rb', line 252

def ports
  attributes[:ports]
end

#tagsArray<String>

Returns:

  • (Array<String>)


273
274
275
# File 'lib/mihari/structs/shodan.rb', line 273

def tags
  attributes[:tags]
end

#vulnsArray<String>

Returns:

  • (Array<String>)


280
281
282
# File 'lib/mihari/structs/shodan.rb', line 280

def vulns
  attributes[:vulns]
end