NexposeRunner 0.0.4 → 0.0.5
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 +4 -4
- data/bin/scan +9 -1
- data/lib/NexposeRunner/version.rb +2 -2
- data/lib/nexpose-runner/scan.rb +2 -2
- data/lib/nexpose-runner/scan_run_description.rb +8 -8
- data/spec/scan_spec.rb +68 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fc954479b13a6d1ee5538438ef4e0e9d155acef
|
4
|
+
data.tar.gz: 92f8b3905afd4c71bc0f316c42b605d33b2cf2c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
+
})
|
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(
|
9
|
+
def Scan.start(options)
|
10
10
|
|
11
|
-
run_details = ScanRunDescription.new
|
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(
|
7
|
-
self.connection_url = connection_url
|
8
|
-
self.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(@
|
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(@
|
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
|
-
|
60
|
-
|
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
|
-
|
65
|
-
|
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
|
-
|
70
|
-
|
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
|
-
|
75
|
-
|
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
|
-
|
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
|
-
|
84
|
-
|
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(@
|
122
|
+
.with(@options['connection_url'],
|
123
|
+
@options['username'],
|
124
|
+
@options['password'],
|
125
|
+
'3780')
|
90
126
|
.and_return(@mock_nexpose_client)
|
91
127
|
|
92
|
-
|
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(@
|
136
|
+
.with(@options['site_name'], @options['scan_template'])
|
98
137
|
.and_return(@mock_nexpose_site)
|
99
138
|
|
100
|
-
NexposeRunner::Scan.start(@
|
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(@
|
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(@
|
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(@
|
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(@
|
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(@
|
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(@
|
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 {
|
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 {
|
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
|
+
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-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nexpose
|