Class: Dradis::Plugins::Nexpose::XmlFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/dradis/plugins/nexpose/xml_formatter.rb

Instance Method Summary collapse

Instance Method Details

#cleanup_html(source) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dradis/plugins/nexpose/xml_formatter.rb', line 9

def cleanup_html(source)
  result = source.to_s
  result.gsub!(/<ContainerBlockElement>(.*?)<\/ContainerBlockElement>/m) { |m| "#{ $1 }" }
  result.gsub!(/<Paragraph preformat=\"true\">(\s*)<Paragraph preformat=\"true\">(.*?)<\/Paragraph>(\s*)<\/Paragraph>/mi) do
    text = $2
    text[/\n/] ? "\nbc.. #{ text }\n\np. " : "@#{text}@"
  end
  result.gsub!(/<Paragraph preformat=\"true\">(.*?)<\/Paragraph>/mi) do
    text = $1
    text[/\n/] ? "\nbc.. #{ text }\n\np. " : "@#{text}@"
  end
  result.gsub!(/<Paragraph>(.*?)<\/Paragraph>/m) { |m| "#{ $1 }\n" }
  result.gsub!(/<Paragraph>|<\/Paragraph>/, '')
  result.gsub!(/          /, '')
  result.gsub!(/   /, '')
  result.gsub!(/\t\t/, '')
  result.gsub!(/<URLLink(.*)LinkURL=\"(.*?)\"(.*?)>(.*?)<\/URLLink>/im) { "\"#{$4.strip}\":#{$2.strip} " }
  result.gsub!(/<URLLink LinkTitle=\"(.*?)\"(.*?)LinkURL=\"(.*?)\"\/>/i) { "\"#{$1.strip}\":#{$3.strip} " }
  result.gsub!(/<URLLink LinkURL=\"(.*?)\"(.*?)LinkTitle=\"(.*?)\"\/>/i) { "\"#{$3.strip}\":#{$1.strip} " }
  result.gsub!(/&gt;/, '>')
  result.gsub!(/&lt;/, '<')
  result
end

#cleanup_nested(source) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dradis/plugins/nexpose/xml_formatter.rb', line 33

def cleanup_nested(source)
  result = source.to_s
  result.gsub!(/<references>/, '')
  result.gsub!(/<\/references>/, '')
  result.gsub!(/<reference source=\"(.*?)\">(.*?)<\/reference>/i) { "#{$1.strip}: #{$2.strip}\n" }
  result.gsub!(/<tags>/, '')
  result.gsub!(/<\/tags>/, '')
  result.gsub!(/<tag>(.*?)<\/tag>/) { "#{$1}\n" }
  result.gsub!(/        /, '')
  result
end

#format_html_content(source) ⇒ Object



3
4
5
6
7
# File 'lib/dradis/plugins/nexpose/xml_formatter.rb', line 3

def format_html_content(source)
  result = format_list(source)

  cleanup_html(result)
end