foreman_openscap 0.4.3 → 0.5.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 (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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b3596aacd8cc7e71c0eb938de52709ba4f79e79
4
- data.tar.gz: d12acf03d688076d4367e84773c2af2ddbc0bf93
3
+ metadata.gz: f4717f3191e1244335417139e2dddef5297b612d
4
+ data.tar.gz: 54ac0f517e808a186d74a6a42a03f07a79565abf
5
5
  SHA512:
6
- metadata.gz: a2f76e27c08d996a5c3ef629736c872f6638e2bbdcb53d8ab95b4d145e9f80a97279146aca5e87b55db8669924cab50a957e02f312c46aab834a816854034b5d
7
- data.tar.gz: 7d667fb69ecd4568f960f73e23667d3ce9a8df69bbf0c1c0ffd8f745765ef2e33b7cbb870726c29e153e958879e88271e7932460d0070573595e451c49d8a6ef
6
+ metadata.gz: 2dbb8f627fdb059e1099c4f95288bfdc7b4ee9e2eef011cec3c45c9c7419ee8ccf7e99813894d46ba659c8d2cfc88d44cc86ebec0a5e24f91312489478133193
7
+ data.tar.gz: c74cd26daf940251810f9aae28728897da0d8d35848939476c2e90a882ae569e5a698835c11b24d669539c187c2bd6526a3c46f6e319bf5b251382190c09ae11
@@ -2,5 +2,5 @@ $(document).ready(function() {
2
2
  $('#frame').load(function() {
3
3
  $('#loading').hide();
4
4
  $('#frame').show().css('min-height', '800px');
5
- });
5
+ });
6
6
  });
@@ -8,9 +8,7 @@ function scap_content_selected(element){
8
8
  url: url,
9
9
  complete: function() { $(element).indicator_hide();},
10
10
  success: function(request) {
11
- $('#file-location').remove();
12
11
  $('#scap_content_profile_select').html(request);
13
- $('#scap_content .alert-info').append($('#file-location'));
14
12
  }
15
13
  })
16
14
  }
@@ -8,7 +8,6 @@
8
8
  # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
9
  #
10
10
 
11
- require 'scaptimony/arf_reports_helper'
12
11
  require 'foreman_openscap/helper'
13
12
 
14
13
  module Api
@@ -24,7 +23,7 @@ module Api
24
23
  before_filter :find_resource, :only => %w{show destroy}
25
24
 
26
25
  def resource_name
27
- 'Scaptimony::ArfReport'
26
+ '::ForemanOpenscap::ArfReport'
28
27
  end
29
28
 
30
29
  def get_resource
@@ -32,7 +31,7 @@ module Api
32
31
  end
33
32
 
34
33
  resource_description do
35
- resource_id 'scaptimony_arf_reports'
34
+ resource_id 'foreman_openscap_arf_reports'
36
35
  api_version 'v2'
37
36
  api_base_url "/api/v2"
38
37
  end
@@ -41,7 +40,7 @@ module Api
41
40
  param_group :search_and_pagination, ::Api::V2::BaseController
42
41
 
43
42
  def index
44
- @arf_reports = resource_scope_for_index(:permission => :edit_compliance).includes(:arf_report_breakdown, :asset)
43
+ @arf_reports = resource_scope_for_index(:permission => :edit_compliance).includes(:asset)
45
44
  end
46
45
 
47
46
  api :GET, '/compliance/arf_reports/:id', N_('Show an Arf report')
@@ -64,27 +63,13 @@ module Api
64
63
 
65
64
  def create
66
65
  asset = ForemanOpenscap::Helper::get_asset(params[:cname], params[:policy_id])
67
- arf_bzip2 = request.body.read
68
- arf_bzip2_size = request.body.size
69
- Scaptimony::ArfReportsHelper.create_arf(asset, params, arf_bzip2, arf_bzip2_size)
70
- render :json => { :result => :OK, :received => arf_bzip2_size }
71
- end
72
-
73
- def check_content_type
74
- # Well, this is unfortunate. Parent class asserts that content-type is
75
- # application/json. While we want to have content-type text/xml. We
76
- # also need the content-encoding to equal with x-bzip2. However, when
77
- # the framework sees text/xml, it will rewrite it to application/xml.
78
- # What's worse, a framework will try to parse body as an utf8 string,
79
- # no matter what content-encoding says. Let's pass content-type arf-bzip2
80
- # and move forward.
81
- super unless
82
- params[:action] == 'create' and
83
- request.content_type.end_with? 'arf-bzip2' and
84
- request.env['HTTP_CONTENT_ENCODING'] == 'x-bzip2'
66
+ arf_report = ForemanOpenscap::ArfReport.create_arf(asset, params)
67
+ asset.host.refresh_statuses if asset.host
68
+ render :json => { :result => :OK, :id => arf_report.id.to_s }
85
69
  end
86
70
 
87
71
  private
72
+
88
73
  def find_resource
89
74
  not_found and return if params[:id].blank?
90
75
  instance_variable_set("@arf_report", resource_scope.find(params[:id]))
@@ -4,13 +4,13 @@ module Api::V2
4
4
  include Foreman::Controller::SmartProxyAuth
5
5
 
6
6
  add_smart_proxy_filters :content, :features => 'Openscap'
7
-
7
+
8
8
  before_filter :find_resource, :except => %w{index create}
9
9
 
10
10
  skip_after_filter :log_response_body, :only => [:content]
11
-
11
+
12
12
  def resource_name
13
- 'Scaptimony::Policy'
13
+ '::ForemanOpenscap::Policy'
14
14
  end
15
15
 
16
16
  def get_resource
@@ -22,7 +22,7 @@ module Api::V2
22
22
  end
23
23
 
24
24
  resource_description do
25
- resource_id 'scaptimony_policies'
25
+ resource_id 'foreman_openscap_policies'
26
26
  api_version 'v2'
27
27
  api_base_url "/api/v2"
28
28
  end
@@ -57,7 +57,7 @@ module Api::V2
57
57
  param_group :policy, :as => :create
58
58
 
59
59
  def create
60
- @policy = Scaptimony::Policy.new(params[:policy])
60
+ @policy = ForemanOpenscap::Policy.new(params[:policy])
61
61
  process_response @policy.save
62
62
  end
63
63
 
@@ -4,7 +4,7 @@ module Api::V2
4
4
  before_filter :find_resource, :except => %w{index create}
5
5
 
6
6
  def resource_name
7
- 'Scaptimony::ScapContent'
7
+ '::ForemanOpenscap::ScapContent'
8
8
  end
9
9
 
10
10
  def get_resource
@@ -12,7 +12,7 @@ module Api::V2
12
12
  end
13
13
 
14
14
  resource_description do
15
- resource_id 'scaptimony_scap_contents'
15
+ resource_id 'foreman_openscap_scap_contents'
16
16
  api_version 'v2'
17
17
  api_base_url "/api/v2"
18
18
  end
@@ -45,7 +45,7 @@ module Api::V2
45
45
  param_group :scap_content, :as => :create
46
46
 
47
47
  def create
48
- @scap_content = Scaptimony::ScapContent.new(params[:scap_content])
48
+ @scap_content = ForemanOpenscap::ScapContent.new(params[:scap_content])
49
49
  process_response @scap_content.save
50
50
  end
51
51
 
@@ -0,0 +1,62 @@
1
+ class ArfReportsController < ApplicationController
2
+ include Foreman::Controller::AutoCompleteSearch
3
+
4
+ before_filter :find_by_id, :only => [:show, :show_html, :destroy, :parse_html, :parse_bzip]
5
+
6
+ def model_of_controller
7
+ ::ForemanOpenscap::ArfReport
8
+ end
9
+
10
+ def index
11
+ @arf_reports = resource_base.includes(: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 show_html
20
+ end
21
+
22
+ def parse_html
23
+ begin
24
+ self.response_body = @arf_report.to_html
25
+ rescue => e
26
+ render :text => _(e.message)
27
+ end
28
+ end
29
+
30
+ def parse_bzip
31
+ begin
32
+ response = @arf_report.to_bzip
33
+ send_data response, :filename => "#{@arf_report.id}_arf_report.bz2", :type => 'application/octet-stream', :disposition => 'attachement'
34
+ rescue => e
35
+ process_error(:error_msg => (_("Failed to downloaded Arf report as bzip: #{e.message}")),
36
+ :error_redirect => arf_report_path(@arf_report.id))
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ if @arf_report.destroy
42
+ process_success(:success_msg => (_("Successfully deleted Arf report.")), :success_redirect => arf_reports_path)
43
+ else
44
+ process_error
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def find_by_id
51
+ @arf_report = resource_base.find(params[:id])
52
+ end
53
+
54
+ def action_permission
55
+ case params[:action]
56
+ when 'show_html', 'parse_html', 'parse_bzip'
57
+ :view
58
+ else
59
+ super
60
+ end
61
+ end
62
+ end
@@ -1,4 +1,4 @@
1
- class ScaptimonyDashboardController < ApplicationController
1
+ class ComplianceDashboardController < ApplicationController
2
2
  include Foreman::Controller::AutoCompleteSearch
3
3
 
4
4
  def index
@@ -0,0 +1,5 @@
1
+ class ComplianceHostsController < ApplicationController
2
+ def show
3
+ @host = Host.find(params[:id])
4
+ end
5
+ end
@@ -1,10 +1,10 @@
1
- class ScaptimonyPoliciesController < ApplicationController
1
+ class PoliciesController < ApplicationController
2
2
  include Foreman::Controller::AutoCompleteSearch
3
3
  before_filter :find_by_id, :only => [:show, :edit, :update, :parse, :destroy]
4
4
  before_filter :find_multiple, :only => [:select_multiple_hosts, :update_multiple_hosts, :disassociate_multiple_hosts, :remove_policy_from_multiple_hosts]
5
5
 
6
6
  def model_of_controller
7
- ::Scaptimony::Policy
7
+ ::ForemanOpenscap::Policy
8
8
  end
9
9
 
10
10
  def index
@@ -12,13 +12,13 @@ class ScaptimonyPoliciesController < ApplicationController
12
12
  .search_for(params[:search], :order => params[:order])
13
13
  .paginate(:page => params[:page], :per_page => params[:per_page])
14
14
  .includes(:scap_content, :scap_content_profile)
15
- if @policies.empty? && Scaptimony::ScapContent.unconfigured?
16
- redirect_to scaptimony_scap_contents_path
15
+ if @policies.empty? && ForemanOpenscap::ScapContent.unconfigured?
16
+ redirect_to scap_contents_path
17
17
  end
18
18
  end
19
19
 
20
20
  def new
21
- @policy = ::Scaptimony::Policy.new
21
+ @policy = ::ForemanOpenscap::Policy.new
22
22
  end
23
23
 
24
24
  def show
@@ -29,9 +29,9 @@ class ScaptimonyPoliciesController < ApplicationController
29
29
  end
30
30
 
31
31
  def create
32
- @policy = ::Scaptimony::Policy.new(params[:policy])
32
+ @policy = ::ForemanOpenscap::Policy.new(params[:policy])
33
33
  if @policy.wizard_completed? && @policy.save
34
- process_success :success_redirect => scaptimony_policies_path
34
+ process_success :success_redirect => policies_path
35
35
  else
36
36
  if @policy.valid?
37
37
  render 'new' and return
@@ -47,7 +47,7 @@ class ScaptimonyPoliciesController < ApplicationController
47
47
 
48
48
  def update
49
49
  if @policy.update_attributes(params[:policy])
50
- process_success :success_redirect => scaptimony_policies_path
50
+ process_success :success_redirect => policies_path
51
51
  else
52
52
  process_error :object => @policy
53
53
  end
@@ -62,8 +62,8 @@ class ScaptimonyPoliciesController < ApplicationController
62
62
  end
63
63
 
64
64
  def scap_content_selected
65
- if params[:scap_content_id] && (@scap_content = ::Scaptimony::ScapContent.find(params[:scap_content_id]))
66
- @policy ||= ::Scaptimony::Policy.new
65
+ if params[:scap_content_id] && (@scap_content = ::ForemanOpenscap::ScapContent.find(params[:scap_content_id]))
66
+ @policy ||= ::ForemanOpenscap::Policy.new
67
67
  render :partial => 'scap_content_results', :locals => {:policy => @policy}
68
68
  end
69
69
  end
@@ -72,14 +72,14 @@ class ScaptimonyPoliciesController < ApplicationController
72
72
 
73
73
  def update_multiple_hosts
74
74
  if (id = params['policy']['id'])
75
- policy = ::Scaptimony::Policy.find(id)
75
+ policy = ::ForemanOpenscap::Policy.find(id)
76
76
  policy.assign_hosts(@hosts)
77
77
  notice _("Updated hosts: Assigned with compliance policy: #{policy.name}")
78
78
  # We prefer to go back as this does not lose the current search
79
79
  redirect_to hosts_path
80
80
  else
81
81
  error _('No compliance policy selected.')
82
- redirect_to(select_multiple_hosts_scaptimony_policies_path)
82
+ redirect_to(select_multiple_hosts_policies_path)
83
83
  end
84
84
  end
85
85
 
@@ -87,7 +87,7 @@ class ScaptimonyPoliciesController < ApplicationController
87
87
 
88
88
  def remove_policy_from_multiple_hosts
89
89
  if (id = params.fetch(:policy, {})[:id])
90
- policy = ::Scaptimony::Policy.find(id)
90
+ policy = ::ForemanOpenscap::Policy.find(id)
91
91
  policy.unassign_hosts(@hosts)
92
92
  notice _("Updated hosts: Unassigned from compliance policy '%s'") % policy.name
93
93
  redirect_to hosts_path
@@ -8,14 +8,14 @@
8
8
  # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
9
  #
10
10
 
11
- class ScaptimonyPolicyDashboardController < ApplicationController
11
+ class PolicyDashboardController < ApplicationController
12
12
  before_filter :prefetch_data, :only => :index
13
13
 
14
14
  def index; end
15
15
 
16
16
  def prefetch_data
17
- @policy = ::Scaptimony::Policy.find(params[:id])
18
- dashboard = Scaptimony::PolicyDashboard::Data.new(@policy, params[:search])
17
+ @policy = ::ForemanOpenscap::Policy.find(params[:id])
18
+ dashboard = ForemanOpenscap::PolicyDashboard::Data.new(@policy, params[:search])
19
19
  @report = dashboard.report
20
20
  end
21
21
  end
@@ -1,10 +1,10 @@
1
- class ScaptimonyScapContentsController < ApplicationController
1
+ class ScapContentsController < ApplicationController
2
2
  include Foreman::Controller::AutoCompleteSearch
3
3
  before_filter :handle_file_upload, :only => [:create, :update]
4
4
  before_filter :find_by_id, :only => [:show, :edit, :update, :destroy]
5
5
 
6
6
  def model_of_controller
7
- ::Scaptimony::ScapContent
7
+ ::ForemanOpenscap::ScapContent
8
8
  end
9
9
 
10
10
  def index
@@ -12,18 +12,18 @@ class ScaptimonyScapContentsController < ApplicationController
12
12
  end
13
13
 
14
14
  def show
15
- send_data @scaptimony_scap_content.scap_file,
15
+ send_data @scap_content.scap_file,
16
16
  :type => 'application/xml',
17
- :filename => @scaptimony_scap_content.original_filename
17
+ :filename => @scap_content.original_filename
18
18
  end
19
19
 
20
20
  def new
21
- @scaptimony_scap_content = ::Scaptimony::ScapContent.new
21
+ @scap_content = ForemanOpenscap::ScapContent.new
22
22
  end
23
23
 
24
24
  def create
25
- @scaptimony_scap_content = ::Scaptimony::ScapContent.new(params[:scap_content])
26
- if @scaptimony_scap_content.save
25
+ @scap_content = ForemanOpenscap::ScapContent.new(params[:scap_content])
26
+ if @scap_content.save
27
27
  process_success
28
28
  else
29
29
  process_error
@@ -31,7 +31,7 @@ class ScaptimonyScapContentsController < ApplicationController
31
31
  end
32
32
 
33
33
  def update
34
- if @scaptimony_scap_content.update_attributes(params[:scap_content])
34
+ if @scap_content.update_attributes(params[:scap_content])
35
35
  process_success
36
36
  else
37
37
  process_error
@@ -39,10 +39,10 @@ class ScaptimonyScapContentsController < ApplicationController
39
39
  end
40
40
 
41
41
  def destroy
42
- if @scaptimony_scap_content.destroy
42
+ if @scap_content.destroy
43
43
  process_success
44
44
  else
45
- process_error :object => @scaptimony_scap_content
45
+ process_error :object => @scap_content
46
46
  end
47
47
  end
48
48
 
@@ -58,7 +58,7 @@ class ScaptimonyScapContentsController < ApplicationController
58
58
 
59
59
  private
60
60
  def find_by_id
61
- @scaptimony_scap_content = resource_base.find(params[:id])
61
+ @scap_content = resource_base.find(params[:id])
62
62
  end
63
63
 
64
64
  def handle_file_upload
@@ -1,20 +1,18 @@
1
- module ScaptimonyReportDashboardHelper
2
- Colors = {
1
+ module ArfReportDashboardHelper
2
+ COLORS = {
3
3
  :passed => '#89A54E',
4
4
  :failed => '#AA4643',
5
5
  :othered => '#DB843D',
6
6
  }
7
7
 
8
-
9
8
  def reports_breakdown_chart(report, options = {})
10
9
  data = []
11
10
  [[:failed, _('Failed')],
12
11
  [:passed, _('Passed')],
13
12
  [:othered, _('Othered')],
14
13
  ].each { |i|
15
- data << {:label => i[1], :data => report[i[0]], :color => Colors[i[0]]}
14
+ data << {:label => i[1], :data => report[i[0]], :color => COLORS[i[0]]}
16
15
  }
17
16
  flot_pie_chart 'overview', _('Compliance reports breakdown'), data, options
18
17
  end
19
-
20
18
  end
@@ -13,4 +13,25 @@ module ArfReportsHelper
13
13
  style = "label-default" if event == 0
14
14
  content_tag(:span, event, :class=>'label ' + style)
15
15
  end
16
+
17
+ def show_logs
18
+ return unless @arf_report.logs.size > 0
19
+ form_tag arf_report_path(@arf_report), :id => 'level_filter', :method => :get, :class => "form form-horizontal" do
20
+ content_tag(:span, _("Show log messages:") + ' ') +
21
+ select(nil, 'level', [[_('All messages'), 'info'],[_('Failed and Othered'), 'warning'],[_('Failed only'), 'error']],
22
+ {}, {:class=>"col-md-1 form-control", :onchange =>"filter_by_level(this);"})
23
+ end
24
+ end
25
+
26
+ def result_tag(level)
27
+ tag = case level
28
+ when 'pass'
29
+ "success"
30
+ when 'fail'
31
+ "danger"
32
+ else
33
+ "warning"
34
+ end
35
+ "class='label label-#{tag}'".html_safe
36
+ end
16
37
  end