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 +4 -4
- data/lib/smart_proxy_openscap/openscap_api.rb +16 -2
- data/lib/smart_proxy_openscap/openscap_lib.rb +2 -2
- data/lib/smart_proxy_openscap/storage.rb +1 -1
- data/lib/smart_proxy_openscap/storage_fs.rb +10 -0
- data/lib/smart_proxy_openscap/version.rb +1 -1
- data/smart_proxy_openscap.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f62ed4762438b0c37885cb031bdec5257e72721c
|
4
|
+
data.tar.gz: f4060366424d6b06adb28c21732286c984a70fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
39
|
-
.
|
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'
|
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)
|
@@ -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 = '
|
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.
|
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-
|
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:
|
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: []
|