foreman_openscap 0.12.3 → 1.0.0

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_openscap/policy_dashboard.js +5 -0
  3. data/app/assets/stylesheets/foreman_openscap/policy_dashboard.css +3 -0
  4. data/app/controllers/concerns/foreman_openscap/api/v2/hosts_controller_extensions.rb +26 -0
  5. data/app/controllers/policies_controller.rb +2 -3
  6. data/app/controllers/policy_dashboard_controller.rb +5 -0
  7. data/app/controllers/scap_contents_controller.rb +1 -1
  8. data/app/controllers/tailoring_files_controller.rb +1 -2
  9. data/app/helpers/policy_dashboard_helper.rb +23 -0
  10. data/app/mailers/foreman_openscap/policy_mailer.rb +1 -1
  11. data/app/models/concerns/foreman_openscap/host_extensions.rb +48 -3
  12. data/app/models/foreman_openscap/policy.rb +4 -0
  13. data/app/models/foreman_openscap/scap_content.rb +1 -0
  14. data/app/models/foreman_openscap/tailoring_file.rb +1 -0
  15. data/app/services/foreman_openscap/policy_dashboard/data.rb +3 -4
  16. data/app/views/api/v2/hosts/policies_enc.json.rabl +2 -0
  17. data/app/views/api/v2/hosts/policy_enc.json.rabl +3 -0
  18. data/app/views/arf_reports/_output.html.erb +4 -4
  19. data/app/views/arf_reports/show.html.erb +2 -2
  20. data/app/views/policies/_list.html.erb +9 -7
  21. data/app/views/policies/index.html.erb +2 -2
  22. data/app/views/policy_dashboard/_policy_reports.html.erb +29 -22
  23. data/app/views/policy_dashboard/_policy_status_widget.html.erb +7 -4
  24. data/app/views/policy_dashboard/index.html.erb +1 -1
  25. data/app/views/scap_contents/_list.html.erb +7 -6
  26. data/app/views/scap_contents/index.html.erb +2 -2
  27. data/app/views/tailoring_files/_list.html.erb +6 -5
  28. data/app/views/tailoring_files/index.html.erb +2 -1
  29. data/config/routes.rb +15 -0
  30. data/db/migrate/20190103093409_add_deployment_option_to_policy.foreman_openscap.rb +1 -1
  31. data/lib/foreman_openscap/engine.rb +3 -1
  32. data/lib/foreman_openscap/version.rb +1 -1
  33. data/locale/de/foreman_openscap.edit.po +81 -77
  34. data/locale/de/foreman_openscap.po +26 -23
  35. data/locale/en_GB/foreman_openscap.edit.po +81 -77
  36. data/locale/en_GB/foreman_openscap.po +26 -23
  37. data/locale/es/foreman_openscap.edit.po +81 -77
  38. data/locale/es/foreman_openscap.po +26 -23
  39. data/locale/foreman_openscap.pot +88 -84
  40. data/locale/fr/foreman_openscap.edit.po +81 -77
  41. data/locale/fr/foreman_openscap.po +26 -23
  42. data/locale/gl/foreman_openscap.edit.po +81 -77
  43. data/locale/gl/foreman_openscap.po +26 -23
  44. data/locale/it/foreman_openscap.edit.po +81 -77
  45. data/locale/it/foreman_openscap.po +26 -23
  46. data/locale/ja/foreman_openscap.edit.po +81 -77
  47. data/locale/ja/foreman_openscap.po +26 -23
  48. data/locale/ko/foreman_openscap.edit.po +81 -77
  49. data/locale/ko/foreman_openscap.po +26 -23
  50. data/locale/pt_BR/foreman_openscap.edit.po +81 -77
  51. data/locale/pt_BR/foreman_openscap.po +26 -23
  52. data/locale/ru/foreman_openscap.edit.po +81 -77
  53. data/locale/ru/foreman_openscap.po +26 -23
  54. data/locale/sv_SE/foreman_openscap.edit.po +81 -77
  55. data/locale/sv_SE/foreman_openscap.po +26 -23
  56. data/locale/zh_CN/foreman_openscap.edit.po +81 -77
  57. data/locale/zh_CN/foreman_openscap.po +26 -23
  58. data/locale/zh_TW/foreman_openscap.edit.po +81 -77
  59. data/locale/zh_TW/foreman_openscap.po +26 -23
  60. data/test/functional/api/v2/hosts_controller_test.rb +17 -0
  61. data/test/test_plugin_helper.rb +6 -1
  62. data/test/unit/concerns/host_extensions_test.rb +41 -0
  63. metadata +9 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce7f1231ac98c8b2e24699151fda71aba37f3561
4
- data.tar.gz: e8631cb1cc2a02dcaa84f14d974ad4d45dad804d
3
+ metadata.gz: 9bfb00d33c3c3830de03a63d7f0d49d58546964f
4
+ data.tar.gz: 30f6ae8f460f01bcd5b1c67bf44057e3e7eb61cf
5
5
  SHA512:
6
- metadata.gz: 178205d8a72c403f737e468b5bfef78327de3838545e28d7c776c8e6e8fa509854ff86dbea99ba710df84292e66a93b2ac9c280ba72c4e7d878bcc4d18db67e6
7
- data.tar.gz: 5062f40577ecd10899465ffd45c4d384dd3c5c8e939e0fdc23957c718d3284a0798d2e8db8c5d7db72c55a0c4677d8f76f65985cd4926af2ccff17ef9c6e5aff
6
+ metadata.gz: 02b7fdac41c2ebae43b5dafd36018f20ebf279a5cd662a6a861412757a96b03cdb0c6376826a4e032d8010fb7f5b4288dd169caede2e515e7577d2f5fddb800f
7
+ data.tar.gz: 55afbffc1f5d4f68b51b6d5d6eb2498f591aaa15d47bb6328e9977a1a8d8dad46def864c758b77a60d50dfed1f2ef5f224349884b9a7fb0966e13a69d7162381
@@ -0,0 +1,5 @@
1
+ $(document).on('ContentLoad', () => {
2
+ if (/^\/compliance\/policies\/\d+\/dashboard$/.test(window.location.pathname)) {
3
+ tfm.dashboard.startGridster();
4
+ }
5
+ });
@@ -0,0 +1,3 @@
1
+ #latest-arf-reports-table .content-view-pf-pagination.table-view-pf-pagination {
2
+ margin-bottom: 30px;
3
+ }
@@ -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 = resource_base.search_for(params[:search], :order => params[:order])
15
- .paginate(:page => params[:page], :per_page => params[:per_page])
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,7 +10,7 @@ class ScapContentsController < ApplicationController
10
10
  end
11
11
 
12
12
  def index
13
- @contents = resource_base.search_for(params[:search])
13
+ @contents = resource_base_search_and_page.search_for(params[:search])
14
14
  end
15
15
 
16
16
  def show
@@ -10,8 +10,7 @@ class TailoringFilesController < ApplicationController
10
10
  end
11
11
 
12
12
  def index
13
- @tailoring_files = resource_base.search_for(params[:search], :order => params[:order])
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.incomply_with policy }.flatten
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 :incomply_with, lambda { |policy|
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).to_json
104
+ combined_policies.map(&method)
85
105
  end
86
106
 
87
107
  def combined_policies
88
- combined = self.hostgroup ? self.policies + self.hostgroup.policies + self.hostgroup.inherited_policies : self.policies
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
@@ -13,6 +13,7 @@ module ForemanOpenscap
13
13
 
14
14
  scoped_search :on => :title, :complete_value => true
15
15
  scoped_search :on => :original_filename, :complete_value => true, :rename => :filename
16
+ scoped_search :on => :created_at
16
17
 
17
18
  default_scope do
18
19
  with_taxonomy_scope do
@@ -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.incomply_with(@policy).count,
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 => assigned_count,
28
- :unassigned_hosts => hosts.count - assigned_count }
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
@@ -0,0 +1,2 @@
1
+ collection @encs
2
+ extends "api/v2/hosts/policy_enc"
@@ -0,0 +1,3 @@
1
+ object @enc
2
+
3
+ attributes :id, :profile_id, :content_path, :tailoring_path, :download_path, :tailoring_download_path, :minute, :hour, :monthday, :month, :week
@@ -1,22 +1,22 @@
1
1
  <table id='report_log' class="<%= table_css_classes %>">
2
2
  <thead>
3
3
  <tr>
4
- <th><%= _("Severity") %></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"><%= _("Result") %></th>
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 <%= severity_tag log.message.severity %>><%= h log.message.severity %></span></td>
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 <%= result_tag log.result %>><%= h log.result %></span></td>
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-danger"),
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-default"),
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><%= _('Name') %></th>
4
- <th><%= _('Content') %></th>
5
- <th><%= _('Profile') %></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, hash_for_policy_dashboard_policy_path(:id => policy.id)) %>
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-default"),
6
- link_to(_("Help"), { :action => "welcome" }, { :class => "btn btn-info" })
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
- <table class="<%= table_css_classes('ellipsis') %>">
2
- <tr>
3
- <th><%= _('Host') %></th>
4
- <th><%= _("Date") %></th>
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
- <td><%= name_column(arf_report.host) %></td>
13
- <td><%= date_time_relative_value(arf_report.reported_at) %></td>
14
- <td><%= report_arf_column(arf_report.passed, "label-info") %></th>
15
- <td><%= report_arf_column(arf_report.failed, "label-danger") %></th>
16
- <td><%= report_arf_column(arf_report.othered, "label-warning") %></th>
17
- <td>
18
- <%= action_buttons(
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
- <% end %>
24
- </table>
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, arf_reports_path(:search => "comply_with = \"#{@policy.name}\"") %>
5
- <%= status_link _('Not compliant with the policy'), :incompliant_hosts, arf_reports_path(:search => "not_comply_with = \"#{@policy.name}\"") %>
6
- <%= status_link _('Inconclusive results'), :inconclusive_hosts, arf_reports_path(:search => " inconclusive_with = \"#{@policy.name}\"") %>
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,4 +1,4 @@
1
- <% javascript 'charts', 'dashboard' %>
1
+ <% javascript 'charts', 'foreman_openscap/policy_dashboard' %>
2
2
 
3
3
  <% title _("Compliance policy: %s") % @policy.name %>
4
4
 
@@ -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">Title</th>
4
- <th class="col-md-4">Filename</th>
5
- <th class="col-md-3">Created</th>
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 compliance policy %s with all the reports?") % content.title)
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-default'),
4
- link_to(_("Help"), { :action => "welcome" }, { :class => 'btn btn-info' })) %>
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"><%= _('Name')%></th>
4
- <th class="col-md-4"><%= _('Filename') %></th>
5
- <th class="col-md-3"><%= _('Created') %></th>
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-default')) %>
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.update_attribute(:deploy_by, 'puppet')
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.21'
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)
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "0.12.3".freeze
2
+ VERSION = "1.0.0".freeze
3
3
  end