foreman_openscap 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/policies_controller.rb +8 -4
- data/app/models/concerns/foreman_openscap/host_extensions.rb +11 -7
- data/app/models/foreman_openscap/policy.rb +11 -9
- data/app/views/job_templates/run_openscap_scans.erb +1 -0
- data/app/views/policy_dashboard/_policy_reports.html.erb +1 -1
- data/lib/foreman_openscap/version.rb +1 -1
- data/locale/de/foreman_openscap.edit.po +1231 -0
- data/locale/de/foreman_openscap.po +3 -0
- data/locale/de/foreman_openscap.po.time_stamp +0 -0
- data/locale/en_GB/foreman_openscap.edit.po +1231 -0
- data/locale/en_GB/foreman_openscap.po +3 -0
- data/locale/en_GB/foreman_openscap.po.time_stamp +0 -0
- data/locale/es/foreman_openscap.edit.po +1231 -0
- data/locale/es/foreman_openscap.po +3 -0
- data/locale/es/foreman_openscap.po.time_stamp +0 -0
- data/locale/foreman_openscap.pot +82 -78
- data/locale/fr/foreman_openscap.edit.po +1231 -0
- data/locale/fr/foreman_openscap.po +3 -0
- data/locale/fr/foreman_openscap.po.time_stamp +0 -0
- data/locale/gl/foreman_openscap.edit.po +1231 -0
- data/locale/gl/foreman_openscap.po +3 -0
- data/locale/gl/foreman_openscap.po.time_stamp +0 -0
- data/locale/it/foreman_openscap.edit.po +1231 -0
- data/locale/it/foreman_openscap.po +3 -0
- data/locale/it/foreman_openscap.po.time_stamp +0 -0
- data/locale/ja/foreman_openscap.edit.po +1231 -0
- data/locale/ja/foreman_openscap.po +3 -0
- data/locale/ja/foreman_openscap.po.time_stamp +0 -0
- data/locale/ko/foreman_openscap.edit.po +1231 -0
- data/locale/ko/foreman_openscap.po +3 -0
- data/locale/ko/foreman_openscap.po.time_stamp +0 -0
- data/locale/pt_BR/foreman_openscap.edit.po +1231 -0
- data/locale/pt_BR/foreman_openscap.po +3 -0
- data/locale/pt_BR/foreman_openscap.po.time_stamp +0 -0
- data/locale/ru/foreman_openscap.edit.po +1232 -0
- data/locale/ru/foreman_openscap.po +3 -0
- data/locale/ru/foreman_openscap.po.time_stamp +0 -0
- data/locale/sv_SE/foreman_openscap.edit.po +1231 -0
- data/locale/sv_SE/foreman_openscap.po +3 -0
- data/locale/sv_SE/foreman_openscap.po.time_stamp +0 -0
- data/locale/zh_CN/foreman_openscap.edit.po +1231 -0
- data/locale/zh_CN/foreman_openscap.po +3 -0
- data/locale/zh_CN/foreman_openscap.po.time_stamp +0 -0
- data/locale/zh_TW/foreman_openscap.edit.po +1231 -0
- data/locale/zh_TW/foreman_openscap.po +3 -0
- data/locale/zh_TW/foreman_openscap.po.time_stamp +0 -0
- data/test/unit/arf_report_test.rb +21 -0
- data/test/unit/concerns/host_extensions_test.rb +8 -0
- data/test/unit/openscap_host_test.rb +14 -2
- data/test/unit/policy_test.rb +8 -0
- metadata +63 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0b6304ecdc7fd28bb61ee2274acf8bf5a281bad437a67aa4b0fbe8214b438432
|
4
|
+
data.tar.gz: e7545538f9f374458f0b1d3b365367bf21532971d2043068fd83b3b7afbe7db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8206badfe4852a6a74ba2ced8aeb863f1fdb09383b4522c92604eb255fed2ee0fbe98bb3544b81be75969de2b581c2123ad5619f01f9e324e30f081a7224239f
|
7
|
+
data.tar.gz: baf9118c0c690b4c446f565848848cd11368345c59bcd44b44b4e443f387ba26c631e173d352cdc5de150a2cd792bad3cadb55b292c325cd7c93642e88eaf47d
|
@@ -79,10 +79,14 @@ class PoliciesController < ApplicationController
|
|
79
79
|
def update_multiple_hosts
|
80
80
|
if (id = params['policy']['id'])
|
81
81
|
policy = ::ForemanOpenscap::Policy.find(id)
|
82
|
-
policy.
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
policy.host_ids = policy.host_ids + @hosts.pluck(:id)
|
83
|
+
if policy.save
|
84
|
+
success _("Updated hosts: Assigned with compliance policy: %s") % policy.name
|
85
|
+
# We prefer to go back as this does not lose the current search
|
86
|
+
return redirect_to hosts_path
|
87
|
+
else
|
88
|
+
return process_error :object => policy, :redirect => hosts_path
|
89
|
+
end
|
86
90
|
else
|
87
91
|
error _('No compliance policy selected.')
|
88
92
|
redirect_to(select_multiple_hosts_policies_path)
|
@@ -9,6 +9,8 @@ module ForemanOpenscap
|
|
9
9
|
base.has_many :arf_reports, :class_name => '::ForemanOpenscap::ArfReport', :foreign_key => :host_id
|
10
10
|
base.has_one :compliance_status_object, :class_name => '::ForemanOpenscap::ComplianceStatus', :foreign_key => 'host_id'
|
11
11
|
|
12
|
+
base.validate :openscap_proxy_in_taxonomy, :if => Proc.new { |host| host.openscap_proxy_id.present? }
|
13
|
+
|
12
14
|
base.scoped_search :relation => :policies, :on => :name, :complete_value => true, :rename => :compliance_policy,
|
13
15
|
:only_explicit => true, :operators => ['= '], :ext_method => :search_by_policy_name
|
14
16
|
|
@@ -121,13 +123,11 @@ module ForemanOpenscap
|
|
121
123
|
end
|
122
124
|
|
123
125
|
def reports_for_policy(policy, limit = nil)
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
.merge(ForemanOpenscap::PolicyArfReport.of_policy(policy.id)).where(:host_id => id)
|
130
|
-
end
|
126
|
+
report_scope = ForemanOpenscap::ArfReport.unscoped.joins(:policy_arf_report)
|
127
|
+
.merge(ForemanOpenscap::PolicyArfReport.of_policy(policy.id)).where(:host_id => id)
|
128
|
+
.order("#{ForemanOpenscap::ArfReport.table_name}.created_at DESC")
|
129
|
+
report_scope = report_scope.limit(limit) if limit
|
130
|
+
report_scope
|
131
131
|
end
|
132
132
|
|
133
133
|
def compliance_status(options = {})
|
@@ -138,6 +138,10 @@ module ForemanOpenscap
|
|
138
138
|
@compliance_status_label ||= get_status(ForemanOpenscap::ComplianceStatus).to_label(options)
|
139
139
|
end
|
140
140
|
|
141
|
+
def openscap_proxy_in_taxonomy
|
142
|
+
validate_association_taxonomy(:openscap_proxy)
|
143
|
+
end
|
144
|
+
|
141
145
|
module ClassMethods
|
142
146
|
def search_by_removed_from_policy(key, operator, policy_name)
|
143
147
|
policy = ForemanOpenscap::Policy.find_by :name => policy_name
|
@@ -36,7 +36,7 @@ module ForemanOpenscap
|
|
36
36
|
validates :scap_content_id, presence: true, if: Proc.new { |policy| policy.should_validate?('SCAP Content') }
|
37
37
|
validate :matching_content_profile, if: Proc.new { |policy| policy.should_validate?('SCAP Content') }
|
38
38
|
|
39
|
-
validate :valid_cron_line, :valid_weekday, :valid_day_of_month, :valid_tailoring, :valid_tailoring_profile
|
39
|
+
validate :valid_cron_line, :valid_weekday, :valid_day_of_month, :valid_tailoring, :valid_tailoring_profile, :no_mixed_deployments
|
40
40
|
after_save :assign_policy_to_hostgroups
|
41
41
|
# before_destroy - ensure that the policy has no hostgroups, or classes
|
42
42
|
|
@@ -46,10 +46,6 @@ module ForemanOpenscap
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
def assign_assets(a)
|
50
|
-
self.asset_ids = (self.asset_ids + a.collect(&:id)).uniq
|
51
|
-
end
|
52
|
-
|
53
49
|
def to_html
|
54
50
|
if scap_content.nil?
|
55
51
|
return html_error_message(_('Cannot generate HTML guide, scap content is missing.'))
|
@@ -112,6 +108,7 @@ module ForemanOpenscap
|
|
112
108
|
end
|
113
109
|
|
114
110
|
def previous_step
|
111
|
+
return steps.last if current_step.empty?
|
115
112
|
steps[steps.index(current_step) - 1]
|
116
113
|
end
|
117
114
|
|
@@ -165,10 +162,6 @@ module ForemanOpenscap
|
|
165
162
|
[]
|
166
163
|
end
|
167
164
|
|
168
|
-
def assign_hosts(hosts)
|
169
|
-
assign_assets hosts.map &:get_asset
|
170
|
-
end
|
171
|
-
|
172
165
|
def unassign_hosts(hosts)
|
173
166
|
host_asset_ids = ForemanOpenscap::Asset.where(:assetable_type => 'Host::Base', :assetable_id => hosts.map(&:id)).pluck(:id)
|
174
167
|
self.asset_ids = self.asset_ids - host_asset_ids
|
@@ -315,5 +308,14 @@ module ForemanOpenscap
|
|
315
308
|
existing_assets = self.assets.where(:assetable_type => complimentary_class_name)
|
316
309
|
self.assets = existing_assets + new_assets
|
317
310
|
end
|
311
|
+
|
312
|
+
def no_mixed_deployments
|
313
|
+
assets.each do |asset|
|
314
|
+
assetable = asset.assetable
|
315
|
+
unless assetable.policies.pluck(:deploy_by).all? { |deployed_by| deployed_by == deploy_by }
|
316
|
+
errors.add(:base, _("cannot assign to %s, all assigned policies must be deployed in the same way") % assetable.name)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
318
320
|
end
|
319
321
|
end
|
@@ -15,6 +15,7 @@ template_inputs:
|
|
15
15
|
provider_type: SSH
|
16
16
|
kind: job_template
|
17
17
|
%>
|
18
|
+
<% raise "Create and assign a policy to this host before proceeding" unless input('policies').respond_to? :map %>
|
18
19
|
|
19
20
|
<% input('policies').map { |policy_config| policy_config['id'] }.each do |id| -%>
|
20
21
|
/usr/bin/foreman_scap_client <%= id %>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<th><%= _("Other") %></th>
|
12
12
|
<th><%= _('Actions') %></th>
|
13
13
|
</tr>
|
14
|
-
<% @
|
14
|
+
<% @latest_reports.each do |arf_report| %>
|
15
15
|
<tr>
|
16
16
|
<td><%= name_column(arf_report.host) %></td>
|
17
17
|
<td><%= assigned_icon(@policy, arf_report) %></td>
|