Skip to content

Commit

Permalink
Merge pull request #15 from ninoseki/set-default-regexp
Browse files Browse the repository at this point in the history
refactor: set default regexp
  • Loading branch information
ninoseki committed Sep 26, 2020
2 parents c52a6ca + 9aa053d commit 574f595
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ Usage:

Options:
[--host=HOST] # Host header
[--port=N] # Port to check (80 or 443)
[--scheme=SCHEME] # Scheme to use (http or https)
[--port=N] # Port
[--scheme=SCHEME] # Scheme (http or https)
[--timeout=N] # Timeout in seconds
[--user-agent=USER_AGENT] # User Agent header
[--verify-ssl], [--no-verify-ssl] # Verify SSL or not
[--user-agent=USER_AGENT] # User Agent
[--verify-ssl], [--no-verify-ssl] # Whether to verify SSL or not
[--max-concurrency=N] # Concurrency limit for HTTP requests to scan

Scan an IP range & filter by a regexp
Scan an IP range & filter by a regexp (default regexp = .)
```

## License
Expand Down
4 changes: 2 additions & 2 deletions lib/rangescan/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

module RangeScan
class CLI < Thor
desc "scan [IP_WITH_SUBNET_MASK, REGEXP]", "Scan an IP range & filter by a regexp"
desc "scan [IP_WITH_SUBNET_MASK, REGEXP]", "Scan an IP range & filter by a regexp (default regexp = .)"
method_option :host, type: :string, desc: "Host header"
method_option :port, type: :numeric, desc: "Port"
method_option :scheme, type: :string, desc: "Scheme (http or https)"
method_option :timeout, type: :numeric, desc: "Timeout in seconds"
method_option :user_agent, type: :string, desc: "User Agent"
method_option :verify_ssl, type: :boolean, desc: "Whether to verify SSL or not"
method_option :max_concurrency, type: :numeric, desc: "Concurrency limit for HTTP requests to scan"
def scan(ip_with_subnet_mask, regexp)
def scan(ip_with_subnet_mask, regexp = ".")
symbolized_options = symbolize_hash_keys(options)
range = Range.new(ip_with_subnet_mask)

Expand Down
6 changes: 5 additions & 1 deletion spec/range_scan/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@

before { allow(scanner).to receive(:scan).and_return(data) }

describe "#censys" do
describe "#scan" do
before { allow(RangeScan::Scanner).to receive(:new).and_return(scanner) }

it do
expect { subject.start ["scan", "127.0.0.1/24", "foo"] }.to output(JSON.pretty_generate(data) + "\n").to_stdout
end

it do
expect { subject.start ["scan", "127.0.0.1/24"] }.to output(JSON.pretty_generate(data) + "\n").to_stdout
end

it do
expect { subject.start ["scan", "127.0.0.1/24", "bar"] }.to output("[\n\n]\n").to_stdout
end
Expand Down

0 comments on commit 574f595

Please sign in to comment.