Class: Risu::Templates::HostFindingsCSV

Inherits:
Base::TemplateBase show all
Defined in:
lib/risu/templates/host_findings_csv.rb

Instance Attribute Summary

Attributes inherited from Base::TemplateBase

#output, #template_info

Instance Method Summary collapse

Methods inherited from Base::TemplateBase

inherited

Constructor Details

#initializeHostFindingsCSV

Returns a new instance of HostFindingsCSV.



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

def initialize
	@template_info =
	{
		:name => "host_findings_csv",
		:author => "hammackj",
		:version => "0.0.3",
		:renderer => "CSV",
		:description => "Generates a findings report by host and outputs to CSV"

	}
end

Instance Method Details

#csv(risks) ⇒ Object

Writes out a CSV block for the risks passed.

Parameters:

  • risks,

    A query from the Plugin model of the risks



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/risu/templates/host_findings_csv.rb', line 43

def csv risks
	risks.order(:cvss_base_score).each do |plugin|
		items = Item.where(:plugin_id => plugin.id).group(:host_id)

		items.each do |item|
			# Skip all PostProcssed Items
			if item.severity == -1
				next
			end

			host = Host.where(:id => item.host_id).first

			solution = plugin.solution.gsub("\n", " ").gsub(",", "")

			@output.text "#{host.ip}, #{host.fqdn}, #{host.netbios}, #{item.plugin_name}, #{plugin.risk_factor}, #{plugin.cvss_base_score}, #{solution}"
		end
	end
end

#render(output) ⇒ Object

TODO doc



64
65
66
67
68
# File 'lib/risu/templates/host_findings_csv.rb', line 64

def render output
	@output.text "IP Address, FQDN, Netbios Name, Finding, Risk Factor, CVSS Base Score, Solution"
	csv Plugin.critical_risks.order(cvss_base_score: :desc)
	csv Plugin.high_risks.order(cvss_base_score: :desc)
end