Class: Risu::Templates::Top25

Inherits:
Base::TemplateBase show all
Includes:
TemplateHelper
Defined in:
lib/risu/templates/top_25.rb

Instance Attribute Summary

Attributes inherited from Base::TemplateBase

#output, #template_info

Instance Method Summary collapse

Methods included from TemplateHelper

#default_credential_plugins, #default_credentials_appendix_section, #default_credentials_section, #definition, #has_default_credentials?, #heading1, #heading2, #heading3, #heading4, #heading5, #heading6, #item_count_by_plugin_id, #item_count_by_plugin_name, #new_page, #report_author, #report_classification, #report_subtitle, #report_title, #table, #text, #title

Methods included from ScanHelper

#authenticated_count, #scan_info_to_hash

Methods included from SharesTemplateHelper

#anon_ftp_count, #anon_ftp_section, #anon_smb_count, #anon_smb_query, #anon_smb_section, #shares_appendix_section, #shares_section, #shares_section_has_findings?

Methods included from GraphTemplateHelper

#other_os_graph_page, #risks_by_service_graph_page, #risks_by_severity_graph_page, #root_cause_graph_page, #windows_os_graph_page

Methods included from MalwareTemplateHelper

#conficker_appendix_section, #conficker_count, #conficker_section, #known_malicious_process_appendix_section, #known_malicious_process_count, #known_malicious_process_section, #malware_appendix_section, #malware_section

Methods included from HostTemplateHelper

#unsupported_os, #unsupported_os_appendix_section

Methods inherited from Base::TemplateBase

inherited

Constructor Details

#initializeTop25

Returns a new instance of Top25.



29
30
31
32
33
34
35
36
37
38
# File 'lib/risu/templates/top_25.rb', line 29

def initialize
	@template_info =
	{
		:name => "top_25",
		:author => "hammackj",
		:version => "0.0.3",
		:renderer => "PDF",
		:description => "Generates a Top 25 Remediation report"
	}
end

Instance Method Details

#render(output) ⇒ Object



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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/risu/templates/top_25.rb', line 42

def render output
	text Report.classification.upcase, :align => :center
	text "\n"

	report_title Report.title
	report_subtitle "Top 25 Remediations"
	report_author "This report was prepared by\n#{Report.author}"
	text "\n\n\n"

	results = Array.new

	headers = ["Remediations", "Vulns", "Exploitability", "Assets", "RiskScore"]

	page_width = output.bounds.width

	#header_widths = {0 => 255, 1 => 56, 2 => 56, 3 => 56, 4 => 57}
	header_widths =
	{
		0 => (page_width * 0.50),
		1 => (page_width * 0.10),
		2 => (page_width * 0.15),
		3 => (page_width * 0.10),
		4 => (page_width * 0.15)
	}

	#Plugin.where(:risk_factor => "Critical").order(:risk_score).limit(25).reverse_order.each do |plugin|
	Plugin.joins(:items).where(:items => {severity: 4}).order(:risk_score).group(:plugin_id).limit(25).reverse_order.each do |plugin|
		row = Array.new

		name = plugin.plugin_name
		vulns = Item.where(:plugin_id => plugin.id).count

		if plugin.exploitability_ease == "Exploits are available"
			exploitability = "Yes"
		else
			exploitability = "No"
		end

		assets = 0

		if Item.where(:plugin_id => plugin.id).group(:host_id) != nil
			assets = Item.where(:plugin_id => plugin.id).group(:host_id).to_a.count
		end

		# vuln_pub_days = 1

		# vuln_pub_days = (DateTime.now.to_date - plugin.vuln_publication_date.to_date).to_i if plugin.vuln_publication_date != nil

		# risk = (plugin.cvss_base_score.to_f * vuln_pub_days)  * assets
		risk = plugin.risk_score

		row.push(name)
		row.push(vulns)
		row.push(exploitability)
		row.push(assets)
		row.push(risk)

		results.push(row)
	end

	output.table([headers] + results, :header => true, :column_widths => header_widths, :row_colors => ['ffffff', 'E5E5E5']) do
		row(0).style(:font_style => :bold, :background_color => 'D0D0D0')
		cells.borders = [:top, :bottom, :left, :right]
	end

	output.number_pages "<page> of <total>", :at => [output.bounds.right - 75, 0], :width => 150, :page_filter => :all
end