From d8364787dfea90ffa16ec3c885eba62442301b40 Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Fri, 30 May 2025 14:47:54 -0400 Subject: [PATCH 1/9] Add patch to fix failing pipeline --- ...ord-Encrypt-Decrypt-to-return-string.patch | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docker/gitlab/patches/0006-Override-ActiveRecord-Encrypt-Decrypt-to-return-string.patch diff --git a/docker/gitlab/patches/0006-Override-ActiveRecord-Encrypt-Decrypt-to-return-string.patch b/docker/gitlab/patches/0006-Override-ActiveRecord-Encrypt-Decrypt-to-return-string.patch new file mode 100644 index 00000000..6bf46d36 --- /dev/null +++ b/docker/gitlab/patches/0006-Override-ActiveRecord-Encrypt-Decrypt-to-return-string.patch @@ -0,0 +1,29 @@ +From 218f42cdc0efefb7dadccedac203cfba892ed98a Mon Sep 17 00:00:00 2001 +From: Irina Bronipolsky +Date: Thu, 21 Dec 2023 16:39:42 -0600 +Subject: [PATCH] Override ActiveRecord encrypt and decrypt methods to return strings + +--- + config/initializers/attr_encrypted_stub.rb | 7 +++++++ + 1 file changed, 7 insertions(+) + create mode 100644 config/initializers/attr_encrypted_stub.rb + +diff --git a/config/initializers/attr_encrypted_stub.rb b/config/initializers/attr_encrypted_stub.rb +new file mode 100644 +index 000000000000..e89ca5d55ffd +--- /dev/null ++++ b/config/initializers/attr_encrypted_stub.rb +@@ -0,0 +1,7 @@ ++# frozen_string_literal: true ++ ++module Encryptor ++ def encrypt(_, *args) ++ +"placeholder cryptogram" ++ end ++ ++ def decrypt(_, *args) ++ +"placeholder cryptogram" ++ end ++end +-- +2.34.1 \ No newline at end of file -- GitLab From 90e9be9202a862d80c97a142c9c98d1c1b212183 Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Fri, 30 May 2025 14:57:02 -0400 Subject: [PATCH 2/9] Update patch logic --- config/initializers/attr_encrypted_stub.rb | 7 +++++++ ...e-activerecord-encrypt-decrypt-to-return-strings.patch} | 2 +- docker/gitlab/patches/apply.sh | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 config/initializers/attr_encrypted_stub.rb rename docker/gitlab/patches/{0006-Override-ActiveRecord-Encrypt-Decrypt-to-return-string.patch => 0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch} (89%) diff --git a/config/initializers/attr_encrypted_stub.rb b/config/initializers/attr_encrypted_stub.rb new file mode 100644 index 00000000..bb47f494 --- /dev/null +++ b/config/initializers/attr_encrypted_stub.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Encryptor + def encrypt(_, *args) + +"placeholder cryptogram" + end + diff --git a/docker/gitlab/patches/0006-Override-ActiveRecord-Encrypt-Decrypt-to-return-string.patch b/docker/gitlab/patches/0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch similarity index 89% rename from docker/gitlab/patches/0006-Override-ActiveRecord-Encrypt-Decrypt-to-return-string.patch rename to docker/gitlab/patches/0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch index 6bf46d36..1d916baa 100644 --- a/docker/gitlab/patches/0006-Override-ActiveRecord-Encrypt-Decrypt-to-return-string.patch +++ b/docker/gitlab/patches/0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch @@ -1,7 +1,7 @@ From 218f42cdc0efefb7dadccedac203cfba892ed98a Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Thu, 21 Dec 2023 16:39:42 -0600 -Subject: [PATCH] Override ActiveRecord encrypt and decrypt methods to return strings +Subject: [PATCH] Override activerecord encrypt and decrypt to return strings --- config/initializers/attr_encrypted_stub.rb | 7 +++++++ diff --git a/docker/gitlab/patches/apply.sh b/docker/gitlab/patches/apply.sh index 179607a9..dd0764d1 100755 --- a/docker/gitlab/patches/apply.sh +++ b/docker/gitlab/patches/apply.sh @@ -10,3 +10,4 @@ git am < "$BASE_PATH"/0002-Disable-automatic-schema-dumping-after-migration.patc git am < "$BASE_PATH"/0003-Force-Gitlab-com-true.patch git am < "$BASE_PATH"/0004-Override-Encryptor-to-return-stub.patch git am < "$BASE_PATH"/0005-Patch-finalize-BBM-helper.patch +git am < "$BASE_PATH"/0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch \ No newline at end of file -- GitLab From 4a46efc2fb3b61c6470e39064f554ca10fde2954 Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Fri, 30 May 2025 16:01:24 -0400 Subject: [PATCH 3/9] Add patch for activrecord encryptor --- .../0006-Patch-encrypted-attributes.patch | 27 +++++++++++++++++++ docker/gitlab/patches/apply.sh | 1 + 2 files changed, 28 insertions(+) create mode 100644 docker/gitlab/patches/0006-Patch-encrypted-attributes.patch diff --git a/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch b/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch new file mode 100644 index 00000000..90816174 --- /dev/null +++ b/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch @@ -0,0 +1,27 @@ +From 9bcbc6ce0378fced45234a0851a08f8152def709 Mon Sep 17 00:00:00 2001 +From: Jon Jenkins +Date: Fri, 30 May 2025 14:58:03 -0500 +Subject: [PATCH] Patch encrypted attributes + +--- + .../fix_active_record_encryption_for_test.rb | 9 +++++++++ + 1 file changed, 9 insertions(+) + create mode 100644 config/initializers/fix_active_record_encryption_for_test.rb + +diff --git a/config/initializers/fix_active_record_encryption_for_test.rb b/config/initializers/fix_active_record_encryption_for_test.rb +new file mode 100644 +index 000000000000..45e4ee580b5f +--- /dev/null ++++ b/config/initializers/fix_active_record_encryption_for_test.rb +@@ -0,0 +1,9 @@ ++module ActiveRecord ++ module Encryption ++ class Encryptor ++ def decrypt(encrypted_text, key_provider: default_key_provider, cipher_options: {}) ++ "placeholder cryptogram for testing" ++ end ++ end ++ end ++end +-- +2.46.0.rc2 \ No newline at end of file diff --git a/docker/gitlab/patches/apply.sh b/docker/gitlab/patches/apply.sh index 179607a9..f5759716 100755 --- a/docker/gitlab/patches/apply.sh +++ b/docker/gitlab/patches/apply.sh @@ -10,3 +10,4 @@ git am < "$BASE_PATH"/0002-Disable-automatic-schema-dumping-after-migration.patc git am < "$BASE_PATH"/0003-Force-Gitlab-com-true.patch git am < "$BASE_PATH"/0004-Override-Encryptor-to-return-stub.patch git am < "$BASE_PATH"/0005-Patch-finalize-BBM-helper.patch +git am < "$BASE_PATH"/0006-Patch-encrypted-attributes.patch -- GitLab From 2edfc47c36d521648ce37d0bcab10a70a471ea60 Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Fri, 30 May 2025 16:28:51 -0400 Subject: [PATCH 4/9] Update patch and delete attr_encrypted_stub --- config/initializers/attr_encrypted_stub.rb | 7 ------- .../0006-Patch-encrypted-attributes.patch | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 config/initializers/attr_encrypted_stub.rb diff --git a/config/initializers/attr_encrypted_stub.rb b/config/initializers/attr_encrypted_stub.rb deleted file mode 100644 index bb47f494..00000000 --- a/config/initializers/attr_encrypted_stub.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -module Encryptor - def encrypt(_, *args) - +"placeholder cryptogram" - end - diff --git a/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch b/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch index 90816174..204f13ab 100644 --- a/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch +++ b/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch @@ -1,11 +1,12 @@ -From 9bcbc6ce0378fced45234a0851a08f8152def709 Mon Sep 17 00:00:00 2001 +From 2ed6fcc2056b13a1c497523a07987bcd21d3ddb9 Mon Sep 17 00:00:00 2001 From: Jon Jenkins Date: Fri, 30 May 2025 14:58:03 -0500 Subject: [PATCH] Patch encrypted attributes --- .../fix_active_record_encryption_for_test.rb | 9 +++++++++ - 1 file changed, 9 insertions(+) + lib/tasks/gitlab/db.rake | 1 + + 2 files changed, 10 insertions(+) create mode 100644 config/initializers/fix_active_record_encryption_for_test.rb diff --git a/config/initializers/fix_active_record_encryption_for_test.rb b/config/initializers/fix_active_record_encryption_for_test.rb @@ -23,5 +24,17 @@ index 000000000000..45e4ee580b5f + end + end +end +diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake +index 995944b865a7..03fd4aed4c1d 100644 +--- a/lib/tasks/gitlab/db.rake ++++ b/lib/tasks/gitlab/db.rake +@@ -470,6 +470,7 @@ namespace :gitlab do + + task up: :environment do + Gitlab::Database::Migrations::Runner.up(database: 'main', legacy_mode: true).run ++ require_relative 'config/initializers/fix_active_record_encryption_for_test.rb' + end + + namespace :up do -- 2.46.0.rc2 \ No newline at end of file -- GitLab From 819254b759a8fe0afabe0f420249293a804dff70 Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Fri, 30 May 2025 16:54:40 -0400 Subject: [PATCH 5/9] Update patch for application settings --- ...rd-encrypt-decrypt-to-return-strings.patch | 29 -------------- .../0006-Patch-application-settings.patch | 24 +++++++++++ .../0006-Patch-encrypted-attributes.patch | 40 ------------------- 3 files changed, 24 insertions(+), 69 deletions(-) delete mode 100644 docker/gitlab/patches/0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch create mode 100644 docker/gitlab/patches/0006-Patch-application-settings.patch delete mode 100644 docker/gitlab/patches/0006-Patch-encrypted-attributes.patch diff --git a/docker/gitlab/patches/0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch b/docker/gitlab/patches/0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch deleted file mode 100644 index 1d916baa..00000000 --- a/docker/gitlab/patches/0006-Override-activerecord-encrypt-decrypt-to-return-strings.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 218f42cdc0efefb7dadccedac203cfba892ed98a Mon Sep 17 00:00:00 2001 -From: Irina Bronipolsky -Date: Thu, 21 Dec 2023 16:39:42 -0600 -Subject: [PATCH] Override activerecord encrypt and decrypt to return strings - ---- - config/initializers/attr_encrypted_stub.rb | 7 +++++++ - 1 file changed, 7 insertions(+) - create mode 100644 config/initializers/attr_encrypted_stub.rb - -diff --git a/config/initializers/attr_encrypted_stub.rb b/config/initializers/attr_encrypted_stub.rb -new file mode 100644 -index 000000000000..e89ca5d55ffd ---- /dev/null -+++ b/config/initializers/attr_encrypted_stub.rb -@@ -0,0 +1,7 @@ -+# frozen_string_literal: true -+ -+module Encryptor -+ def encrypt(_, *args) -+ +"placeholder cryptogram" -+ end -+ -+ def decrypt(_, *args) -+ +"placeholder cryptogram" -+ end -+end --- -2.34.1 \ No newline at end of file diff --git a/docker/gitlab/patches/0006-Patch-application-settings.patch b/docker/gitlab/patches/0006-Patch-application-settings.patch new file mode 100644 index 00000000..af82c972 --- /dev/null +++ b/docker/gitlab/patches/0006-Patch-application-settings.patch @@ -0,0 +1,24 @@ +From 71118a252bd1b740f0c62e887f3bf66ee7599d5d Mon Sep 17 00:00:00 2001 +From: Jon Jenkins +Date: Fri, 30 May 2025 15:52:03 -0500 +Subject: [PATCH] Patch application settings + +--- + lib/gitlab/current_settings.rb | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb +index e5ec2ff44eb7..fb7ffca9f586 100644 +--- a/lib/gitlab/current_settings.rb ++++ b/lib/gitlab/current_settings.rb +@@ -13,6 +13,8 @@ def signup_limited? + + def current_application_settings + Gitlab::SafeRequestStore.fetch(:current_application_settings) { Gitlab::ApplicationSettingFetcher.current_application_settings } ++ rescue StandardError => e ++ puts "current_application_settings call failed with #{e}" + end + + def current_application_settings? +-- +2.46.0.rc2 \ No newline at end of file diff --git a/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch b/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch deleted file mode 100644 index 204f13ab..00000000 --- a/docker/gitlab/patches/0006-Patch-encrypted-attributes.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 2ed6fcc2056b13a1c497523a07987bcd21d3ddb9 Mon Sep 17 00:00:00 2001 -From: Jon Jenkins -Date: Fri, 30 May 2025 14:58:03 -0500 -Subject: [PATCH] Patch encrypted attributes - ---- - .../fix_active_record_encryption_for_test.rb | 9 +++++++++ - lib/tasks/gitlab/db.rake | 1 + - 2 files changed, 10 insertions(+) - create mode 100644 config/initializers/fix_active_record_encryption_for_test.rb - -diff --git a/config/initializers/fix_active_record_encryption_for_test.rb b/config/initializers/fix_active_record_encryption_for_test.rb -new file mode 100644 -index 000000000000..45e4ee580b5f ---- /dev/null -+++ b/config/initializers/fix_active_record_encryption_for_test.rb -@@ -0,0 +1,9 @@ -+module ActiveRecord -+ module Encryption -+ class Encryptor -+ def decrypt(encrypted_text, key_provider: default_key_provider, cipher_options: {}) -+ "placeholder cryptogram for testing" -+ end -+ end -+ end -+end -diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake -index 995944b865a7..03fd4aed4c1d 100644 ---- a/lib/tasks/gitlab/db.rake -+++ b/lib/tasks/gitlab/db.rake -@@ -470,6 +470,7 @@ namespace :gitlab do - - task up: :environment do - Gitlab::Database::Migrations::Runner.up(database: 'main', legacy_mode: true).run -+ require_relative 'config/initializers/fix_active_record_encryption_for_test.rb' - end - - namespace :up do --- -2.46.0.rc2 \ No newline at end of file -- GitLab From d2460e7f2f256a6d10331592c38409486f343418 Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Fri, 30 May 2025 16:57:56 -0400 Subject: [PATCH 6/9] Update apply.sh --- docker/gitlab/patches/apply.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/gitlab/patches/apply.sh b/docker/gitlab/patches/apply.sh index f5759716..24aa9234 100755 --- a/docker/gitlab/patches/apply.sh +++ b/docker/gitlab/patches/apply.sh @@ -10,4 +10,4 @@ git am < "$BASE_PATH"/0002-Disable-automatic-schema-dumping-after-migration.patc git am < "$BASE_PATH"/0003-Force-Gitlab-com-true.patch git am < "$BASE_PATH"/0004-Override-Encryptor-to-return-stub.patch git am < "$BASE_PATH"/0005-Patch-finalize-BBM-helper.patch -git am < "$BASE_PATH"/0006-Patch-encrypted-attributes.patch +git am < "$BASE_PATH"/0006-Patch-application_settings.patch -- GitLab From f8e93ac9ecdddb8b908a8fa4827beaae729987b6 Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Fri, 30 May 2025 17:02:48 -0400 Subject: [PATCH 7/9] Fix typo in apply.sh --- docker/gitlab/patches/apply.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/gitlab/patches/apply.sh b/docker/gitlab/patches/apply.sh index 24aa9234..7ecd8eb8 100755 --- a/docker/gitlab/patches/apply.sh +++ b/docker/gitlab/patches/apply.sh @@ -10,4 +10,4 @@ git am < "$BASE_PATH"/0002-Disable-automatic-schema-dumping-after-migration.patc git am < "$BASE_PATH"/0003-Force-Gitlab-com-true.patch git am < "$BASE_PATH"/0004-Override-Encryptor-to-return-stub.patch git am < "$BASE_PATH"/0005-Patch-finalize-BBM-helper.patch -git am < "$BASE_PATH"/0006-Patch-application_settings.patch +git am < "$BASE_PATH"/0006-Patch-application-settings.patch -- GitLab From cf7c854674058bbd55b9b1f579ce80fa431e69db Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Fri, 30 May 2025 17:24:25 -0400 Subject: [PATCH 8/9] Update patch settings --- .../patches/0006-Patch-application-settings.patch | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docker/gitlab/patches/0006-Patch-application-settings.patch b/docker/gitlab/patches/0006-Patch-application-settings.patch index af82c972..b8ff3b1b 100644 --- a/docker/gitlab/patches/0006-Patch-application-settings.patch +++ b/docker/gitlab/patches/0006-Patch-application-settings.patch @@ -1,22 +1,27 @@ -From 71118a252bd1b740f0c62e887f3bf66ee7599d5d Mon Sep 17 00:00:00 2001 +From 3b004a608e8cda4478d04a83dce22c342fdbb95b Mon Sep 17 00:00:00 2001 From: Jon Jenkins Date: Fri, 30 May 2025 15:52:03 -0500 Subject: [PATCH] Patch application settings --- - lib/gitlab/current_settings.rb | 2 ++ - 1 file changed, 2 insertions(+) + lib/gitlab/current_settings.rb | 7 +++++++ + 1 file changed, 7 insertions(+) diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb -index e5ec2ff44eb7..fb7ffca9f586 100644 +index e5ec2ff44eb7..897b27f06990 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb -@@ -13,6 +13,8 @@ def signup_limited? +@@ -13,6 +13,13 @@ def signup_limited? def current_application_settings Gitlab::SafeRequestStore.fetch(:current_application_settings) { Gitlab::ApplicationSettingFetcher.current_application_settings } + rescue StandardError => e + puts "current_application_settings call failed with #{e}" ++ Class.new do ++ def method_missing(method, *args, &block) ++ method.to_s ++ end ++ end.new end def current_application_settings? -- GitLab From 68d0cc47c888f31dcfdb0d124fff11050e3c1a1a Mon Sep 17 00:00:00 2001 From: Irina Bronipolsky Date: Mon, 2 Jun 2025 11:18:32 -0400 Subject: [PATCH 9/9] Make sure activerecord patch comes first --- .../0006-Patch-application-settings.patch | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/docker/gitlab/patches/0006-Patch-application-settings.patch b/docker/gitlab/patches/0006-Patch-application-settings.patch index b8ff3b1b..711337b0 100644 --- a/docker/gitlab/patches/0006-Patch-application-settings.patch +++ b/docker/gitlab/patches/0006-Patch-application-settings.patch @@ -1,29 +1,27 @@ -From 3b004a608e8cda4478d04a83dce22c342fdbb95b Mon Sep 17 00:00:00 2001 +From 9bcbc6ce0378fced45234a0851a08f8152def709 Mon Sep 17 00:00:00 2001 From: Jon Jenkins -Date: Fri, 30 May 2025 15:52:03 -0500 +Date: Fri, 30 May 2025 14:58:03 -0500 Subject: [PATCH] Patch application settings --- - lib/gitlab/current_settings.rb | 7 +++++++ - 1 file changed, 7 insertions(+) + .../0_active_record_encryption_fix.rb | 9 +++++++++ + 1 file changed, 9 insertions(+) + create mode 100644 config/initializers/0_active_record_encryption_fix.rb -diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb -index e5ec2ff44eb7..897b27f06990 100644 ---- a/lib/gitlab/current_settings.rb -+++ b/lib/gitlab/current_settings.rb -@@ -13,6 +13,13 @@ def signup_limited? - - def current_application_settings - Gitlab::SafeRequestStore.fetch(:current_application_settings) { Gitlab::ApplicationSettingFetcher.current_application_settings } -+ rescue StandardError => e -+ puts "current_application_settings call failed with #{e}" -+ Class.new do -+ def method_missing(method, *args, &block) -+ method.to_s -+ end -+ end.new - end - - def current_application_settings? +diff --git a/config/initializers/0_active_record_encryption_fix.rb b/config/initializers/0_active_record_encryption_fix.rb +new file mode 100644 +index 000000000000..45e4ee580b5f +--- /dev/null ++++ b/config/initializers/0_active_record_encryption_fix.rb +@@ -0,0 +1,9 @@ ++module ActiveRecord ++ module Encryption ++ class Encryptor ++ def decrypt(encrypted_text, key_provider: default_key_provider, cipher_options: {}) ++ "placeholder cryptogram for testing" ++ end ++ end ++ end ++end -- -2.46.0.rc2 \ No newline at end of file +2.46.0.rc2 -- GitLab