smart_proxy_openscap 0.9.2 → 0.10.0
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 +4 -4
- data/bin/smart-proxy-openscap-send +60 -6
- data/lib/smart_proxy_openscap/arf_parser.rb +2 -1
- data/lib/smart_proxy_openscap/content_parser.rb +2 -3
- data/lib/smart_proxy_openscap/profiles_parser.rb +1 -1
- data/lib/smart_proxy_openscap/version.rb +1 -1
- metadata +3 -5
- data/bin/smart-proxy-openscap-send-inner +0 -61
- data/extra/rubygem-smart_proxy_openscap.spec +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02ab6e238370db54d999386c79f2735991d9e1c4b23b3a0e9fc86471e82d238a
|
4
|
+
data.tar.gz: e75f6b653f970415b622304c9526543d81514488be71e3bf62b077bfe41df427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42d35a3f634b32d1936e6cee7cfc94d764bf43a856004fe6907f6a3b1097dd4d2175f59f295a89ff06240fb1948bf29fffb1659a0a1633f593c9cb67f0f8ed91
|
7
|
+
data.tar.gz: 80171b3bcbf413ba40a76875febf710e64faca2b84febf048056cb3b1777ccd7d228aced737a87e51906bffaf163fd60728b1c968117d9edf663442cef18c76a
|
@@ -1,7 +1,61 @@
|
|
1
|
-
#!/bin/
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014--2015 Red Hat Inc.
|
4
|
+
#
|
5
|
+
# This software is licensed to you under the GNU General Public License,
|
6
|
+
# version 3 (GPLv3). There is NO WARRANTY for this software, express or
|
7
|
+
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
|
8
|
+
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
|
9
|
+
# along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
|
10
|
+
#
|
2
11
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
12
|
+
$LOAD_PATH.unshift '/usr/share/foreman-proxy/lib'
|
13
|
+
$LOAD_PATH.unshift '/usr/share/foreman-proxy/modules'
|
14
|
+
|
15
|
+
require 'smart_proxy'
|
16
|
+
require 'smart_proxy_main'
|
17
|
+
require 'smart_proxy_openscap'
|
18
|
+
require 'smart_proxy_openscap/openscap_lib'
|
19
|
+
|
20
|
+
loaded_settings = Proxy::OpenSCAP.plugin_settings
|
21
|
+
|
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
|
26
|
+
|
27
|
+
module Proxy
|
28
|
+
module Log
|
29
|
+
@@logger = ::Logger.new(Proxy::OpenSCAP.fullpath(Proxy::OpenSCAP.plugin_settings.openscap_send_log_file), 6, 1024*1024*10)
|
30
|
+
@@logger.level = ::Logger.const_get(Proxy::SETTINGS.log_level.upcase)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
include Proxy::Log
|
34
|
+
|
35
|
+
if !Proxy::SETTINGS.foreman_url
|
36
|
+
logger.error "Foreman URL not configured"
|
37
|
+
exit 437
|
38
|
+
end
|
39
|
+
|
40
|
+
lockfile = File.join(loaded_settings.spooldir, "spool.lock")
|
41
|
+
|
42
|
+
Signal.trap("TERM") {
|
43
|
+
FileUtils.rm(lockfile) if File.exist?(lockfile)
|
44
|
+
exit
|
45
|
+
}
|
46
|
+
|
47
|
+
if File.exist? lockfile
|
48
|
+
logger.debug "Lock file #{lockfile} for openscap spool exists, not sending spool to server"
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
FileUtils.touch lockfile
|
54
|
+
Proxy::OpenSCAP::send_spool_to_foreman(loaded_settings)
|
55
|
+
rescue StandardError => e
|
56
|
+
logger.error e
|
57
|
+
puts "#{e} See #{Proxy::OpenSCAP.fullpath(loaded_settings.openscap_send_log_file)}"
|
58
|
+
exit 438
|
59
|
+
ensure
|
60
|
+
FileUtils.rm lockfile
|
61
|
+
end
|
@@ -87,7 +87,8 @@ module Proxy
|
|
87
87
|
{
|
88
88
|
:id => fix.id,
|
89
89
|
:system => fix.system,
|
90
|
-
:full_text => fix.full_text(set_values)
|
90
|
+
:full_text => fix.full_text(set_values),
|
91
|
+
:reboot => fix.instance_variable_get('@parsed_xml')['reboot'] # TODO: add this to openscap_parser lib
|
91
92
|
}
|
92
93
|
end
|
93
94
|
end
|
@@ -8,13 +8,12 @@ module Proxy::OpenSCAP
|
|
8
8
|
def validate(file_type, scap_file)
|
9
9
|
msg = 'Invalid XML format'
|
10
10
|
errors = []
|
11
|
-
file = nil
|
12
11
|
begin
|
13
12
|
case file_type
|
14
13
|
when 'scap_content'
|
15
|
-
|
14
|
+
::OpenscapParser::DatastreamFile.new(scap_file)
|
16
15
|
when 'tailoring_file'
|
17
|
-
|
16
|
+
::OpenscapParser::TailoringFile.new(scap_file)
|
18
17
|
end
|
19
18
|
rescue Nokogiri::XML::SyntaxError => e
|
20
19
|
logger.error msg
|
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.10.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:
|
13
|
+
date: 2024-05-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -114,10 +114,8 @@ files:
|
|
114
114
|
- Rakefile
|
115
115
|
- bin/smart-proxy-arf-html
|
116
116
|
- bin/smart-proxy-openscap-send
|
117
|
-
- bin/smart-proxy-openscap-send-inner
|
118
117
|
- bin/smart-proxy-policy-guide
|
119
118
|
- bundler.d/openscap.rb
|
120
|
-
- extra/rubygem-smart_proxy_openscap.spec
|
121
119
|
- extra/smart-proxy-openscap-send.cron
|
122
120
|
- lib/smart_proxy_openscap.rb
|
123
121
|
- lib/smart_proxy_openscap/arf_html.rb
|
@@ -191,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
189
|
version: '0'
|
192
190
|
requirements:
|
193
191
|
- bzip2
|
194
|
-
rubygems_version: 3.
|
192
|
+
rubygems_version: 3.5.9
|
195
193
|
signing_key:
|
196
194
|
specification_version: 4
|
197
195
|
summary: OpenSCAP plug-in for Foreman's smart-proxy.
|
@@ -1,61 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Copyright (c) 2014--2015 Red Hat Inc.
|
4
|
-
#
|
5
|
-
# This software is licensed to you under the GNU General Public License,
|
6
|
-
# version 3 (GPLv3). There is NO WARRANTY for this software, express or
|
7
|
-
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
|
8
|
-
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
|
9
|
-
# along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
|
10
|
-
#
|
11
|
-
|
12
|
-
$LOAD_PATH.unshift '/usr/share/foreman-proxy/lib'
|
13
|
-
$LOAD_PATH.unshift '/usr/share/foreman-proxy/modules'
|
14
|
-
|
15
|
-
require 'smart_proxy'
|
16
|
-
require 'smart_proxy_main'
|
17
|
-
require 'smart_proxy_openscap'
|
18
|
-
require 'smart_proxy_openscap/openscap_lib'
|
19
|
-
|
20
|
-
loaded_settings = Proxy::OpenSCAP.plugin_settings
|
21
|
-
|
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
|
26
|
-
|
27
|
-
module Proxy
|
28
|
-
module Log
|
29
|
-
@@logger = ::Logger.new(Proxy::OpenSCAP.fullpath(Proxy::OpenSCAP.plugin_settings.openscap_send_log_file), 6, 1024*1024*10)
|
30
|
-
@@logger.level = ::Logger.const_get(Proxy::SETTINGS.log_level.upcase)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
include Proxy::Log
|
34
|
-
|
35
|
-
if !Proxy::SETTINGS.foreman_url
|
36
|
-
logger.error "Foreman URL not configured"
|
37
|
-
exit 437
|
38
|
-
end
|
39
|
-
|
40
|
-
lockfile = File.join(loaded_settings.spooldir, "spool.lock")
|
41
|
-
|
42
|
-
Signal.trap("TERM") {
|
43
|
-
FileUtils.rm(lockfile) if File.exist?(lockfile)
|
44
|
-
exit
|
45
|
-
}
|
46
|
-
|
47
|
-
if File.exist? lockfile
|
48
|
-
logger.debug "Lock file #{lockfile} for openscap spool exists, not sending spool to server"
|
49
|
-
exit
|
50
|
-
end
|
51
|
-
|
52
|
-
begin
|
53
|
-
FileUtils.touch lockfile
|
54
|
-
Proxy::OpenSCAP::send_spool_to_foreman(loaded_settings)
|
55
|
-
rescue StandardError => e
|
56
|
-
logger.error e
|
57
|
-
puts "#{e} See #{Proxy::OpenSCAP.fullpath(loaded_settings.openscap_send_log_file)}"
|
58
|
-
exit 438
|
59
|
-
ensure
|
60
|
-
FileUtils.rm lockfile
|
61
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
%global gem_name smart_proxy_openscap
|
2
|
-
|
3
|
-
%global foreman_proxy_bundlerd_dir /usr/share/foreman-proxy/bundler.d
|
4
|
-
%global foreman_proxy_pluginconf_dir /etc/foreman-proxy/settings.d
|
5
|
-
%global spool_dir /var/spool/foreman-proxy/openscap
|
6
|
-
%global proxy_user foreman-proxy
|
7
|
-
|
8
|
-
Name: rubygem-%{gem_name}
|
9
|
-
Version: 0.3.0
|
10
|
-
Release: 1%{?dist}
|
11
|
-
Summary: OpenSCAP plug-in for Foreman's smart-proxy.
|
12
|
-
Group: Applications/Internet
|
13
|
-
License: GPLv2+
|
14
|
-
URL: http://github.com/openscap/smart_proxy_openscap
|
15
|
-
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
|
16
|
-
#Requires: ruby(release)
|
17
|
-
Requires: ruby(rubygems)
|
18
|
-
Requires: foreman-proxy >= 1.7.0-0.develop.201410221520
|
19
|
-
Requires: crontabs
|
20
|
-
#BuildRequires: ruby(release)
|
21
|
-
BuildRequires: rubygems-devel
|
22
|
-
BuildRequires: ruby
|
23
|
-
BuildArch: noarch
|
24
|
-
Provides: rubygem(%{gem_name}) = %{version}
|
25
|
-
Obsoletes: rubygem-foreman-proxy_openscap
|
26
|
-
|
27
|
-
%description
|
28
|
-
A plug-in to the Foreman's smart-proxy which receives bzip2ed ARF files
|
29
|
-
and forwards them to the Foreman.
|
30
|
-
|
31
|
-
%prep
|
32
|
-
gem unpack %{SOURCE0}
|
33
|
-
%setup -q -D -T -n %{gem_name}-%{version}
|
34
|
-
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
35
|
-
|
36
|
-
%build
|
37
|
-
# Create the gem as gem install only works on a gem file
|
38
|
-
gem build %{gem_name}.gemspec
|
39
|
-
|
40
|
-
# %%gem_install compiles any C extensions and installs the gem into ./%gem_dir
|
41
|
-
# by default, so that we can move it into the buildroot in %%install
|
42
|
-
%gem_install
|
43
|
-
|
44
|
-
%install
|
45
|
-
mkdir -p %{buildroot}%{gem_dir}
|
46
|
-
cp -a .%{gem_dir}/* \
|
47
|
-
%{buildroot}%{gem_dir}/
|
48
|
-
mv %{buildroot}%{gem_instdir}/%{gem_name}.gemspec %{buildroot}/%{gem_spec}
|
49
|
-
rm %{buildroot}%{gem_instdir}/extra/*.spec # this specfile
|
50
|
-
|
51
|
-
# executables
|
52
|
-
mkdir -p %{buildroot}%{_bindir}
|
53
|
-
mv %{buildroot}%{gem_instdir}/bin/* \
|
54
|
-
%{buildroot}%{_bindir}
|
55
|
-
|
56
|
-
# bundler file
|
57
|
-
mkdir -p %{buildroot}%{foreman_proxy_bundlerd_dir}
|
58
|
-
mv %{buildroot}%{gem_instdir}/bundler.d/openscap.rb \
|
59
|
-
%{buildroot}%{foreman_proxy_bundlerd_dir}
|
60
|
-
|
61
|
-
# sample config
|
62
|
-
mkdir -p %{buildroot}%{foreman_proxy_pluginconf_dir}
|
63
|
-
mv %{buildroot}%{gem_instdir}/settings.d/openscap.yml.example \
|
64
|
-
%{buildroot}%{foreman_proxy_pluginconf_dir}/
|
65
|
-
|
66
|
-
# crontab
|
67
|
-
mkdir -p %{buildroot}%{_sysconfdir}/cron.d/
|
68
|
-
mv %{buildroot}%{gem_instdir}/extra/smart-proxy-openscap-send.cron \
|
69
|
-
%{buildroot}%{_sysconfdir}/cron.d/%{name}
|
70
|
-
|
71
|
-
# create spool directory
|
72
|
-
mkdir -p %{buildroot}%{spool_dir}
|
73
|
-
|
74
|
-
%files
|
75
|
-
%dir %{gem_instdir}
|
76
|
-
%{gem_libdir}
|
77
|
-
%exclude %{gem_cache}
|
78
|
-
%{gem_spec}
|
79
|
-
|
80
|
-
%attr(-,%{proxy_user},%{proxy_user}) %{spool_dir}
|
81
|
-
%{foreman_proxy_bundlerd_dir}/openscap.rb
|
82
|
-
%{_bindir}/smart-proxy-openscap-send
|
83
|
-
%doc %{foreman_proxy_pluginconf_dir}/openscap.yml.example
|
84
|
-
%config(noreplace) %attr(0644, root, root) %{_sysconfdir}/cron.d/%{name}
|
85
|
-
|
86
|
-
%{gem_docdir}
|
87
|
-
%{gem_instdir}/README.md
|
88
|
-
%{gem_instdir}/COPYING
|
89
|
-
|
90
|
-
%changelog
|
91
|
-
* Tue Jan 20 2015 Šimon Lukašík <slukasik@redhat.com> - 0.3.0-1
|
92
|
-
- new upstream release
|
93
|
-
|
94
|
-
* Tue Jan 20 2015 Šimon Lukašík <slukasik@redhat.com> - 0.1.0-2
|
95
|
-
- renamed to smart_proxy_openscap
|
96
|
-
|
97
|
-
* Fri Oct 24 2014 Šimon Lukašík <slukasik@redhat.com> - 0.1.0-1
|
98
|
-
- rebuilt
|
99
|
-
|
100
|
-
* Fri Jul 18 2014 Šimon Lukašík <slukasik@redhat.com> - 0.0.1-1
|
101
|
-
- Initial package
|