2020-02-06 19:09:12 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'openssl'
|
|
|
|
require 'digest'
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module X509
|
|
|
|
class Commit < Gitlab::SignedCommit
|
|
|
|
private
|
|
|
|
|
2022-07-11 17:08:18 -04:00
|
|
|
def signature_class
|
|
|
|
CommitSignatures::X509CommitSignature
|
2020-02-06 19:09:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def attributes
|
2020-03-24 17:07:54 -04:00
|
|
|
return if @commit.sha.nil? || @commit.project.nil?
|
2020-02-06 19:09:12 -05:00
|
|
|
|
2020-03-24 17:07:54 -04:00
|
|
|
signature = X509::Signature.new(signature_text, signed_text, @commit.committer_email, @commit.created_at)
|
|
|
|
|
|
|
|
return if signature.verified_signature.nil? || signature.x509_certificate.nil?
|
2020-02-06 19:09:12 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
commit_sha: @commit.sha,
|
|
|
|
project: @commit.project,
|
2020-03-24 17:07:54 -04:00
|
|
|
x509_certificate_id: signature.x509_certificate.id,
|
|
|
|
verification_status: signature.verification_status
|
2020-02-06 19:09:12 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|