foreman_openscap 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc5705b1687451fbe2a8f0f416b6503b0e105dc3
4
- data.tar.gz: 3b5ac00445799f5d62850385c64abd04d1e869c5
3
+ metadata.gz: 04b41cc23453fdb1d7229c5ba811774c1f9cd118
4
+ data.tar.gz: f96cdf0e6f73aa48b85ea9589325d6457a4e909a
5
5
  SHA512:
6
- metadata.gz: c8a8613e4bf342ff2431c9769cca767b58ae513bef5684f352109141bf12ea9f3d744ddd13eacba3d3a50848a7739e5e2004d630bad382820a07ce0c17ba885e
7
- data.tar.gz: 654e5e07d79ae90cb273652a608cc431e2382a39d102ba7ebf1dc99da4f0d07a8e090d19f959ccd0a21518ae3aac4ffc28bc27e713c90db2a8d45631b977d51d
6
+ metadata.gz: 70f7c7df9e55fd79e5781dbfc2326b932c7214d37b42ece3bc7b8584710b9518a78da9f7e55fea13b20ec580e03c02966f47a99d6f308d2a4e61a8fff4a21e13
7
+ data.tar.gz: 7fdd61dbbee9fe35a30bb31ed09a745ae24c8f15c84c0386dfc44d5f03a113f80a1c20513d05e42ceefb4e6be287b8db50e62f16855fb6266efb3e3e232f5ec5
@@ -26,7 +26,7 @@ module Api
26
26
  param_group :search_and_pagination, ::Api::V2::BaseController
27
27
 
28
28
  def index
29
- @arf_reports = resource_scope_for_index(:permission => :edit_compliance).includes(:openscap_proxy, :policy, :host)
29
+ @arf_reports = resource_scope_for_index(:permission => :view_arf_reports).includes(:openscap_proxy, :policy, :host)
30
30
  end
31
31
 
32
32
  api :GET, '/compliance/arf_reports/:id', N_('Show an ARF report')
@@ -26,7 +26,7 @@ module Api::V2
26
26
  param_group :search_and_pagination, ::Api::V2::BaseController
27
27
 
28
28
  def index
29
- @policies = resource_scope_for_index(:permission => :edit_compliance)
29
+ @policies = resource_scope_for_index(:permission => :view_policies)
30
30
  end
31
31
 
32
32
  api :GET, '/compliance/policies/:id', N_('Show a Policy')
@@ -16,7 +16,7 @@ module Api::V2
16
16
  param_group :search_and_pagination, ::Api::V2::BaseController
17
17
 
18
18
  def index
19
- @scap_contents = resource_scope_for_index(:permission => :edit_compliance)
19
+ @scap_contents = resource_scope_for_index(:permission => :view_scap_contents)
20
20
  end
21
21
 
22
22
  api :GET, '/compliance/scap_contents/:id/xml', N_('Show an SCAP content as XML')
@@ -12,8 +12,8 @@ module ForemanOpenscap
12
12
 
13
13
  scoped_search :on => :status, :offset => 0, :word_size => 4*BIT_NUM, :complete_value => {:true => true, :false => false}, :rename => :eventful
14
14
 
15
- has_one :policy_arf_report, :dependent => :destroy
16
- has_one :policy, :through => :policy_arf_report
15
+ has_one :policy_arf_report
16
+ has_one :policy, :through => :policy_arf_report, :dependent => :destroy
17
17
  has_one :asset, :through => :host, :class_name => 'ForemanOpenscap::Asset', :as => :assetable
18
18
  after_save :assign_locations_organizations
19
19
  has_one :log, :foreign_key => :report_id
@@ -1,6 +1,6 @@
1
1
  module ForemanOpenscap
2
2
  class PolicyArfReport < ::ActiveRecord::Base
3
- belongs_to :arf_report
3
+ belongs_to :arf_report, :dependent => :destroy
4
4
  belongs_to :policy
5
5
 
6
6
  scope :of_policy, lambda { |policy_id| joins(:policy).where(:policy_id => policy_id) }
@@ -1,6 +1,6 @@
1
1
  <%= javascript "host_checkbox", "foreman_openscap/arf_reports" %>
2
2
 
3
- <table class="table table-bordered table-striped ellipsis">
3
+ <table class="table table-bordered table-striped">
4
4
  <tr>
5
5
  <th class="ca" width="40px"><%= check_box_tag "check_all", "", false, { :onclick => "toggleCheck()", :'check-title' => _("Select all items in this page"), :'uncheck-title'=> _("items selected. Uncheck to Clear") } %></th>
6
6
  <th><%= sort :host %></th>
@@ -36,7 +36,7 @@
36
36
  display_link_if_authorized(_("Show Guide"), hash_for_policy_path(:id => policy.id)),
37
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
- :confirm => _("Delete compliance policy %s with all the reports?") % policy.name)
39
+ :confirm => _("Delete compliance policy %s with all of its reports?") % policy.name)
40
40
  ) %>
41
41
  </td>
42
42
  </tr>
@@ -0,0 +1,8 @@
1
+ class RemoveArfReportsWithoutPolicy < ActiveRecord::Migration
2
+ def up
3
+ ids_to_keep = ForemanOpenscap::ArfReport.unscoped.all.joins(:policy_arf_report).pluck(:id)
4
+ ForemanOpenscap::ArfReport.unscoped.where.not(:id => ids_to_keep).find_in_batches do |batch|
5
+ batch.map(&:destroy!)
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "0.7.8".freeze
2
+ VERSION = "0.7.9".freeze
3
3
  end
@@ -206,4 +206,14 @@ class PolicyTest < ActiveSupport::TestCase
206
206
  refute q.valid?
207
207
  assert_equal "does not have the selected SCAP content profile", q.errors.messages[:scap_content_id].first
208
208
  end
209
+
210
+ test "should delete arf_report when deleting policy" do
211
+ policy = FactoryGirl.create(:policy, :scap_content => @scap_content, :scap_content_profile => @scap_profile)
212
+ host = FactoryGirl.create(:compliance_host)
213
+ arf_report = FactoryGirl.create(:arf_report, :host_id => host.id)
214
+ policy_arf_report = FactoryGirl.create(:policy_arf_report, :policy_id => policy.id, :arf_report_id => arf_report.id)
215
+ policy.destroy
216
+ assert_empty ForemanOpenscap::PolicyArfReport.where(:id => policy_arf_report.id)
217
+ assert_empty ForemanOpenscap::ArfReport.where(:id => arf_report.id)
218
+ end
209
219
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_openscap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - slukasik@redhat.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-27 00:00:00.000000000 Z
11
+ date: 2017-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -217,6 +217,7 @@ files:
217
217
  - db/migrate/20161223153249_add_permissions_to_arf_report.rb
218
218
  - db/migrate/20170821081205_rename_mail_notification.foreman_openscap.rb
219
219
  - db/migrate/20170830221751_add_index_to_logs_result.rb
220
+ - db/migrate/20171011134112_remove_arf_reports_without_policy.rb
220
221
  - db/seeds.d/75-job_templates.rb
221
222
  - db/seeds.d/openscap_feature.rb
222
223
  - db/seeds.d/openscap_policy_notification.rb
@@ -314,45 +315,45 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
315
  version: '0'
315
316
  requirements: []
316
317
  rubyforge_project:
317
- rubygems_version: 2.6.8
318
+ rubygems_version: 2.4.6
318
319
  signing_key:
319
320
  specification_version: 4
320
321
  summary: Foreman plug-in for displaying OpenSCAP audit reports
321
322
  test_files:
322
- - test/lib/foreman_openscap/bulk_upload_test.rb
323
- - test/unit/message_cleaner_test.rb
324
- - test/unit/scap_content_test.rb
325
- - test/unit/concerns/openscap_proxy_extenstions_test.rb
326
- - test/unit/concerns/host_extensions_test.rb
327
- - test/unit/openscap_host_test.rb
328
- - test/unit/tailoring_file_test.rb
329
- - test/unit/policy_test.rb
330
- - test/unit/compliance_status_test.rb
331
- - test/unit/arf_report_status_calculator_test.rb
332
- - test/unit/policy_mailer_test.rb
333
- - test/unit/services/tailoring_files_proxy_check_test.rb
334
- - test/unit/services/report_dashboard/data_test.rb
335
- - test/unit/arf_report_test.rb
336
- - test/test_plugin_helper.rb
337
- - test/functional/arf_reports_controller_test.rb
338
- - test/functional/api/v2/compliance/arf_reports_controller_test.rb
339
- - test/functional/api/v2/compliance/scap_contents_controller_test.rb
340
- - test/functional/api/v2/compliance/policies_controller_test.rb
323
+ - test/functional/tailoring_files_controller_test.rb
341
324
  - test/functional/api/v2/compliance/tailoring_files_controller_test.rb
325
+ - test/functional/api/v2/compliance/policies_controller_test.rb
326
+ - test/functional/api/v2/compliance/scap_contents_controller_test.rb
327
+ - test/functional/api/v2/compliance/arf_reports_controller_test.rb
342
328
  - test/functional/openscap_proxies_controller_test.rb
343
- - test/functional/tailoring_files_controller_test.rb
329
+ - test/functional/arf_reports_controller_test.rb
344
330
  - test/factories/asset_factory.rb
331
+ - test/factories/compliance_host_factory.rb
332
+ - test/factories/scap_content_related.rb
345
333
  - test/factories/compliance_log_factory.rb
346
334
  - test/factories/arf_report_factory.rb
347
- - test/factories/scap_content_related.rb
348
- - test/factories/compliance_host_factory.rb
349
335
  - test/factories/policy_arf_report_factory.rb
350
336
  - test/factories/policy_factory.rb
351
- - test/files/scap_contents/ssg-fedora-ds.xml
352
- - test/files/tailoring_files/ssg-firefox-ds-tailoring-2.xml
353
- - test/files/tailoring_files/ssg-firefox-ds-tailoring.xml
354
- - test/files/arf_report/arf_report_msg_value_changed.json
355
337
  - test/files/arf_report/arf_report.bz2
356
- - test/files/arf_report/arf_report_msg_desc_changed.json
357
338
  - test/files/arf_report/arf_report.json
339
+ - test/files/arf_report/arf_report_msg_value_changed.json
340
+ - test/files/arf_report/arf_report_msg_desc_changed.json
358
341
  - test/files/arf_report/arf_report.html
342
+ - test/files/scap_contents/ssg-fedora-ds.xml
343
+ - test/files/tailoring_files/ssg-firefox-ds-tailoring-2.xml
344
+ - test/files/tailoring_files/ssg-firefox-ds-tailoring.xml
345
+ - test/lib/foreman_openscap/bulk_upload_test.rb
346
+ - test/test_plugin_helper.rb
347
+ - test/unit/arf_report_status_calculator_test.rb
348
+ - test/unit/compliance_status_test.rb
349
+ - test/unit/arf_report_test.rb
350
+ - test/unit/policy_mailer_test.rb
351
+ - test/unit/tailoring_file_test.rb
352
+ - test/unit/message_cleaner_test.rb
353
+ - test/unit/openscap_host_test.rb
354
+ - test/unit/scap_content_test.rb
355
+ - test/unit/concerns/openscap_proxy_extenstions_test.rb
356
+ - test/unit/concerns/host_extensions_test.rb
357
+ - test/unit/services/report_dashboard/data_test.rb
358
+ - test/unit/services/tailoring_files_proxy_check_test.rb
359
+ - test/unit/policy_test.rb