Skip to content

Commit

Permalink
Added WorkerSet#load_file (issue #85).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Jan 9, 2024
1 parent 440462a commit 013027b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/ronin/recon/worker_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ def load(worker_id)
self << Recon.load_class(worker_id)
end

#
# Loads a worker from a file and adds it to the worker set.
#
# @param [String] path
# The path to the file.
#
# @return [self]
#
def load_file(path)
self << Recon.load_class_from_file(path)
end

#
# Removes a worker class from the worker set.
#
Expand Down
23 changes: 23 additions & 0 deletions spec/fixtures/test_worker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'ronin/recon/worker'

module Ronin
module Recon
class TestWorker < Worker

register 'test_worker'

summary 'Test worker'
description <<~DESC
This is a test worker.
DESC
author 'Postmodern', email: 'postmodern.mod3@gmail.com'

intensity :passive

def process(value)
# no-op
end

end
end
end
12 changes: 12 additions & 0 deletions spec/worker_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@
end
end

describe "#load_file" do
let(:fixtures_dir) { File.join(__dir__,'fixtures') }
let(:path) { File.join(fixtures_dir,'test_worker.rb') }

before { subject.load_file(path) }

it "must load the file and add the worker to the worker set" do
expect(defined?(Ronin::Recon::TestWorker)).to be_truthy
expect(subject.workers).to include(Ronin::Recon::TestWorker)
end
end

describe "#delete" do
context "when the worker class does exist in the worker set" do
let(:worker) { Ronin::Recon::DNS::SubdomainEnum }
Expand Down

0 comments on commit 013027b

Please sign in to comment.