Class: Ronin::Recon::Values::Wildcard
- Inherits:
-
Ronin::Recon::Value
- Object
- Ronin::Recon::Value
- Ronin::Recon::Values::Wildcard
- Defined in:
- lib/ronin/recon/values/wildcard.rb
Overview
Represents a wildcard host-name (ex: *.example.com
).
Instance Attribute Summary collapse
-
#template ⇒ String
readonly
The wildcard host name.
Class Method Summary collapse
-
.value_type ⇒ :wildcard
private
Returns the type or kind of recon value.
Instance Method Summary collapse
-
#===(other) ⇒ Boolean
Case equality method used for fuzzy matching.
-
#as_json ⇒ Hash{Symbol => Object}
Coerces the wildcard value into JSON.
-
#eql?(other) ⇒ Boolean
Compares the value to another value.
-
#hash ⇒ Integer
The "hash" value of the wildcard host name.
-
#initialize(template) ⇒ Wildcard
constructor
Initializes the wildcard host object.
-
#to_s ⇒ String
(also: #to_str)
Converts the wildcard host object to a String.
Methods inherited from Ronin::Recon::Value
Constructor Details
#initialize(template) ⇒ Wildcard
Initializes the wildcard host object.
46 47 48 49 50 |
# File 'lib/ronin/recon/values/wildcard.rb', line 46 def initialize(template) @template = template @prefix, @suffix = template.split('*',2) end |
Instance Attribute Details
#template ⇒ String (readonly)
The wildcard host name.
39 40 41 |
# File 'lib/ronin/recon/values/wildcard.rb', line 39 def template @template end |
Class Method Details
.value_type ⇒ :wildcard
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is used internally to map a recon value class to a printable type.
Returns the type or kind of recon value.
133 134 135 |
# File 'lib/ronin/recon/values/wildcard.rb', line 133 def self.value_type :wildcard end |
Instance Method Details
#===(other) ⇒ Boolean
Case equality method used for fuzzy matching.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ronin/recon/values/wildcard.rb', line 73 def ===(other) case other when Wildcard eql?(other) when Domain, Host name = other.name name.start_with?(@prefix) && name.end_with?(@suffix) when URL host = other.uri.host host.start_with?(@prefix) && host.end_with?(@suffix) else false end end |
#as_json ⇒ Hash{Symbol => Object}
Coerces the wildcard value into JSON.
118 119 120 |
# File 'lib/ronin/recon/values/wildcard.rb', line 118 def as_json {type: :wildcard, template: @template} end |
#eql?(other) ⇒ Boolean
Compares the value to another value.
59 60 61 |
# File 'lib/ronin/recon/values/wildcard.rb', line 59 def eql?(other) other.kind_of?(self.class) && @template == other.template end |
#hash ⇒ Integer
The "hash" value of the wildcard host name.
96 97 98 |
# File 'lib/ronin/recon/values/wildcard.rb', line 96 def hash [self.class, @template].hash end |
#to_s ⇒ String Also known as: to_str
Converts the wildcard host object to a String.
106 107 108 |
# File 'lib/ronin/recon/values/wildcard.rb', line 106 def to_s @template.to_s end |