smart_proxy_openscap 0.9.1 → 0.10.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
  SHA256:
3
- metadata.gz: 036b916c4c925ac4cd054d81b3af2529b348064ff419e510443adbb8206d76af
4
- data.tar.gz: 07a87fb60a80a69ca4d0645a2ff63c124ef28d073dc86ce54cbc667d959b5c00
3
+ metadata.gz: 02ab6e238370db54d999386c79f2735991d9e1c4b23b3a0e9fc86471e82d238a
4
+ data.tar.gz: e75f6b653f970415b622304c9526543d81514488be71e3bf62b077bfe41df427
5
5
  SHA512:
6
- metadata.gz: 02c63d56b4fde7076aa00b51629c5d472cf7f39e5cfaa174f5b84a821ff218151e6a71fe82d57082b5a8a997f4671535426e39de69ac7b39e997c1f9630387b9
7
- data.tar.gz: f66b98c2d9db0bbb0f5f5958632a1d924f09dbc063a69c1aa768419298bd0e555367ee6cd0b200ced5dbd837d3d1d3dcf585b0fed66a90e5a1ba9d24068b6fec
6
+ metadata.gz: 42d35a3f634b32d1936e6cee7cfc94d764bf43a856004fe6907f6a3b1097dd4d2175f59f295a89ff06240fb1948bf29fffb1659a0a1633f593c9cb67f0f8ed91
7
+ data.tar.gz: 80171b3bcbf413ba40a76875febf710e64faca2b84febf048056cb3b1777ccd7d228aced737a87e51906bffaf163fd60728b1c968117d9edf663442cef18c76a
@@ -1,7 +1,61 @@
1
- #!/bin/bash
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
- if command -v scl &>/dev/null;then
4
- scl enable tfm smart-proxy-openscap-send-inner
5
- else
6
- smart-proxy-openscap-send-inner
7
- fi
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
@@ -3,19 +3,21 @@ require 'openscap_parser/tailoring_file'
3
3
 
4
4
  module Proxy::OpenSCAP
5
5
  class ContentParser
6
+ include ::Proxy::Log
7
+
6
8
  def validate(file_type, scap_file)
7
- msg = 'Invalid SCAP file type'
9
+ msg = 'Invalid XML format'
8
10
  errors = []
9
- file = nil
10
11
  begin
11
12
  case file_type
12
13
  when 'scap_content'
13
- file = ::OpenscapParser::DatastreamFile.new(scap_file)
14
+ ::OpenscapParser::DatastreamFile.new(scap_file)
14
15
  when 'tailoring_file'
15
- file = ::OpenscapParser::TailoringFile.new(scap_file)
16
+ ::OpenscapParser::TailoringFile.new(scap_file)
16
17
  end
17
- errors << msg unless file.valid?
18
18
  rescue Nokogiri::XML::SyntaxError => e
19
+ logger.error msg
20
+ logger.error e.backtrace.join("\n")
19
21
  errors << msg
20
22
  end
21
23
  { errors: errors }
@@ -22,7 +22,7 @@ module Proxy
22
22
 
23
23
  raise OpenSCAPException, error_msg if profiles.empty?
24
24
 
25
- result = profiles.reduce({}) do |memo, profile|
25
+ profiles.reduce({}) do |memo, profile|
26
26
  memo.tap { |acc| acc[profile.id] = profile.title }
27
27
  end.to_json
28
28
  end
@@ -10,6 +10,6 @@
10
10
 
11
11
  module Proxy
12
12
  module OpenSCAP
13
- VERSION = '0.9.1'
13
+ VERSION = '0.10.0'
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_openscap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Šimon Lukašík
8
8
  - Shlomi Zadok
9
9
  - Marek Hulan
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-07-14 00:00:00.000000000 Z
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
@@ -175,7 +173,7 @@ homepage: https://github.com/theforeman/smart_proxy_openscap
175
173
  licenses:
176
174
  - GPL-3.0-or-later
177
175
  metadata: {}
178
- post_install_message:
176
+ post_install_message:
179
177
  rdoc_options: []
180
178
  require_paths:
181
179
  - lib
@@ -191,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
189
  version: '0'
192
190
  requirements:
193
191
  - bzip2
194
- rubygems_version: 3.1.2
195
- signing_key:
192
+ rubygems_version: 3.5.9
193
+ signing_key:
196
194
  specification_version: 4
197
195
  summary: OpenSCAP plug-in for Foreman's smart-proxy.
198
196
  test_files: []
@@ -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