NexposeRunner 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/lib/NexposeRunner/version.rb +1 -1
- data/lib/nexpose-runner/scan.rb +6 -4
- data/lib/nexpose-runner/scan_run_description.rb +14 -6
- data/spec/scan_spec.rb +29 -30
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MTRiZGMzMjZmNzFlNDhhZWI4MTlkNGIxYmIyMzFhMzM5YjcwYTI2MA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 02276abd1b4120d897508fcb94c7feaa3fccf278
|
4
|
+
data.tar.gz: c46e6ce75664e562fd927c02001e5314413e2902
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MTY1YjJhMTczOTg3YzhiMzI4Y2MzZDJkN2QwZjFjOGI5ZTA2YWY0MDk1ZDNk
|
11
|
-
N2ZlNzYwMDVmZjA2NWU3ZDk2NjZhNWJlNTM3N2VjNDI0MjNkMmQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NWIzNzEyMmU1ZjM2NTQ2YTIwZGFjZjAwYTQ3YTA5M2ZlMGU1MzcxZWEwNWQ2
|
14
|
-
MzEwZWM3MzExMGIyZWI3OTk4MjRkZWJiZDA4Mzg3Zjk1ZDY0MzYxZDk5OTA3
|
15
|
-
ODM1ZGU2YmNmZGUzZjE0MjQ4MzViZTM5ZDg4MjNmYjcxMWVlMTQ=
|
6
|
+
metadata.gz: c1a363a68c45979d152092fb147b061947476f8043e4b5ea957d86933607ba51fe221bea9b674d45b9e8ed570fd856169fb42d1f2c69d091292286e8b3a714ab
|
7
|
+
data.tar.gz: 11dd648fab97053056db276678cdf6dcd407b91266a3352e055bd81a90589040ab6296b30390c2f23db6fcb35af84155e8061412536671e5a7a39b8d9a9bed25
|
data/lib/nexpose-runner/scan.rb
CHANGED
@@ -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,
|
9
|
+
def Scan.start(connection_url, username, password, port, site_name, ip_addresses, scan_template)
|
10
10
|
|
11
|
-
run_details = ScanRunDescription.new connection_url, username, password, port, site_name,
|
11
|
+
run_details = ScanRunDescription.new connection_url, username, password, port, site_name, ip_addresses, scan_template
|
12
12
|
run_details.verify
|
13
13
|
|
14
14
|
nsc = get_new_nexpose_connection(run_details)
|
@@ -59,9 +59,11 @@ module NexposeRunner
|
|
59
59
|
def self.create_site(run_details, nsc)
|
60
60
|
puts "Creating a nexpose site named #{run_details.site_name}"
|
61
61
|
site = Nexpose::Site.new run_details.site_name, run_details.scan_template
|
62
|
-
|
62
|
+
run_details.ip_addresses.each { |address|
|
63
|
+
site.add_ip address
|
64
|
+
}
|
63
65
|
site.save nsc
|
64
|
-
puts "Created site #{run_details.site_name} successfully with the following host #{run_details.
|
66
|
+
puts "Created site #{run_details.site_name} successfully with the following host(s) #{run_details.ip_addresses.join(', ')}"
|
65
67
|
site
|
66
68
|
end
|
67
69
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
class ScanRunDescription
|
2
|
-
attr_accessor :connection_url, :username, :password, :port, :site_name, :
|
2
|
+
attr_accessor :connection_url, :username, :password, :port, :site_name, :ip_addresses, :scan_template
|
3
3
|
@@port_value = ''
|
4
|
+
@@ip_addresses = ''
|
4
5
|
|
5
|
-
|
6
|
-
def initialize(connection_url, username, password, port, site_name, ip_address, scan_template)
|
6
|
+
def initialize(connection_url, username, password, port, site_name, ip_addresses, scan_template)
|
7
7
|
self.connection_url = connection_url
|
8
8
|
self.username = username
|
9
9
|
self.password = password
|
10
10
|
@@port_value = port
|
11
11
|
self.site_name = site_name
|
12
|
-
self.
|
12
|
+
self.ip_addresses = ip_addresses
|
13
13
|
self.scan_template = scan_template
|
14
14
|
end
|
15
15
|
|
@@ -18,7 +18,7 @@ class ScanRunDescription
|
|
18
18
|
raise StandardError, CONSTANTS::REQUIRED_USERNAME_MESSAGE if username.nil? || username.empty?
|
19
19
|
raise StandardError, CONSTANTS::REQUIRED_PASSWORD_MESSAGE if password.nil? || password.empty?
|
20
20
|
raise StandardError, CONSTANTS::REQUIRED_SITE_NAME_MESSAGE if site_name.nil? || site_name.empty?
|
21
|
-
raise StandardError, CONSTANTS::REQUIRED_IP_ADDRESS_MESSAGE if
|
21
|
+
raise StandardError, CONSTANTS::REQUIRED_IP_ADDRESS_MESSAGE if ip_addresses.length == 0
|
22
22
|
raise StandardError, CONSTANTS::REQUIRED_SCAN_TEMPLATE_MESSAGE if scan_template.nil? || scan_template.empty?
|
23
23
|
end
|
24
24
|
|
@@ -30,7 +30,15 @@ class ScanRunDescription
|
|
30
30
|
get_value(@@port_value, CONSTANTS::DEFAULT_PORT)
|
31
31
|
end
|
32
32
|
|
33
|
+
def ip_addresses=(value)
|
34
|
+
@@ip_addresses = value.split(',')
|
35
|
+
end
|
36
|
+
|
37
|
+
def ip_addresses
|
38
|
+
@@ip_addresses
|
39
|
+
end
|
40
|
+
|
33
41
|
def get_value(value_to_check, default)
|
34
42
|
(value_to_check.nil? || value_to_check.empty?) ? default : value_to_check
|
35
43
|
end
|
36
|
-
end
|
44
|
+
end
|
data/spec/scan_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe 'nexpose-runner' do
|
|
13
13
|
@expected_password = 'password'
|
14
14
|
@expected_port = '3781'
|
15
15
|
@expected_site_name = 'my_cool_software_build-28'
|
16
|
-
@
|
16
|
+
@expected_ips = '10.5.0.15,10.5.0.20,10.5.0.35'
|
17
17
|
@expected_scan_template = 'full-audit-widget-corp'
|
18
18
|
@mock_scan_id = '12'
|
19
19
|
@mock_site_id = '1'
|
@@ -52,37 +52,36 @@ describe 'nexpose-runner' do
|
|
52
52
|
expect(@mock_nexpose_client).to receive(:login)
|
53
53
|
.and_return(true)
|
54
54
|
|
55
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
55
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
|
56
56
|
end
|
57
57
|
|
58
58
|
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, @
|
60
|
-
expect { NexposeRunner::Scan.start(nil, @expected_port, @expected_username, @expected_password, @expected_site_name, @
|
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')
|
61
61
|
end
|
62
62
|
|
63
63
|
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, @
|
65
|
-
expect { NexposeRunner::Scan.start(@expected_connection, nil, @expected_password, @expected_port, @expected_site_name, @
|
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')
|
66
66
|
end
|
67
67
|
|
68
68
|
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, @
|
70
|
-
expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, nil, @expected_port, @expected_site_name, @
|
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')
|
71
71
|
end
|
72
72
|
|
73
73
|
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, '', @
|
75
|
-
expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, nil, @
|
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')
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'should throw an error if no ip address is passed' do
|
79
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')
|
80
|
-
expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, nil, @expected_scan_template) }.to raise_error(StandardError, 'OOPS! Looks like you forgot to give me an IP Address to scan')
|
81
80
|
end
|
82
81
|
|
83
82
|
it 'should throw an error if no scan template is passed' do
|
84
|
-
expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
85
|
-
expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
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')
|
86
85
|
end
|
87
86
|
|
88
87
|
it 'should use 3780 as default if port is empty string' do
|
@@ -90,7 +89,7 @@ describe 'nexpose-runner' do
|
|
90
89
|
.with(@expected_connection, @expected_username, @expected_password, '3780')
|
91
90
|
.and_return(@mock_nexpose_client)
|
92
91
|
|
93
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, '', @expected_site_name, @
|
92
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, '', @expected_site_name, @expected_ips, @expected_scan_template)
|
94
93
|
end
|
95
94
|
|
96
95
|
it 'should create a new Nexpose site with the supplied site name and scan template' do
|
@@ -98,21 +97,21 @@ describe 'nexpose-runner' do
|
|
98
97
|
.with(@expected_site_name, @expected_scan_template)
|
99
98
|
.and_return(@mock_nexpose_site)
|
100
99
|
|
101
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
100
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
|
102
101
|
end
|
103
102
|
|
104
103
|
it 'should add the supplied ip address to the newly created site' do
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
104
|
+
@expected_ips.split(',').each { |ip|
|
105
|
+
expect(@mock_nexpose_site).to receive(:add_ip).with(ip)
|
106
|
+
}
|
107
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
|
109
108
|
end
|
110
109
|
|
111
110
|
it 'should save the new site configuration' do
|
112
111
|
expect(@mock_nexpose_site).to receive(:save)
|
113
112
|
.with(@mock_nexpose_client)
|
114
113
|
|
115
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
114
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
|
116
115
|
end
|
117
116
|
|
118
117
|
it 'should initiate a scan' do
|
@@ -120,14 +119,14 @@ describe 'nexpose-runner' do
|
|
120
119
|
.with(@mock_nexpose_client)
|
121
120
|
.and_return(@mock_scan)
|
122
121
|
|
123
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
122
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
|
124
123
|
end
|
125
124
|
|
126
125
|
describe 'wait for the Nexpose Scan to complete' do
|
127
126
|
it 'should call to check the status of the scan' do
|
128
127
|
expect(@mock_nexpose_client).to receive(:scan_status).with(@mock_scan_id)
|
129
128
|
|
130
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
129
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
|
131
130
|
end
|
132
131
|
|
133
132
|
it 'should call to check the status until it is not running' do
|
@@ -143,7 +142,7 @@ describe 'nexpose-runner' do
|
|
143
142
|
.once
|
144
143
|
.ordered
|
145
144
|
|
146
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
145
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
|
147
146
|
end
|
148
147
|
|
149
148
|
it 'should sleep for 3 seconds if the status is still running' do
|
@@ -161,7 +160,7 @@ describe 'nexpose-runner' do
|
|
161
160
|
|
162
161
|
expect(NexposeRunner::Scan).to receive(:sleep).with(3).exactly(4).times
|
163
162
|
|
164
|
-
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
163
|
+
NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @expected_ips, @expected_scan_template)
|
165
164
|
end
|
166
165
|
end
|
167
166
|
|
@@ -175,14 +174,14 @@ describe 'nexpose-runner' do
|
|
175
174
|
expect_report_to_be_called_with(CONSTANTS::SOFTWARE_REPORT_NAME, CONSTANTS::SOFTWARE_REPORT_QUERY, @mock_software_report)
|
176
175
|
expect_report_to_be_called_with(CONSTANTS::POLICY_REPORT_NAME, CONSTANTS::POLICY_REPORT_QUERY, @mock_policy_report)
|
177
176
|
|
178
|
-
expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
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)
|
179
178
|
end
|
180
179
|
end
|
181
180
|
|
182
181
|
it 'should throw exception if vulnerability exists' do
|
183
182
|
expect_report_to_be_called_with(CONSTANTS::VULNERABILITY_REPORT_NAME, CONSTANTS::VULNERABILITY_REPORT_QUERY, @mock_vuln_report)
|
184
183
|
|
185
|
-
expect { NexposeRunner::Scan.start(@expected_connection, @expected_username, @expected_password, @expected_port, @expected_site_name, @
|
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)
|
186
185
|
end
|
187
186
|
end
|
188
187
|
end
|
@@ -230,9 +229,9 @@ def get_mock_nexpose_site
|
|
230
229
|
allow(mock_nexpose_site).to receive(:id)
|
231
230
|
.and_return(@mock_site_id)
|
232
231
|
|
233
|
-
|
234
|
-
|
235
|
-
|
232
|
+
@expected_ips.split(',').each { |ip|
|
233
|
+
allow(mock_nexpose_site).to receive(:add_ip).with(ip)
|
234
|
+
}
|
236
235
|
|
237
236
|
allow(mock_nexpose_site).to receive(:save)
|
238
237
|
.with(@mock_nexpose_client)
|
@@ -276,4 +275,4 @@ def get_mock_scan
|
|
276
275
|
mock_scan = double(Nexpose::Scan)
|
277
276
|
allow(mock_scan).to receive(:id).and_return(@mock_scan_id)
|
278
277
|
mock_scan
|
279
|
-
end
|
278
|
+
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
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Gibson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nexpose
|
@@ -28,28 +28,28 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.6'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -74,9 +74,9 @@ executables:
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .rspec
|
79
|
-
- .travis.yml
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
80
|
- Gemfile
|
81
81
|
- LICENSE.txt
|
82
82
|
- NexposeRunner.gemspec
|
@@ -100,12 +100,12 @@ require_paths:
|
|
100
100
|
- lib
|
101
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|