Class: Workers::Recon

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
workers/recon.rb

Overview

ronin-recon run worker.

Constant Summary collapse

Params =

The accepted JSON params which will be passed to #perform.

Dry::Schema::JSON() do
  required(:scope).array(:string).each(:filled?)

  optional(:ignore).maybe(:array)
  optional(:max_depth).maybe(:integer)
end

Instance Method Summary collapse

Instance Method Details

#perform(params) ⇒ Object

Processes a recon job.

Parameters:

  • params (Hash{String => Object})

    The JSON deserialized params for the job.

Raises:

  • (ArgumentError)

    The params could not be validated or coerced.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'workers/recon.rb', line 54

def perform(params)
  kwargs = validate(params)
  values = kwargs[:scope].map(&Ronin::Recon::Value.method(:parse))

  ignore = if (ignore_kwargs = kwargs[:ignore])
             ignore_kwargs.map(&Ronin::Recon::Value.method(:parse))
           else
             []
           end

  Ronin::Recon::Engine.run(values, ignore:    ignore,
                                   max_depth: kwargs[:max_depth]) do |engine|
    engine.on(:value) do |value,parent|
      Ronin::Recon::Importer.import_value(value)
    end
  end
end

#validate(params) ⇒ Hash{Symbol => Object}

Validates the given job params.

Parameters:

  • params (Hash{String => Object})

    The JSON deserialized params for the job.

Returns:

  • (Hash{Symbol => Object})

    The validated and coerced params as a Symbol Hash.

Raises:

  • (ArgumentError)

    The params could not be validated or coerced.



84
85
86
87
88
89
90
91
92
# File 'workers/recon.rb', line 84

def validate(params)
  result = Params.call(params)

  if result.failure?
    raise(ArgumentError,"invalid recon params (#{params.inspect}): #{result.errors.inspect}")
  end

  return result.to_h
end