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
@@ -0,0 +1,6 @@
1
+ module ForemanOpenscap
2
+ class ScapContentProfile < ActiveRecord::Base
3
+ belongs_to :scap_content
4
+ has_many :policies
5
+ end
6
+ end
@@ -1,4 +1,4 @@
1
- Deface::Override.new(:virtual_path => "hosts/_overview",
2
- :name => "add_compliance_check",
3
- :insert_after => "#properties_table",
4
- :partial => "scaptimony_hosts/host_status")
1
+ Deface::Override.new(:virtual_path => "hosts/show",
2
+ :name => "add_compliance_link_to_host",
3
+ :insert_bottom => 'td:last',
4
+ :partial => 'compliance_hosts/compliance_status')
@@ -0,0 +1,45 @@
1
+ module ForemanOpenscap
2
+ class ArfReportStatusCalculator
3
+
4
+ def initialize(options = {})
5
+ @counters = options[:counters] || {}
6
+ @raw_status = options[:bit_field] || 0
7
+ end
8
+
9
+ def calculate
10
+ @raw_status = 0
11
+ counters.each do |type, value|
12
+ value = value.to_i
13
+ value = ArfReport::MAX if value > ArfReport::MAX
14
+ @raw_status |= value << (ArfReport::BIT_NUM * ArfReport::METRIC.index(type))
15
+ end
16
+ raw_status
17
+ end
18
+
19
+ def status
20
+ @status ||= begin
21
+ calculate if raw_status == 0
22
+ counters = Hash.new(0)
23
+ ArfReport::METRIC.each do |m|
24
+ counters[m] = (raw_status || 0) >> (ArfReport::BIT_NUM * ArfReport::METRIC.index(m)) & ArfReport::MAX
25
+ end
26
+ counters
27
+ end
28
+ end
29
+
30
+ def status_of(counter)
31
+ fail(Foreman::Exception.new(N_("invalid type %s"), counter)) unless ArfReport::METRIC.include?(counter)
32
+ status[counter]
33
+ end
34
+
35
+ ArfReport::METRIC.each do |method|
36
+ define_method method do
37
+ status_of(method)
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ attr_accessor :raw_status, :counters
44
+ end
45
+ end
@@ -1,13 +1,19 @@
1
- module Scaptimony::HostReportDashboard
1
+ module ForemanOpenscap::HostReportDashboard
2
2
  class Data
3
3
  attr_reader :report
4
4
 
5
- def initialize(policy_id, asset_id)
6
- @latest_report = Scaptimony::ArfReport.where(:asset_id => asset_id, :policy_id => policy_id).order('created_at DESC').limit(1).first
5
+ def initialize(policy, host)
6
+ @latest_report = ::ForemanOpenscap::ArfReport.latest_of_policy(policy)
7
+ .where(:host_id => host.id)
8
+ .order('created_at DESC').first
7
9
  @report = {}
8
10
  fetch_data
9
11
  end
10
12
 
13
+ def has_data?
14
+ latest_report.present?
15
+ end
16
+
11
17
  private
12
18
  attr_writer :report
13
19
  attr_accessor :latest_report
@@ -23,15 +29,15 @@ module Scaptimony::HostReportDashboard
23
29
  end
24
30
 
25
31
  def report_passed
26
- @latest_report.passed
32
+ has_data? ? @latest_report.passed : 0
27
33
  end
28
34
 
29
35
  def report_failed
30
- @latest_report.failed
36
+ has_data? ? @latest_report.failed : 0
31
37
  end
32
38
 
33
39
  def report_othered
34
- @latest_report.othered
40
+ has_data? ? @latest_report.othered : 0
35
41
  end
36
42
 
37
43
  end
@@ -1,4 +1,4 @@
1
- module Scaptimony::PolicyDashboard
1
+ module ForemanOpenscap::PolicyDashboard
2
2
  class Data
3
3
  attr_reader :report
4
4
 
@@ -18,10 +18,10 @@ module Scaptimony::PolicyDashboard
18
18
 
19
19
  def fetch_data
20
20
  report.update(
21
- {:compliant_hosts => @policy.assets.hosts.comply_with(@policy).count,
22
- :incompliant_hosts => @policy.assets.hosts.incomply_with(@policy).count,
23
- :inconclusive_hosts => @policy.assets.hosts.inconclusive_with(@policy).count,
24
- :report_missing => @policy.assets.hosts.policy_reports_missing(@policy).count,
21
+ {:compliant_hosts => Host::Managed.comply_with(@policy).count,
22
+ :incompliant_hosts => Host::Managed.incomply_with(@policy).count,
23
+ :inconclusive_hosts => Host::Managed.inconclusive_with(@policy).count,
24
+ :report_missing => Host::Managed.policy_reports_missing(@policy).count,
25
25
  :assigned_hosts => @policy.assets.hosts.count,
26
26
  :unassigned_hosts => hosts.count - @policy.assets.hosts.count
27
27
  })
@@ -1,4 +1,4 @@
1
- module Scaptimony::ReportDashboard
1
+ module ForemanOpenscap::ReportDashboard
2
2
  class Data
3
3
  attr_reader :report
4
4
 
@@ -23,15 +23,15 @@ module Scaptimony::ReportDashboard
23
23
  end
24
24
 
25
25
  def passed_breakdowns
26
- (::Scaptimony::ArfReportBreakdown.sum(:passed)).to_f
26
+ Log.where(:result => 'pass').joins("INNER JOIN reports ON reports.id = report_id").count(:id).to_f
27
27
  end
28
28
 
29
29
  def failed_breakdowns
30
- (::Scaptimony::ArfReportBreakdown.sum(:failed)).to_f
30
+ Log.where(:result => 'fail').joins("INNER JOIN reports ON reports.id = report_id").count(:id).to_f
31
31
  end
32
32
 
33
33
  def othered_breakdowns
34
- (::Scaptimony::ArfReportBreakdown.sum(:othered)).to_f
34
+ Log.where(:result => ForemanOpenscap::ArfReport::RESULT[2..-1]).joins("INNER JOIN reports ON reports.id = report_id").count(:id).to_f
35
35
  end
36
36
  end
37
37
  end
@@ -0,0 +1,3 @@
1
+ object @policy
2
+
3
+ extends "api/v2/compliance/policies/main"
@@ -1,7 +1,7 @@
1
1
  <table class="table table-bordered table-striped ellipsis">
2
2
  <tr>
3
3
  <th><%= sort :host %></th>
4
- <th><%= sort :date, :as => _("Date") %></th>
4
+ <th><%= sort :reported_at, :as => _("Reported At") %></th>
5
5
  <th><%= sort :passed, :as => _("Passed") %></th>
6
6
  <th><%= sort :failed, :as => _("Failed") %></th>
7
7
  <th><%= sort :othered, :as => _("Other") %></th>
@@ -10,14 +10,14 @@
10
10
  <% for arf_report in @arf_reports %>
11
11
  <tr>
12
12
  <td><%= name_column(arf_report.host) %></td>
13
- <td><%= _("%s ago") % time_ago_in_words(arf_report.date) %></td>
13
+ <td><%= _("%s ago") % time_ago_in_words(arf_report.reported_at) %></td>
14
14
  <td><%= report_arf_column(arf_report.passed, "label-info") %></th>
15
15
  <td><%= report_arf_column(arf_report.failed, "label-danger") %></th>
16
16
  <td><%= report_arf_column(arf_report.othered, "label-warning") %></th>
17
17
  <td>
18
18
  <%= action_buttons(
19
- display_link_if_authorized(_("View Report"), hash_for_scaptimony_arf_report_path(:id => arf_report.id)),
20
- display_delete_if_authorized(hash_for_scaptimony_arf_report_path(:id => arf_report.id),
19
+ display_link_if_authorized(_("View Report"), hash_for_arf_report_path(:id => arf_report.id)),
20
+ display_delete_if_authorized(hash_for_arf_report_path(:id => arf_report.id),
21
21
  :confirm => _("Delete compliance report for %s?") % arf_report.asset.host)
22
22
  ) %>
23
23
  </td>
@@ -0,0 +1,37 @@
1
+ <div class="row">
2
+ <div class="col-md-4">
3
+ <div class="stats-well">
4
+ <h4 class="ca" ><%= _('Report Metrics') %></h4>
5
+ <div style="margin-top:50px;padding-bottom: 40px;">
6
+ <%= reports_breakdown_chart(metrics, :class => 'statistics-pie small') %>
7
+ </div>
8
+ </div>
9
+ </div>
10
+ <div class="col-md-4">
11
+ <div class="stats-well">
12
+ <h4 class="ca" ><%= _('Report Status') %></h4>
13
+ <%= flot_bar_chart("status" ,"", _("Number of Events"), status, :class => "statistics-bar")%>
14
+ </div>
15
+ </div>
16
+ <div class="col-md-4">
17
+ <table class='table table-bordered table-striped'>
18
+ <tbody>
19
+ <% metrics.sort.each do |title, value|%>
20
+ <tr>
21
+ <td>
22
+ <%= title %>
23
+ </td>
24
+ <td>
25
+ <%= value %>
26
+ </td>
27
+ </tr>
28
+ <% end %>
29
+ </tbody>
30
+ <tfoot>
31
+ <tr>
32
+ <th><%= _("Total") %></th><th><%= @arf_report.rules_count %></th>
33
+ </tr>
34
+ </tfoot>
35
+ </table>
36
+ </div>
37
+ </div>
@@ -0,0 +1,23 @@
1
+ <table id='report_log' class="table table-bordered table-striped">
2
+ <thead>
3
+ <tr>
4
+ <th><%= _("Level") %></th>
5
+ <th><%= _("Resource") %></th>
6
+ <th><%= _("Message") %></th>
7
+ <th><%= _("Result") %></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% logs.each do |log| %>
12
+ <tr>
13
+ <td><span <%= report_tag log.level %>><%= h log.level %></span></td>
14
+ <td><%= h log.source %></td>
15
+ <td><%= h log.message %></td>
16
+ <td><span <%= result_tag log.result %>><%= h log.result %></span></td>
17
+ </tr>
18
+ <% end %>
19
+ <tr id='ntsh' <%= "style='display: none;'".html_safe if logs.size > 0%>><td colspan="3">
20
+ <%= _("Nothing to show") %>
21
+ </td></tr>
22
+ </tbody>
23
+ </table>
@@ -0,0 +1,14 @@
1
+ <% title "#{@arf_report.host}" %>
2
+ <p class='ra'> <%= _("Reported at %s ") % @arf_report.reported_at %> </p>
3
+
4
+ <% content_for(:search_bar) {show_logs} %>
5
+
6
+ <%= render 'output', :logs => @arf_report.logs%>
7
+ <%= render 'metrics', :status => @arf_report.status, :metrics => @arf_report.metrics %>
8
+
9
+ <%= title_actions link_to(_('Back'), :back),
10
+ display_delete_if_authorized(hash_for_arf_report_path(:id => @arf_report), :class=> "btn btn-danger"),
11
+ link_to(_("Host details"), @arf_report.host),
12
+ link_to(_("View full report"), show_html_arf_report_path(:id => @arf_report.id)),
13
+ link_to(_("Download XML in bzip"), parse_bzip_arf_report_path(:id => @arf_report.id))
14
+ %>
@@ -1,6 +1,5 @@
1
1
  <%= javascript 'foreman_openscap/load_report'%>
2
2
  <div class="row">
3
-
4
3
  <div id="loading">
5
4
  <div class="col-md-4"></div>
6
5
  <div class="col-md-4">
@@ -8,5 +7,5 @@
8
7
  <%= _('Loading...') %>
9
8
  </div>
10
9
  </div>
11
- <iframe id="frame" style="display: none" height="100%" width="100%" frameborder="0" src="<%= parse_scaptimony_arf_report_path(@arf_report) %>"></iframe>
12
- </div>
10
+ <iframe id="frame" style="display: none" height="100%" width="100%" frameborder="0" src="<%= parse_html_arf_report_path(@arf_report) %>"></iframe>
11
+ </div>
@@ -0,0 +1,6 @@
1
+ <%= link_to(
2
+ _('Compliance'),
3
+ compliance_host_path(@host.id),
4
+ :title => _("Host compliance details"),
5
+ :class => 'btn btn-default') if @host.arf_reports.any?
6
+ %>
@@ -1,13 +1,15 @@
1
1
  <%= javascript 'dashboard', 'foreman_openscap/scap_hosts_show' %>
2
2
 
3
3
  <% title _("%s compliance reports by policy") % @host.to_label %>
4
- <% @host.policies.each do |policy| %>
4
+ <% @host.combined_policies.each do |policy| %>
5
5
  <h2 class="center-block"><%= _('Policy %s') % policy %></h2>
6
6
  <div class="row">
7
+ <% data = ForemanOpenscap::HostReportDashboard::Data.new(policy, @host) %>
8
+ <% if data.has_data? %>
7
9
  <div class="col-md-4">
8
10
  <div class="stats-well">
9
11
  <h4 class="header ca"><%= _('%s latest report') % policy.name %></h4>
10
- <% report = Scaptimony::HostReportDashboard::Data.new(policy.id, @host.asset.id).report %>
12
+ <% report = data.report %>
11
13
  <%= host_policy_breakdown_chart(report, :class => 'statistics-pie small') %>
12
14
  </div>
13
15
  </div>
@@ -18,6 +20,11 @@
18
20
  <%= flot_chart('resource_graph', '', '', host_arf_reports_chart(policy.id)) %>
19
21
  </div>
20
22
  </div>
23
+ <% else %>
24
+ <div class="col-md-4">
25
+ <h4 class="header ca"><%= _('No report for this policy') %></h4>
26
+ </div>
27
+ <% end %>
21
28
  </div>
22
29
  <hr style="border: 1px solid #eeeeee"/>
23
30
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <h4 class="ca"><%= _('Latest compliance reports') %></h4>
2
- <% latest_reports = Scaptimony::ArfReport.latest %>
2
+ <% latest_reports = ForemanOpenscap::ArfReport.latest %>
3
3
  <% if latest_reports.empty? %>
4
4
  <p class="ca"><%= _("No reports available") %></p>
5
5
  <% else %>
@@ -13,8 +13,8 @@
13
13
  </tr>
14
14
  <% latest_reports.each do |report| %>
15
15
  <tr>
16
- <td><%= link_to h(report.host.nil? ? _('Host does not exist anymore') : report.host.name), scaptimony_arf_report_path(report) %></td>
17
- <td><%= link_to h(report.policy.name), scaptimony_policy_dashboard_scaptimony_policy_path(report.policy) %></td>
16
+ <td><%= link_to h(report.host.nil? ? _('Host does not exist anymore') : report.host.name), arf_report_path(report) %></td>
17
+ <td><%= link_to h(report.policy.name), policy_dashboard_policy_path(report.policy) %></td>
18
18
  <td><%= report_event_column(report.passed, "label-success") %></td>
19
19
  <td><%= report_event_column(report.failed, "label-danger") %></td>
20
20
  <td><%= report_event_column(report.othered, "label-info") %></td>
@@ -1,3 +1,3 @@
1
1
  <h4 class="header ca"><%= _('Compliance reports breakdown') %></h4>
2
- <% report = Scaptimony::ReportDashboard::Data.new().report %>
2
+ <% report = ForemanOpenscap::ReportDashboard::Data.new().report %>
3
3
  <%= reports_breakdown_chart(report, :class => 'statistics-pie small') %>
@@ -0,0 +1,21 @@
1
+ <% td_style = "font-size: 125%; width: 33%; padding: 5px; border: 1px solid #ccc;" %>
2
+ <% p_style = "font-weight: bold; margin: 5px; padding: 0px;" %>
3
+ <% b_style = "color: #6bb5df;" %>
4
+ <table style="border: 1px solid #cccccc; padding: 5px; background-color: #ffffff; border-collapse: collapse; text-align: center; width: 100%">
5
+ <tbody>
6
+ <tr>
7
+ <td style="<%= td_style %>">
8
+ <b style="<%= b_style %>"><%= (changed_hosts.length.to_s).html_safe %></b>
9
+ <p style="<%= p_style %>"><%= _('Changed').html_safe %></p>
10
+ </td>
11
+ <td style="<%= td_style %>">
12
+ <b style="<%= b_style %>"><%= (compliant_hosts.length.to_s).html_safe %></b>
13
+ <p style="<%= p_style %>"><%= _('Compliant').html_safe %></p>
14
+ </td>
15
+ <td style="<%= td_style %>">
16
+ <b style="<%= b_style %>"><%= (incompliant_hosts.length.to_s).html_safe %></b>
17
+ <p style="<%= p_style %>"><%= _('Incompliant').html_safe %></p>
18
+ </td>
19
+ </tr>
20
+ </tbody>
21
+ </table>
@@ -0,0 +1,44 @@
1
+ <% th_style = "text-align: left; border-collapse: collapse; background: #f5f5f5; background: linear-gradient(#f5f5f5, #e8e8e8); padding: 4px; border: 1px solid #cccccc;" %>
2
+ <% td_style = "text-align: left; border-collapse: collapse; background-color: #FFFFFF; padding: 4px; border: 1px solid #cccccc;" %>
3
+ <tr>
4
+ <th style="<%= th_style %>">
5
+ <%= _('Hostname') %>
6
+ </th>
7
+ <th style="<%= th_style %>">
8
+ <%= _('Passed') %>
9
+ </th>
10
+ <th style="<%= th_style %>">
11
+ <%= _('Failed') %>
12
+ </th>
13
+ <th style="<%= th_style %>">
14
+ <%= _('Other') %>
15
+ </th>
16
+ <th style="<%= th_style %>">
17
+ <%= _('Changed?') %>
18
+ </th>
19
+ </tr>
20
+ <% hosts.each do |host| %>
21
+ <tr>
22
+ <% last_report = host.reports_for_policy(policy, 1).first %>
23
+
24
+ <%= render "host_mailer/link_to_host", :host => host %>
25
+ <% if last_report %>
26
+ <td style="<%= td_style %>">
27
+ <%= last_report.passed %>
28
+ </td>
29
+ <td style="<%= td_style %>">
30
+ <%= last_report.failed %>
31
+ </td>
32
+ <td style="<%= td_style %>">
33
+ <%= last_report.othered %>
34
+ </td>
35
+ <td style="<%= td_style %>">
36
+ <%= host.scap_status_changed?(policy) ? _('Yes') : _('No') %>
37
+ </td>
38
+ <% else %>
39
+ <td style="<%= td_style %> border-right: 0px;">
40
+ <%= _('No ARF reports for this policy') %>
41
+ </td>
42
+ <% end %>
43
+ </tr>
44
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <div>
2
+ <h2><%= title %></h2>
3
+ <% if list.size > 0 %>
4
+ <% list.each do |policy| %>
5
+ <%= render :partial => 'policy', :locals => { :policy => policy } %>
6
+ <% end%>
7
+ <% else %>
8
+ <b><%= _('None!') %></b>
9
+ <% end %>
10
+ </div>
@@ -0,0 +1,7 @@
1
+ <h3><%= policy.name %></h3>
2
+ <table style="border: 1px solid #cccccc; padding: 5px; background-color: #ffffff; border-collapse: collapse; text-align: justify; width: 100%;" bgcolor="#ffffff">
3
+ <tbody>
4
+ <%= render :partial => "hosts", :locals => { :hosts => policy.hosts, :policy => policy } %>
5
+ </tbody>
6
+ </table>
7
+ <p style="background-color: #e1e2e3; margin: 5px 0px; padding: 0px; line-height: 24px;"><%= n_('Total of one host', 'Total of %{hosts} hosts', policy.hosts.size) % {:hosts => policy.hosts.size} %></p>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
6
+ <title> Summary report for OpenScap from Foreman </title>
7
+ </head>
8
+ <body style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #3f3f3f; background-color: #f1f1f1; padding: 10px 24px">
9
+ <h2 style="font-weight: normal; text-transform: uppercase; font-size: 120%;"><%= _("<b>Foreman</b> OpenScap summary").html_safe %></h2>
10
+ <h2 style="margin: 5px 0px;"><%= _("Summary from %{time} ago to now") % {:time => distance_of_time_in_words(Time.now - @time)} %></h2>
11
+ <h3 style="margin: 0px;"><%= _("Summary report from Foreman server at %{foreman_url}") % {:foreman_url => Setting[:foreman_url]} %></h3>
12
+ <div style="background: #e1e2e3; padding: 20px 40px; margin: 5px 0px 10px;">
13
+ <%= render :partial => 'dashboard', :locals => {:changed_hosts => @changed_hosts, :compliant_hosts => @compliant_hosts, :incompliant_hosts => @incompliant_hosts} %>
14
+ </div>
15
+ <div style="background: #fff; padding: 10px 20px; border: 1px solid #e1e2e3">
16
+ <%= render :partial => 'list', :locals => {:title => _("Policies with hosts:"), :list => @policies} %>
17
+ </div>
18
+ </body>
19
+ </html>