Class: Ronin::Recon::CLI::WorkerCommand Private

Inherits:
Command
  • Object
show all
Defined in:
lib/ronin/recon/cli/worker_command.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.

Base class for commands which load an individual worker.

Direct Known Subclasses

Commands::Test, Commands::Worker

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#worker_classClass<Worker>? (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 loaded worker class.

Returns:



47
48
49
# File 'lib/ronin/recon/cli/worker_command.rb', line 47

def worker_class
  @worker_class
end

Instance Method Details

#load_worker(id) ⇒ Object

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.

Loads the recon worker class and sets #worker_class.

Parameters:

  • id (String)

    The recon worker name to load.



73
74
75
76
77
78
79
80
81
82
# File 'lib/ronin/recon/cli/worker_command.rb', line 73

def load_worker(id)
  @worker_class = Recon.load_class(id)
rescue Recon::ClassNotFound => error
  print_error(error.message)
  exit(1)
rescue => error
  print_exception(error)
  print_error("an unhandled exception occurred while loading recon worker #{id}")
  exit(-1)
end

#load_worker_from(file) ⇒ Object

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.

Loads the recon worker class from the given file and sets #worker_class.

Parameters:

  • file (String)

    The file to load the recon worker class from.



91
92
93
94
95
96
97
98
99
100
# File 'lib/ronin/recon/cli/worker_command.rb', line 91

def load_worker_from(file)
  @worker_class = Recon.load_class_from_file(file)
rescue Recon::ClassNotFound => error
  print_error(error.message)
  exit(1)
rescue => error
  print_exception(error)
  print_error("an unhandled exception occurred while loading recon worker from file #{file}")
  exit(-1)
end

#run(name = nil) ⇒ Class<Worker>

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.

Loads the recon worker class.

Parameters:

  • name (String, nil) (defaults to: nil)

    The optional recon worker name to load.

Returns:

  • (Class<Worker>)

    The loaded recon worker class.



58
59
60
61
62
63
64
65
# File 'lib/ronin/recon/cli/worker_command.rb', line 58

def run(name=nil)
  if name              then load_worker(name)
  elsif options[:file] then load_worker_from(options[:file])
  else
    print_error("must specify --file or a NAME")
    exit(-1)
  end
end