smart_proxy_openscap 0.6.11 → 0.7.0

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: 6076ca39518813d5f4ac1dbf16a0f741200c8d66
4
- data.tar.gz: 0045badb98b310b25bed8fd61faae944856dfcf4
3
+ metadata.gz: f62ed4762438b0c37885cb031bdec5257e72721c
4
+ data.tar.gz: f4060366424d6b06adb28c21732286c984a70fc7
5
5
  SHA512:
6
- metadata.gz: 2acd7a57974547171d678219a32ac804a6606f5508ff20bcfbe07bc348c8ef5c1d7802618ee69fa79590898748a6d2f3724bcf2354c271d27dcdef95deeb2f17
7
- data.tar.gz: 54fd17a312559d449bbbcf0a7d5d6826e9c1149d6d55503f80575c2087302ff687ee9beed33c927343aad234c4978e2c9ea64f9640a7178012de8c2c92575e5a
6
+ metadata.gz: d1b8e805310270da3fe76bea4771d29c150a2a6ed7d5fbaa62d156c0edcd59aba152f5e36cd4cc47de36396fb3b2806a0d21cb1c9a996a3b89bd8497767b41f3
7
+ data.tar.gz: ff8b396f02fea2f3244bde0988a5ef6a39d643b5f38917199221968d88a85e18714d4b39f0ee2432ef9f654fbb01260dbefe796737704ffaadb451689e9a66e9
@@ -39,17 +39,23 @@ module Proxy::OpenSCAP
39
39
  begin
40
40
  post_to_foreman = ForemanForwarder.new.post_arf_report(cn, policy, date, request.body.string)
41
41
  Proxy::OpenSCAP::StorageFS.new(Proxy::OpenSCAP::Plugin.settings.reportsdir, cn, post_to_foreman['id'], date).store_archive(request.body.string)
42
+ post_to_foreman.to_json
42
43
  rescue Proxy::OpenSCAP::StoreReportError => e
43
44
  Proxy::OpenSCAP::StorageFS.new(Proxy::OpenSCAP::Plugin.settings.failed_dir, cn, post_to_foreman['id'], date).store_failed(request.body.string)
44
45
  logger.error "Failed to save Report in reports directory (#{Proxy::OpenSCAP::Plugin.settings.reportsdir}). Failed with: #{e.message}.
45
46
  Saving file in #{Proxy::OpenSCAP::Plugin.settings.failed_dir}. Please copy manually to #{Proxy::OpenSCAP::Plugin.settings.reportsdir}"
47
+ { :result => 'Storage failure on proxy, see proxy logs for details' }.to_json
46
48
  rescue Proxy::OpenSCAP::OpenSCAPException => e
47
- logger.error "Failed to parse Arf Report, moving to #{Proxy::OpenSCAP::Plugin.settings.corrupted_dir}"
49
+ error = "Failed to parse Arf Report, moving to #{Proxy::OpenSCAP::Plugin.settings.corrupted_dir}"
50
+ logger.error error
48
51
  Proxy::OpenSCAP::StorageFS.new(Proxy::OpenSCAP::Plugin.settings.corrupted_dir, cn, policy, date).store_corrupted(request.body.string)
52
+ { :result => (error << ' on proxy') }.to_json
49
53
  rescue *HTTP_ERRORS => e
50
54
  ### If the upload to foreman fails then store it in the spooldir
51
- logger.error "Failed to upload to Foreman, saving in spool. Failed with: #{e.message}"
55
+ msg = "Failed to upload to Foreman, saving in spool. Failed with: #{e.message}"
56
+ logger.error msg
52
57
  Proxy::OpenSCAP::StorageFS.new(Proxy::OpenSCAP::Plugin.settings.spooldir, cn, policy, date).store_spool(request.body.string)
58
+ { :result => msg }.to_json
53
59
  rescue Proxy::OpenSCAP::StoreSpoolError => e
54
60
  log_halt 500, e.message
55
61
  end
@@ -156,6 +162,14 @@ module Proxy::OpenSCAP
156
162
  end
157
163
  end
158
164
 
165
+ get "/spool_errors" do
166
+ begin
167
+ Proxy::OpenSCAP::StorageFS.new(Proxy::OpenSCAP::Plugin.settings.corrupted_dir, nil, nil, nil).spool_errors.to_json
168
+ rescue StandardError => e
169
+ log_halt 500, "Error occurred: #{e.message}"
170
+ end
171
+ end
172
+
159
173
  private
160
174
 
161
175
  def validate_scap_file(params)
@@ -35,8 +35,8 @@ module Proxy::OpenSCAP
35
35
  end
36
36
 
37
37
  def self.read_settings
38
- YAML.load_file(File.join(::Proxy::SETTINGS.settings_directory, ::Proxy::OpenSCAP::Plugin.settings_file))
39
- .merge(::Proxy::OpenSCAP::Plugin.default_settings)
38
+ ::Proxy::OpenSCAP::Plugin.default_settings.merge(
39
+ YAML.load_file(File.join(::Proxy::SETTINGS.settings_directory, ::Proxy::OpenSCAP::Plugin.settings_file)))
40
40
  end
41
41
 
42
42
  def self.common_name(request)
@@ -41,7 +41,7 @@ module Proxy::OpenSCAP
41
41
  private
42
42
 
43
43
  def validate_id(id)
44
- raise Proxy::OpenSCAP::OpenSCAPException, 'Malformed ARF ID' unless /\A\d+\Z/ =~ id
44
+ raise Proxy::OpenSCAP::OpenSCAPException, 'Malformed ARF ID' if (id.is_a?(String) && !id.match(/\A\d+\Z/))
45
45
  end
46
46
  end
47
47
  end
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'smart_proxy_openscap/storage'
2
3
 
3
4
  module Proxy::OpenSCAP
@@ -45,6 +46,15 @@ module Proxy::OpenSCAP
45
46
  full_path
46
47
  end
47
48
 
49
+ def spool_errors
50
+ path = "#{@path_to_dir}/#{@namespace}"
51
+ { :errors_count => File.exists?(path) ? list_dirs(path).count : 0 }
52
+ end
53
+
54
+ def list_dirs(path)
55
+ Pathname.new(path).children.select(&:directory?)
56
+ end
57
+
48
58
  private
49
59
 
50
60
  def store_arf(spool_arf_dir, data)
@@ -10,6 +10,6 @@
10
10
 
11
11
  module Proxy
12
12
  module OpenSCAP
13
- VERSION = '0.6.11'
13
+ VERSION = '0.7.0'
14
14
  end
15
15
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
9
9
 
10
10
  s.author = ['Šimon Lukašík', 'Shlomi Zadok', 'Marek Hulan']
11
11
  s.email = 'slukasik@redhat.com'
12
- s.homepage = 'http://github.com/OpenSCAP/smart_proxy_openscap'
13
- s.license = 'GPL-3'
12
+ s.homepage = 'https://github.com/theforeman/smart_proxy_openscap'
13
+ s.license = 'GPL-3.0-or-later'
14
14
 
15
15
  s.files = `git ls-files`.split("\n") - ['.gitignore']
16
16
  s.executables = ['smart-proxy-openscap-send']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_openscap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Šimon Lukašík
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-09-19 00:00:00.000000000 Z
13
+ date: 2018-10-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -153,9 +153,9 @@ files:
153
153
  - test/script_class_test.rb
154
154
  - test/spool_forwarder_test.rb
155
155
  - test/test_helper.rb
156
- homepage: http://github.com/OpenSCAP/smart_proxy_openscap
156
+ homepage: https://github.com/theforeman/smart_proxy_openscap
157
157
  licenses:
158
- - GPL-3
158
+ - GPL-3.0-or-later
159
159
  metadata: {}
160
160
  post_install_message:
161
161
  rdoc_options: []