Class: Mihari::Structs::Shodan::Match
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Mihari::Structs::Shodan::Match
- Includes:
- Mixins::AutonomousSystem
- Defined in:
- lib/mihari/structs/shodan.rb
Class Method Summary collapse
Instance Method Summary collapse
- #asn ⇒ String?
- #hostnames ⇒ Array<String>
- #ip_str ⇒ String
- #location ⇒ Location
- #metadata ⇒ Hash
- #port ⇒ Integer
- #to_asn ⇒ Mihari::AutonomousSystem?
Methods included from Mixins::AutonomousSystem
Class Method Details
.from_dynamic!(d) ⇒ Match
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/mihari/structs/shodan.rb', line 120 def from_dynamic!(d) d = Types::Hash[d] # hostnames should be an array of string but sometimes Shodan returns a string # e.g. "hostnames": "set(['149.28.146.131.vultr.com', 'rebs.ga'])", # https://github.com/ninoseki/mihari/issues/424 # so use an empty array if hostnames is a string hostnames = d.fetch("hostnames") hostnames = [] if hostnames.is_a?(String) new( asn: d["asn"], hostnames: hostnames, location: Location.from_dynamic!(d.fetch("location")), domains: d.fetch("domains"), ip_str: d.fetch("ip_str"), port: d.fetch("port"), metadata: d ) end |
Instance Method Details
#asn ⇒ String?
66 67 68 |
# File 'lib/mihari/structs/shodan.rb', line 66 def asn attributes[:asn] end |
#hostnames ⇒ Array<String>
73 74 75 |
# File 'lib/mihari/structs/shodan.rb', line 73 def hostnames attributes[:hostnames] end |
#ip_str ⇒ String
87 88 89 |
# File 'lib/mihari/structs/shodan.rb', line 87 def ip_str attributes[:ip_str] end |
#location ⇒ Location
80 81 82 |
# File 'lib/mihari/structs/shodan.rb', line 80 def location attributes[:location] end |
#metadata ⇒ Hash
101 102 103 |
# File 'lib/mihari/structs/shodan.rb', line 101 def attributes[:metadata] end |
#port ⇒ Integer
94 95 96 |
# File 'lib/mihari/structs/shodan.rb', line 94 def port attributes[:port] end |
#to_asn ⇒ Mihari::AutonomousSystem?
108 109 110 111 112 |
# File 'lib/mihari/structs/shodan.rb', line 108 def to_asn return nil if asn.nil? Mihari::AutonomousSystem.new(asn: normalize_asn(asn)) end |