Class: OpenvasCli::VasNVT

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

Overview

Describes a NSIS/OpenVAS scan rule. – TODO: Filter by other useful fields TODO: Find external links for more information TODO: Redcloth and Autolink description TODO: Implement sorting options ++

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

#bugtraq_idObject

Returns the value of attribute bugtraq_id.



24
25
26
# File 'lib/openvas-cli/vas_nvt.rb', line 24

def bugtraq_id
  @bugtraq_id
end

#categoryObject

Returns the value of attribute category.



15
16
17
# File 'lib/openvas-cli/vas_nvt.rb', line 15

def category
  @category
end

Returns the value of attribute copyright.



16
17
18
# File 'lib/openvas-cli/vas_nvt.rb', line 16

def copyright
  @copyright
end

#cve_idObject

Returns the value of attribute cve_id.



23
24
25
# File 'lib/openvas-cli/vas_nvt.rb', line 23

def cve_id
  @cve_id
end

#cvss_baseObject

Returns the value of attribute cvss_base.



21
22
23
# File 'lib/openvas-cli/vas_nvt.rb', line 21

def cvss_base
  @cvss_base
end

#descriptionObject

Returns the value of attribute description.



17
18
19
# File 'lib/openvas-cli/vas_nvt.rb', line 17

def description
  @description
end

#familyObject

Returns the value of attribute family.



19
20
21
# File 'lib/openvas-cli/vas_nvt.rb', line 19

def family
  @family
end

#nameObject

Human readable name of the rule.



13
14
15
# File 'lib/openvas-cli/vas_nvt.rb', line 13

def name
  @name
end

#preferencesObject

Returns the value of attribute preferences.



27
28
29
# File 'lib/openvas-cli/vas_nvt.rb', line 27

def preferences
  @preferences
end

#risk_factorObject

Returns the value of attribute risk_factor.



22
23
24
# File 'lib/openvas-cli/vas_nvt.rb', line 22

def risk_factor
  @risk_factor
end

#summaryObject

Returns the value of attribute summary.



18
19
20
# File 'lib/openvas-cli/vas_nvt.rb', line 18

def summary
  @summary
end

#tagsObject

Returns the value of attribute tags.



26
27
28
# File 'lib/openvas-cli/vas_nvt.rb', line 26

def tags
  @tags
end

#versionObject

Returns the value of attribute version.



20
21
22
# File 'lib/openvas-cli/vas_nvt.rb', line 20

def version
  @version
end

#xrefsObject

Returns the value of attribute xrefs.



25
26
27
# File 'lib/openvas-cli/vas_nvt.rb', line 25

def xrefs
  @xrefs
end

Class Method Details

.get_all(options = {}) ⇒ Object

Pulls VasNVT rules that match the provided options.

Options:

:id => [VasNVT.oid]

will pull only the NVT rule that matches the given OID

:family => [VasFamily.name]

will pull all NVT rules for the specified family



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/openvas-cli/vas_nvt.rb', line 35

def self.get_all(options = {})
  params = {:details => '1'}
  params[:nvt_oid] = options[:id] if options[:id]
  params[:family]  = options[:family] if options[:family]
  params[:config_id] = options[:config_id] if options[:config_id]

  req = Nokogiri::XML::Builder.new { |xml|
    xml.get_nvts(params)
  }
  
  rules = connection.send_receive(req.doc)
  
  ret = []
  rules.xpath("/get_nvts_response/nvt").each { |nvt|
    rule             = VasNVT.new
    rule.id          = extract_value_from("@oid", nvt)
    rule.name        = extract_value_from("name", nvt)
    rule.category    = extract_value_from("category", nvt)
    rule.copyright   = extract_value_from("copyright", nvt)
    rule.description = extract_value_from("description", nvt).strip
    rule.summary     = extract_value_from("summary", nvt)
    rule.family      = extract_value_from("family", nvt)
    rule.version     = extract_value_from("version", nvt)
    rule.cvss_base   = extract_value_from("cvss_base", nvt)
    rule.risk_factor = extract_value_from("risk_factor", nvt)
    rule.cve_id      = extract_value_from("cve_id", nvt)
    rule.bugtraq_id  = extract_value_from("bugtraq_id", nvt)
    rule.xrefs       = extract_value_from("xrefs", nvt).split(/, ?/)
    rule.tags        = extract_value_from("tags", nvt).split(/, ?/)
    ret << rule
  }
  
  ret
end