Module: Ronin::Recon::Value::Parser
- Defined in:
- lib/ronin/recon/value/parser.rb
Overview
Module that parses strings into Ronin::Recon::Values::IP, Ronin::Recon::Values::IPRange, Ronin::Recon::Values::Domain, Ronin::Recon::Values::Host, or Ronin::Recon::Values::Website.
Constant Summary collapse
- IP_REGEX =
Regular expression to match IPv4 and IPv6 addresses.
Support::Network::IP::REGEX
- IP_RANGE_REGEX =
Regular expression to match IPv4 and IPv6 CIDR ranges.
Support::Network::IPRange::REGEX
- HOSTNAME_REGEX =
Regular expression to match sub-domain host-names.
/\A(?:[a-zA-Z0-9_-]{1,63}\.)+#{Support::Text::Patterns::DOMAIN}\z/
- DOMAIN_REGEX =
Regular expression to match domain host-names.
/\A#{Support::Text::Patterns::DOMAIN}\z/
- WILDCARD_REGEX =
Regular expression to match wildcard host-names.
/\A\*(?:\.[a-z0-9_-]+)+\z/
- WEBSITE_REGEX =
Regular expression to match https:// and http:// website base URLs.
%r{\Ahttp(?:s)?://[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)*(?::\d+)?/?\z}
Class Method Summary collapse
-
.parse(string) ⇒ Values::IP, ...
Parses a value string.
Class Method Details
.parse(string) ⇒ Values::IP, ...
Parses a value string.
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ronin/recon/value/parser.rb', line 79 def self.parse(string) case string when IP_REGEX then Values::IP.new(string) when IP_RANGE_REGEX then Values::IPRange.new(string) when WEBSITE_REGEX then Values::Website.parse(string) when WILDCARD_REGEX then Values::Wildcard.new(string) when HOSTNAME_REGEX then Values::Host.new(string) when DOMAIN_REGEX then Values::Domain.new(string) else raise(UnknownValue,"unrecognized recon value: #{string.inspect}") end end |