class ForemanCveScanner::Engine
Rails engine for the Foreman CVE Scanner plugin.
Public Class Methods
documented_controllers()
click to toggle source
# File lib/foreman_cve_scanner/engine.rb, line 61 def self.documented_controllers ["#{ForemanCveScanner::Engine.root}/app/controllers/api/v2/*.rb"] end
register_katello_integration()
click to toggle source
# File lib/foreman_cve_scanner/engine.rb, line 65 def self.register_katello_integration return unless Foreman::Plugin.installed?(:katello) return unless defined?(::Katello::Host::ProfilesUploader) ::Katello::Host::ProfilesUploader.prepend(ForemanCveScanner::ProfilesUploader) end
register_permissions(plugin)
click to toggle source
# File lib/foreman_cve_scanner/engine.rb, line 96 def self.register_permissions(plugin) plugin.security_block :foreman_cve_scanner do permission :view_cve_scans, { 'api/v2/cve_scans': %i[index latest show export compare] }, resource_type: 'Host' permission :import_cve_scans, { 'api/v2/cve_scans': %i[import] }, resource_type: 'Host' permission :destroy_cve_scans, { 'api/v2/cve_scans': %i[destroy] }, resource_type: 'Host' end end
register_plugin()
click to toggle source
# File lib/foreman_cve_scanner/engine.rb, line 49 def self.register_plugin Foreman::Plugin.register :foreman_cve_scanner do requires_foreman '>= 3.13' register_global_js_file 'fills' apipie_documented_controllers ForemanCveScanner::Engine.documented_controllers extend_template_helpers ForemanCveScanner::TemplateHelpers ForemanCveScanner::Engine.register_settings(self) ForemanCveScanner::Engine.register_permissions(self) add_all_permissions_to_default_roles end end
register_rex_features()
click to toggle source
# File lib/foreman_cve_scanner/engine.rb, line 39 def self.register_rex_features RemoteExecutionFeature.register( :run_cve_scan, N_('Run CVE scan'), description: N_('Run CVE scan'), host_action_button: true, provided_inputs: %w[scanner] ) end
register_settings(plugin)
click to toggle source
# File lib/foreman_cve_scanner/engine.rb, line 71 def self.register_settings(plugin) plugin.settings do category :foreman_cve_scanner, N_('CVE Scanner') do setting 'preferred_cve_scanner', type: :string, default: 'trivy', full_name: N_('Preferred CVE scanner'), description: N_('Default scanner used by the Run CVE scan job template.') setting 'run_cve_scan_after_host_profiles_upload', type: :boolean, default: false, full_name: N_('Run CVE scan after host profiles upload'), description: N_('When Katello is installed, schedule a CVE scan after a host profiles upload completes.') setting 'cve_scan_delete_after_days', type: :integer, default: 90, full_name: N_('Delete CVE scans after X days'), description: N_( 'Delete CVE scans older than the configured number of days. ' \ 'Set to 0 to disable automatic cleanup.' ) end end end