Skip to content

Commit

Permalink
Added Ronin::Masscan.parse.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 4, 2023
1 parent 15b69fe commit d3f56e6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/ronin/masscan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions spec/masscan_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d3f56e6

Please sign in to comment.