NexposeRunner 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02276abd1b4120d897508fcb94c7feaa3fccf278
4
- data.tar.gz: c46e6ce75664e562fd927c02001e5314413e2902
3
+ metadata.gz: 3fc954479b13a6d1ee5538438ef4e0e9d155acef
4
+ data.tar.gz: 92f8b3905afd4c71bc0f316c42b605d33b2cf2c6
5
5
  SHA512:
6
- metadata.gz: c1a363a68c45979d152092fb147b061947476f8043e4b5ea957d86933607ba51fe221bea9b674d45b9e8ed570fd856169fb42d1f2c69d091292286e8b3a714ab
7
- data.tar.gz: 11dd648fab97053056db276678cdf6dcd407b91266a3352e055bd81a90589040ab6296b30390c2f23db6fcb35af84155e8061412536671e5a7a39b8d9a9bed25
6
+ metadata.gz: faee2b9d52875bb8e2fe4b3112b96a49746953d1784ca29f8cd3b3c9beb00bc215eaf1440f7bfe459393474f564969175440b2a40446680bf1c61f71cafba9f6
7
+ data.tar.gz: 4bfb76dc4cf58c81f06c90d2c8ef071c472323b21861d831898c729ce23764e66d5cdc2373255459b21470233582539291f7177a7552f7ff090018b151328f78
data/bin/scan CHANGED
@@ -3,4 +3,12 @@
3
3
  require 'nexpose-runner/scan'
4
4
 
5
5
  $stdout.sync = true
6
- NexposeRunner::Scan.start ARGV[0], ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5], ARGV[6]
6
+ NexposeRunner::Scan.start({
7
+ 'connection_url' => ARGV[0],
8
+ 'username' => ARGV[1],
9
+ 'password' => ARGV[2],
10
+ 'port' => ARGV[3],
11
+ 'site_name' => ARGV[4],
12
+ 'ip_addresses' => ARGV[5],
13
+ 'scan_template' => ARGV[6]
14
+ })
@@ -1,4 +1,4 @@
1
1
  module NexposeRunner
2
- VERSION = '0.0.4'
3
- end
2
+ VERSION = '0.0.5'
3
+ end
4
4
 
@@ -6,9 +6,9 @@ require 'nexpose-runner/scan_run_description'
6
6
 
7
7
  module NexposeRunner
8
8
  module Scan
9
- def Scan.start(connection_url, username, password, port, site_name, ip_addresses, scan_template)
9
+ def Scan.start(options)
10
10
 
11
- run_details = ScanRunDescription.new connection_url, username, password, port, site_name, ip_addresses, scan_template
11
+ run_details = ScanRunDescription.new(options)
12
12
  run_details.verify
13
13
 
14
14
  nsc = get_new_nexpose_connection(run_details)
@@ -3,14 +3,14 @@ class ScanRunDescription
3
3
  @@port_value = ''
4
4
  @@ip_addresses = ''
5
5
 
6
- def initialize(connection_url, username, password, port, site_name, ip_addresses, scan_template)
7
- self.connection_url = connection_url
8
- self.username = username
9
- self.password = password
10
- @@port_value = port
11
- self.site_name = site_name
12
- self.ip_addresses = ip_addresses
13
- self.scan_template = scan_template
6
+ def initialize(options)
7
+ self.connection_url = options['connection_url']
8
+ self.username = options['username']
9
+ self.password = options['password']
10
+ @@port_value = options['port']
11
+ self.site_name = options['site_name']
12
+ self.ip_addresses = options['ip_addresses']
13
+ self.scan_template = options['scan_template']
14
14
  end
15
15
 
16
16
  def verify
data/spec/scan_spec.rb CHANGED
@@ -42,76 +42,115 @@ describe 'nexpose-runner' do
42
42
  @mock_nexpose_client = get_mock_nexpose_client
43
43
  @mock_nexpose_site = get_mock_nexpose_site
44
44
  @mock_report = get_mock_report
45
+
46
+ @options = {
47
+ 'connection_url' => @expected_connection,
48
+ 'username' => @expected_username,
49
+ 'password' => @expected_password,
50
+ 'port' => @expected_port,
51
+ 'site_name' => @expected_site_name,
52
+ 'ip_addresses' => @expected_ips,
53
+ 'scan_template' => @expected_scan_template
54
+ }
55
+
45
56
  end
46
57
 
47
58
  it 'should create a session with the nexpose server' do
48
59
  expect(Nexpose::Connection).to receive(:new)
49
- .with(@expected_connection, @expected_username, @expected_password, @expected_port)
60
+ .with(@options['connection_url'],
61
+ @options['username'],
62
+ @options['password'],
63
+ @options['port'])
50
64
  .and_return(@mock_nexpose_client)
51
65
 
52
66
  expect(@mock_nexpose_client).to receive(:login)
53
67
  .and_return(true)
54
68
 
55
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
69
+ NexposeRunner::Scan.start(@options)
56
70
  end
57
71
 
58
72
  it 'should throw an error if no connection url is passed' do
59
- expect { NexposeRunner::Scan.start('', @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me the URL/IP address to your Nexpose Server')
60
- expect { NexposeRunner::Scan.start(nil, @expected_port, @expected_username, @expected_password, @expected_site_name, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me the URL/IP address to your Nexpose Server')
73
+ options = @options.clone
74
+ options['connection_url'] = nil
75
+ expect {
76
+ NexposeRunner::Scan.start(options)
77
+ }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me the URL/IP address to your Nexpose Server')
61
78
  end
62
79
 
63
80
  it 'should throw an error if no username is passed' do
64
- expect { NexposeRunner::Scan.start(@expected_connection, '', @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a username to login to Nexpose with')
65
- expect { NexposeRunner::Scan.start(@expected_connection, nil, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a username to login to Nexpose with')
81
+ options = @options.clone
82
+ options['username'] = nil
83
+ expect {
84
+ NexposeRunner::Scan.start(options)
85
+ }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a username to login to Nexpose with')
66
86
  end
67
87
 
68
88
  it 'should throw an error if no password is passed' do
69
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, '', @expected_port, @expected_site_name, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a password to login to Nexpose with')
70
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, nil, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a password to login to Nexpose with')
89
+ options = @options.clone
90
+ options['password'] = nil
91
+ expect {
92
+ NexposeRunner::Scan.start(options)
93
+ }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a password to login to Nexpose with')
71
94
  end
72
95
 
73
96
  it 'should throw an error if no site name is passed' do
74
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, '', @expected_ips, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a Nexpose Site Name')
75
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, nil, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a Nexpose Site Name')
97
+ options = @options.clone
98
+ options['site_name'] = nil
99
+ expect {
100
+ NexposeRunner::Scan.start(options)
101
+ }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a Nexpose Site Name')
76
102
  end
77
103
 
78
104
  it 'should throw an error if no ip address is passed' do
79
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, '', @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me an IP Address to scan')
105
+ options = @options.clone
106
+ options['ip_addresses'] = '';
107
+ expect {
108
+ NexposeRunner::Scan.start(options)
109
+ }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me an IP Address to scan')
80
110
  end
81
111
 
82
112
  it 'should throw an error if no scan template is passed' do
83
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, '') }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a Scan Template to use')
84
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, nil) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a Scan Template to use')
113
+ options = @options.clone
114
+ options['scan_template'] = nil
115
+ expect {
116
+ NexposeRunner::Scan.start(options)
117
+ }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me a Scan Template to use')
85
118
  end
86
119
 
87
120
  it 'should use 3780 as default if port is empty string' do
88
121
  expect(Nexpose::Connection).to receive(:new)
89
- .with(@expected_connection, @expected_username, @expected_password, '3780')
122
+ .with(@options['connection_url'],
123
+ @options['username'],
124
+ @options['password'],
125
+ '3780')
90
126
  .and_return(@mock_nexpose_client)
91
127
 
92
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, '', @expected_site_name, @expected_ips, @expected_scan_template)
128
+
129
+ run_options = @options.clone
130
+ run_options['port'] = ''
131
+ NexposeRunner::Scan.start(run_options)
93
132
  end
94
133
 
95
134
  it 'should create a new Nexpose site with the supplied site name and scan template' do
96
135
  expect(Nexpose::Site).to receive(:new)
97
- .with(@expected_site_name, @expected_scan_template)
136
+ .with(@options['site_name'], @options['scan_template'])
98
137
  .and_return(@mock_nexpose_site)
99
138
 
100
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
139
+ NexposeRunner::Scan.start(@options)
101
140
  end
102
141
 
103
142
  it 'should add the supplied ip address to the newly created site' do
104
143
  @expected_ips.split(',').each { |ip|
105
144
  expect(@mock_nexpose_site).to receive(:add_ip).with(ip)
106
145
  }
107
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
146
+ NexposeRunner::Scan.start(@options)
108
147
  end
109
148
 
110
149
  it 'should save the new site configuration' do
111
150
  expect(@mock_nexpose_site).to receive(:save)
112
151
  .with(@mock_nexpose_client)
113
152
 
114
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
153
+ NexposeRunner::Scan.start(@options)
115
154
  end
116
155
 
117
156
  it 'should initiate a scan' do
@@ -119,14 +158,14 @@ describe 'nexpose-runner' do
119
158
  .with(@mock_nexpose_client)
120
159
  .and_return(@mock_scan)
121
160
 
122
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
161
+ NexposeRunner::Scan.start(@options)
123
162
  end
124
163
 
125
164
  describe 'wait for the Nexpose Scan to complete' do
126
165
  it 'should call to check the status of the scan' do
127
166
  expect(@mock_nexpose_client).to receive(:scan_status).with(@mock_scan_id)
128
167
 
129
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
168
+ NexposeRunner::Scan.start(@options)
130
169
  end
131
170
 
132
171
  it 'should call to check the status until it is not running' do
@@ -142,7 +181,7 @@ describe 'nexpose-runner' do
142
181
  .once
143
182
  .ordered
144
183
 
145
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
184
+ NexposeRunner::Scan.start(@options)
146
185
  end
147
186
 
148
187
  it 'should sleep for 3 seconds if the status is still running' do
@@ -160,7 +199,7 @@ describe 'nexpose-runner' do
160
199
 
161
200
  expect(NexposeRunner::Scan).to receive(:sleep).with(3).exactly(4).times
162
201
 
163
- NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
202
+ NexposeRunner::Scan.start(@options)
164
203
  end
165
204
  end
166
205
 
@@ -174,14 +213,18 @@ describe 'nexpose-runner' do
174
213
  expect_report_to_be_called_with(CONSTANTS::SOFTWARE_REPORT_NAME, CONSTANTS::SOFTWARE_REPORT_QUERY, @mock_software_report)
175
214
  expect_report_to_be_called_with(CONSTANTS::POLICY_REPORT_NAME, CONSTANTS::POLICY_REPORT_QUERY, @mock_policy_report)
176
215
 
177
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, CONSTANTS::VULNERABILITY_FOUND_MESSAGE)
216
+ expect {
217
+ NexposeRunner::Scan.start(@options)
218
+ }.to raise_error(StandardError, CONSTANTS::VULNERABILITY_FOUND_MESSAGE)
178
219
  end
179
220
  end
180
221
 
181
222
  it 'should throw exception if vulnerability exists' do
182
223
  expect_report_to_be_called_with(CONSTANTS::VULNERABILITY_REPORT_NAME, CONSTANTS::VULNERABILITY_REPORT_QUERY, @mock_vuln_report)
183
224
 
184
- expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template) }.to raise_error(StandardError, CONSTANTS::VULNERABILITY_FOUND_MESSAGE)
225
+ expect {
226
+ NexposeRunner::Scan.start(@options)
227
+ }.to raise_error(StandardError, CONSTANTS::VULNERABILITY_FOUND_MESSAGE)
185
228
  end
186
229
  end
187
230
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: NexposeRunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Gibson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-26 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nexpose