Class: Openvas::Scan
Overview
Class used to interact with OpenVAS’ scans
Constant Summary
Constants inherited from Client
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#status ⇒ Object
Returns the value of attribute status.
-
#target ⇒ Object
Returns the value of attribute target.
-
#trend ⇒ Object
Returns the value of attribute trend.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #finished? ⇒ Boolean
-
#initialize(scan) ⇒ Scan
constructor
A new instance of Scan.
- #last_report ⇒ Object
- #last_results ⇒ Object
Methods inherited from Client
connect, disconnect, query, version
Constructor Details
#initialize(scan) ⇒ Scan
Returns a new instance of Scan.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/openvas/scan.rb', line 10 def initialize(scan) @id = scan.at_xpath('@id').value @name = scan.at_xpath('name').text @comment = scan.at_xpath('comment').text @user = scan.at_xpath('owner/name').text @trend = scan.at_xpath('trend').text @status = scan.at_xpath('status').text @target = scan.at_xpath('target')&.first_element_child&.text @created_at = Time.parse(scan.at_xpath('creation_time').text) @updated_at = Time.parse(scan.at_xpath('modification_time').text) @last_report_id = scan.at_xpath('last_report/report/@id')&.value end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def comment @comment end |
#created_at ⇒ Object
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def name @name end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def status @status end |
#target ⇒ Object
Returns the value of attribute target.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def target @target end |
#trend ⇒ Object
Returns the value of attribute trend.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def trend @trend end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def updated_at @updated_at end |
#user ⇒ Object
Returns the value of attribute user.
8 9 10 |
# File 'lib/openvas/scan.rb', line 8 def user @user end |
Class Method Details
.all ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/openvas/scan.rb', line 38 def all data = Nokogiri::XML::Builder.new { get_tasks } query(data).xpath('//get_tasks_response/task').map do |scan| new(scan) end end |
.find_by(id:) ⇒ Object
46 47 48 49 |
# File 'lib/openvas/scan.rb', line 46 def find_by(id:) data = Nokogiri::XML::Builder.new { get_tasks(task_id: id) } new(query(data).at_xpath('//get_tasks_response/task')) end |
Instance Method Details
#finished? ⇒ Boolean
33 34 35 |
# File 'lib/openvas/scan.rb', line 33 def finished? @status == 'Done' end |
#last_report ⇒ Object
25 26 27 |
# File 'lib/openvas/scan.rb', line 25 def last_report Openvas::Reports.find_by_id(@last_report_id) end |
#last_results ⇒ Object
29 30 31 |
# File 'lib/openvas/scan.rb', line 29 def last_results Openvas::Result.find_by_report_id(@last_report_id) end |