Class: ForemanCveScanner::ScanImporter

Inherits:
Object
  • Object
show all
Defined in:
app/services/foreman_cve_scanner/scan_importer.rb

Overview

Import CVE scan results from REX job output and persist them.

Instance Method Summary collapse

Constructor Details

#initialize(job_output) ⇒ ScanImporter

Returns a new instance of ScanImporter.



6
7
8
# File 'app/services/foreman_cve_scanner/scan_importer.rb', line 6

def initialize(job_output)
  @job_output = job_output
end

Instance Method Details

#import_for_host!(host) ⇒ Object



10
11
12
13
14
15
16
# File 'app/services/foreman_cve_scanner/scan_importer.rb', line 10

def import_for_host!(host)
  scan_json = format_output(@job_output)
  return nil if scan_json.nil?

  scanner_name = ::ForemanCveScanner::CveReportScanner.detect_scanner(scan_json)
  persist_scan!(host, scanner_name, scan_json)
end