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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5a3c7008ebc9f55a9fcd647cbfdb606873a3f552d1a24aa5a0e757799105a33
4
- data.tar.gz: e4bcfac7b8139a743af163706a38473217b93fa6e56f11161de0f35ee7b794c2
3
+ metadata.gz: 02ab6e238370db54d999386c79f2735991d9e1c4b23b3a0e9fc86471e82d238a
4
+ data.tar.gz: e75f6b653f970415b622304c9526543d81514488be71e3bf62b077bfe41df427
5
5
  SHA512:
6
- metadata.gz: bcf32ad8d12435f95129e2c07648bcc81d6a0dd3d752f722ef7e042f222861676b728ced19eed64e7d1479306894e49865691bdd843443543c07eb199c596283
7
- data.tar.gz: fcb0f9f37c84202ee094c4d5810a7687559b72d3bd593cbb40e5cfe6757ba9e9200dea534e4a7f09e75b84b347c162112a3cca677887b717e56adb7474b1fd0d
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
@@ -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
- file = ::OpenscapParser::DatastreamFile.new(scap_file)
14
+ ::OpenscapParser::DatastreamFile.new(scap_file)
16
15
  when 'tailoring_file'
17
- file = ::OpenscapParser::TailoringFile.new(scap_file)
16
+ ::OpenscapParser::TailoringFile.new(scap_file)
18
17
  end
19
18
  rescue Nokogiri::XML::SyntaxError => e
20
19
  logger.error msg
@@ -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.2'
13
+ VERSION = '0.10.0'
14
14
  end
15
15
  end
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.9.2
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: 2022-04-05 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
@@ -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.0.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