Class: OpenvasCli::VasNVTFamily

Inherits:
VasBase
  • Object
show all
Defined in:
lib/openvas-cli/vas_nvt_family.rb

Overview

Category for NVT rules

Instance Attribute Summary collapse

Attributes inherited from VasBase

#id

Class Method Summary collapse

Methods inherited from VasBase

#create_or_update, #delete_record, #destroy, #destroy!, get_by_id, #initialize, #new_record?, #reset_changes, #save, #save!, #to_key, #to_param, #update_attributes

Methods included from ConnAddin

included

Methods included from XmlAddin

included

Constructor Details

This class inherits a constructor from OpenvasCli::VasBase

Instance Attribute Details

#is_growingObject

Returns the value of attribute is_growing.



10
11
12
# File 'lib/openvas-cli/vas_nvt_family.rb', line 10

def is_growing
  @is_growing
end

#nameObject

Category Name



7
8
9
# File 'lib/openvas-cli/vas_nvt_family.rb', line 7

def name
  @name
end

#nvt_countObject

Number of rules in the family



9
10
11
# File 'lib/openvas-cli/vas_nvt_family.rb', line 9

def nvt_count
  @nvt_count
end

Class Method Details

.from_xml_node(node) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/openvas-cli/vas_nvt_family.rb', line 37

def self.from_xml_node(node)
  family            = VasNVTFamily.new
  family.name       = extract_value_from('name', node)
  family.nvt_count  = extract_value_from('max_nvt_count', node).to_i
  family.is_growing = (extract_value_from("growing", node).to_i > 0)

  family
end

.get_all(options = {}) ⇒ Object

Pulls all NVT Families defined on the server.

Options:

None. – TODO: Implement options ++



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/openvas-cli/vas_nvt_family.rb', line 21

def self.get_all(options = {})

  req = Nokogiri::XML::Builder.new { |xml|
    xml.get_nvt_families
  }
  
  fams = connection.send_receive(req.doc)
  
  ret = []
  fams.xpath('//family').each { |f|
    ret << from_xml_node(f)
  }
  
  ret
end