diff --git a/lib/ronin/masscan.rb b/lib/ronin/masscan.rb index e90b8b1..b2a85b9 100644 --- a/lib/ronin/masscan.rb +++ b/lib/ronin/masscan.rb @@ -76,5 +76,28 @@ def self.scan(*ips,**kwargs,&block) return status end end + + # + # Parses a masscan output file. + # + # @param [String] path + # The path to the output file. + # + # @param [:binary, :list, :json, :ndjson] format + # The format of the output file. Defaults to {infer_format}. + # + # @return [::Masscan::OutputFile] + # The parsed masscan output file. + # + # @raise [ArgumentError] + # The output format was not given and it cannot be inferred. + # + # @see https://rubydoc.info/gems/ruby-masscan/Masscan/OutputFile + # + # @api public + # + def self.parse(path,**kwargs) + ::Masscan::OutputFile.new(path,**kwargs) + end end end diff --git a/spec/masscan_spec.rb b/spec/masscan_spec.rb new file mode 100644 index 0000000..bf4a249 --- /dev/null +++ b/spec/masscan_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' +require 'ronin/masscan' + +describe Ronin::Masscan do + let(:fixtures_dir) { File.join(__dir__,'spec','fixtures') } + + describe ".parse" do + let(:path) { File.join(fixtures_dir,'masscan.json') } + + it "must return a Masscan::OutputFile object for the given path" do + output_file = subject.parse(path) + + expect(output_file).to be_kind_of(Masscan::OutputFile) + expect(output_file.path).to eq(path) + end + end +end