foreman_maintain 1.8.2 → 1.9.1

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: a042b3f0cd480eab2e674abcbd5aecb247943b481bad114e31376610a3b785d0
4
- data.tar.gz: 16e74a0e82caffb11d5d0363046bfa5120afab203ce1d88ad88a4311f664e1f4
3
+ metadata.gz: 73708bb032234b95b2f4e43e6a754f4edd5a10b5fab5b0fe48e025e97c07b045
4
+ data.tar.gz: 804e89098c9776b9eaabbe8ddbf25b42fadafca9180bfaaafcc1e2ad19a68cbd
5
5
  SHA512:
6
- metadata.gz: 7bcc01a88e2f8bebb549a83af6d0b1f33a714a76925dc51ee48a2a979611e7d8fc47ed91b162ce97bd004360f9bb8cef7499c34160283e539e63e8b7f4b8315f
7
- data.tar.gz: 4e056e25de905cb6bb98da55c10dc1c1a57b99de6ed39b13241c4d09d7e2ca8cbaacaf6a44153ccd0f9675f432cda32ed9cb617399c3258940b0569898b12448
6
+ metadata.gz: 7436f734603158c084a33422808590fc4de98432ecf44d64106c58d625c7356e015d9fba968dd89c72aff8974364bbcd2493e7f74d99e079be59489df4a00714
7
+ data.tar.gz: d24586355b6f3bd785d8222ee93443712c4de0ce14a0dff53705b029e9a1bf0ab83db582cbce0ccf0da9e603edd5f030c259220d814a466faa20e78e40ef09fd
@@ -0,0 +1,29 @@
1
+ class Checks::CheckSha1CertificateAuthority < ForemanMaintain::Check
2
+ metadata do
3
+ label :check_sha1_certificate_authority
4
+ description 'Check if server certificate authority is sha1 signed'
5
+
6
+ confine do
7
+ feature(:katello) || feature(:foreman_proxy)
8
+ end
9
+
10
+ do_not_whitelist
11
+ end
12
+
13
+ def run
14
+ installer_answers = feature(:installer).answers
15
+ server_ca = installer_answers['certs']['server_ca_cert']
16
+
17
+ return unless server_ca
18
+
19
+ certificate = OpenSSL::X509::Certificate.new(File.read(server_ca))
20
+
21
+ msg = <<~MSG
22
+ Server CA certificate signed with sha1 which will break on upgrade.
23
+ Update the server CA certificate with one signed with sha256 or
24
+ stronger then proceed with the upgrade.
25
+ MSG
26
+
27
+ assert(certificate.signature_algorithm != 'sha1WithRSAEncryption', msg)
28
+ end
29
+ end
@@ -0,0 +1,61 @@
1
+ module Checks
2
+ module Foreman
3
+ class CheckExternalDbEvrPermissions < ForemanMaintain::Check
4
+ metadata do
5
+ label :external_db_evr_permissions
6
+ for_feature :foreman_database
7
+ description 'Check that external databases have proper EVR extension permissions'
8
+ tags :pre_upgrade
9
+ confine do
10
+ feature(:foreman_database) && !feature(:foreman_database).local? && feature(:katello)
11
+ end
12
+ end
13
+
14
+ def run
15
+ return true unless evr_exists?
16
+
17
+ error_msg = 'The evr extension is not owned by the foreman database owner. ' \
18
+ 'Please run the following command on the external foreman database to fix it: ' \
19
+ 'UPDATE pg_extension SET extowner = (SELECT oid FROM pg_authid WHERE ' \
20
+ "rolname='#{foreman_db_user}') WHERE extname='evr';"
21
+ fail!(error_msg) unless foreman_owns_evr?
22
+ end
23
+
24
+ private
25
+
26
+ def foreman_db_user
27
+ feature(:foreman_database).configuration['username'] || 'foreman'
28
+ end
29
+
30
+ def evr_exists?
31
+ evr_exists = feature(:foreman_database).query(query_for_evr_existence)
32
+ return false if evr_exists.empty?
33
+ return evr_exists.first['evr_exists'] == '1'
34
+ end
35
+
36
+ def foreman_owns_evr?
37
+ evr_owned_by_postgres = feature(:foreman_database).query(query_if_postgres_owns_evr)
38
+ unless evr_owned_by_postgres.empty?
39
+ return evr_owned_by_postgres.first['evr_owned_by_postgres'] == '0'
40
+ end
41
+ failure_msg = 'Could not determine if the evr extension is owned by the ' \
42
+ 'foreman database owner. Check that the foreman database is accessible ' \
43
+ "and that the database connection configuration is up to date."
44
+ fail!(failure_msg)
45
+ end
46
+
47
+ def query_for_evr_existence
48
+ <<-SQL
49
+ SELECT 1 AS evr_exists FROM pg_extension WHERE extname = 'evr'
50
+ SQL
51
+ end
52
+
53
+ def query_if_postgres_owns_evr
54
+ <<-SQL
55
+ SELECT CASE WHEN r.rolname = '#{foreman_db_user}' THEN 0 ELSE 1 END AS evr_owned_by_postgres
56
+ FROM pg_extension e JOIN pg_roles r ON e.extowner = r.oid WHERE e.extname = 'evr'
57
+ SQL
58
+ end
59
+ end
60
+ end
61
+ end
@@ -25,7 +25,14 @@ class Features::Pulpcore < ForemanMaintain::Feature
25
25
  end
26
26
 
27
27
  def running_tasks
28
- cli('task list --state-in running --state-in canceling')
28
+ tasks = cli('task list --state-in running --state-in canceling')
29
+ # cli() uses parse_json() which swallows JSON::ParserError and returns nil
30
+ # but running_tasks should return an Array
31
+ if tasks.nil?
32
+ []
33
+ else
34
+ tasks
35
+ end
29
36
  rescue ForemanMaintain::Error::ExecutionError
30
37
  []
31
38
  end
@@ -40,6 +40,7 @@ module Scenarios::Foreman
40
40
  Checks::Disk::AvailableSpaceCandlepin, # if candlepin
41
41
  Checks::Disk::AvailableSpacePostgresql13,
42
42
  Checks::Foreman::ValidateExternalDbVersion, # if external database
43
+ Checks::Foreman::CheckExternalDbEvrPermissions, # if external database
43
44
  Checks::Foreman::CheckCorruptedRoles,
44
45
  Checks::Foreman::CheckDuplicatePermissions,
45
46
  Checks::Foreman::TuningRequirements, # if katello present
@@ -53,6 +54,7 @@ module Scenarios::Foreman
53
54
  Checks::PackageManager::Dnf::ValidateDnfConfig,
54
55
  Checks::Repositories::CheckNonRhRepository,
55
56
  Checks::CheckOrganizationContentAccessMode,
57
+ Checks::CheckSha1CertificateAuthority,
56
58
  Checks::Repositories::Validate
57
59
  )
58
60
  end
@@ -39,6 +39,7 @@ module Scenarios::Satellite
39
39
  Checks::Disk::AvailableSpace,
40
40
  Checks::Disk::AvailableSpaceCandlepin, # if candlepin
41
41
  Checks::Foreman::ValidateExternalDbVersion, # if external database
42
+ Checks::Foreman::CheckExternalDbEvrPermissions, # if external database
42
43
  Checks::Foreman::CheckCorruptedRoles,
43
44
  Checks::Foreman::CheckDuplicatePermissions,
44
45
  Checks::Foreman::TuningRequirements, # if katello present
@@ -54,6 +55,7 @@ module Scenarios::Satellite
54
55
  Checks::CheckIpv6Disable,
55
56
  Checks::Disk::AvailableSpacePostgresql13,
56
57
  Checks::CheckOrganizationContentAccessMode,
58
+ Checks::CheckSha1CertificateAuthority,
57
59
  Checks::Repositories::Validate.new(:version => target_version),
58
60
  )
59
61
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.8.2'.freeze
2
+ VERSION = '1.9.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-13 00:00:00.000000000 Z
11
+ date: 2024-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -161,6 +161,7 @@ files:
161
161
  - definitions/checks/candlepin/db_up.rb
162
162
  - definitions/checks/check_hotfix_installed.rb
163
163
  - definitions/checks/check_ipv6_disable.rb
164
+ - definitions/checks/check_sha1_certificate_authority.rb
164
165
  - definitions/checks/check_tmout.rb
165
166
  - definitions/checks/disk/available_space.rb
166
167
  - definitions/checks/disk/available_space_candlepin.rb
@@ -169,6 +170,7 @@ files:
169
170
  - definitions/checks/env_proxy.rb
170
171
  - definitions/checks/foreman/check_corrupted_roles.rb
171
172
  - definitions/checks/foreman/check_duplicate_permission.rb
173
+ - definitions/checks/foreman/check_external_db_evr_permissions.rb
172
174
  - definitions/checks/foreman/check_puppet_capsules.rb
173
175
  - definitions/checks/foreman/check_tuning_requirements.rb
174
176
  - definitions/checks/foreman/db_up.rb
@@ -409,7 +411,7 @@ homepage: https://github.com/theforeman/foreman_maintain
409
411
  licenses:
410
412
  - GPL-3.0
411
413
  metadata: {}
412
- post_install_message:
414
+ post_install_message:
413
415
  rdoc_options: []
414
416
  require_paths:
415
417
  - lib
@@ -428,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
428
430
  version: '0'
429
431
  requirements: []
430
432
  rubygems_version: 3.3.27
431
- signing_key:
433
+ signing_key:
432
434
  specification_version: 4
433
435
  summary: Foreman maintenance tool belt
434
436
  test_files: []