Class: Ronin::Recon::Scope Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/recon/scope.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defines which domains, hosts, IP addresses are considered "in scope".

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values, ignore: []) ⇒ Scope

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.

Initializes the scope.

Parameters:

Raises:

  • (NotImplementedError)

    An unsupported value object was given.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ronin/recon/scope.rb', line 60

def initialize(values, ignore: [])
  @values = values
  @ignore = ignore

  @host_values = []
  @ip_values   = []

  values.each do |value|
    case value
    when Values::Wildcard, Values::Domain, Values::Host, Values::Website
      @host_values << value
    when Values::IP, Values::IPRange
      @ip_values << value
    else
      raise(NotImplementedError,"scope value type not supported: #{value.inspect}")
    end
  end
end

Instance Attribute Details

#ignoreArray<Value> (readonly)

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.

The list of values to ignore and are not considered "in scope".

Returns:



46
47
48
# File 'lib/ronin/recon/scope.rb', line 46

def ignore
  @ignore
end

#valuesArray<Values::Domain, Values::Host, Values::IPRange, Values::IP> (readonly)

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.

List of domain or IP range values which are considered "in scope".



41
42
43
# File 'lib/ronin/recon/scope.rb', line 41

def values
  @values
end

Instance Method Details

#include?(value) ⇒ Boolean

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.

Determines if a value is "in scope".

Parameters:

  • value (Value)

    The value to check.

Returns:

  • (Boolean)

    Indicates whether the value is "in scope" or not. If the given value is not a Domain, Host, IPRange, or IP then true is returned by default.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/ronin/recon/scope.rb', line 91

def include?(value)
  scope_values = case value
                 when Values::Wildcard,
                      Values::Domain,
                      Values::Host,
                      Values::Website,
                      Values::URL,
                      Values::EmailAddress
                   @host_values
                 when Values::IP,
                      Values::IPRange
                   @ip_values
                 end

  return false if @ignore.any? { |ignore| ignore === value }

  if (scope_values && !scope_values.empty?)
    scope_values.any? { |scope_value| scope_value === value }
  else
    true
  end
end