Class: Proxy::OpenSCAP::ScapProfiles
- Inherits:
-
Object
- Object
- Proxy::OpenSCAP::ScapProfiles
- Defined in:
- lib/smart_proxy_openscap/scap_profiles.rb
Instance Method Summary collapse
- #benchmark_profiles(source) ⇒ Object
- #collect_profiles(profile_source) ⇒ Object
- #profiles(in_file, out_file, type) ⇒ Object
- #scap_content_profiles(source) ⇒ Object
- #tailoring_profiles(source) ⇒ Object
Instance Method Details
#benchmark_profiles(source) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/smart_proxy_openscap/scap_profiles.rb', line 40 def benchmark_profiles(source) sds = ::OpenSCAP::DS::Sds.new(source) bench_source = sds.select_checklist! benchmark = ::OpenSCAP::Xccdf::Benchmark.new(bench_source) sds.destroy benchmark end |
#collect_profiles(profile_source) ⇒ Object
34 35 36 37 38 |
# File 'lib/smart_proxy_openscap/scap_profiles.rb', line 34 def collect_profiles(profile_source) profile_source.profiles.inject({}) do |memo, (key, profile)| memo.tap { |hash| hash[key] = profile.title.strip } end end |
#profiles(in_file, out_file, type) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/smart_proxy_openscap/scap_profiles.rb', line 11 def profiles(in_file, out_file, type) ::OpenSCAP.oscap_init source = ::OpenSCAP::Source.new(in_file) json = type == 'scap_content' ? scap_content_profiles(source) : tailoring_profiles(source) File.write out_file, json source.destroy ::OpenSCAP.oscap_cleanup end |
#scap_content_profiles(source) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/smart_proxy_openscap/scap_profiles.rb', line 20 def scap_content_profiles(source) bench = benchmark_profiles source profiles = collect_profiles bench bench.destroy profiles.to_json end |
#tailoring_profiles(source) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/smart_proxy_openscap/scap_profiles.rb', line 27 def tailoring_profiles(source) tailoring = ::OpenSCAP::Xccdf::Tailoring.new(source, nil) profiles = collect_profiles tailoring tailoring.destroy profiles.to_json end |