foreman_openscap 0.8.4 → 0.8.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c549bddac8d76de26371740d282a226a08300f5
4
- data.tar.gz: efb9f59e37b0b2bb7351f2ccd62e3dc3dab41aea
3
+ metadata.gz: e44b157d6a98bde81102199865d962801c45714f
4
+ data.tar.gz: a68bd3f0a7f14a5b434fb888926feb0d01e266e2
5
5
  SHA512:
6
- metadata.gz: 07c6aa94f281c2a5617e92667fcb4dd85f4b2fce25ca8bd1fe7a1ed87facb618b75f019a8e9f82d2b8be61010ddf08ad69b4230d019ff90407bc745522e81f50
7
- data.tar.gz: 4ff5e641877263dcd2792106893610c7183bb6d15d2b65772600722790475cd4b4d1b1480c5ba741f889310c329605eb8032ebc1e1136fb107a88419b0c3d9e2
6
+ metadata.gz: 593b4ebec5ef8a449b3263c98fb041f223817ad369c526d17eb2b8626db36176b593c14abea960ea09c354850245ab8fac03984cc8f6876e0e15c37aee0a1496
7
+ data.tar.gz: ee4bc44b6d03ef9afbefdba3cf194582ffc05cc62df7356f1f3d4ed0a939fd2141cebf8d8a9a3dbd9f987ed62d89737400dea37f00ad412895c03063dbf395f2
@@ -51,8 +51,9 @@ module ::ProxyAPI
51
51
  begin
52
52
  parse(delete("arf/#{report.id}/#{cname}/#{report.reported_at.to_i}/#{report.policy_arf_report.digest}"))
53
53
  rescue => e
54
- logger.error "Failed to destroy arf report with id #{report.id} on Smart Proxy"
55
- logger.debug e.backtrace.join("\n\t")
54
+ msg = "Failed to destroy arf report with id #{report.id} on Smart Proxy, cause: #{e.message}"
55
+ logger.error msg
56
+ report.errors.add(:base, msg)
56
57
  false
57
58
  end
58
59
  end
@@ -189,18 +189,22 @@ module ForemanOpenscap
189
189
  end
190
190
 
191
191
  def destroy_from_proxy
192
- if host
193
- begin
194
- openscap_proxy_api.destroy_report(self, ForemanOpenscap::Helper::find_name_or_uuid_by_host(host))
195
- rescue Foreman::Exception => e
196
- logger.error "Failed to delete report with id #{id} from proxy, cause: #{e.message}"
197
- logger.debug e.backtrace.join("\n\t")
198
- end
192
+ if !host
193
+ destroy_from_proxy_warning "host"
194
+ elsif !policy
195
+ destroy_from_proxy_warning "policy"
196
+ elsif !openscap_proxy
197
+ destroy_from_proxy_warning "OpenSCAP proxy"
199
198
  else
200
- logger.error "Failed to delete report with id #{id} from proxy, no host associated with report"
199
+ openscap_proxy_api.destroy_report(self, ForemanOpenscap::Helper::find_name_or_uuid_by_host(host))
201
200
  end
202
201
  end
203
202
 
203
+ def destroy_from_proxy_warning(associated)
204
+ logger.warn "Skipping deletion of report with id #{id} from proxy, no #{associated} associated with report"
205
+ true
206
+ end
207
+
204
208
  def self.newline_to_space(string)
205
209
  string.gsub(/ *\n+/, " ")
206
210
  end
@@ -1,8 +1,10 @@
1
1
  class RemoveArfReportsWithoutPolicy < ActiveRecord::Migration
2
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!)
3
+ User.as_anonymous_admin do
4
+ ids_to_keep = ForemanOpenscap::ArfReport.unscoped.all.joins(:policy_arf_report).pluck(:id)
5
+ ForemanOpenscap::ArfReport.unscoped.where.not(:id => ids_to_keep).find_in_batches do |batch|
6
+ batch.map(&:destroy!)
7
+ end
6
8
  end
7
9
  end
8
10
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "0.8.4".freeze
2
+ VERSION = "0.8.5".freeze
3
3
  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.4
4
+ version: 0.8.5
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: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2018-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface