Class: ForemanCveScanner::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- ForemanCveScanner::Engine
- Defined in:
- lib/foreman_cve_scanner/engine.rb
Overview
Rails engine for the Foreman CVE Scanner plugin.
Class Method Summary collapse
- .documented_controllers ⇒ Object
- .register_katello_integration ⇒ Object
- .register_permissions(plugin) ⇒ Object
- .register_plugin ⇒ Object
- .register_rex_features ⇒ Object
- .register_settings(plugin) ⇒ Object
Class Method Details
.documented_controllers ⇒ Object
61 62 63 |
# 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 ⇒ Object
65 66 67 68 69 |
# 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) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/foreman_cve_scanner/engine.rb', line 96 def self.(plugin) plugin.security_block :foreman_cve_scanner do :view_cve_scans, { 'api/v2/cve_scans': %i[index latest show export compare] }, resource_type: 'Host' :import_cve_scans, { 'api/v2/cve_scans': %i[import] }, resource_type: 'Host' :destroy_cve_scans, { 'api/v2/cve_scans': %i[destroy] }, resource_type: 'Host' end end |
.register_plugin ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# 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.(self) end end |
.register_rex_features ⇒ Object
39 40 41 42 43 44 45 46 47 |
# 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) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# 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 |