diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/gitlab/gpg | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/gitlab/gpg')
-rw-r--r-- | lib/gitlab/gpg/commit.rb | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/gitlab/gpg/commit.rb b/lib/gitlab/gpg/commit.rb index 1abbd6dc45b..9a6317e2b76 100644 --- a/lib/gitlab/gpg/commit.rb +++ b/lib/gitlab/gpg/commit.rb @@ -48,7 +48,7 @@ module Gitlab if gpg_key Gitlab::Gpg::CurrentKeyChain.add(gpg_key.key) - clear_memoization(:verified_signature) + clear_memoization(:gpg_signatures) end yield gpg_key @@ -56,16 +56,7 @@ module Gitlab end def verified_signature - strong_memoize(:verified_signature) { gpgme_signature } - end - - def gpgme_signature - GPGME::Crypto.new.verify(signature_text, signed_text: signed_text) do |verified_signature| - # Return the first signature for now: https://gitlab.com/gitlab-org/gitlab-foss/issues/54932 - break verified_signature - end - rescue GPGME::Error - nil + gpg_signatures.first end def create_cached_signature! @@ -77,6 +68,24 @@ module Gitlab end end + def gpg_signatures + strong_memoize(:gpg_signatures) do + signatures = [] + + GPGME::Crypto.new.verify(signature_text, signed_text: signed_text) do |verified_signature| + signatures << verified_signature + end + + signatures + rescue GPGME::Error + [] + end + end + + def multiple_signatures? + gpg_signatures.size > 1 + end + def attributes(gpg_key) user_infos = user_infos(gpg_key) verification_status = verification_status(gpg_key) @@ -93,6 +102,7 @@ module Gitlab end def verification_status(gpg_key) + return :multiple_signatures if multiple_signatures? && Feature.enabled?(:multiple_gpg_signatures, @commit.project, default_enabled: :yaml) return :unknown_key unless gpg_key return :unverified_key unless gpg_key.verified? return :unverified unless verified_signature&.valid? |