Skip to content

Commit

Permalink
Rubcocop
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-r7 committed Aug 18, 2020
1 parent fa60cdc commit b821f03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
3 changes: 0 additions & 3 deletions lib/msf/core/opt_http_rhost_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ def single_rhost?(value)
return false unless walker.valid?
# if there is only a single ip then it's not a range
walker.length == 1
rescue ::Exception
# couldn't create a range therefore it isn't one
return true
end

end
Expand Down
13 changes: 5 additions & 8 deletions spec/lib/msf/core/opt_http_rhost_url_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,18 @@

it_behaves_like 'an option', valid_values, invalid_values, 'rhost http url'


describe '#calculate_value' do
[
{ expected_url: 'http://example.com', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 80, 'SSL' => false, 'TARGETURI' => '', 'URI' => '', 'VHOST' => 'example.com', 'HttpUsername' => '', 'HttpPassword' => '' } },
{ expected_url: 'https://example.com', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 443, 'SSL' => true, 'TARGETURI' => '', 'URI' => '', 'VHOST' => 'example.com', 'HttpUsername' => '', 'HttpPassword' => '' } },
{ expected_url: 'http://user:pass@example.com:1234/somePath', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 1234, 'SSL' => false, 'TARGETURI' => '/somePath', 'URI' => '/somePath', 'VHOST' => 'example.com', 'HttpUsername' => 'user', 'HttpPassword' => 'pass' } },
{ expected_url: 'http://127.0.0.1', datastore: { 'RHOSTS' => '127.0.0.1', 'RPORT' => 80, 'SSL' => false, 'TARGETURI' => '', 'URI' => '', 'VHOST' => nil, 'HttpUsername' => '', 'HttpPassword' => '' } }
].each do | test |

{ expected_url: 'http://example.com', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 80, 'SSL' => false, 'TARGETURI' => '', 'URI' => '', 'VHOST' => 'example.com', 'HttpUsername' => '', 'HttpPassword' => '' } },
{ expected_url: 'https://example.com', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 443, 'SSL' => true, 'TARGETURI' => '', 'URI' => '', 'VHOST' => 'example.com', 'HttpUsername' => '', 'HttpPassword' => '' } },
{ expected_url: 'http://user:pass@example.com:1234/somePath', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 1234, 'SSL' => false, 'TARGETURI' => '/somePath', 'URI' => '/somePath', 'VHOST' => 'example.com', 'HttpUsername' => 'user', 'HttpPassword' => 'pass' } },
{ expected_url: 'http://127.0.0.1', datastore: { 'RHOSTS' => '127.0.0.1', 'RPORT' => 80, 'SSL' => false, 'TARGETURI' => '', 'URI' => '', 'VHOST' => nil, 'HttpUsername' => '', 'HttpPassword' => '' } }
].each do |test|
context test[:datastore].to_s do
it "should return #{test[:expected_url]}" do
expect(subject.calculate_value(test[:datastore])).to eq(test[:expected_url])
end
end
end
end

end

0 comments on commit b821f03

Please sign in to comment.