#447 fix: enforce use of API Key for Bugzilla Authentication
Merged 2 years ago by ngompa. Opened 2 years ago by yizhengxie.
yizhengxie/FedoraReview master  into  master

@@ -243,16 +243,13 @@ 

                  + "\n\n This is a Rename request for the former package '%s'"

                  % rename_request

              )

-         if self.settings.bugzilla_api_key:

-             data["api_key"] = self.settings.bugzilla_api_key

          self.log.debug("bz.createbug(%s)", data)

          try:

              bug = self.bzclient.createbug(**data)

              bug.refresh()

          except Fault as ex:

              print(ex)

-             self.login_bz()

-             return self.create_review_request(rename_request)

+             raise("Fail to create Bugzilla bug")

          return bug

  

      def run_command(self, cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE):
@@ -338,8 +335,6 @@ 

              "query_format": "advanced",

              "component": "Package Review",

          }

-         if self.settings.bugzilla_api_key:

-             query["api_key"] = self.settings.bugzilla_api_key

          bugbz = self.bzclient.query(query)

  

          if bugbz:
@@ -385,7 +380,9 @@ 

                  url="%s/xmlrpc.cgi" % bzurl, api_key=self.settings.bugzilla_api_key

              )

          else:

-             self.bzclient = RHBugzilla(url="%s/xmlrpc.cgi" % bzurl)

+             print("Could not find Bugzilla API Key. To create a new API Key: https://bugzilla.redhat.com/userprefs.cgi?tab=apikey")

+             self.settings.bugzilla_api_key = input("Bugzilla API Key: ")

+             self.bzclient = RHBugzilla(url="%s/xmlrpc.cgi" % bzurl, api_key=self.settings.bugzilla_api_key)

          self.srpmfile = os.path.expanduser(args.srpmfile)

          self.specfile = os.path.expanduser(args.specfile)

          self.spec = rpm.spec(self.specfile)

Address Issue #434

Fix:
1. Force use of API key for Bugzilla Authentication and remove login_bz() for login with password/username.
2. Remove unsupported "api_key" parameters for request.

Test example on Bugzilla Stage Server: https://bugzilla.stage.redhat.com/show_bug.cgi?id=1998156
Screenshot: https://raw.githubusercontent.com/yizhengx/yizhengx/main/bugzilla_stage_server.png

Remove these two lines instead of commenting them out

rebased onto 7330e7f

2 years ago

Remove these two lines instead of commenting them out

Amend it, thank you!

Pull-Request has been merged by ngompa

2 years ago
Metadata