foreman_openscap 0.12.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/foreman_openscap/policy_dashboard.js +5 -0
- data/app/assets/stylesheets/foreman_openscap/policy_dashboard.css +3 -0
- data/app/controllers/concerns/foreman_openscap/api/v2/hosts_controller_extensions.rb +26 -0
- data/app/controllers/policies_controller.rb +2 -3
- data/app/controllers/policy_dashboard_controller.rb +5 -0
- data/app/controllers/scap_contents_controller.rb +1 -1
- data/app/controllers/tailoring_files_controller.rb +1 -2
- data/app/helpers/policy_dashboard_helper.rb +23 -0
- data/app/mailers/foreman_openscap/policy_mailer.rb +1 -1
- data/app/models/concerns/foreman_openscap/host_extensions.rb +48 -3
- data/app/models/foreman_openscap/policy.rb +4 -0
- data/app/models/foreman_openscap/scap_content.rb +1 -0
- data/app/models/foreman_openscap/tailoring_file.rb +1 -0
- data/app/services/foreman_openscap/policy_dashboard/data.rb +3 -4
- data/app/views/api/v2/hosts/policies_enc.json.rabl +2 -0
- data/app/views/api/v2/hosts/policy_enc.json.rabl +3 -0
- data/app/views/arf_reports/_output.html.erb +4 -4
- data/app/views/arf_reports/show.html.erb +2 -2
- data/app/views/policies/_list.html.erb +9 -7
- data/app/views/policies/index.html.erb +2 -2
- data/app/views/policy_dashboard/_policy_reports.html.erb +29 -22
- data/app/views/policy_dashboard/_policy_status_widget.html.erb +7 -4
- data/app/views/policy_dashboard/index.html.erb +1 -1
- data/app/views/scap_contents/_list.html.erb +7 -6
- data/app/views/scap_contents/index.html.erb +2 -2
- data/app/views/tailoring_files/_list.html.erb +6 -5
- data/app/views/tailoring_files/index.html.erb +2 -1
- data/config/routes.rb +15 -0
- data/db/migrate/20190103093409_add_deployment_option_to_policy.foreman_openscap.rb +1 -1
- data/lib/foreman_openscap/engine.rb +3 -1
- data/lib/foreman_openscap/version.rb +1 -1
- data/locale/de/foreman_openscap.edit.po +81 -77
- data/locale/de/foreman_openscap.po +26 -23
- data/locale/en_GB/foreman_openscap.edit.po +81 -77
- data/locale/en_GB/foreman_openscap.po +26 -23
- data/locale/es/foreman_openscap.edit.po +81 -77
- data/locale/es/foreman_openscap.po +26 -23
- data/locale/foreman_openscap.pot +88 -84
- data/locale/fr/foreman_openscap.edit.po +81 -77
- data/locale/fr/foreman_openscap.po +26 -23
- data/locale/gl/foreman_openscap.edit.po +81 -77
- data/locale/gl/foreman_openscap.po +26 -23
- data/locale/it/foreman_openscap.edit.po +81 -77
- data/locale/it/foreman_openscap.po +26 -23
- data/locale/ja/foreman_openscap.edit.po +81 -77
- data/locale/ja/foreman_openscap.po +26 -23
- data/locale/ko/foreman_openscap.edit.po +81 -77
- data/locale/ko/foreman_openscap.po +26 -23
- data/locale/pt_BR/foreman_openscap.edit.po +81 -77
- data/locale/pt_BR/foreman_openscap.po +26 -23
- data/locale/ru/foreman_openscap.edit.po +81 -77
- data/locale/ru/foreman_openscap.po +26 -23
- data/locale/sv_SE/foreman_openscap.edit.po +81 -77
- data/locale/sv_SE/foreman_openscap.po +26 -23
- data/locale/zh_CN/foreman_openscap.edit.po +81 -77
- data/locale/zh_CN/foreman_openscap.po +26 -23
- data/locale/zh_TW/foreman_openscap.edit.po +81 -77
- data/locale/zh_TW/foreman_openscap.po +26 -23
- data/test/functional/api/v2/hosts_controller_test.rb +17 -0
- data/test/test_plugin_helper.rb +6 -1
- data/test/unit/concerns/host_extensions_test.rb +41 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bfb00d33c3c3830de03a63d7f0d49d58546964f
|
4
|
+
data.tar.gz: 30f6ae8f460f01bcd5b1c67bf44057e3e7eb61cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02b7fdac41c2ebae43b5dafd36018f20ebf279a5cd662a6a861412757a96b03cdb0c6376826a4e032d8010fb7f5b4288dd169caede2e515e7577d2f5fddb800f
|
7
|
+
data.tar.gz: 55afbffc1f5d4f68b51b6d5d6eb2498f591aaa15d47bb6328e9977a1a8d8dad46def864c758b77a60d50dfed1f2ef5f224349884b9a7fb0966e13a69d7162381
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ForemanOpenscap
|
2
|
+
module Api::V2::HostsControllerExtensions
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module Overrides
|
6
|
+
def action_permission
|
7
|
+
case params[:action]
|
8
|
+
when 'policies_enc'
|
9
|
+
'view'
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
included do
|
17
|
+
prepend Overrides
|
18
|
+
|
19
|
+
api :GET, "/hosts/:id/policies_enc", N_("Show config information for foreman_scap_client")
|
20
|
+
param :id, :identifier_dottable, :required => true, :desc => N_("The identifier of the host")
|
21
|
+
def policies_enc
|
22
|
+
@encs = @host.policies_enc_raw.map { |hash| OpenStruct.new(hash) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -11,9 +11,8 @@ class PoliciesController < ApplicationController
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def index
|
14
|
-
@policies =
|
15
|
-
|
16
|
-
.includes(:scap_content, :scap_content_profile, :tailoring_file)
|
14
|
+
@policies = resource_base_search_and_page.search_for(params[:search])
|
15
|
+
.includes(:scap_content, :scap_content_profile, :tailoring_file, :tailoring_file_profile)
|
17
16
|
if @policies.empty? && ForemanOpenscap::ScapContent.unconfigured?
|
18
17
|
redirect_to scap_contents_path
|
19
18
|
end
|
@@ -8,5 +8,10 @@ class PolicyDashboardController < ApplicationController
|
|
8
8
|
@policy = ::ForemanOpenscap::Policy.find(params[:id])
|
9
9
|
dashboard = ForemanOpenscap::PolicyDashboard::Data.new(@policy, params[:search])
|
10
10
|
@report = dashboard.report
|
11
|
+
@latest_reports = ForemanOpenscap::ArfReport
|
12
|
+
.includes(:host)
|
13
|
+
.of_policy(@policy.id)
|
14
|
+
.latest
|
15
|
+
.paginate(:page => params[:page], :per_page => params[:per_page])
|
11
16
|
end
|
12
17
|
end
|
@@ -10,8 +10,7 @@ class TailoringFilesController < ApplicationController
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def index
|
13
|
-
@tailoring_files =
|
14
|
-
.paginate(:page => params[:page], :per_page => params[:per_page])
|
13
|
+
@tailoring_files = resource_base_search_and_page.search_for(params[:search])
|
15
14
|
end
|
16
15
|
|
17
16
|
def new
|
@@ -34,4 +34,27 @@ module PolicyDashboardHelper
|
|
34
34
|
widget.template = template
|
35
35
|
widget
|
36
36
|
end
|
37
|
+
|
38
|
+
def assigned_icon(policy, arf_report)
|
39
|
+
if arf_report.host.combined_policies.include? policy
|
40
|
+
icon = 'check'
|
41
|
+
tooltip_text = _('Host is assigned to policy')
|
42
|
+
else
|
43
|
+
icon = 'close'
|
44
|
+
tooltip_text = _('Host is not assigned to policy but reports were found. You may want to delete the reports or assign the policy again.')
|
45
|
+
end
|
46
|
+
trunc_with_tooltip icon_text(icon, '', :kind => 'fa'), 32, tooltip_text, false
|
47
|
+
end
|
48
|
+
|
49
|
+
def unassigned_hosts_link
|
50
|
+
trunc_with_tooltip(
|
51
|
+
link_to(
|
52
|
+
_("Hosts no longer assigned: %s") % @report[:unassigned_hosts],
|
53
|
+
hosts_path(:search => "removed_from_policy = \"#{@policy.name}\"")
|
54
|
+
),
|
55
|
+
32,
|
56
|
+
_("Total hosts with reports where policy is no longer assigned."),
|
57
|
+
false
|
58
|
+
)
|
59
|
+
end
|
37
60
|
end
|
@@ -7,7 +7,7 @@ module ForemanOpenscap
|
|
7
7
|
|
8
8
|
@policies = ::ForemanOpenscap::Policy.all.reject { |policy| policy.assets.map(&:host).compact.empty? }
|
9
9
|
@compliant_hosts = @policies.map { |policy| Host.comply_with policy }.flatten
|
10
|
-
@incompliant_hosts = @policies.map { |policy| Host.
|
10
|
+
@incompliant_hosts = @policies.map { |policy| Host.not_comply_with policy }.flatten
|
11
11
|
changed_hosts_of_policies(@policies)
|
12
12
|
|
13
13
|
if user.nil? || user.mail.nil?
|
@@ -36,6 +36,18 @@ module ForemanOpenscap
|
|
36
36
|
base.scoped_search :on => :id, :rename => :others_xccdf_rule,
|
37
37
|
:only_explicit => true, :operators => ['= '], :ext_method => :search_by_rule_othered
|
38
38
|
|
39
|
+
base.scoped_search :on => :id, :rename => :comply_with,
|
40
|
+
:only_explicit => true, :operators => ['= '], :ext_method => :search_by_comply_with
|
41
|
+
|
42
|
+
base.scoped_search :on => :id, :rename => :not_comply_with,
|
43
|
+
:only_explicit => true, :operators => ['= '], :ext_method => :search_by_not_comply_with
|
44
|
+
|
45
|
+
base.scoped_search :on => :id, :rename => :inconclusive_with,
|
46
|
+
:only_explicit => true, :operators => ['= '], :ext_method => :search_by_inconclusive_with
|
47
|
+
|
48
|
+
base.scoped_search :on => :id, :rename => :removed_from_policy,
|
49
|
+
:only_explicit => true, :operators => ['= '], :ext_method => :search_by_removed_from_policy
|
50
|
+
|
39
51
|
base.after_update :puppetrun!, :if => ->(host) do
|
40
52
|
Setting[:puppetrun] &&
|
41
53
|
host.changed.include?('openscap_proxy_id') &&
|
@@ -46,7 +58,7 @@ module ForemanOpenscap
|
|
46
58
|
joins(:arf_reports).merge(ArfReport.latest_of_policy(policy)).merge(ArfReport.passed)
|
47
59
|
}
|
48
60
|
|
49
|
-
base.scope :
|
61
|
+
base.scope :not_comply_with, lambda { |policy|
|
50
62
|
joins(:arf_reports).merge(ArfReport.latest_of_policy(policy)).merge(ArfReport.failed)
|
51
63
|
}
|
52
64
|
|
@@ -62,6 +74,10 @@ module ForemanOpenscap
|
|
62
74
|
search_for("compliance_policy = \"#{policy.name}\"")
|
63
75
|
}
|
64
76
|
|
77
|
+
base.scope :removed_from_policy, lambda { |policy|
|
78
|
+
joins(:arf_reports).merge(ArfReport.latest_of_policy(policy)).where.not(:id => assigned_to_policy(policy).pluck(:id))
|
79
|
+
}
|
80
|
+
|
65
81
|
base.send :extend, ClassMethods
|
66
82
|
end
|
67
83
|
|
@@ -79,13 +95,18 @@ module ForemanOpenscap
|
|
79
95
|
end
|
80
96
|
|
81
97
|
def policies_enc
|
98
|
+
policies_enc_raw.to_json
|
99
|
+
end
|
100
|
+
|
101
|
+
def policies_enc_raw
|
82
102
|
check = ForemanOpenscap::OpenscapProxyAssignedVersionCheck.new(self).run
|
83
103
|
method = check.pass? ? :to_enc : :to_enc_legacy
|
84
|
-
combined_policies.map(&method)
|
104
|
+
combined_policies.map(&method)
|
85
105
|
end
|
86
106
|
|
87
107
|
def combined_policies
|
88
|
-
|
108
|
+
inc = %i[scap_content scap_content_profile tailoring_file tailoring_file_profile]
|
109
|
+
combined = self.hostgroup ? self.policies.includes(inc) + self.hostgroup.policies.includes(inc) + self.hostgroup.inherited_policies : self.policies.includes(inc)
|
89
110
|
combined.uniq
|
90
111
|
end
|
91
112
|
|
@@ -118,6 +139,30 @@ module ForemanOpenscap
|
|
118
139
|
end
|
119
140
|
|
120
141
|
module ClassMethods
|
142
|
+
def search_by_removed_from_policy(key, operator, policy_name)
|
143
|
+
policy = ForemanOpenscap::Policy.find_by :name => policy_name
|
144
|
+
host_ids = policy ? removed_from_policy(policy).pluck(:id) : []
|
145
|
+
{ :conditions => Host::Managed.arel_table[:id].in(host_ids).to_sql }
|
146
|
+
end
|
147
|
+
|
148
|
+
def search_by_compliance(key, operator, policy_name, method)
|
149
|
+
policy = ForemanOpenscap::Policy.find_by :name => policy_name
|
150
|
+
host_ids = policy ? public_send(method, policy).pluck(:id) : []
|
151
|
+
{ :conditions => Host::Managed.arel_table[:id].in(host_ids).to_sql }
|
152
|
+
end
|
153
|
+
|
154
|
+
def search_by_comply_with(key, operator, policy_name)
|
155
|
+
search_by_compliance key, operator, policy_name, :comply_with
|
156
|
+
end
|
157
|
+
|
158
|
+
def search_by_not_comply_with(key, operator, policy_name)
|
159
|
+
search_by_compliance key, operator, policy_name, :not_comply_with
|
160
|
+
end
|
161
|
+
|
162
|
+
def search_by_inconclusive_with(key, operator, policy_name)
|
163
|
+
search_by_compliance key, operator, policy_name, :inconclusive_with
|
164
|
+
end
|
165
|
+
|
121
166
|
def search_by_rule_passed(key, operator, rule_name)
|
122
167
|
search_by_rule rule_name, 'pass'
|
123
168
|
end
|
@@ -16,6 +16,10 @@ module ForemanOpenscap
|
|
16
16
|
has_many :assets, :through => :asset_policies, :as => :assetable, :dependent => :destroy
|
17
17
|
|
18
18
|
scoped_search :on => :name, :complete_value => true
|
19
|
+
scoped_search :in => :scap_content, :on => :title, :rename => 'content', :complete_value => true
|
20
|
+
scoped_search :in => :scap_content_profile, :on => :title, :rename => 'profile', :complete_value => true
|
21
|
+
scoped_search :in => :tailoring_file, :on => :name, :rename => 'tailoring_file', :complete_value => true
|
22
|
+
scoped_search :in => :tailoring_file_profile, :on => :title, :rename => 'tailoring_file_profile', :complete_value => true
|
19
23
|
before_validation :update_period_attrs
|
20
24
|
|
21
25
|
def self.deploy_by_variants
|
@@ -11,6 +11,7 @@ module ForemanOpenscap
|
|
11
11
|
|
12
12
|
scoped_search :on => :name, :complete_value => true
|
13
13
|
scoped_search :on => :original_filename, :complete_value => true, :rename => :filename
|
14
|
+
scoped_search :on => :created_at
|
14
15
|
|
15
16
|
def fetch_profiles
|
16
17
|
api = ProxyAPI::Openscap.new(:url => proxy_url)
|
@@ -18,14 +18,13 @@ module ForemanOpenscap::PolicyDashboard
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def fetch_data
|
21
|
-
assigned_count = Host::Managed.assigned_to_policy(@policy).count
|
22
21
|
report.update(
|
23
22
|
{ :compliant_hosts => Host::Managed.comply_with(@policy).count,
|
24
|
-
:incompliant_hosts => Host::Managed.
|
23
|
+
:incompliant_hosts => Host::Managed.not_comply_with(@policy).count,
|
25
24
|
:inconclusive_hosts => Host::Managed.inconclusive_with(@policy).count,
|
26
25
|
:report_missing => Host::Managed.policy_reports_missing(@policy).count,
|
27
|
-
:assigned_hosts =>
|
28
|
-
:unassigned_hosts =>
|
26
|
+
:assigned_hosts => Host::Managed.assigned_to_policy(@policy).count,
|
27
|
+
:unassigned_hosts => Host::Managed.removed_from_policy(@policy).count }
|
29
28
|
)
|
30
29
|
end
|
31
30
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
<table id='report_log' class="<%= table_css_classes %>">
|
2
2
|
<thead>
|
3
3
|
<tr>
|
4
|
-
<th><%= _("
|
4
|
+
<th><%= _("Result") %></th>
|
5
5
|
<th><%= _("Message") %></th>
|
6
6
|
<th class="col-md-4"><%= _("Resource") %></th>
|
7
|
-
<th class="col-md-1"><%= _("
|
7
|
+
<th class="col-md-1"><%= _("Severity") %></th>
|
8
8
|
<th class="col-md-1"><%= _("Actions") %></th>
|
9
9
|
</tr>
|
10
10
|
</thead>
|
11
11
|
<tbody>
|
12
12
|
<% logs.each do |log| %>
|
13
13
|
<tr>
|
14
|
-
<td><span <%=
|
14
|
+
<td><span <%= result_tag log.result %>><%= h log.result %></span></td>
|
15
15
|
<td>
|
16
16
|
<%= render :partial => 'detailed_message', :locals => { :message => log.message } %>
|
17
17
|
</td>
|
18
18
|
<td><%= log.source %></td>
|
19
|
-
<td><span <%=
|
19
|
+
<td><span <%= severity_tag log.message.severity %>><%= h log.message.severity %></span></td>
|
20
20
|
<td><%= host_search_by_rule_result_buttons(log.source) %></td>
|
21
21
|
</tr>
|
22
22
|
<% end %>
|
@@ -13,9 +13,9 @@
|
|
13
13
|
<%= render 'metrics', :status => @arf_report.status, :metrics => @arf_report.metrics if @arf_report.logs.any? %>
|
14
14
|
|
15
15
|
<%= title_actions link_to(_('Back'), :back, :class => "btn btn-default"),
|
16
|
-
display_delete_if_authorized(hash_for_arf_report_path(:id => @arf_report), :class=> "btn btn-
|
16
|
+
display_delete_if_authorized(hash_for_arf_report_path(:id => @arf_report), :class=> "btn btn-default"),
|
17
17
|
link_to(_("Host details"), @arf_report.host, :class => "btn btn-default"),
|
18
|
-
link_to(_("View full report"), show_html_arf_report_path(:id => @arf_report.id), :class => "btn btn-
|
18
|
+
link_to(_("View full report"), show_html_arf_report_path(:id => @arf_report.id), :class => "btn btn-primary"),
|
19
19
|
link_to(_("Download XML in bzip"), parse_bzip_arf_report_path(:id => @arf_report.id), :class => "btn btn-default", :data => { :no_turbolink => true }),
|
20
20
|
link_to(_("Download HTML"), download_html_arf_report_path(:id => @arf_report.id), :class => "btn btn-default", :data => { :no_turbolink => true })
|
21
21
|
%>
|
@@ -1,16 +1,16 @@
|
|
1
1
|
<table class="<%= table_css_classes('table-fixed') %>">
|
2
2
|
<tr>
|
3
|
-
<th><%=
|
4
|
-
<th><%=
|
5
|
-
<th><%=
|
6
|
-
<th><%= _('Tailoring File') %></th>
|
7
|
-
<th><%= _('Effective Profile') %></th>
|
3
|
+
<th><%= sort :name %></th>
|
4
|
+
<th><%= sort :content %></th>
|
5
|
+
<th><%= sort :profile %></th>
|
6
|
+
<th><%= sort :tailoring_file, :as => _('Tailoring File') %></th>
|
7
|
+
<th><%= sort :tailoring_file_profile, :as => _('Effective Profile') %></th>
|
8
8
|
<th><%= _('Actions') %></th>
|
9
9
|
</tr>
|
10
10
|
<% for policy in @policies %>
|
11
11
|
<tr>
|
12
12
|
<td class="ellipsis">
|
13
|
-
<%= link_to_if_authorized(policy.name.to_s,
|
13
|
+
<%= link_to_if_authorized(policy.name.to_s, hash_for_edit_policy_path(:id => policy.id)) %>
|
14
14
|
</td>
|
15
15
|
<td>
|
16
16
|
<% if !policy.scap_content.nil? %>
|
@@ -33,8 +33,8 @@
|
|
33
33
|
</td>
|
34
34
|
<td>
|
35
35
|
<%= action_buttons(
|
36
|
+
display_link_if_authorized(_("Dashboard"), hash_for_policy_dashboard_policy_path(:id => policy.id)),
|
36
37
|
display_link_if_authorized(_("Show Guide"), hash_for_policy_path(:id => policy.id)),
|
37
|
-
display_link_if_authorized(_("Edit"), hash_for_edit_policy_path(:id => policy.id)),
|
38
38
|
display_delete_if_authorized(hash_for_policy_path(:id => policy.id),
|
39
39
|
:confirm => _("Delete compliance policy %s with all of its reports?") % policy.name)
|
40
40
|
) %>
|
@@ -42,3 +42,5 @@
|
|
42
42
|
</tr>
|
43
43
|
<% end %>
|
44
44
|
</table>
|
45
|
+
|
46
|
+
<%= will_paginate_with_info @policies %>
|
@@ -2,8 +2,8 @@
|
|
2
2
|
<% title _("Compliance Policies") %>
|
3
3
|
|
4
4
|
<% title_actions(
|
5
|
-
display_link_if_authorized(_("New Compliance Policy"), hash_for_new_policy_path, :class => "btn btn-
|
6
|
-
|
5
|
+
display_link_if_authorized(_("New Compliance Policy"), hash_for_new_policy_path, :class => "btn btn-primary"),
|
6
|
+
documentation_button('#4.2Creatingpolicywizard', :root_url => scap_doc_url)
|
7
7
|
) %>
|
8
8
|
|
9
9
|
<%= render :partial => 'list' %>
|
@@ -1,24 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<th><%= _("Passed") %></th>
|
6
|
-
<th><%= _("Failed") %></th>
|
7
|
-
<th><%= _("Other") %></th>
|
8
|
-
<th><%= _('Actions') %></th>
|
9
|
-
</tr>
|
10
|
-
<% for arf_report in @policy.arf_reports.latest %>
|
1
|
+
<% stylesheet 'foreman_openscap/policy_dashboard'%>
|
2
|
+
|
3
|
+
<div id="latest-arf-reports-table">
|
4
|
+
<table class="<%= table_css_classes('ellipsis') %>">
|
11
5
|
<tr>
|
12
|
-
<
|
13
|
-
<
|
14
|
-
<
|
15
|
-
<
|
16
|
-
<
|
17
|
-
<
|
18
|
-
|
19
|
-
link_to(_("View Report"), hash_for_arf_report_path(:id => arf_report.id))
|
20
|
-
) %>
|
21
|
-
</td>
|
6
|
+
<th><%= _('Host') %></th>
|
7
|
+
<th><%= _('Policy assigned') %></th>
|
8
|
+
<th><%= _("Date") %></th>
|
9
|
+
<th><%= _("Passed") %></th>
|
10
|
+
<th><%= _("Failed") %></th>
|
11
|
+
<th><%= _("Other") %></th>
|
12
|
+
<th><%= _('Actions') %></th>
|
22
13
|
</tr>
|
23
|
-
|
24
|
-
|
14
|
+
<% @policy.arf_reports.latest.each do |arf_report| %>
|
15
|
+
<tr>
|
16
|
+
<td><%= name_column(arf_report.host) %></td>
|
17
|
+
<td><%= assigned_icon(@policy, arf_report) %></td>
|
18
|
+
<td><%= date_time_relative_value(arf_report.reported_at) %></td>
|
19
|
+
<td><%= report_arf_column(arf_report.passed, "label-info") %></th>
|
20
|
+
<td><%= report_arf_column(arf_report.failed, "label-danger") %></th>
|
21
|
+
<td><%= report_arf_column(arf_report.othered, "label-warning") %></th>
|
22
|
+
<td>
|
23
|
+
<%= action_buttons(
|
24
|
+
link_to(_("View Report"), hash_for_arf_report_path(:id => arf_report.id))
|
25
|
+
) %>
|
26
|
+
</td>
|
27
|
+
</tr>
|
28
|
+
<% end %>
|
29
|
+
</table>
|
30
|
+
<%= will_paginate_with_info @latest_reports %>
|
31
|
+
</div>
|
@@ -1,12 +1,15 @@
|
|
1
1
|
<div id='status-table'>
|
2
2
|
<h4 class="header"><%= _('Hosts Breakdown') %></h4>
|
3
3
|
<ul>
|
4
|
-
<%= status_link _('Compliant with the policy'), :compliant_hosts,
|
5
|
-
<%= status_link _('Not compliant with the policy'), :incompliant_hosts,
|
6
|
-
<%= status_link _('Inconclusive results'), :inconclusive_hosts,
|
4
|
+
<%= status_link _('Compliant with the policy'), :compliant_hosts, hosts_path(:search => "comply_with = \"#{@policy.name}\"") %>
|
5
|
+
<%= status_link _('Not compliant with the policy'), :incompliant_hosts, hosts_path(:search => "not_comply_with = \"#{@policy.name}\"") %>
|
6
|
+
<%= status_link _('Inconclusive results'), :inconclusive_hosts, hosts_path(:search => " inconclusive_with = \"#{@policy.name}\"") %>
|
7
7
|
<%= status_link _('Never audited'), :report_missing, hosts_path(:search => "compliance_report_missing_for = \"#{@policy.name}\"") %>
|
8
8
|
<h4 class="total">
|
9
|
-
<%= link_to(_("Total hosts: %s") % @report[:assigned_hosts], hosts_path(:search => "compliance_policy = \"#{@policy.name}\"")) %>
|
9
|
+
<%= link_to(_("Total hosts with policy: %s") % @report[:assigned_hosts], hosts_path(:search => "compliance_policy = \"#{@policy.name}\"")) %>
|
10
|
+
</h4>
|
11
|
+
<h4>
|
12
|
+
<%= unassigned_hosts_link %>
|
10
13
|
</h4>
|
11
14
|
</ul>
|
12
15
|
</div>
|
@@ -1,25 +1,26 @@
|
|
1
1
|
<table class="<%= table_css_classes('table-two-pane table-fixed') %>">
|
2
2
|
<tr>
|
3
|
-
<th class="col-md-4"
|
4
|
-
<th class="col-md-
|
5
|
-
<th class="col-md-
|
3
|
+
<th class="col-md-4"><%= sort :title %></th>
|
4
|
+
<th class="col-md-5"><%= sort :filename %></th>
|
5
|
+
<th class="col-md-2"><%= sort :created_at %></th>
|
6
6
|
<th class="col-md-1"><%= _('Actions') %></th>
|
7
7
|
</tr>
|
8
8
|
<% for content in @contents %>
|
9
9
|
<tr>
|
10
|
-
<td class="ellipsis"><%= content.title %></td>
|
10
|
+
<td class="ellipsis"><%= link_to_if_authorized content.title, hash_for_edit_scap_content_path(:id => content.id) %></td>
|
11
11
|
<td class="ellipsis"><%= content.original_filename %></td>
|
12
12
|
<td>
|
13
13
|
<%= date_time_relative_value(content.created_at.getlocal) %>
|
14
14
|
</td>
|
15
15
|
<td>
|
16
16
|
<%= action_buttons(
|
17
|
-
display_link_if_authorized(_("Edit"), hash_for_edit_scap_content_path(:id => content.id)),
|
18
17
|
display_link_if_authorized(_("Download"), hash_for_scap_content_path(:id => content.id), :data => { :no_turbolink => true }),
|
19
18
|
display_delete_if_authorized(hash_for_scap_content_path(:id => content.id),
|
20
|
-
:confirm => _("Delete
|
19
|
+
:confirm => _("Delete scap content %s?") % content.title)
|
21
20
|
) %>
|
22
21
|
</td>
|
23
22
|
</tr>
|
24
23
|
<% end %>
|
25
24
|
</table>
|
25
|
+
|
26
|
+
<%= will_paginate_with_info @contents %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% title _("SCAP Contents") %>
|
2
2
|
|
3
|
-
<% title_actions(display_link_if_authorized(_("Upload New SCAP Content"), hash_for_new_scap_content_path, :class => 'btn btn-
|
4
|
-
|
3
|
+
<% title_actions(display_link_if_authorized(_("Upload New SCAP Content"), hash_for_new_scap_content_path, :class => 'btn btn-primary'),
|
4
|
+
documentation_button('#4.1CreatingSCAPcontent', :root_url => scap_doc_url)) %>
|
5
5
|
|
6
6
|
<%= render :partial => 'list' %>
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<table class="<%= table_css_classes('table-fixed') %>">
|
2
2
|
<tr>
|
3
|
-
<th class="col-md-4"><%=
|
4
|
-
<th class="col-md-
|
5
|
-
<th class="col-md-
|
3
|
+
<th class="col-md-4"><%= sort :name %></th>
|
4
|
+
<th class="col-md-5"><%= sort :filename %></th>
|
5
|
+
<th class="col-md-2"><%= sort :created_at %></th>
|
6
6
|
<th class="col-md-1"><%= _('Actions') %></th>
|
7
7
|
</tr>
|
8
8
|
<% @tailoring_files.each do |file| %>
|
9
9
|
<tr>
|
10
10
|
<td class="ellipsis">
|
11
|
-
<%= file.name %>
|
11
|
+
<%= link_to_if_authorized file.name, hash_for_edit_tailoring_file_path(:id => file.id) %>
|
12
12
|
</td>
|
13
13
|
<td>
|
14
14
|
<%= file.original_filename %>
|
@@ -18,7 +18,6 @@
|
|
18
18
|
</td>
|
19
19
|
<td>
|
20
20
|
<%= action_buttons(
|
21
|
-
display_link_if_authorized(_("Edit"), hash_for_edit_tailoring_file_path(:id => file.id)),
|
22
21
|
display_delete_if_authorized(hash_for_tailoring_file_path(:id => file.id),
|
23
22
|
:confirm => _("Delete tailoring file %s?") % file.name),
|
24
23
|
display_link_if_authorized(_("Download"), hash_for_xml_tailoring_file_path(:id => file.id), :data => { :no_turbolink => true })
|
@@ -27,3 +26,5 @@
|
|
27
26
|
</tr>
|
28
27
|
<% end %>
|
29
28
|
</table>
|
29
|
+
|
30
|
+
<%= will_paginate_with_info @tailoring_files %>
|
@@ -1,3 +1,4 @@
|
|
1
1
|
<% title _("Tailoring Files") %>
|
2
|
-
<% title_actions(display_link_if_authorized(_("Upload New Tailoring file"), hash_for_new_tailoring_file_path, :class => 'btn btn-
|
2
|
+
<% title_actions(display_link_if_authorized(_("Upload New Tailoring file"), hash_for_new_tailoring_file_path, :class => 'btn btn-primary'),
|
3
|
+
documentation_button('#4.5Tailoringfiles(foreman_openscap>=0.6.5)', :root_url => scap_doc_url)) %>
|
3
4
|
<%= render :partial => 'list' %>
|
data/config/routes.rb
CHANGED
@@ -103,4 +103,19 @@ Foreman::Application.routes.draw do
|
|
103
103
|
post 'openscap_proxy_changed'
|
104
104
|
end
|
105
105
|
end
|
106
|
+
|
107
|
+
namespace :api do
|
108
|
+
scope "(:api_version)", :module => :v2,
|
109
|
+
:defaults => { :api_version => 'v2' },
|
110
|
+
:api_version => /v2/,
|
111
|
+
:constraints => ApiConstraints.new(:version => 2, :default => true) do
|
112
|
+
constraints(:id => %r{[^\/]+}) do
|
113
|
+
resources :hosts, :only => [] do
|
114
|
+
member do
|
115
|
+
get :policies_enc
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
106
121
|
end
|
@@ -3,7 +3,7 @@ class AddDeploymentOptionToPolicy < ActiveRecord::Migration[5.2]
|
|
3
3
|
add_column :foreman_openscap_policies, :deploy_by, :string
|
4
4
|
ForemanOpenscap::Policy.unscoped.in_batches do |batch|
|
5
5
|
batch.map do |policy|
|
6
|
-
policy.
|
6
|
+
policy.update_column(:deploy_by, 'puppet')
|
7
7
|
end
|
8
8
|
end
|
9
9
|
change_column :foreman_openscap_policies, :deploy_by, :string, :null => false
|
@@ -50,7 +50,7 @@ module ForemanOpenscap
|
|
50
50
|
|
51
51
|
initializer 'foreman_openscap.register_plugin', :before => :finisher_hook do |app|
|
52
52
|
Foreman::Plugin.register :foreman_openscap do
|
53
|
-
requires_foreman '>= 1.
|
53
|
+
requires_foreman '>= 1.22'
|
54
54
|
|
55
55
|
apipie_documented_controllers ["#{ForemanOpenscap::Engine.root}/app/controllers/api/v2/compliance/*.rb"]
|
56
56
|
|
@@ -104,6 +104,7 @@ module ForemanOpenscap
|
|
104
104
|
select_multiple_openscap_proxy
|
105
105
|
update_multiple_openscap_proxy] },
|
106
106
|
:resource_type => "Host"
|
107
|
+
permission :view_hosts, { 'api/v2/hosts' => [:policies_enc] }, :resource_type => 'Host'
|
107
108
|
permission :edit_hostgroups, { :hostgroups => [:openscap_proxy_changed] }, :resource_type => "Hostgroup"
|
108
109
|
permission :create_tailoring_files, { :tailoring_files => %i[create new],
|
109
110
|
'api/v2/compliance/tailoring_files' => [:create] },
|
@@ -210,6 +211,7 @@ module ForemanOpenscap
|
|
210
211
|
|
211
212
|
# Include concerns in this config.to_prepare block
|
212
213
|
config.to_prepare do
|
214
|
+
::Api::V2::HostsController.send(:include, ForemanOpenscap::Api::V2::HostsControllerExtensions)
|
213
215
|
Host::Managed.send(:include, ForemanOpenscap::OpenscapProxyExtensions)
|
214
216
|
Host::Managed.send(:include, ForemanOpenscap::OpenscapProxyCoreExtensions)
|
215
217
|
Host::Managed.send(:prepend, ForemanOpenscap::HostExtensions)
|