Class: Risu::Models::Plugin
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Risu::Models::Plugin
- Defined in:
- lib/risu/models/plugin.rb
Overview
Plugin Model
Class Method Summary collapse
-
.critical_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor.
-
.high_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor.
-
.in_the_news ⇒ Object
TODO doc.
-
.low_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor.
-
.medium_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor.
-
.none_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor.
-
.risks ⇒ Array
Queries for all risks based on Plugin.risk_factor.
- .root_cause_graph ⇒ Object
- .root_cause_graph_text ⇒ Object
-
.top_by_count_graph(limit = 10) ⇒ Object
Creates a graph based on the top plugins sorted by count.
Instance Method Summary collapse
Class Method Details
.critical_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor
53 54 55 |
# File 'lib/risu/models/plugin.rb', line 53 def critical_risks where(:risk_factor => "Critical") end |
.high_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor
60 61 62 |
# File 'lib/risu/models/plugin.rb', line 60 def high_risks where(:risk_factor => "High") end |
.in_the_news ⇒ Object
TODO doc
87 88 89 |
# File 'lib/risu/models/plugin.rb', line 87 def in_the_news where(:in_the_news => true) end |
.low_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor
74 75 76 |
# File 'lib/risu/models/plugin.rb', line 74 def low_risks where(:risk_factor => "Low") end |
.medium_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor
67 68 69 |
# File 'lib/risu/models/plugin.rb', line 67 def medium_risks where(:risk_factor => "Medium") end |
.none_risks ⇒ ActiveRelation
Queries for all the critical risks based on Plugin.risk_factor
81 82 83 |
# File 'lib/risu/models/plugin.rb', line 81 def none_risks where(:risk_factor => "None") end |
.risks ⇒ Array
Queries for all risks based on Plugin.risk_factor
46 47 48 |
# File 'lib/risu/models/plugin.rb', line 46 def risks critical_risks + high_risks + medium_risks + low_risks + none_risks end |
.root_cause_graph ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/risu/models/plugin.rb', line 130 def root_cause_graph g = Gruff::Pie.new(GRAPH_WIDTH) g.title = sprintf "Vulnerability Root Cause" g.sort = false g.marker_count = 1 g.theme = { :colors => Risu::GRAPH_COLORS, :background_colors => %w(white white) } g.data('Vendor Patch', Plugin.where(:root_cause => 'Vendor Patch').count) g.data('Vendor Support', Plugin.where(:root_cause => 'Vendor Support').count) g.data('Configuration', Plugin.where(:root_cause => 'Configuration').count) StringIO.new(g.to_blob) end |
.root_cause_graph_text ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/risu/models/plugin.rb', line 147 def root_cause_graph_text graph_text = "This graph shows the basic root cause of a vulnerability, the data is broken up into " + "three categories. Vendor Patch, Vendor Support and Configuration.\n\n" graph_text << "Vendor Patch represents vulnerabilities from missing patches. IE missing Microsoft patches.\n" graph_text << "Vendor Support represents vulnerabilities caused by the lack of vendor support. IE unsupported software.\n" graph_text << "Configuration represents vulnerabilities caused by misconfiguration of software or hardware. IE default passwords.\n\n" return graph_text end |
.top_by_count_graph(limit = 10) ⇒ Object
Creates a graph based on the top plugins sorted by count
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/risu/models/plugin.rb', line 94 def top_by_count_graph(limit=10) g = Gruff::Bar.new(GRAPH_WIDTH) g.title = sprintf "Top %d Critical Findings By Plugin", Item.risks_by_plugin(limit).to_a.count g.sort = false g.marker_count = 1 g.theme = { :colors => Risu::GRAPH_COLORS, :background_colors => %w(white white) } Item.risks_by_plugin(limit).to_a.each do |plugin| plugin_name = Plugin.find_by_id(plugin.plugin_id).plugin_name #We need to filter the names a little to make everything look nice on the graph #@TODO this concept should be added to the database via a yaml file plugin_name = case plugin.plugin_id when 35362 then plugin_name.split(":")[0] when 34477 then plugin_name.split(":")[0] when 35635 then plugin_name.split(":")[0] when 21564 then "VNC Remote Authentication Bypass" when 38664 then "Intel Common Base Agent Remote Command Execution" when 42411 then "Windows SMB Shares Unprivileged Access" else plugin_name = Plugin.find_by_id(plugin.plugin_id).plugin_name end if plugin_name =~ /^(MS\d{2}-\d{3}):/ plugin_name = $1 end g.data(plugin_name, Item.where(:plugin_id => plugin.plugin_id).count) end StringIO.new(g.to_blob) end |
Instance Method Details
#cvss_base_score ⇒ Object
37 38 39 |
# File 'lib/risu/models/plugin.rb', line 37 def cvss_base_score read_attribute(:cvss_base_score).to_s end |
#cvss_base_score=(cvss_base_score) ⇒ Object
33 34 35 |
# File 'lib/risu/models/plugin.rb', line 33 def cvss_base_score=(cvss_base_score) write_attribute(:cvss_base_score, cvss_base_score.to_f) end |