Module: RubyAcunetix

Defined in:
lib/ruby_acunetix.rb,
lib/ruby_acunetix/version.rb

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.parse(path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby_acunetix.rb', line 11

def self.parse(path)
  report_items = []
  
  doc = Nokogiri::XML(File.open(path))
  doc.xpath('//ReportItems/ReportItem').map do |xml_report_item|
    report_item = RaReportItem.new
    [:Name, :ModuleName, :Details, :Affects, :Parameter, :AOP_SourceFile, :AOP_SourceLine, :IsFalsePositive, :Severity, :Type, :Impact, :Description, :DetailedInformation, :Recommendation, :Request].each do |field|
      report_item.send("#{ra_underscore(field.to_s)}=", xml_report_item.css(field.to_s).text)
    end
    
    cwe = xml_report_item.css('CWEList')
    report_item.send("cwe=", cwe.css('CWE').text) if !cwe.nil?

    cve = xml_report_item.css('CVEList')
    report_item.send("cve=", cwe.css('CVE').text) if !cwe.nil?

    cvss = xml_report_item.css('CVSS')
    report_item.cvss = RaCvss.parse(cvss) if !cvss.nil? 
    
    cvss3 = xml_report_item.css('CVSS3')
    report_item.cvss3 = RaCvss3.parse(cvss3) if !cvss3.nil? 
    
    report_item.references = []
    
    references = xml_report_item.css('References')
    if !references.nil? 
      references.css('Reference').each do |reference|
        report_item.references.push(RaReference.parse(reference))
      end
    end
          
    report_items.push report_item
  end
  
  return report_items
end

.ra_underscore(value) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/ruby_acunetix.rb', line 48

def self.ra_underscore(value)
  value.gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").
  downcase
end