foreman_openscap 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_openscap/load_report.js +1 -1
  3. data/app/assets/javascripts/foreman_openscap/policy_edit.js +0 -2
  4. data/app/controllers/api/v2/compliance/arf_reports_controller.rb +7 -22
  5. data/app/controllers/api/v2/compliance/policies_controller.rb +5 -5
  6. data/app/controllers/api/v2/compliance/scap_contents_controller.rb +3 -3
  7. data/app/controllers/arf_reports_controller.rb +62 -0
  8. data/app/controllers/{scaptimony_dashboard_controller.rb → compliance_dashboard_controller.rb} +1 -1
  9. data/app/controllers/compliance_hosts_controller.rb +5 -0
  10. data/app/controllers/{scaptimony_policies_controller.rb → policies_controller.rb} +13 -13
  11. data/app/controllers/{scaptimony_policy_dashboard_controller.rb → policy_dashboard_controller.rb} +3 -3
  12. data/app/controllers/{scaptimony_scap_contents_controller.rb → scap_contents_controller.rb} +11 -11
  13. data/app/helpers/{scaptimony_report_dashboard_helper.rb → arf_report_dashboard_helper.rb} +3 -5
  14. data/app/helpers/arf_reports_helper.rb +21 -0
  15. data/app/helpers/compliance_hosts_helper.rb +25 -0
  16. data/app/helpers/concerns/foreman_openscap/hosts_helper_extensions.rb +2 -32
  17. data/app/helpers/{scaptimony_policies_helper.rb → policies_helper.rb} +6 -2
  18. data/app/helpers/{scaptimony_policy_dashboard_helper.rb → policy_dashboard_helper.rb} +8 -8
  19. data/app/lib/proxy_api/available_proxy.rb +26 -0
  20. data/app/lib/proxy_api/openscap.rb +40 -0
  21. data/app/mailers/foreman_openscap/policy_mailer.rb +42 -0
  22. data/app/models/concerns/foreman_openscap/compliance_status_scoped_search.rb +91 -0
  23. data/app/models/concerns/foreman_openscap/host_extensions.rb +73 -17
  24. data/app/models/concerns/foreman_openscap/hostgroup_extensions.rb +3 -5
  25. data/app/models/foreman_openscap/arf_report.rb +165 -0
  26. data/app/models/foreman_openscap/asset.rb +27 -0
  27. data/app/models/foreman_openscap/asset_policy.rb +6 -0
  28. data/app/models/foreman_openscap/compliance_status.rb +50 -0
  29. data/app/models/{concerns/foreman_openscap/policy_extensions.rb → foreman_openscap/policy.rb} +72 -45
  30. data/app/models/foreman_openscap/policy_arf_report.rb +8 -0
  31. data/app/models/foreman_openscap/policy_revision.rb +6 -0
  32. data/app/models/foreman_openscap/scap_content.rb +112 -0
  33. data/app/models/foreman_openscap/scap_content_profile.rb +6 -0
  34. data/app/overrides/hosts/overview/host_compliance_status.rb +4 -4
  35. data/app/services/foreman_openscap/arf_report_status_calculator.rb +45 -0
  36. data/app/services/{scaptimony → foreman_openscap}/host_report_dashboard/data.rb +12 -6
  37. data/app/services/{scaptimony → foreman_openscap}/policy_dashboard/data.rb +5 -5
  38. data/app/services/{scaptimony → foreman_openscap}/report_dashboard/data.rb +4 -4
  39. data/app/views/api/v2/compliance/policies/create.json.rabl +3 -0
  40. data/app/views/{scaptimony_arf_reports → arf_reports}/_list.html.erb +4 -4
  41. data/app/views/arf_reports/_metrics.html.erb +37 -0
  42. data/app/views/arf_reports/_output.html.erb +23 -0
  43. data/app/views/{scaptimony_arf_reports → arf_reports}/index.html.erb +0 -0
  44. data/app/views/arf_reports/show.html.erb +14 -0
  45. data/app/views/{scaptimony_arf_reports/show.html.erb → arf_reports/show_html.html.erb} +2 -3
  46. data/app/views/compliance_hosts/_compliance_status.erb +6 -0
  47. data/app/views/{scaptimony_hosts → compliance_hosts}/show.html.erb +9 -2
  48. data/app/views/dashboard/{_foreman_openscap_host_reports_widget.html.erb → _compliance_host_reports_widget.html.erb} +3 -3
  49. data/app/views/dashboard/{_foreman_openscap_reports_breakdown_widget.html.erb → _compliance_reports_breakdown_widget.html.erb} +1 -1
  50. data/app/views/foreman_openscap/policy_mailer/_dashboard.erb +21 -0
  51. data/app/views/foreman_openscap/policy_mailer/_hosts.erb +44 -0
  52. data/app/views/foreman_openscap/policy_mailer/_list.erb +10 -0
  53. data/app/views/foreman_openscap/policy_mailer/_policy.erb +7 -0
  54. data/app/views/foreman_openscap/policy_mailer/policy_summary.erb +19 -0
  55. data/app/views/{scaptimony_policies → policies}/_form.html.erb +2 -8
  56. data/app/views/{scaptimony_policies → policies}/_list.html.erb +5 -5
  57. data/app/views/policies/_scap_content_results.html.erb +3 -0
  58. data/app/views/policies/create.html.erb +2 -0
  59. data/app/views/{scaptimony_policies → policies}/disassociate_multiple_hosts.html.erb +2 -2
  60. data/app/views/{scaptimony_policies → policies}/edit.html.erb +0 -0
  61. data/app/views/{scaptimony_policies → policies}/index.html.erb +1 -1
  62. data/app/views/policies/new.html.erb +2 -0
  63. data/app/views/{scaptimony_policies → policies}/select_multiple_hosts.html.erb +2 -2
  64. data/app/views/{scaptimony_policies → policies}/show.html.erb +1 -1
  65. data/app/views/{scaptimony_policies → policies}/steps/_create_policy_form.html.erb +0 -0
  66. data/app/views/{scaptimony_policies → policies}/steps/_hostgroups_form.html.erb +0 -0
  67. data/app/views/{scaptimony_policies → policies}/steps/_locations_form.html.erb +0 -0
  68. data/app/views/{scaptimony_policies → policies}/steps/_organizations_form.html.erb +0 -0
  69. data/app/views/policies/steps/_scap_content_form.html.erb +9 -0
  70. data/app/views/{scaptimony_policies → policies}/steps/_schedule_form.html.erb +1 -1
  71. data/app/views/{scaptimony_policies → policies}/steps/_step_form.html.erb +3 -3
  72. data/app/views/{scaptimony_policies → policies}/welcome.html.erb +2 -2
  73. data/app/views/{scaptimony_policy_dashboard → policy_dashboard}/_policy_chart_widget.html.erb +0 -0
  74. data/app/views/{scaptimony_policy_dashboard → policy_dashboard}/_policy_reports.html.erb +2 -2
  75. data/app/views/{scaptimony_policy_dashboard → policy_dashboard}/_policy_status_widget.html.erb +3 -3
  76. data/app/views/{scaptimony_policy_dashboard → policy_dashboard}/index.html.erb +0 -0
  77. data/app/views/{scaptimony_scap_contents → scap_contents}/_form.html.erb +5 -6
  78. data/app/views/{scaptimony_scap_contents → scap_contents}/_list.html.erb +3 -3
  79. data/app/views/{scaptimony_scap_contents → scap_contents}/edit.html.erb +0 -0
  80. data/app/views/{scaptimony_scap_contents → scap_contents}/index.html.erb +1 -1
  81. data/app/views/{scaptimony_scap_contents → scap_contents}/new.html.erb +0 -0
  82. data/app/views/{scaptimony_scap_contents → scap_contents}/welcome.html.erb +2 -2
  83. data/config/routes.rb +15 -11
  84. data/db/migrate/20141013172051_create_scaptimony_policies.rb +9 -0
  85. data/db/migrate/20141014105333_create_scaptimony_assets.rb +10 -0
  86. data/db/migrate/20141015092642_create_scaptimony_arf_reports.rb +13 -0
  87. data/db/migrate/20141015115511_add_arf_report_unique_constraint.rb +6 -0
  88. data/db/migrate/20141104164201_create_scaptimony_scap_contents.rb +7 -0
  89. data/db/migrate/20141104171545_create_scaptimony_policy_revisions.rb +14 -0
  90. data/db/migrate/20141105174625_add_description_to_scaptimony_policy_revisions.rb +5 -0
  91. data/db/migrate/20141105174834_add_columns_to_scaptimony_policies.rb +12 -0
  92. data/db/migrate/20141107091756_add_columns_to_scaptimony_scap_contents.rb +8 -0
  93. data/db/migrate/20141111104519_add_constraint_to_scaptimony_scap_contents.rb +5 -0
  94. data/db/migrate/20141113221054_create_scaptimony_scap_content_profiles.rb +12 -0
  95. data/db/migrate/20141116170632_remove_xccdf_profile_from_scaptimony_policies.rb +5 -0
  96. data/db/migrate/20141116171305_add_profile_to_scaptimony_policies.rb +6 -0
  97. data/db/migrate/20141118142954_add_constraint_to_scaptimony_policies.rb +5 -0
  98. data/db/migrate/20141119164918_create_scaptimony_xccdf_results.rb +8 -0
  99. data/db/migrate/20141119175434_create_scaptimony_xccdf_rules.rb +8 -0
  100. data/db/migrate/20141119182606_create_scaptimony_xccdf_rule_results.rb +9 -0
  101. data/db/migrate/20141121120326_create_scaptimony_arf_report_breakdowns.rb +24 -0
  102. data/db/migrate/20141121164042_replace_arf_report_breakdown_view.rb +25 -0
  103. data/db/migrate/20141206211151_create_scaptimony_assets_policies.rb +9 -0
  104. data/db/migrate/20141214112917_add_scap_file_to_scap_content.rb +5 -0
  105. data/db/migrate/20141216154502_rename_scaptimony_asset_policies.rb +5 -0
  106. data/db/migrate/20150111085317_polymorph_asset.rb +8 -0
  107. data/db/migrate/20150112152944_create_scaptimony_arf_report_raws.rb +10 -0
  108. data/db/migrate/20150114210634_rename_scaptimony_arf_report_raw_raw.rb +5 -0
  109. data/db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb +21 -0
  110. data/db/migrate/20150116083129_add_day_of_month_and_cron_line_to_scaptimony_policy.rb +6 -0
  111. data/db/migrate/20150821100137_migrate_from_scaptimony.rb +59 -0
  112. data/db/migrate/20150827123826_remove_scaptimony_permissions.rb +21 -0
  113. data/db/migrate/20150925124959_create_policy_arf_reports.rb +13 -0
  114. data/db/migrate/20150929124853_add_result_to_logs.rb +9 -0
  115. data/db/migrate/20150929152345_move_arf_reports_to_reports_table.rb +179 -0
  116. data/db/migrate/20151023131950_link_arf_report_directly_to_host.rb +17 -0
  117. data/db/seeds.d/openscap_policy_notification.rb +9 -0
  118. data/lib/foreman_openscap/bulk_upload.rb +3 -1
  119. data/lib/foreman_openscap/engine.rb +53 -42
  120. data/lib/foreman_openscap/helper.rb +8 -0
  121. data/lib/foreman_openscap/version.rb +1 -1
  122. data/lib/tasks/foreman_openscap_tasks.rake +14 -0
  123. data/test/factories/arf_report_factory.rb +9 -6
  124. data/test/factories/asset_factory.rb +1 -1
  125. data/test/factories/compliance_host_factory.rb +9 -0
  126. data/test/factories/compliance_log_factory.rb +11 -0
  127. data/test/factories/policy_arf_report_factory.rb +6 -0
  128. data/test/factories/policy_factory.rb +3 -2
  129. data/test/factories/scap_content_related.rb +2 -2
  130. data/test/functional/api/v2/compliance/arf_reports_controller_test.rb +4 -3
  131. data/test/functional/api/v2/compliance/policies_controller_test.rb +2 -2
  132. data/test/functional/api/v2/compliance/scap_contents_controller_test.rb +3 -1
  133. data/test/lib/foreman_openscap/bulk_upload_test.rb +1 -1
  134. data/test/test_plugin_helper.rb +30 -0
  135. data/test/unit/arf_report_status_calculator_test.rb +11 -0
  136. data/test/unit/arf_report_test.rb +148 -0
  137. data/test/unit/compliance_status_test.rb +71 -0
  138. data/test/unit/openscap_host_test.rb +38 -7
  139. data/test/unit/policy_mailer_test.rb +38 -0
  140. data/test/unit/scap_content_test.rb +32 -0
  141. metadata +130 -74
  142. data/app/controllers/scaptimony_arf_reports_controller.rb +0 -34
  143. data/app/controllers/scaptimony_hosts_controller.rb +0 -5
  144. data/app/models/concerns/foreman_openscap/arf_report_extensions.rb +0 -50
  145. data/app/models/concerns/foreman_openscap/asset_extensions.rb +0 -34
  146. data/app/models/concerns/foreman_openscap/scap_content_extensions.rb +0 -40
  147. data/app/overrides/hosts/index/host_arf_report.rb +0 -5
  148. data/app/views/scaptimony_arf_reports/_host_report.html.erb +0 -8
  149. data/app/views/scaptimony_hosts/_host_status.html.erb +0 -17
  150. data/app/views/scaptimony_policies/_scap_content_results.html.erb +0 -7
  151. data/app/views/scaptimony_policies/create.html.erb +0 -2
  152. data/app/views/scaptimony_policies/new.html.erb +0 -2
  153. data/app/views/scaptimony_policies/steps/_scap_content_form.html.erb +0 -17
@@ -1,34 +0,0 @@
1
- class ScaptimonyArfReportsController < ApplicationController
2
- include Foreman::Controller::AutoCompleteSearch
3
-
4
- before_filter :find_by_id, :only => [:show, :parse, :destroy]
5
-
6
- def model_of_controller
7
- ::Scaptimony::ArfReport
8
- end
9
-
10
- def index
11
- @arf_reports = resource_base.includes(:arf_report_breakdown, :asset)
12
- .search_for(params[:search], :order => params[:order])
13
- .paginate(:page => params[:page], :per_page => params[:per_page])
14
- end
15
-
16
- def show
17
- end
18
-
19
- def parse
20
- self.response_body = @arf_report.to_html
21
- end
22
-
23
- def destroy
24
- if @arf_report.destroy
25
- process_success
26
- else
27
- process_error
28
- end
29
- end
30
-
31
- def find_by_id
32
- @arf_report = resource_base.find(params[:id])
33
- end
34
- end
@@ -1,5 +0,0 @@
1
- class ScaptimonyHostsController < ApplicationController
2
- def show
3
- @host = Host.find(params[:id])
4
- end
5
- end
@@ -1,50 +0,0 @@
1
- #
2
- # Copyright (c) 2014 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
- require 'scaptimony/arf_report'
12
-
13
- module ForemanOpenscap
14
- module ArfReportExtensions
15
- extend ActiveSupport::Concern
16
- include Taxonomix
17
- included do
18
- has_one :host, :through => :asset, :as => :assetable, :source => :assetable, :source_type => 'Host::Base'
19
-
20
- after_save :assign_locations_organizations
21
-
22
- scope :hosts, lambda { includes(:policy, :arf_report_breakdown) }
23
- scope :latest, lambda { includes(:host, :policy, :arf_report_breakdown).limit(5).order("scaptimony_arf_reports.created_at DESC") }
24
- scope :of_policy, lambda {|policy_id| {:conditions => {:policy_id => policy_id}}}
25
-
26
- scoped_search :in => :host, :on => :name, :complete_value => :true, :rename => "host"
27
-
28
- default_scope {
29
- with_taxonomy_scope do
30
- order("scaptimony_arf_reports.created_at DESC")
31
- end
32
- }
33
- end
34
-
35
- def assign_locations_organizations
36
- if host
37
- self.location_ids = [host.location_id] if SETTINGS[:locations_enabled]
38
- self.organization_ids = [host.organization_id] if SETTINGS[:organizations_enabled]
39
- end
40
- end
41
-
42
- def failed?
43
- failed > 0
44
- end
45
-
46
- def passed?
47
- passed > 0 && !failed?
48
- end
49
- end
50
- end
@@ -1,34 +0,0 @@
1
- #
2
- # Copyright (c) 2014 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
- require 'scaptimony/asset'
12
-
13
- module ForemanOpenscap
14
- module AssetExtensions
15
- extend ActiveSupport::Concern
16
- included do
17
- belongs_to :assetable, :polymorphic => true
18
- scope :hosts, where(:assetable_type => 'Host::Base')
19
- end
20
-
21
- def host
22
- fetch_asset('Host::Base')
23
- end
24
-
25
- def name
26
- assetable.name
27
- end
28
-
29
- private
30
- def fetch_asset(type)
31
- assetable if assetable_type == type
32
- end
33
- end
34
- end
@@ -1,40 +0,0 @@
1
- #
2
- # Copyright (c) 2014 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
- require 'scaptimony/scap_content'
12
-
13
- module ForemanOpenscap
14
- module ScapContentExtensions
15
- extend ActiveSupport::Concern
16
- include Authorizable
17
- include Taxonomix
18
- included do
19
- attr_accessible :location_ids, :organization_ids
20
-
21
- default_scope {
22
- with_taxonomy_scope do
23
- order("scaptimony_scap_contents.title")
24
- end
25
- }
26
- end
27
-
28
- def used_location_ids
29
- Location.joins(:taxable_taxonomies).where(
30
- 'taxable_taxonomies.taxable_type' => 'Scaptimony::ScapContent',
31
- 'taxable_taxonomies.taxable_id' => id).pluck("#{Location.arel_table.name}.id")
32
- end
33
-
34
- def used_organization_ids
35
- Organization.joins(:taxable_taxonomies).where(
36
- 'taxable_taxonomies.taxable_type' => 'Scaptimony::ScapContent',
37
- 'taxable_taxonomies.taxable_id' => id).pluck("#{Location.arel_table.name}.id")
38
- end
39
- end
40
- end
@@ -1,5 +0,0 @@
1
-
2
- Deface::Override.new(:virtual_path => "hosts/_list",
3
- :name => "add_compliance_host_data",
4
- :surround_contents => "td[@class='ellipsis']",
5
- :partial => "scaptimony_arf_reports/host_report")
@@ -1,8 +0,0 @@
1
- <% if host.arf_reports.any? %>
2
- <% if host.arf_reports.search_for('failed > 0').blank? %>
3
- <%= link_to(report_event_column('O', "label-success"), scaptimony_arf_reports_path(:search => "host=#{host.name}")) %>
4
- <% else %>
5
- <%= link_to(report_event_column('F', "label-danger"), scaptimony_arf_reports_path(:search => "host=#{host.name}")) %>
6
- <% end %>
7
- <% end %>
8
- <%= render_original %>
@@ -1,17 +0,0 @@
1
- <% if host.arf_reports.any? %>
2
- <table class="table table-bordered table-striped" id="compliance">
3
- <tr>
4
- <th colspan="2"><%= _('Compliance Properties') %></th>
5
- </tr>
6
- <tr>
7
- <td><%= _('Compliance') %></td>
8
- <td>
9
- <% if host.arf_reports.search_for('failed > 0').blank? %>
10
- <%= link_to(report_event_column('O', "label-success"), scaptimony_host_path(host.id)) %>
11
- <% else %>
12
- <%= link_to(report_event_column('F', "label-danger"), scaptimony_host_path(host.id)) %>
13
- <% end %>
14
- </td>
15
- </tr>
16
- </table>
17
- <% end %>
@@ -1,7 +0,0 @@
1
- <%= fields_for @policy do |f| %>
2
- <%= scap_content_profile_selector(f) %>
3
- <% end %>
4
-
5
- <div id="file-location">
6
- <b><%= _('SCAP content file should be /var/lib/openscap/content/%s.xml on your clients.') % @scap_content.digest %></b>
7
- </div>
@@ -1,2 +0,0 @@
1
- <% title _("New Compliance Policy") %>
2
- <%= render :partial => "scaptimony_policies/steps/step_form" %>
@@ -1,2 +0,0 @@
1
- <% title _("New Compliance Policy") %>
2
- <%= render :partial => "scaptimony_policies/steps/step_form" %>
@@ -1,17 +0,0 @@
1
- <div class="tab-pane <%= show_partial_wizard(step) %>" id="scap_content">
2
- <%= wizard_header @policy.step_index, *@policy.steps %>
3
-
4
- <%= scap_content_selector(f) %>
5
- <span id="scap_content_profile_select">
6
- <%= scap_content_profile_selector(f) %>
7
- </span>
8
- <div class="alert alert-info">
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>
15
- </div>
16
- </div>
17
-