openvas 0.1.0 → 0.2.0

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: 82164fc6425d0877dbf5cbff5de61ea444155e8f
4
- data.tar.gz: 611bcc9ca8bc58cf38a81a56bef6350cb69223ea
3
+ metadata.gz: acf595702c215ac4f3aca74733ed49f7c847dc45
4
+ data.tar.gz: c6c2a3e6591bbf676ed06a1bf6cb89458c668134
5
5
  SHA512:
6
- metadata.gz: 236ea50cf8113e17ed9870f2dfe1a856dac4eb244b1d22014954036f1d85c9e0ce02065fa7726d6821e8edd8eaee6d21744694eb4087687ee4daac9dd11af81c
7
- data.tar.gz: 13b7e6de70a8004aa94112c47a2a591b49d9ef300cf848fa0b4a835d76104e1e1c9847460174133435bb9312f8bed9652a2965e86b64cdf889debc067c3a2f99
6
+ metadata.gz: 5364649f586d412cb71a9cef748ea74fa7115c51107b12b71672505d8efb41b96bce4b83ed4055a43a2d5899c35f8344daa67821dd5cadb8cfaa0b81573dee66
7
+ data.tar.gz: b819f87b6af0f656eef9853995e6bfa6a6aee1c9d1f52f9d8c295c95ccc66725e2330b46fd85770bd29f302871580da612ea3c6ce579334331807f93070c617c
data/.rubocop_todo.yml CHANGED
@@ -1,11 +1,16 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-12-12 13:58:50 +0100 using RuboCop version 0.51.0.
3
+ # on 2017-12-12 16:24:24 +0100 using RuboCop version 0.52.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 2
10
+ # Configuration parameters: CountComments, ExcludedMethods.
11
+ Metrics/BlockLength:
12
+ Max: 43
13
+
9
14
  # Offense count: 10
10
15
  Style/Documentation:
11
16
  Exclude:
@@ -20,7 +25,16 @@ Style/Documentation:
20
25
  - 'lib/openvas/scans.rb'
21
26
 
22
27
  # Offense count: 2
23
- # Configuration parameters: EnforcedStyle, SupportedStyles.
28
+ # Cop supports --auto-correct.
29
+ # Configuration parameters: Autocorrect, EnforcedStyle.
30
+ # SupportedStyles: module_function, extend_self
31
+ Style/ExtendSelf:
32
+ Exclude:
33
+ - 'lib/openvas.rb'
34
+ - 'lib/openvas/config.rb'
35
+
36
+ # Offense count: 2
37
+ # Configuration parameters: EnforcedStyle.
24
38
  # SupportedStyles: module_function, extend_self
25
39
  Style/ModuleFunction:
26
40
  Exclude:
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/Cyberwatch/ruby-openvas.svg?branch=master)](https://travis-ci.org/Cyberwatch/ruby-openvas)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/Cyberwatch/ruby-openvas/badge.svg?branch=master)](https://coveralls.io/github/Cyberwatch/ruby-openvas?branch=master)
5
+ [![Gem Version](https://badge.fury.io/rb/openvas.svg)](https://badge.fury.io/rb/openvas)
5
6
 
6
7
  A ruby client for OpenVas API OMP 7.0.
7
8
 
data/lib/openvas/auth.rb CHANGED
@@ -8,6 +8,9 @@ module Openvas
8
8
 
9
9
  # Do Login
10
10
  def self.login
11
+ raise InvalidLogin, 'Please configure the username' unless Openvas::Config.username
12
+ raise InvalidLogin, 'Please configure the password' unless Openvas::Config.password
13
+
11
14
  content = Nokogiri::XML::Builder.new do |xml|
12
15
  xml.authenticate do
13
16
  xml.credentials do
@@ -3,7 +3,7 @@
3
3
  module Openvas
4
4
  module Config
5
5
  class RequiredOptionMissing < RuntimeError; end
6
- module_function
6
+ extend self
7
7
 
8
8
  attr_accessor :url, :username, :password, :socket
9
9
  end
data/lib/openvas/scans.rb CHANGED
@@ -18,7 +18,7 @@ module Openvas
18
18
  end
19
19
 
20
20
  class Scan
21
- attr_accessor :id, :name, :comment, :status, :target, :created_at, :updated_at
21
+ attr_accessor :id, :name, :comment, :status, :target, :user, :created_at, :updated_at
22
22
 
23
23
  def initialize(scan)
24
24
  @id = scan.at_xpath('@id').value
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openvas
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/openvas.rb CHANGED
@@ -11,7 +11,7 @@ require 'openvas/reports'
11
11
  require 'openvas/results'
12
12
 
13
13
  module Openvas
14
- module_function
14
+ extend self
15
15
 
16
16
  def configure
17
17
  block_given? ? yield(Config) : Config
@@ -0,0 +1,297 @@
1
+ <?xml version="1.0"?>
2
+ <get_tasks_response status="200" status_text="OK">
3
+ <apply_overrides>0</apply_overrides>
4
+ <task id="96625625-8e22-4b1c-9c65-4ddf80f78d20">
5
+ <owner>
6
+ <name>admin</name>
7
+ </owner>
8
+ <name>shellshock_01</name>
9
+ <comment/>
10
+ <creation_time>2017-12-11T16:40:16Z</creation_time>
11
+ <modification_time>2017-12-12T08:13:44Z</modification_time>
12
+ <writable>1</writable>
13
+ <in_use>0</in_use>
14
+ <permissions>
15
+ <permission>
16
+ <name>Everything</name>
17
+ </permission>
18
+ </permissions>
19
+ <user_tags>
20
+ <count>0</count>
21
+ </user_tags>
22
+ <alterable>0</alterable>
23
+ <config id="daba56c8-73ec-11df-a475-002264764cea">
24
+ <name>Full and fast</name>
25
+ <type>0</type>
26
+ <trash>0</trash>
27
+ </config>
28
+ <target id="2225c572-a669-47a5-8173-1e95fc670f60">
29
+ <name>shellshock</name>
30
+ <trash>0</trash>
31
+ </target>
32
+ <hosts_ordering>sequential</hosts_ordering>
33
+ <scanner id="08b69003-5fc2-4037-a479-93b440211c73">
34
+ <name>OpenVAS Default</name>
35
+ <type>2</type>
36
+ <trash>0</trash>
37
+ </scanner>
38
+ <status>Done</status>
39
+ <progress>-1</progress>
40
+ <report_count>2<finished>2</finished></report_count>
41
+ <trend>same</trend>
42
+ <schedule id="">
43
+ <name/>
44
+ <next_time>over</next_time>
45
+ <trash>0</trash>
46
+ </schedule>
47
+ <schedule_periods>0</schedule_periods>
48
+ <first_report>
49
+ <report id="74ee3645-e81d-481d-996d-7b6360c87518">
50
+ <timestamp>2017-12-11T16:40:21Z</timestamp>
51
+ <scan_start>2017-12-11T16:40:32Z</scan_start>
52
+ <scan_end>2017-12-11T16:49:09Z</scan_end>
53
+ <result_count>
54
+ <debug>0</debug>
55
+ <hole>0</hole>
56
+ <info>2</info>
57
+ <log>38</log>
58
+ <warning>2</warning>
59
+ <false_positive>0</false_positive>
60
+ </result_count>
61
+ <severity>5.0</severity>
62
+ </report>
63
+ </first_report>
64
+ <last_report>
65
+ <report id="46203d29-ba11-4171-81ef-83d227063c7d">
66
+ <timestamp>2017-12-12T08:13:34Z</timestamp>
67
+ <scan_start>2017-12-12T08:13:43Z</scan_start>
68
+ <scan_end>2017-12-12T08:21:05Z</scan_end>
69
+ <result_count>
70
+ <debug>0</debug>
71
+ <hole>0</hole>
72
+ <info>2</info>
73
+ <log>38</log>
74
+ <warning>2</warning>
75
+ <false_positive>0</false_positive>
76
+ </result_count>
77
+ <severity>5.0</severity>
78
+ </report>
79
+ </last_report>
80
+ <second_last_report>
81
+ <report id="74ee3645-e81d-481d-996d-7b6360c87518">
82
+ <timestamp>2017-12-11T16:40:21Z</timestamp>
83
+ <scan_start>2017-12-11T16:40:32Z</scan_start>
84
+ <scan_end>2017-12-11T16:49:09Z</scan_end>
85
+ <result_count>
86
+ <debug>0</debug>
87
+ <hole>0</hole>
88
+ <info>2</info>
89
+ <log>38</log>
90
+ <warning>2</warning>
91
+ <false_positive>0</false_positive>
92
+ </result_count>
93
+ <severity>5.0</severity>
94
+ </report>
95
+ </second_last_report>
96
+ <observers/>
97
+ <result_count>84</result_count>
98
+ <preferences>
99
+ <preference>
100
+ <name>Maximum concurrently executed NVTs per host</name>
101
+ <scanner_name>max_checks</scanner_name>
102
+ <value>4</value>
103
+ </preference>
104
+ <preference>
105
+ <name>Maximum concurrently scanned hosts</name>
106
+ <scanner_name>max_hosts</scanner_name>
107
+ <value>20</value>
108
+ </preference>
109
+ <preference>
110
+ <name>Network Source Interface</name>
111
+ <scanner_name>source_iface</scanner_name>
112
+ <value/>
113
+ </preference>
114
+ <preference>
115
+ <name>Add results to Asset Management</name>
116
+ <scanner_name>in_assets</scanner_name>
117
+ <value>yes</value>
118
+ </preference>
119
+ <preference>
120
+ <name>Apply Overrides when adding Assets</name>
121
+ <scanner_name>assets_apply_overrides</scanner_name>
122
+ <value>yes</value>
123
+ </preference>
124
+ <preference>
125
+ <name>Min QOD when adding Assets</name>
126
+ <scanner_name>assets_min_qod</scanner_name>
127
+ <value>70</value>
128
+ </preference>
129
+ <preference>
130
+ <name>Auto Delete Reports</name>
131
+ <scanner_name>auto_delete</scanner_name>
132
+ <value>no</value>
133
+ </preference>
134
+ <preference>
135
+ <name>Auto Delete Reports Data</name>
136
+ <scanner_name>auto_delete_data</scanner_name>
137
+ <value>5</value>
138
+ </preference>
139
+ </preferences>
140
+ </task>
141
+ <task id="22e6530d-2516-4e01-aad3-e357f1b1a2bb">
142
+ <owner>
143
+ <name>admin</name>
144
+ </owner>
145
+ <name>test</name>
146
+ <comment/>
147
+ <creation_time>2017-12-12T08:14:36Z</creation_time>
148
+ <modification_time>2017-12-12T08:14:45Z</modification_time>
149
+ <writable>1</writable>
150
+ <in_use>0</in_use>
151
+ <permissions>
152
+ <permission>
153
+ <name>Everything</name>
154
+ </permission>
155
+ </permissions>
156
+ <user_tags>
157
+ <count>0</count>
158
+ </user_tags>
159
+ <alterable>0</alterable>
160
+ <config id="2d3f051c-55ba-11e3-bf43-406186ea4fc5">
161
+ <name>Host Discovery</name>
162
+ <type>0</type>
163
+ <trash>0</trash>
164
+ </config>
165
+ <target id="2225c572-a669-47a5-8173-1e95fc670f60">
166
+ <name>shellshock</name>
167
+ <trash>0</trash>
168
+ </target>
169
+ <hosts_ordering>sequential</hosts_ordering>
170
+ <scanner id="08b69003-5fc2-4037-a479-93b440211c73">
171
+ <name>OpenVAS Default</name>
172
+ <type>2</type>
173
+ <trash>0</trash>
174
+ </scanner>
175
+ <status>Done</status>
176
+ <progress>-1</progress>
177
+ <report_count>1<finished>1</finished></report_count>
178
+ <trend/>
179
+ <schedule id="">
180
+ <name/>
181
+ <next_time>over</next_time>
182
+ <trash>0</trash>
183
+ </schedule>
184
+ <schedule_periods>0</schedule_periods>
185
+ <first_report>
186
+ <report id="7a537c8d-a721-410b-9929-db22f46c7099">
187
+ <timestamp>2017-12-12T08:14:44Z</timestamp>
188
+ <scan_start>2017-12-12T08:14:44Z</scan_start>
189
+ <scan_end>2017-12-12T08:14:52Z</scan_end>
190
+ <result_count>
191
+ <debug>0</debug>
192
+ <hole>0</hole>
193
+ <info>0</info>
194
+ <log>1</log>
195
+ <warning>0</warning>
196
+ <false_positive>0</false_positive>
197
+ </result_count>
198
+ <severity>0.0</severity>
199
+ </report>
200
+ </first_report>
201
+ <last_report>
202
+ <report id="7a537c8d-a721-410b-9929-db22f46c7099">
203
+ <timestamp>2017-12-12T08:14:44Z</timestamp>
204
+ <scan_start>2017-12-12T08:14:44Z</scan_start>
205
+ <scan_end>2017-12-12T08:14:52Z</scan_end>
206
+ <result_count>
207
+ <debug>0</debug>
208
+ <hole>0</hole>
209
+ <info>0</info>
210
+ <log>1</log>
211
+ <warning>0</warning>
212
+ <false_positive>0</false_positive>
213
+ </result_count>
214
+ <severity>0.0</severity>
215
+ </report>
216
+ </last_report>
217
+ <observers/>
218
+ <result_count>1</result_count>
219
+ <preferences>
220
+ <preference>
221
+ <name>Maximum concurrently executed NVTs per host</name>
222
+ <scanner_name>max_checks</scanner_name>
223
+ <value>4</value>
224
+ </preference>
225
+ <preference>
226
+ <name>Maximum concurrently scanned hosts</name>
227
+ <scanner_name>max_hosts</scanner_name>
228
+ <value>20</value>
229
+ </preference>
230
+ <preference>
231
+ <name>Network Source Interface</name>
232
+ <scanner_name>source_iface</scanner_name>
233
+ <value/>
234
+ </preference>
235
+ <preference>
236
+ <name>Add results to Asset Management</name>
237
+ <scanner_name>in_assets</scanner_name>
238
+ <value>yes</value>
239
+ </preference>
240
+ <preference>
241
+ <name>Apply Overrides when adding Assets</name>
242
+ <scanner_name>assets_apply_overrides</scanner_name>
243
+ <value>yes</value>
244
+ </preference>
245
+ <preference>
246
+ <name>Min QOD when adding Assets</name>
247
+ <scanner_name>assets_min_qod</scanner_name>
248
+ <value>70</value>
249
+ </preference>
250
+ <preference>
251
+ <name>Auto Delete Reports</name>
252
+ <scanner_name>auto_delete</scanner_name>
253
+ <value>no</value>
254
+ </preference>
255
+ <preference>
256
+ <name>Auto Delete Reports Data</name>
257
+ <scanner_name>auto_delete_data</scanner_name>
258
+ <value>5</value>
259
+ </preference>
260
+ </preferences>
261
+ </task>
262
+ <filters id="">
263
+ <term>apply_overrides=0 min_qod=70 first=1 rows=10 sort=name</term>
264
+ <keywords>
265
+ <keyword>
266
+ <column>apply_overrides</column>
267
+ <relation>=</relation>
268
+ <value>0</value>
269
+ </keyword>
270
+ <keyword>
271
+ <column>min_qod</column>
272
+ <relation>=</relation>
273
+ <value>70</value>
274
+ </keyword>
275
+ <keyword>
276
+ <column>first</column>
277
+ <relation>=</relation>
278
+ <value>1</value>
279
+ </keyword>
280
+ <keyword>
281
+ <column>rows</column>
282
+ <relation>=</relation>
283
+ <value>10</value>
284
+ </keyword>
285
+ <keyword>
286
+ <column>sort</column>
287
+ <relation>=</relation>
288
+ <value>name</value>
289
+ </keyword>
290
+ </keywords>
291
+ </filters>
292
+ <sort>
293
+ <field>name<order>ascending</order></field>
294
+ </sort>
295
+ <tasks start="1" max="1000"/>
296
+ <task_count>2<filtered>2</filtered><page>2</page></task_count>
297
+ </get_tasks_response>
@@ -0,0 +1,177 @@
1
+ <?xml version="1.0"?>
2
+ <get_tasks_response status="200" status_text="OK">
3
+ <apply_overrides>0</apply_overrides>
4
+ <task id="96625625-8e22-4b1c-9c65-4ddf80f78d20">
5
+ <owner>
6
+ <name>admin</name>
7
+ </owner>
8
+ <name>shellshock_01</name>
9
+ <comment/>
10
+ <creation_time>2017-12-11T16:40:16Z</creation_time>
11
+ <modification_time>2017-12-12T08:13:44Z</modification_time>
12
+ <writable>1</writable>
13
+ <in_use>0</in_use>
14
+ <permissions>
15
+ <permission>
16
+ <name>Everything</name>
17
+ </permission>
18
+ </permissions>
19
+ <user_tags>
20
+ <count>0</count>
21
+ </user_tags>
22
+ <alterable>0</alterable>
23
+ <config id="daba56c8-73ec-11df-a475-002264764cea">
24
+ <name>Full and fast</name>
25
+ <type>0</type>
26
+ <trash>0</trash>
27
+ </config>
28
+ <target id="2225c572-a669-47a5-8173-1e95fc670f60">
29
+ <name>shellshock</name>
30
+ <trash>0</trash>
31
+ </target>
32
+ <hosts_ordering>sequential</hosts_ordering>
33
+ <scanner id="08b69003-5fc2-4037-a479-93b440211c73">
34
+ <name>OpenVAS Default</name>
35
+ <type>2</type>
36
+ <trash>0</trash>
37
+ </scanner>
38
+ <status>Done</status>
39
+ <progress>-1</progress>
40
+ <report_count>2<finished>2</finished></report_count>
41
+ <trend>same</trend>
42
+ <schedule id="">
43
+ <name/>
44
+ <next_time>over</next_time>
45
+ <trash>0</trash>
46
+ </schedule>
47
+ <schedule_periods>0</schedule_periods>
48
+ <first_report>
49
+ <report id="74ee3645-e81d-481d-996d-7b6360c87518">
50
+ <timestamp>2017-12-11T16:40:21Z</timestamp>
51
+ <scan_start>2017-12-11T16:40:32Z</scan_start>
52
+ <scan_end>2017-12-11T16:49:09Z</scan_end>
53
+ <result_count>
54
+ <debug>0</debug>
55
+ <hole>0</hole>
56
+ <info>2</info>
57
+ <log>38</log>
58
+ <warning>2</warning>
59
+ <false_positive>0</false_positive>
60
+ </result_count>
61
+ <severity>5.0</severity>
62
+ </report>
63
+ </first_report>
64
+ <last_report>
65
+ <report id="46203d29-ba11-4171-81ef-83d227063c7d">
66
+ <timestamp>2017-12-12T08:13:34Z</timestamp>
67
+ <scan_start>2017-12-12T08:13:43Z</scan_start>
68
+ <scan_end>2017-12-12T08:21:05Z</scan_end>
69
+ <result_count>
70
+ <debug>0</debug>
71
+ <hole>0</hole>
72
+ <info>2</info>
73
+ <log>38</log>
74
+ <warning>2</warning>
75
+ <false_positive>0</false_positive>
76
+ </result_count>
77
+ <severity>5.0</severity>
78
+ </report>
79
+ </last_report>
80
+ <second_last_report>
81
+ <report id="74ee3645-e81d-481d-996d-7b6360c87518">
82
+ <timestamp>2017-12-11T16:40:21Z</timestamp>
83
+ <scan_start>2017-12-11T16:40:32Z</scan_start>
84
+ <scan_end>2017-12-11T16:49:09Z</scan_end>
85
+ <result_count>
86
+ <debug>0</debug>
87
+ <hole>0</hole>
88
+ <info>2</info>
89
+ <log>38</log>
90
+ <warning>2</warning>
91
+ <false_positive>0</false_positive>
92
+ </result_count>
93
+ <severity>5.0</severity>
94
+ </report>
95
+ </second_last_report>
96
+ <observers/>
97
+ <average_duration>479</average_duration>
98
+ <result_count>84</result_count>
99
+ <preferences>
100
+ <preference>
101
+ <name>Maximum concurrently executed NVTs per host</name>
102
+ <scanner_name>max_checks</scanner_name>
103
+ <value>4</value>
104
+ </preference>
105
+ <preference>
106
+ <name>Maximum concurrently scanned hosts</name>
107
+ <scanner_name>max_hosts</scanner_name>
108
+ <value>20</value>
109
+ </preference>
110
+ <preference>
111
+ <name>Network Source Interface</name>
112
+ <scanner_name>source_iface</scanner_name>
113
+ <value/>
114
+ </preference>
115
+ <preference>
116
+ <name>Add results to Asset Management</name>
117
+ <scanner_name>in_assets</scanner_name>
118
+ <value>yes</value>
119
+ </preference>
120
+ <preference>
121
+ <name>Apply Overrides when adding Assets</name>
122
+ <scanner_name>assets_apply_overrides</scanner_name>
123
+ <value>yes</value>
124
+ </preference>
125
+ <preference>
126
+ <name>Min QOD when adding Assets</name>
127
+ <scanner_name>assets_min_qod</scanner_name>
128
+ <value>70</value>
129
+ </preference>
130
+ <preference>
131
+ <name>Auto Delete Reports</name>
132
+ <scanner_name>auto_delete</scanner_name>
133
+ <value>no</value>
134
+ </preference>
135
+ <preference>
136
+ <name>Auto Delete Reports Data</name>
137
+ <scanner_name>auto_delete_data</scanner_name>
138
+ <value>5</value>
139
+ </preference>
140
+ </preferences>
141
+ </task>
142
+ <filters id="">
143
+ <term>apply_overrides=0 min_qod=70 first=1 rows=10 sort=name</term>
144
+ <keywords>
145
+ <keyword>
146
+ <column>apply_overrides</column>
147
+ <relation>=</relation>
148
+ <value>0</value>
149
+ </keyword>
150
+ <keyword>
151
+ <column>min_qod</column>
152
+ <relation>=</relation>
153
+ <value>70</value>
154
+ </keyword>
155
+ <keyword>
156
+ <column>first</column>
157
+ <relation>=</relation>
158
+ <value>1</value>
159
+ </keyword>
160
+ <keyword>
161
+ <column>rows</column>
162
+ <relation>=</relation>
163
+ <value>10</value>
164
+ </keyword>
165
+ <keyword>
166
+ <column>sort</column>
167
+ <relation>=</relation>
168
+ <value>name</value>
169
+ </keyword>
170
+ </keywords>
171
+ </filters>
172
+ <sort>
173
+ <field>name<order>ascending</order></field>
174
+ </sort>
175
+ <tasks start="1" max="1000"/>
176
+ <task_count>2<filtered>1</filtered><page>1</page></task_count>
177
+ </get_tasks_response>
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Openvas::Auth do
6
+ describe '#login' do
7
+ before(:each) do
8
+ allow(Openvas::Auth).to receive(:query).and_return(nil)
9
+ end
10
+
11
+ it 'authenticate' do
12
+ Openvas.configure do |config|
13
+ config.url = 'https://localhost:9390'
14
+ config.username = 'admin'
15
+ config.password = 'admin'
16
+ end
17
+
18
+ expect(Openvas::Auth.login).to be_truthy
19
+ end
20
+
21
+ it 'without username' do
22
+ Openvas::Config.username = nil
23
+ expect { Openvas::Auth.login }.to raise_exception(Openvas::Auth::InvalidLogin)
24
+ end
25
+
26
+ it 'without password' do
27
+ Openvas::Config.password = nil
28
+ expect { Openvas::Auth.login }.to raise_exception(Openvas::Auth::InvalidLogin)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Openvas::Scans do
6
+ describe '#all' do
7
+ before(:each) do
8
+ allow(Openvas::Scans).to receive(:query).and_return(fixture_xml('openvas/scans/all.xml'))
9
+ end
10
+
11
+ it 'list scans' do
12
+ expect(Openvas::Scans.all.count).to eq 2
13
+ end
14
+ end
15
+
16
+ describe '#find_by_id' do
17
+ before(:each) do
18
+ allow(Openvas::Scans).to receive(:query).and_return(fixture_xml('openvas/scans/find_by_id.xml'))
19
+ end
20
+
21
+ it 'get the version' do
22
+ expect(Openvas::Scans.find_by_id('96625625-8e22-4b1c-9c65-4ddf80f78d20')).to be_a(Openvas::Scan)
23
+ end
24
+
25
+ context 'scan' do
26
+ let(:scan) { Openvas::Scans.find_by_id('96625625-8e22-4b1c-9c65-4ddf80f78d20') }
27
+
28
+ it '#id' do
29
+ expect(scan.id).to eq '96625625-8e22-4b1c-9c65-4ddf80f78d20'
30
+ end
31
+
32
+ it '#name' do
33
+ expect(scan.name).to eq 'shellshock_01'
34
+ end
35
+
36
+ it '#comment' do
37
+ expect(scan.comment).to eq ''
38
+ end
39
+
40
+ it '#user' do
41
+ expect(scan.user).to eq 'admin'
42
+ end
43
+
44
+ it '#status' do
45
+ expect(scan.status).to eq 'Done'
46
+ end
47
+
48
+ it '#finished' do
49
+ expect(scan.finished?).to be_truthy
50
+ end
51
+
52
+ it '#created_at' do
53
+ expect(scan.created_at.to_s).to eq '2017-12-11 16:40:16 UTC'
54
+ end
55
+
56
+ it '#updated_at' do
57
+ expect(scan.updated_at.to_s).to eq '2017-12-12 08:13:44 UTC'
58
+ end
59
+ end
60
+ end
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Wininger
@@ -106,7 +106,11 @@ files:
106
106
  - lib/openvas/version.rb
107
107
  - openvas.gemspec
108
108
  - spec/fixtures/openvas/client/version.xml
109
+ - spec/fixtures/openvas/scans/all.xml
110
+ - spec/fixtures/openvas/scans/find_by_id.xml
111
+ - spec/openvas/auth_spec.rb
109
112
  - spec/openvas/client_spec.rb
113
+ - spec/openvas/scans_spec.rb
110
114
  - spec/openvas_spec.rb
111
115
  - spec/spec_helper.rb
112
116
  homepage: https://github.com/Cyberwatch/ruby-openvas
@@ -135,6 +139,10 @@ specification_version: 4
135
139
  summary: Openvas API Client (OMP 7.0)
136
140
  test_files:
137
141
  - spec/fixtures/openvas/client/version.xml
142
+ - spec/fixtures/openvas/scans/all.xml
143
+ - spec/fixtures/openvas/scans/find_by_id.xml
144
+ - spec/openvas/auth_spec.rb
138
145
  - spec/openvas/client_spec.rb
146
+ - spec/openvas/scans_spec.rb
139
147
  - spec/openvas_spec.rb
140
148
  - spec/spec_helper.rb