smart_proxy_openscap 0.6.9 → 0.6.10
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a93f2467106e6d7bcdeab29c7cc83671c3f3922
|
4
|
+
data.tar.gz: 59d764d975e32881bc3a5469c7b0be5651bdd623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf5e451c9bc4d9e0ae2ef7e149b482b13934b85db03bd8875a78378a0535e6c0c858f7e020f7484cc2d3bb7477e15a7673177b48c1f1abdb4f1fbaee58d4814
|
7
|
+
data.tar.gz: 36e945df701ac5c9122011552bce0cce6e65ae2eb5aa7c48242f9c3db210099a3bd4ffa1c2d38f7c16d2fb9b288a141262b031427d4169fba38c922b37023da6
|
data/.travis.yml
ADDED
@@ -17,14 +17,16 @@ require 'smart_proxy_main'
|
|
17
17
|
require 'smart_proxy_openscap'
|
18
18
|
require 'smart_proxy_openscap/openscap_lib'
|
19
19
|
|
20
|
-
|
21
|
-
exit unless Proxy::OpenSCAP::Plugin.settings.enabled == true
|
20
|
+
loaded_settings = Proxy::OpenSCAP.plugin_settings
|
22
21
|
|
23
|
-
#
|
22
|
+
# Don't run if OpenSCAP plugin is disabled or settings are missing.
|
23
|
+
if !loaded_settings.enabled || loaded_settings.nil? || loaded_settings.empty?
|
24
|
+
exit 436
|
25
|
+
end
|
24
26
|
|
25
27
|
module Proxy
|
26
28
|
module Log
|
27
|
-
@@logger = ::Logger.new(Proxy::OpenSCAP.fullpath(Proxy::OpenSCAP
|
29
|
+
@@logger = ::Logger.new(Proxy::OpenSCAP.fullpath(Proxy::OpenSCAP.plugin_settings.openscap_send_log_file), 6, 1024*1024*10)
|
28
30
|
@@logger.level = ::Logger.const_get(Proxy::SETTINGS.log_level.upcase)
|
29
31
|
end
|
30
32
|
end
|
@@ -32,13 +34,13 @@ include Proxy::Log
|
|
32
34
|
|
33
35
|
if !Proxy::SETTINGS.foreman_url
|
34
36
|
logger.error "Foreman URL not configured"
|
35
|
-
exit
|
37
|
+
exit 437
|
36
38
|
end
|
37
39
|
|
38
40
|
begin
|
39
|
-
Proxy::OpenSCAP::send_spool_to_foreman
|
41
|
+
Proxy::OpenSCAP::send_spool_to_foreman(loaded_settings)
|
40
42
|
rescue StandardError => e
|
41
43
|
logger.error e
|
42
|
-
puts "#{e} See #{Proxy::OpenSCAP.fullpath(
|
43
|
-
exit
|
44
|
+
puts "#{e} See #{Proxy::OpenSCAP.fullpath(loaded_settings.openscap_send_log_file)}"
|
45
|
+
exit 438
|
44
46
|
end
|
@@ -13,6 +13,8 @@ require 'fileutils'
|
|
13
13
|
require 'pathname'
|
14
14
|
require 'json'
|
15
15
|
require 'proxy/error'
|
16
|
+
require 'yaml'
|
17
|
+
require 'ostruct'
|
16
18
|
require 'proxy/request'
|
17
19
|
require 'smart_proxy_openscap/fetch_scap_content'
|
18
20
|
require 'smart_proxy_openscap/foreman_forwarder'
|
@@ -28,6 +30,15 @@ require 'smart_proxy_openscap/profiles_parser'
|
|
28
30
|
module Proxy::OpenSCAP
|
29
31
|
extend ::Proxy::Log
|
30
32
|
|
33
|
+
def self.plugin_settings
|
34
|
+
@@settings ||= OpenStruct.new(read_settings)
|
35
|
+
end
|
36
|
+
|
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)
|
40
|
+
end
|
41
|
+
|
31
42
|
def self.common_name(request)
|
32
43
|
client_cert = request.env['SSL_CLIENT_CERT']
|
33
44
|
raise Proxy::Error::Unauthorized, "Client certificate required!" if client_cert.to_s.empty?
|
@@ -43,10 +54,10 @@ module Proxy::OpenSCAP
|
|
43
54
|
cn
|
44
55
|
end
|
45
56
|
|
46
|
-
def self.send_spool_to_foreman
|
47
|
-
arf_dir = File.join(
|
57
|
+
def self.send_spool_to_foreman(loaded_settings)
|
58
|
+
arf_dir = File.join(loaded_settings.spooldir, "/arf")
|
48
59
|
return unless File.exist? arf_dir
|
49
|
-
SpoolForwarder.new.post_arf_from_spool(arf_dir)
|
60
|
+
SpoolForwarder.new(loaded_settings).post_arf_from_spool(arf_dir)
|
50
61
|
end
|
51
62
|
|
52
63
|
def self.fullpath(path = Proxy::OpenSCAP::Plugin.settings.contentdir)
|
@@ -2,6 +2,10 @@ module Proxy::OpenSCAP
|
|
2
2
|
class SpoolForwarder
|
3
3
|
include ::Proxy::Log
|
4
4
|
|
5
|
+
def initialize(loaded_settings)
|
6
|
+
@loaded_settings = loaded_settings
|
7
|
+
end
|
8
|
+
|
5
9
|
def post_arf_from_spool(arf_dir)
|
6
10
|
Dir.foreach(arf_dir) do |cname|
|
7
11
|
next if cname == '.' || cname == '..'
|
@@ -49,12 +53,12 @@ module Proxy::OpenSCAP
|
|
49
53
|
def forward_arf_file(cname, policy_id, date, arf_file_path)
|
50
54
|
data = File.open(arf_file_path, 'rb') { |io| io.read }
|
51
55
|
post_to_foreman = ForemanForwarder.new.post_arf_report(cname, policy_id, date, data)
|
52
|
-
Proxy::OpenSCAP::StorageFS.new(
|
56
|
+
Proxy::OpenSCAP::StorageFS.new(@loaded_settings.reportsdir, cname, post_to_foreman['id'], date).store_archive(data)
|
53
57
|
File.delete arf_file_path
|
54
58
|
rescue Proxy::OpenSCAP::OpenSCAPException => e
|
55
|
-
logger.error "Failed to parse Arf Report at #{arf_file_path}, moving to #{
|
59
|
+
logger.error "Failed to parse Arf Report at #{arf_file_path}, moving to #{@loaded_settings.corrupted_dir}"
|
56
60
|
|
57
|
-
Proxy::OpenSCAP::StorageFS.new(
|
61
|
+
Proxy::OpenSCAP::StorageFS.new(@loaded_settings.corrupted_dir, cname, policy_id, date).
|
58
62
|
move_corrupted(arf_file_path.split('/').last)
|
59
63
|
|
60
64
|
rescue StandardError => e
|
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.
|
4
|
+
version: 0.6.10
|
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-03-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -93,6 +93,7 @@ extra_rdoc_files: []
|
|
93
93
|
files:
|
94
94
|
- ".rubocop.yml"
|
95
95
|
- ".rubocop_todo.yml"
|
96
|
+
- ".travis.yml"
|
96
97
|
- COPYING
|
97
98
|
- Gemfile
|
98
99
|
- README.md
|