foreman_openscap 0.8.2 → 0.8.3

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: ab3aabb6896d03f783813b7f15ce07398832a62f
4
- data.tar.gz: acbe97d223373e5c632dd829cc291ff60b927387
3
+ metadata.gz: 4da93ad56f1a41635d2c5dbefbfb60d0dccb09ef
4
+ data.tar.gz: 61b13cee3f7671c56dc006ec365ff63c5a64eef3
5
5
  SHA512:
6
- metadata.gz: 74e750b1270d55d37c399adcdc2d01299d071ae87fd100115ee1f6aec2f30bd050f1fee08ae380ad6cf949f48209419627128405a367530c45a1bace3c25720a
7
- data.tar.gz: 20b34c1021f6390319c5a39b3b005ad77ab283881597f7f0e286e1d669f2ba9e10eeb457b2f8f9e7c55206cec848b5f2b72f6bcbb6079d819377c7c1ceccc192
6
+ metadata.gz: 71f5244439f5aca602a9440c6c4a9b1a95afcb946ba1a279fcd2386c0834ae08e85fc9a94bc74c6c6fb08b4e056ff2d099db0c32621a94d8805f51f63fc5ce00
7
+ data.tar.gz: 9264fedc8b169a4678e750456ef019374a8df3ec4d7639cd16217a3bcad510e5fd2a31549c38e6af76c7f989837302fadc94f4b4e3cb3467f272b27dce41a6da
@@ -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')
@@ -25,7 +25,7 @@ module Api::V2
25
25
  def xml
26
26
  send_data @scap_content.scap_file,
27
27
  :type => 'application/xml',
28
- :filename => @scap_content.original_filename
28
+ :filename => @scap_content.original_filename || "#{@scap_content.title}.xml"
29
29
  end
30
30
 
31
31
  api :GET, '/compliance/scap_contents/:id', N_('Show an SCAP content')
@@ -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>
@@ -1,7 +1,7 @@
1
1
  class RemoveDeletedPolicy < ActiveRecord::Migration
2
2
  def up
3
3
  ForemanOpenscap::AssetPolicy.all.collect(&:policy_id).uniq.each do |policy_id|
4
- execute("DELETE FROM foreman_openscap_asset_policies WHERE policy_id = '#{policy_id}';") if ForemanOpenscap::Policy.find_by(id: policy_id).nil?
4
+ execute("DELETE FROM foreman_openscap_asset_policies WHERE policy_id = '#{policy_id}';") if ForemanOpenscap::Policy.unscoped.find_by(id: policy_id).nil?
5
5
  end
6
6
  end
7
7
 
@@ -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.8.2".freeze
2
+ VERSION = "0.8.3".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.8.2
4
+ version: 0.8.3
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-24 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