Sha256: 257f671f4cc4c1a5c8835e499a0ee61cbf56d700916199d8304b9b0934a40808

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

require 'smart_proxy_openscap/openscap_exception'

module Proxy
  module OpenSCAP
    class PolicyGuide
      include ::Proxy::Log

      def generate_guide(file_content, policy_id)
        Tempfile.create do |file|
          file.write file_content
          file.flush
          command = ['oscap', 'xccdf', 'generate'] + profile_opt(policy_id) + ['guide', file.path]
          Proxy::OpenSCAP.execute!(*command).first
        end
      rescue => e
        logger.debug e.message
        logger.debug e.backtrace.join("\n\t")
        raise OpenSCAPException, "Failed to generate policy guide, cause: #{e.message}"
      end

      def profile_opt(policy_id)
        policy_id ? ['--profile', policy_id] : []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_proxy_openscap-0.12.0 lib/smart_proxy_openscap/policy_guide.rb