Skip to content

Commit

Permalink
Add Ronin::Recon::Config#to_yaml method
Browse files Browse the repository at this point in the history
  • Loading branch information
moozzi committed Aug 19, 2024
1 parent d6a4822 commit aa83557
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/ronin/recon/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,20 @@ def eql?(other)

alias == eql?

#
# Converts config into YAML string.
#
# @return [String]
#
def to_yaml
res = {}

res[:params] = params unless params.empty?
res[:concurrency] = concurrency unless concurrency.empty?
res[:workers] = workers.ids.to_a if workers

res.to_yaml
end
end
end
end
9 changes: 9 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -759,4 +759,13 @@
end
end
end

describe "#to_yaml" do
subject { described_class.load(expected_yml) }
let(:expected_yml) { File.join(fixtures_dir,'with_params_and_workers.yml') }

it "must convert Config into YAML string" do
expect(subject.to_yaml).to eq(File.read(expected_yml))
end
end
end
24 changes: 24 additions & 0 deletions spec/fixtures/config/with_params_and_workers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
:params:
test/worker1:
:foo: a
:bar: b
test/worker2:
:foo: x
:bar: "y"
:workers:
- 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

0 comments on commit aa83557

Please sign in to comment.