foreman_openscap 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/compliance/arf_reports_controller.rb +1 -1
- data/app/models/concerns/foreman_openscap/host_extensions.rb +6 -1
- data/app/models/concerns/foreman_openscap/hostgroup_extensions.rb +13 -0
- data/app/models/concerns/foreman_openscap/policy_extensions.rb +2 -2
- data/app/views/scaptimony_policies/steps/_scap_content_form.html.erb +5 -0
- data/lib/foreman_openscap/engine.rb +1 -0
- data/lib/foreman_openscap/helper.rb +4 -2
- data/lib/foreman_openscap/version.rb +1 -1
- data/test/unit/openscap_host_test.rb +28 -0
- metadata +5 -4
- data/test/unit/foreman_openscap_test.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc23a893a6f93d33f710ee464f998add2a5e1498
|
4
|
+
data.tar.gz: fcf1e51452a94983844f42a62d198bc0f95240d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68084f2791991b42c7e1eb313a892f892b5a16e10f1fe14e2ac6ab45cc1c00684b587a218cf0b9ea81a7ce28fc9d73598606e962bfb0189d1b35a63ae7d464c4
|
7
|
+
data.tar.gz: 930e20cabae6c401715cf968d438b87afcb0b2de32364f9e72a2e51c2dfb29fa5071164ee9edf763e901e62e26e1331e8d98c99dfc2bc83ffd68459f3bf68688
|
@@ -27,7 +27,7 @@ module Api
|
|
27
27
|
param :date, :identifier, :required => true
|
28
28
|
|
29
29
|
def create
|
30
|
-
asset = ForemanOpenscap::Helper::get_asset(params[:cname])
|
30
|
+
asset = ForemanOpenscap::Helper::get_asset(params[:cname], params[:policy_id])
|
31
31
|
arf_bzip2 = request.body.read
|
32
32
|
arf_bzip2_size = request.body.size
|
33
33
|
Scaptimony::ArfReportsHelper.create_arf(asset, params, arf_bzip2, arf_bzip2_size)
|
@@ -22,7 +22,12 @@ module ForemanOpenscap
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def policies_enc
|
25
|
-
|
25
|
+
combined_policies.map(&:to_enc).to_json
|
26
|
+
end
|
27
|
+
|
28
|
+
def combined_policies
|
29
|
+
combined = self.policies + self.hostgroup.policies
|
30
|
+
combined.uniq
|
26
31
|
end
|
27
32
|
|
28
33
|
module ClassMethods
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'scaptimony/asset'
|
2
|
+
|
3
|
+
module ForemanOpenscap
|
4
|
+
module HostgroupExtensions
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
has_one :asset, :as => :assetable, :class_name => "::Scaptimony::Asset"
|
9
|
+
has_many :asset_policies, :through => :asset, :class_name => "::Scaptimony::AssetPolicy"
|
10
|
+
has_many :policies, :through => :asset_policies, :class_name => "::Scaptimony::Policy"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -29,9 +29,9 @@ module ForemanOpenscap
|
|
29
29
|
validates :period, :inclusion => {:in => %w[weekly monthly custom]},
|
30
30
|
:if => Proc.new { | policy | policy.new_record? ? policy.step_index > 3 : !policy.id.blank? }
|
31
31
|
validates :weekday, :inclusion => {:in => Date::DAYNAMES.map(&:downcase)},
|
32
|
-
:if => Proc.new { | policy | policy.new_record? ? policy.step_index > 3
|
32
|
+
:if => Proc.new { | policy | policy.period == 'weekly' && (policy.new_record? ? policy.step_index > 3 : !policy.id.blank?) }
|
33
33
|
validates :day_of_month, :numericality => {:greater_than => 0, :less_than => 32},
|
34
|
-
:if => Proc.new { | policy | policy.new_record? ? policy.step_index > 3
|
34
|
+
:if => Proc.new { | policy | policy.period == 'monthly'&& (policy.new_record? ? policy.step_index > 3 : !policy.id.blank?) }
|
35
35
|
validate :valid_cron_line
|
36
36
|
validate :ensure_period_specification_present
|
37
37
|
|
@@ -7,6 +7,11 @@
|
|
7
7
|
</span>
|
8
8
|
<div class="alert alert-info">
|
9
9
|
<%= icon_text("info-sign", _('Notice: Ensure the selected SCAP content exists on your hosts.')) %>
|
10
|
+
<div id="file-location">
|
11
|
+
<% if @policy.scap_content %>
|
12
|
+
<b><%= _('SCAP content file should be /var/lib/openscap/content/%s.xml on your clients.') % @policy.scap_content.digest %></b>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
10
15
|
</div>
|
11
16
|
</div>
|
12
17
|
|
@@ -72,6 +72,7 @@ module ForemanOpenscap
|
|
72
72
|
config.to_prepare do
|
73
73
|
Host::Managed.send(:include, ForemanOpenscap::HostExtensions)
|
74
74
|
HostsHelper.send(:include, ForemanOpenscap::HostsHelperExtensions)
|
75
|
+
Hostgroup.send(:include, ForemanOpenscap::HostgroupExtensions)
|
75
76
|
::Scaptimony::ArfReport.send(:include, ForemanOpenscap::ArfReportExtensions)
|
76
77
|
::Scaptimony::Asset.send(:include, ForemanOpenscap::AssetExtensions)
|
77
78
|
::Scaptimony::Policy.send(:include, ForemanOpenscap::PolicyExtensions)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class OpenscapHostTest < ActiveSupport::TestCase
|
4
|
+
setup do
|
5
|
+
disable_orchestration
|
6
|
+
User.current = users :admin
|
7
|
+
Setting[:token_duration] = 0
|
8
|
+
Scaptimony::Policy.any_instance.stubs(:ensure_needed_puppetclasses).returns(true)
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'Host has policy' do
|
12
|
+
host = FactoryGirl.create(:host)
|
13
|
+
assert_empty(host.policies)
|
14
|
+
policy = FactoryGirl.create(:policy)
|
15
|
+
|
16
|
+
assert(policy.assign_hosts([host]), 'Host policies should be assigned')
|
17
|
+
assert_includes(host.policies, policy)
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'Host has policies via its hostgroup' do
|
21
|
+
host = FactoryGirl.create(:host, :with_hostgroup)
|
22
|
+
hostgroup = host.hostgroup
|
23
|
+
policy = FactoryGirl.create(:policy)
|
24
|
+
assert(policy.hostgroup_ids = ["#{hostgroup.id}"])
|
25
|
+
refute_empty(host.combined_policies)
|
26
|
+
assert_includes(host.combined_policies, policy)
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_openscap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Šimon Lukašík"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- app/models/concerns/foreman_openscap/arf_report_extensions.rb
|
66
66
|
- app/models/concerns/foreman_openscap/asset_extensions.rb
|
67
67
|
- app/models/concerns/foreman_openscap/host_extensions.rb
|
68
|
+
- app/models/concerns/foreman_openscap/hostgroup_extensions.rb
|
68
69
|
- app/models/concerns/foreman_openscap/policy_extensions.rb
|
69
70
|
- app/models/concerns/foreman_openscap/scap_content_extensions.rb
|
70
71
|
- app/overrides/hosts/index/host_arf_report.rb
|
@@ -114,7 +115,7 @@ files:
|
|
114
115
|
- lib/tasks/foreman_openscap_tasks.rake
|
115
116
|
- test/factories/foreman_openscap_factories.rb
|
116
117
|
- test/test_plugin_helper.rb
|
117
|
-
- test/unit/
|
118
|
+
- test/unit/openscap_host_test.rb
|
118
119
|
homepage: https://github.com/OpenSCAP/foreman_openscap
|
119
120
|
licenses:
|
120
121
|
- GPL-3.0
|
@@ -140,7 +141,7 @@ signing_key:
|
|
140
141
|
specification_version: 4
|
141
142
|
summary: Foreman plug-in for displaying OpenSCAP audit reports
|
142
143
|
test_files:
|
143
|
-
- test/unit/
|
144
|
+
- test/unit/openscap_host_test.rb
|
144
145
|
- test/test_plugin_helper.rb
|
145
146
|
- test/factories/foreman_openscap_factories.rb
|
146
147
|
has_rdoc:
|