From a6ba9eef569439ee108fdb9b8f14e356dc01376b Mon Sep 17 00:00:00 2001 From: Postmodern Date: Fri, 6 Sep 2024 01:37:17 -0700 Subject: [PATCH] Added `--output-dir` to `ronin-recon run` (closes #180). --- lib/ronin/recon/cli/commands/run.rb | 9 +++++++++ man/ronin-recon-run.1.md | 3 +++ spec/cli/commands/run_spec.rb | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/lib/ronin/recon/cli/commands/run.rb b/lib/ronin/recon/cli/commands/run.rb index 5ce70eb..8551b3d 100644 --- a/lib/ronin/recon/cli/commands/run.rb +++ b/lib/ronin/recon/cli/commands/run.rb @@ -56,6 +56,7 @@ module Commands # -I, --ignore VALUE The values to ignore in result # -F txt|list|csv|json|ndjson|dot|svg|png|pdf, # --output-format The output format + # --output-dir DIR Writes data to an output directory # --import Imports each newly discovered value into the Ronin database # -h, --help Print help information # @@ -153,6 +154,14 @@ class Run < Command }, desc: 'The output format' + option :output_dir, value: { + type: String, + usage: 'DIR' + }, + desc: 'Writes data to an output directory' do |path| + @outputs << [path, OutputFormats::Dir] + end + option :import, desc: 'Imports each newly discovered value into the Ronin database' option :ignore, short: '-I', diff --git a/man/ronin-recon-run.1.md b/man/ronin-recon-run.1.md index 91da395..8a9e544 100644 --- a/man/ronin-recon-run.1.md +++ b/man/ronin-recon-run.1.md @@ -70,6 +70,9 @@ Runs the recon engine with one or more initial values. : The output format. If not specified, the output format will be inferred from the `--output` *FILE* extension. +`--output-dir` *DIR* +: Writes the output to a directory of separate files for each value type. + `--import` : Imports each newly discovered value into the Ronin database. diff --git a/spec/cli/commands/run_spec.rb b/spec/cli/commands/run_spec.rb index 4febdc8..e277058 100644 --- a/spec/cli/commands/run_spec.rb +++ b/spec/cli/commands/run_spec.rb @@ -162,6 +162,17 @@ end end + context "when the '--output-dir' option is given" do + let(:path) { 'path/to/dir' } + let(:argv) { ['--output-dir', path] } + + it "must add the output directory path to #outputs" do + expect(subject.outputs).to eq([ + [path, Ronin::Recon::OutputFormats::Dir] + ]) + end + end + context "when the '--ignore' option is given" do let(:value1) { Ronin::Recon::Values::Host.new('staging.example.com') } let(:value2) { Ronin::Recon::Values::Host.new('dev.example.com') }