Class: ForemanCveScanner::CveReportScanner
- Inherits:
-
Object
- Object
- ForemanCveScanner::CveReportScanner
- Defined in:
- app/services/foreman_cve_scanner/cve_report_scanner.rb
Overview
Scans ConfigReports after import for indicators of an CveScanner report and sets the origin of the report to ‘CveScanner’
Instance Attribute Summary collapse
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
- .add_reporter_data(_report, raw) ⇒ Object
- .cve_scanner_report?(raw) ⇒ Boolean
- .identify_origin(raw) ⇒ Object
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(raw) ⇒ CveReportScanner
constructor
A new instance of CveReportScanner.
- #metrics ⇒ Object
Constructor Details
#initialize(raw) ⇒ CveReportScanner
Returns a new instance of CveReportScanner.
24 25 26 27 |
# File 'app/services/foreman_cve_scanner/cve_report_scanner.rb', line 24 def initialize(raw) @raw_data = raw @cve_report_data = generate_unified_vuls end |
Instance Attribute Details
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
38 39 40 |
# File 'app/services/foreman_cve_scanner/cve_report_scanner.rb', line 38 def logs @logs end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
38 39 40 |
# File 'app/services/foreman_cve_scanner/cve_report_scanner.rb', line 38 def status @status end |
Class Method Details
.add_reporter_data(_report, raw) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/services/foreman_cve_scanner/cve_report_scanner.rb', line 7 def self.add_reporter_data(_report, raw) scanner = ForemanCveScanner::CveReportScanner.new(raw) scanner.generate raw['logs'] = scanner.logs raw['status'] = scanner.status raw['metrics'] = scanner.metrics raw['report_status_calculator_options'] = { :metrics => %w[critical high medium low total] } end |
.cve_scanner_report?(raw) ⇒ Boolean
20 21 22 |
# File 'app/services/foreman_cve_scanner/cve_report_scanner.rb', line 20 def self.cve_scanner_report?(raw) raw['reporter'] == 'cve_scan' end |
.identify_origin(raw) ⇒ Object
16 17 18 |
# File 'app/services/foreman_cve_scanner/cve_report_scanner.rb', line 16 def self.identify_origin(raw) 'CveScanner' if cve_scanner_report?(raw) end |
Instance Method Details
#generate ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/services/foreman_cve_scanner/cve_report_scanner.rb', line 29 def generate @status = {} @logs = [] @cve_report_data.each do |id, cve| @logs << generate_log_from_unified(id, cve) end @logs end |
#metrics ⇒ Object
40 41 42 43 44 |
# File 'app/services/foreman_cve_scanner/cve_report_scanner.rb', line 40 def metrics res = @status res['total'] = @status.values.sum res end |