summaryrefslogtreecommitdiff
path: root/lib/gitlab/spamcheck
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-10-19 09:09:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-19 09:09:54 +0000
commit811f549164618e3607721eecbfd76e292555b339 (patch)
treedf6d8f2927aaf74d4165b1904f4f8d43da13b3de /lib/gitlab/spamcheck
parenta04f7f36d7a8fb7657de899879f904e23b93ce42 (diff)
downloadgitlab-ce-811f549164618e3607721eecbfd76e292555b339.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/spamcheck')
-rw-r--r--lib/gitlab/spamcheck/client.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/gitlab/spamcheck/client.rb b/lib/gitlab/spamcheck/client.rb
index df6d3eb7d0a..b8c07c0c316 100644
--- a/lib/gitlab/spamcheck/client.rb
+++ b/lib/gitlab/spamcheck/client.rb
@@ -5,6 +5,7 @@ module Gitlab
module Spamcheck
class Client
include ::Spam::SpamConstants
+
DEFAULT_TIMEOUT_SECS = 2
VERDICT_MAPPING = {
@@ -27,12 +28,7 @@ module Gitlab
# connect with Spamcheck
@endpoint_url = @endpoint_url.gsub(%r(^grpc:\/\/), '')
- @creds =
- if Rails.env.development? || Rails.env.test?
- :this_channel_is_insecure
- else
- GRPC::Core::ChannelCredentials.new
- end
+ @creds = stub_creds
end
def issue_spam?(spam_issue:, user:, context: {})
@@ -98,6 +94,14 @@ module Gitlab
nanos: ar_timestamp.to_time.nsec)
end
+ def stub_creds
+ if Rails.env.development? || Rails.env.test?
+ :this_channel_is_insecure
+ else
+ GRPC::Core::ChannelCredentials.new ::Gitlab::X509::Certificate.ca_certs_bundle
+ end
+ end
+
def grpc_client
@grpc_client ||= ::Spamcheck::SpamcheckService::Stub.new(@endpoint_url, @creds,
interceptors: interceptors,