lib/output/htmlout.rb in prenus-0.0.10 vs lib/output/htmlout.rb in prenus-0.0.11
- old
+ new
@@ -86,14 +86,14 @@
med_total += 1 if v[:severity] == 2
low_total += 1 if v[:severity] == 1
end
pie_data = []
- pie_data << ['Low',low_total.to_i,'green'] if @options[:severity] <= 1
- pie_data << ['Medium',med_total.to_i,'orange'] if @options[:severity] <= 2
- pie_data << ['High',high_total.to_i,'red'] if @options[:severity] <= 3
- pie_data << ['Critical',crit_total.to_i,'purple'] if @options[:severity] <= 4
+ pie_data << ['Low',low_total.to_i,'green'] if @options[:severity] <= 1 and low_total.to_i > 0
+ pie_data << ['Medium',med_total.to_i,'orange'] if @options[:severity] <= 2 and med_total.to_i > 0
+ pie_data << ['High',high_total.to_i,'red'] if @options[:severity] <= 3 and high_total.to_i > 0
+ pie_data << ['Critical',crit_total.to_i,'purple'] if @options[:severity] <= 4 and crit_total.to_i > 0
pie_js(f,"pie_graph","Unique Vulnerability Breakdown","Unique Vuln Breakdown",pie_data,"document.location.href = 'vuln_overview.html';")
crit_total = 0
high_total = 0
@@ -106,14 +106,14 @@
med_total += values[:med].to_i
low_total += values[:low].to_i
end
pie_data = []
- pie_data << ['Low',low_total.to_i,'green'] if @options[:severity] <= 1
- pie_data << ['Medium',med_total.to_i,'orange'] if @options[:severity] <= 2
- pie_data << ['High',high_total.to_i,'red'] if @options[:severity] <= 3
- pie_data << ['Critical',crit_total.to_i,'purple'] if @options[:severity] <= 4
+ pie_data << ['Low',low_total.to_i,'green'] if @options[:severity] <= 1 and low_total.to_i > 0
+ pie_data << ['Medium',med_total.to_i,'orange'] if @options[:severity] <= 2 and med_total.to_i > 0
+ pie_data << ['High',high_total.to_i,'red'] if @options[:severity] <= 3 and high_total.to_i > 0
+ pie_data << ['Critical',crit_total.to_i,'purple'] if @options[:severity] <= 4 and crit_total.to_i > 0
pie_js(f,"pie_graph2","Total Vunerability Breakdown","Total Vuln Breakdown",pie_data,"document.location = href= 'vuln_overview.html';")
target_lookup = "var target_lookup = {"
@hosts.each_with_index do |host,index|
@@ -129,13 +129,17 @@
f.puts target_lookup
close_html_header(f)
+ unless @options[:indexfile].nil?
+ IO.copy_stream(File.open(@options[:indexfile]),f)
+ end
+
body = '<div style="width: 800px; margin-left: auto; margin-right: auto; padding-top: 30px;">'
- body += '<div id="pie_graph" style="min-width: 300px; height: 300px; margin: 0 auto; float: left"></div>'
- body += '<div id="pie_graph2" style="min-width: 300px; height: 300px; margin: 0 auto; float: left"></div>'
+ body += '<div id="pie_graph" style="min-width: 375px; height: 375px; margin: 0 auto; float: left"></div>'
+ body += '<div id="pie_graph2" style="min-width: 375px; height: 375px; margin: 0 auto; float: left"></div>'
body += '</div>'
body += '<div style="clear: both;"></div>'
body += '<div id="bar_graph" style="min-width: 400px; height: 900px; margin: 0 auto"></div>'
body += '<div id="allhosts"><h3>All Hosts</h3>'
@@ -143,14 +147,25 @@
ips = []
@hosts.each do |host|
ips << host[1][:ip]
end
- body += '<table id="hosts_table" class="display"><thead><tr><th>IP</th><th>Hostname</th><th>OS</th><th>Number of vulns (Low to Critical)</th></tr></thead><tbody>'
+ body += '<table id="hosts_table" class="display"><thead><tr><th>IP</th><th>Hostname</th><th>OS</th><th>Vulnerability Count (Low to Critical)</th></tr></thead><tbody>'
ips.sort_by{|ip| ip.split('.').map{|octet| octet.to_i}}.each do |ip|
@hosts.select{|k,v| v[:ip] == ip}.each do |k,v|
- body += '<tr><td><a href="host_' + k.to_s + '.html">' + ip + '</a></td><td>' + v[:hostname] + '</td><td>' + v[:os] + '</td><td>' + v[:total_excl_info].to_s + '</td></tr>'
+ tmp_actual_v_count = 0
+ tmp_actual_v_count += v[:low].to_i if @options[:severity] <= 1 and v[:low].to_i > 0
+ tmp_actual_v_count += v[:med].to_i if @options[:severity] <= 2 and v[:med].to_i > 0
+ tmp_actual_v_count += v[:high].to_i if @options[:severity] <= 3 and v[:high].to_i > 0
+ tmp_actual_v_count += v[:crit].to_i if @options[:severity] <= 4 and v[:crit].to_i > 0
+ body += '<tr><td>'
+ if tmp_actual_v_count > 0
+ body += '<a href="host_' + k.to_s + '.html">' + ip + '</a>'
+ else
+ body += ip
+ end
+ body += '</td><td>' + v[:hostname] + '</td><td>' + v[:os] + '</td><td>' + v[:total_excl_info].to_s + '</td></tr>'
end
end
body += '</tbody></table>'
body += '<script>$(document).ready(function() { $(\'#hosts_table\').dataTable({"bPaginate": false}); });</script>'
@@ -177,11 +192,11 @@
File.open(@options[:output] + "/vuln_overview.html", 'w') do |f|
html_header(f,"Vulns Overview")
close_html_header(f)
- body = '<a href="index.html">Home</a><br /><div id="vulns"><h2>Vulns</h2>'
+ body = '<a href="index.html">Home</a><br /><div id="vulns"><h2>Vulnerabilities</h2>'
body += '<table id="vulns_table" class="display"><thead><tr><th>Nessus ID</th><th>Severity</th><th>Name</th><th>Family</th><th>Ports</th><th>Number of impacted hosts</th></tr></thead><tbody>'
@events.each do |k,v|
next if v[:severity].to_i < @options[:severity].to_i
body += '<tr><td><a href="vuln_' + k.to_s + '.html">' + k.to_s
@@ -289,28 +304,28 @@
if values[:total_excl_info] == 0
pie_js(f,"pie_graph","Criticality Breakdown","Criticality Breakdown",[['Informational ONLY',values[:info].to_i,'blue']])
else
pie_data = []
- pie_data << ['Low',values[:low].to_i,'green'] if @options[:severity] <= 1
- pie_data << ['Medium',values[:med].to_i,'orange'] if @options[:severity] <= 2
- pie_data << ['High',values[:high].to_i,'red'] if @options[:severity] <= 3
- pie_data << ['Critical',values[:crit].to_i,'purple'] if @options[:severity] <= 4
+ pie_data << ['Low',values[:low].to_i,'green'] if @options[:severity] <= 1 and values[:low].to_i > 0
+ pie_data << ['Medium',values[:med].to_i,'orange'] if @options[:severity] <= 2 and values[:med].to_i > 0
+ pie_data << ['High',values[:high].to_i,'red'] if @options[:severity] <= 3 and values[:high].to_i > 0
+ pie_data << ['Critical',values[:crit].to_i,'purple'] if @options[:severity] <= 4 and values[:crit].to_i > 0
pie_js(f,"pie_graph","Criticality Breakdown","Criticality Breakdown",pie_data,"document.location.href = '#' + event.point.name;")
end
close_html_header(f)
body = '<a href="index.html">Home</a><br /><div id="host"><div id="overview">Hostname: ' + values[:hostname] + '<br />IP: ' + values[:ip] + '<br />OS: ' + values[:os] + '<br /></div>'
body += '<div id="graphs"><h2>Overview</h2>'
body += '<div id="pie_graph" style="min-width: 400px; height: 400px; margin: 0 auto"></div>'
body += '</div>'
- body += '<div id="vulns"><h2>Vulns</h2>'
+ body += '<div id="vulns"><h2>Vulnerabilities</h2>'
- if @options[:severity] <= 4
+ if @options[:severity] <= 4 and values[:crit].to_i > 0
body += '<div id="critical"><a name="Critical"></a><h3>Critical</h3>'
body += '<table id="critical_table" class="display"><thead><tr><th>Nessus ID</th><th>Name</th><th>Synopsis</th><th>Result</th><th>Family</th><th>Port</th></tr></thead><tbody>'
@events.sort_by{|k,v| v[:port].to_s}.each do |vuln_id,vuln_data|
vuln_data[:ports].each {|k,v|
@@ -323,11 +338,11 @@
}
end
body += '</tbody></table></div>'
end
- if @options[:severity] <= 3
+ if @options[:severity] <= 3 and values[:high].to_i > 0
body += '<div id="high"><a name="High"></a><h3>High</h3>'
body += '<table id="high_table" class="display"><thead><tr><th>Nessus ID</th><th>Name</th><th>Synopsis</th><th>Result</th><th>Family</th><th>Port</th></tr></thead><tbody>'
@events.sort_by{|k,v| v[:port].to_s}.each do |vuln_id,vuln_data|
@@ -340,11 +355,11 @@
}
end
body += '</tbody></table></div>'
end
- if @options[:severity] <= 2
+ if @options[:severity] <= 2 and values[:med].to_i > 0
body += '<div id="medium"><a name="Medium"></a><h3>Medium</h3>'
body += '<table id="medium_table" class="display"><thead><tr><th>Nessus ID</th><th>Name</th><th>Synopsis</th><th>Result</th><th>Family</th><th>Port</th></tr></thead><tbody>'
@events.sort_by{|k,v| v[:port].to_s}.each do |vuln_id,vuln_data|
@@ -358,11 +373,11 @@
end
body += '</tbody></table></div>'
end
- if @options[:severity] <= 1
+ if @options[:severity] <= 1 and values[:low].to_i > 0
body += '<div id="low"><a name="Low"></a><h3>Low</h3>'
body += '<table id="low_table" class="display"><thead><tr><th>Nessus ID</th><th>Name</th><th>Synopsis</th><th>Result</th><th>Family</th><th>Port</th></tr></thead><tbody>'
@events.sort_by{|k,v| v[:port].to_s}.each do |vuln_id,vuln_data|
@@ -375,11 +390,11 @@
}
end
body += '</tbody></table></div>'
end
- if @options[:severity] <= 0
+ if @options[:severity] <= 0 and values[:info].to_i > 0
body += '<div id="informational"><a name="Informational"></a><h3>Informational</h3>'
body += '<table id="informational_table" class="display"><thead><tr><th>Nessus ID</th><th>Name</th><th>Synopsis</th><th>Result</th><th>Family</th><th>Port</th></tr></thead><tbody>'
@events.sort_by{|k,v| v[:port].to_s}.each do |vuln_id,vuln_data|
@@ -394,15 +409,15 @@
body += '</tbody></table></div>'
end
body += "<script>$(document).ready(function() {\n ";
- body += "$('#critical_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] > 4
- body += "$('#high_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] > 3
- body += "$('#medium_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] > 2
- body += "$('#low_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] > 1
- body += "$('#informational_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] > 0
+ body += "$('#critical_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] <= 4
+ body += "$('#high_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] <= 3
+ body += "$('#medium_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] <= 2
+ body += "$('#low_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] <= 1
+ body += "$('#informational_table').dataTable({\"bPaginate\": false});\n" if @options[:severity] <= 0
body += "});</script>"
body += '</div></div>'
body_text(f,body)
@@ -569,10 +584,13 @@
fp.puts <<-eos
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
+ credits: {
+ enabled: false
+ },
chart: {
renderTo: '#{renderto}',
type: 'bar'
},
title: {
@@ -596,10 +614,11 @@
fp.puts <<-eos
]
},
yAxis: {
min: 0,
+ allowDecimals: false,
title: {
text: 'Findings'
}
},
legend: {
@@ -613,15 +632,21 @@
}
},
plotOptions: {
series: {
stacking: 'normal',
+ //threshold: 1,
dataLabels: {
enabled: true,
color: '#000000',
x: 0,
- align: 'center'
+ align: 'center',
+ formatter: function() {
+ if (this.y !=0) {
+ return this.y;
+ }
+ }
},
events: {
click: function(event) {
//alert(target_lookup[event.point.category])
document.location.href = 'host_' + target_lookup[event.point.category] + '.html#' + event.currentTarget.name;
@@ -725,10 +750,13 @@
fp.puts <<-eos
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
+ credits: {
+ enabled: false
+ },
chart: {
renderTo: '#{renderto}',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
@@ -736,27 +764,29 @@
title: {
text: '#{title}'
},
tooltip: {
formatter: function() {
- return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
+ return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %';
}
},
plotOptions: {
pie: {
+ size: '60%',
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y;
- }
+ },
+ distance: 20
}
eos
- if not clickfunction.nil?
+ unless clickfunction.nil?
fp.puts ',events: { click: function(event) { ' + clickfunction + '} }'
end
fp.puts <<-eos
}
\ No newline at end of file