From fca671dbae6648714fb0d31e88e2375f397dcafd Mon Sep 17 00:00:00 2001 From: Sandro Bonazzola Date: Fri, 27 Sep 2024 10:26:19 +0200 Subject: [PATCH] Allow to skip SSL verification in bugzilla plugin Recently Red Hat bugzilla SSL certificate is failing verification. In order to allow querying bugzilla while this issue is getting fixed, allowing to skip SSL certificate validation. Signed-off-by: Sandro Bonazzola --- did/plugins/bugzilla.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/did/plugins/bugzilla.py b/did/plugins/bugzilla.py index 8e6fefdb..0bd94aac 100644 --- a/did/plugins/bugzilla.py +++ b/did/plugins/bugzilla.py @@ -18,6 +18,7 @@ type = bugzilla prefix = BZ url = https://bugzilla.redhat.com/xmlrpc.cgi + ssl_verify = True resolutions = notabug, duplicate Resolutions: @@ -48,7 +49,7 @@ from did.base import Config, ReportError from did.stats import Stats, StatsGroup -from did.utils import log, pretty, split +from did.utils import log, pretty, split, strtobool # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Constants @@ -56,11 +57,14 @@ DEFAULT_RESOLUTIONS = ["notabug", "duplicate"] +# Enable ssl verify +SSL_VERIFY = True # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Bugzilla # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + class Bugzilla(object): """ Bugzilla investigator """ @@ -73,7 +77,10 @@ def __init__(self, parent): def server(self): """ Connection to the server """ if self._server is None: - self._server = bugzilla.Bugzilla(url=self.parent.url) + self._server = bugzilla.Bugzilla( + url=self.parent.url, + sslverify=self.parent.ssl_verify + ) return self._server def search(self, query, options): @@ -645,6 +652,18 @@ def __init__(self, option, name=None, parent=None, user=None): except KeyError: raise ReportError( "No bugzilla url set in the [{0}] section".format(option)) + + # SSL verification + if "ssl_verify" in config: + try: + self.ssl_verify = strtobool( + config["ssl_verify"]) + except Exception as error: + raise ReportError( + "Error when parsing 'ssl_verify': {0}".format(error)) + else: + self.ssl_verify = SSL_VERIFY + # Make sure we have prefix set try: self.prefix = config["prefix"]