module Proxy::OpenSCAP

lib/helpers.rb

Constants

HTTP_ERRORS
VERSION

Public Class Methods

common_name(request) click to toggle source
# File lib/smart_proxy_openscap/openscap_lib.rb, line 42
def self.common_name(request)
  client_cert = request.env['SSL_CLIENT_CERT']
  raise Proxy::Error::Unauthorized, "Client certificate required!" if client_cert.to_s.empty?

  begin
    client_cert = OpenSSL::X509::Certificate.new(client_cert)
  rescue OpenSSL::OpenSSLError => e
    raise Proxy::Error::Unauthorized, e.message
  end
  cn = client_cert.subject.to_a.detect { |name, value| name == 'CN' }
  cn = cn[1] unless cn.nil?
  raise Proxy::Error::Unauthorized, "Common Name not found in the certificate" unless cn
  cn
end
execute!(*cmd) click to toggle source
# File lib/smart_proxy_openscap/openscap_lib.rb, line 68
def self.execute!(*cmd)
  out, err, status = Open3.capture3(*cmd)
  raise "'#{cmd.join(' ')} exited with #{status.exitstatus}: #{err}" unless status.success?
  [out, err, status]
end
fullpath(path = Proxy::OpenSCAP::Plugin.settings.contentdir) click to toggle source
# File lib/smart_proxy_openscap/openscap_lib.rb, line 63
def self.fullpath(path = Proxy::OpenSCAP::Plugin.settings.contentdir)
  pathname = Pathname.new(path)
  pathname.relative? ? pathname.expand_path(Sinatra::Base.root).to_s : path
end
plugin_settings() click to toggle source
# File lib/smart_proxy_openscap/openscap_lib.rb, line 33
def self.plugin_settings
  @@settings ||= OpenStruct.new(read_settings)
end
read_settings() click to toggle source
# File lib/smart_proxy_openscap/openscap_lib.rb, line 37
def self.read_settings
  ::Proxy::OpenSCAP::Plugin.default_settings.merge(
    YAML.load_file(File.join(::Proxy::SETTINGS.settings_directory, ::Proxy::OpenSCAP::Plugin.settings_file)))
end
send_spool_to_foreman(loaded_settings) click to toggle source
# File lib/smart_proxy_openscap/openscap_lib.rb, line 57
def self.send_spool_to_foreman(loaded_settings)
  arf_dir = File.join(loaded_settings.spooldir, "/arf")
  return unless File.exist? arf_dir
  SpoolForwarder.new(loaded_settings).post_arf_from_spool(arf_dir)
end