Class: Openvas::Scan

Inherits:
Object
  • Object
show all
Defined in:
lib/openvas/scans.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scan) ⇒ Scan

Returns a new instance of Scan.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/openvas/scans.rb', line 23

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

  @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

#commentObject

Returns the value of attribute comment.



21
22
23
# File 'lib/openvas/scans.rb', line 21

def comment
  @comment
end

#created_atObject

Returns the value of attribute created_at.



21
22
23
# File 'lib/openvas/scans.rb', line 21

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



21
22
23
# File 'lib/openvas/scans.rb', line 21

def id
  @id
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/openvas/scans.rb', line 21

def name
  @name
end

#statusObject

Returns the value of attribute status.



21
22
23
# File 'lib/openvas/scans.rb', line 21

def status
  @status
end

#targetObject

Returns the value of attribute target.



21
22
23
# File 'lib/openvas/scans.rb', line 21

def target
  @target
end

#updated_atObject

Returns the value of attribute updated_at.



21
22
23
# File 'lib/openvas/scans.rb', line 21

def updated_at
  @updated_at
end

#userObject

Returns the value of attribute user.



21
22
23
# File 'lib/openvas/scans.rb', line 21

def user
  @user
end

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
# File 'lib/openvas/scans.rb', line 46

def finished?
  return true if @status.eql? 'Done'

  false
end

#last_reportObject



38
39
40
# File 'lib/openvas/scans.rb', line 38

def last_report
  Openvas::Reports.find_by_id(@last_report_id)
end

#last_resultsObject



42
43
44
# File 'lib/openvas/scans.rb', line 42

def last_results
  Openvas::Results.find_by_report_id(@last_report_id)
end