Class: Ronin::Recon::Config::Workers Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ronin/recon/config.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.

Represents the set of workers to use.

Constant Summary collapse

DEFAULT =

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

The default workers configuration.

Set[
  # NOTE: disabled due to rate limiting issues
  # 'api/crt_sh',
  'dns/lookup',
  'dns/mailservers',
  'dns/nameservers',
  'dns/reverse_lookup',
  'dns/srv_enum',
  'dns/subdomain_enum',
  'dns/suffix_enum',
  'net/ip_range_enum',
  'net/port_scan',
  'net/service_id',
  'ssl/cert_grab',
  'ssl/cert_enum',
  'web/dir_enum',
  'web/email_addresses',
  'web/spider'
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workers) ⇒ Workers

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 workers.

Parameters:

  • workers (Set<String>, Array<String>, Hash{String => Boolean})

    The set of worker IDs.

Raises:

  • (ArgumentError)

    The given workers argument was not a Set, Array, or Hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ronin/recon/config.rb', line 56

def initialize(workers)
  case workers
  when Set   then @ids = workers.dup
  when Array then @ids = workers.to_set
  when Hash
    @ids = DEFAULT.dup

    workers.each do |worker_id,enabled|
      if enabled then add(worker_id)
      else            delete(worker_id)
      end
    end
  else
    raise(ArgumentError,"workers value must be a Set, Array, or Hash: #{workers.inspect}")
  end
end

Instance Attribute Details

#idsSet<String> (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 set of worker IDs.

Returns:

  • (Set<String>)


45
46
47
# File 'lib/ronin/recon/config.rb', line 45

def ids
  @ids
end

Class Method Details

.defaultWorkers

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 default workers.

Returns:



99
100
101
# File 'lib/ronin/recon/config.rb', line 99

def self.default
  new(DEFAULT)
end

Instance Method Details

#add(worker_id) ⇒ self

Adds a worker to the workers.

Parameters:

  • worker_id (String)

    The worker ID to add.

Returns:

  • (self)


113
114
115
116
# File 'lib/ronin/recon/config.rb', line 113

def add(worker_id)
  @ids.add(worker_id)
  return self
end

#delete(worker_id) ⇒ Object

Deletes a worker from the workers.

Parameters:

  • worker_id (String)

    The worker ID to disable.



126
127
128
129
# File 'lib/ronin/recon/config.rb', line 126

def delete(worker_id)
  @ids.delete(worker_id)
  return self
end

#each {|worker_id| ... } ⇒ Enumerator

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.

Enumerates over each worker in the set.

Yields:

  • (worker_id)

    The given block will be passed each worker ID in the set.

Yield Parameters:

  • worker_id (String)

    A worker ID in the set.

Returns:

  • (Enumerator)

    If no block is given, an Enumerator will be returned.



157
158
159
# File 'lib/ronin/recon/config.rb', line 157

def each(&block)
  @ids.each(&block)
end

#eql?(other) ⇒ Boolean Also known as: ==

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.

Compares the workers to another object.

Parameters:

  • other (Object)

    The other object.

Returns:

  • (Boolean)


169
170
171
# File 'lib/ronin/recon/config.rb', line 169

def eql?(other)
  self.class == other.class && @ids == other.ids
end

#include?(worker_id) ⇒ Boolean

Determines if the worker is enabled in the workers.

Parameters:

  • worker_id (String)

    The worker ID to search for.

Returns:

  • (Boolean)


141
142
143
# File 'lib/ronin/recon/config.rb', line 141

def include?(worker_id)
  @ids.include?(worker_id)
end