Python library and command line tool for interacting with Bugzilla

Overview

CI codecov PyPI

python-bugzilla

This package provides two bits:

  • bugzilla python module for talking to a Bugzilla instance over XMLRPC or REST
  • /usr/bin/bugzilla command line tool for performing actions from the command line: create or edit bugs, various queries, etc.

This was originally written specifically for Red Hat's Bugzilla instance and is used heavily at Red Hat and in Fedora, but it should be generically useful.

You can find some code examples in the examples directory.

For questions about submitting patches, see CONTRIBUTING.md

Comments
  • Use a more portable LICENSE?

    Use a more portable LICENSE?

    Any hope of getting this on a permissive license?

    I can't use this on github.com/tony/patches, as I'm hoping to be able to use it to grab bugzilla issues/attachments, GPL isn't backward compatible with MIT (only forwards).

    Looks like you may be able to keep it permissively licensed:

    'bugzilla' python module for talking to a Bugzilla instance over XMLRPC

    But I haven't looked over the code closely enough.

    If not, the only other client lib I see is https://github.com/gdestuynder/simple_bugzilla (MPL), but this lib has more activity ATM.

    opened by tony 34
  • RFE: Option for 'minor_update' to not send email

    RFE: Option for 'minor_update' to not send email

    I have the option to 'not send email as this is a minor update" option in the Red Hat bugzilla, I'd like to be able to use this from the command line.

    Is this something that I can be set with a CLI option or is it a field in can trigger? If not, please consider this as a feature request.

    Thanks in advance.

    opened by wmealing 13
  • RFE: Support bugzilla REST API

    RFE: Support bugzilla REST API

    For bugzilla 5 and later, the XMLRPC API is deprecated and won't be receiving new features, and eventually removed (though I suspect not for a while). So we need to add support for the REST API to python-bugzilla soon

    opened by crobinso 13
  • RFE Support API Keys when using the cli tool

    RFE Support API Keys when using the cli tool

    This library seems to have support for using API keys, but they don't seem to be able to be used by the command line client.

    This would be very useful.

    opened by pgagne 9
  • package broken on bugzilla 4.4.1

    package broken on bugzilla 4.4.1

    Hi, I have a bugzilla running on 4.4.1 which the package works fine with if I use 1.2.2. If I use 2.1.0 though, I start getting these stack traces

    Traceback (most recent call last):
      File "ok2.py", line 6, in <module>
        BZ.login('user', 'password')
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/base.py", line 608, in login
        ret = self._login(self.user, self.password)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/base.py", line 574, in _login
        return self._proxy.User.login({'login': user, 'password': password})
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1240, in __call__
        return self.__send(self.__name, args)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/transport.py", line 100, in _ServerProxy__request
        ret = ServerProxy._ServerProxy__request(self, methodname, params)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1599, in __request
        verbose=self.__verbose
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/transport.py", line 195, in request
        return self._request_helper(url, request_body)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/transport.py", line 158, in _request_helper
        url, data=request_body, **self.request_defaults)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/requests/sessions.py", line 549, in post
        return self.request('POST', url, data=data, json=json, **kwargs)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/requests/sessions.py", line 502, in request
        resp = self.send(prep, **send_kwargs)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/requests/sessions.py", line 612, in send
        r = adapter.send(request, **kwargs)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/q.py", line 279, in wrapper
        result = func(*args, **kwargs)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/requests/adapters.py", line 492, in send
        raise ConnectionError(err, request=request)
    requests.exceptions.ConnectionError: ('Connection aborted.', error("(54, 'ECONNRESET')",))
    

    This seems to happen whether I use the Bugzilla class or the Bugzilla44 class.

    Any thoughts on why this might be occurring? I recognize that there are quite a number of changes between the two versions. Just curious if you have any insight.

    opened by caphrim007 9
  • Client side certificate support

    Client side certificate support

    Adds the cert command line and configuration options that allow you to specify a client-side certificate file to use for TLS authentication against the web server.

    File format should be concatenated certificate and (unencrypted) private key. Encrypted private key should also be possible, but would have to deal with passing the password along to requests, and I'm not comfortable enough with Python to actually facilitate that.

    opened by towo 7
  • Fetching component details does not work in Bugzilla 5.0

    Fetching component details does not work in Bugzilla 5.0

    When requesting the component details in Bugzilla 5.0, the following error comes:

    RuntimeError: This bugzilla version does not support fetching component details.

    The related code is:

    def _getcomponentsdetails(self, product): # Originally this was a RH extension getProdCompDetails # Upstream support has been available since 4.2 if not self._check_version(4, 2): raise RuntimeError("This bugzilla version does not support " "fetching component details.")

    However, when omitting this check, the function seems to be supported.

    opened by janhollevoet 7
  • Fix path rules, add basic auth

    Fix path rules, add basic auth

    This PR rewrites path rules in a standard way, using urlparse/urlunparse as well as adds sometimes required Basic authentication via headers, so the XML-RPC API URL can be at all accessed before even calling any functions.

    Example usage:

    # coding: utf-8
    import bugzilla
    import getpass
    
    bug_id = input("Bug ID: ")
    user = input("Username: ")
    pwd = getpass.getpass("Password: ")
    
    bz = bugzilla.Bugzilla(url='https://apibugzilla.suse.com',
        user=user, password=pwd, basic_auth=True)
    print(bz.getbug(bug_id).id)
    
    opened by isbm 6
  • [RFE] Add coroutines (asyncio) support

    [RFE] Add coroutines (asyncio) support

    I'd like to use Python to talk to Bugzilla from a coroutine. Currently, python-bugzilla uses xmlrpc.client and every call to Bugzilla is blocking. This is an RFC to also allow async operations. Maybe via aiohttp-xmlrpc.

    Currently I can get around this problem by using asyncio.loop.run_in_executor like this:

    def _bugzillas():
        bzapi = bugzilla.Bugzilla(BUGZILLA)
        query = bzapi.build_query(product='Fedora')
        query['blocks'] = TRACKER
        return sorted(bzapi.query(query), key=lambda b: -b.id)
    
    
    async def bugzillas():
        loop = asyncio.get_event_loop()
        with concurrent.futures.ThreadPoolExecutor() as pool:
            return await loop.run_in_executor(pool, _bugzillas)
    

    Thanks for considering.

    wishlist 
    opened by hroncok 6
  • Fix missing authentication regression

    Fix missing authentication regression

    Identifiers with a leading "__" are mangled, ensure that the original method is overridden such that authentication tokens are added.

    Fixes: v2.1.0-11-g3c692f4f4e ("_BugzillaServerProxy as new-style class")


    This should have been caught by the rw test (#52).

    opened by Lekensteyn 6
  • Feature Request: enhance output for external trackers

    Feature Request: enhance output for external trackers

    Today, if you query for information (from the cli) and use 'external_bug' the data you get back is in the BZ's array of 1 format, which gets translated, to a dictionary of sub-elements.

    Because of this, the --outputformats inability to parse/define what (subfields) you see from this, the output is not very usable, or parsable!

    Is there a way, like what we do with CVE/comments to improve this?

    Mainly the (fields):

    • [ ] ext_bz_bug_id
    • [ ] ext_status
    • [ ] ext_description
    opened by sferich888 6
  • IndexError raised in Bugzilla._getbug

    IndexError raised in Bugzilla._getbug

    When using/enforcing the use of the REST API, the _getbug method raises an IndexError, if

    1. the specified bug ID does not exist or
    2. the user is not authorized to access the bug

    1. ID does not exist

    >>> b = Bugzilla(url='https://bugzilla.redhat.com', force_rest=True)
    >>> b.getbug(214525300)
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/usr/lib/python3.6/site-packages/bugzilla/base.py", line 1133, in getbug
        extra_fields=extra_fields)
      File "/usr/lib/python3.6/site-packages/bugzilla/base.py", line 1123, in _getbug
        return self._getbugs([objid], permissive=False, **kwargs)[0]
    IndexError: list index out of range
    

    2. Not authorized

    >>> b = Bugzilla(url='https://bugzilla.redhat.com', force_rest=True)
    >>> b.getbug(2145254)
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/usr/lib/python3.6/site-packages/bugzilla/base.py", line 1133, in getbug
        extra_fields=extra_fields)
      File "/usr/lib/python3.6/site-packages/bugzilla/base.py", line 1123, in _getbug
        return self._getbugs([objid], permissive=False, **kwargs)[0]
    IndexError: list index out of range
    

    Preliminary analysis

    When using the API route /rest/bug/<bug_id> one would get appropriate answers from the API (i.e. error 404 and 401), but the _getbug method uses the /rest/bug endpoint instead with an ids argument containing a single ID. In this case the API returns an empty list, which seems to be the direct cause of the IndexError.

    opened by crazyscientist 0
  • Provide 'total_matches' in query response if server provides it

    Provide 'total_matches' in query response if server provides it

    The RH Bugzilla provides a 'total_matches' value in a query response which the querier can use to know whether the response included all matching bugs or not. This patch adds a proxy object wrapped around the list of returned bugs to expose this value if the server has provided it. The proxy object implements enough of the Python iterator protocol so that it can be used as a replacement for existing code issuing queries, as long as that code does not attempt to modify the returned list object.

    Related to #149. Read-only functional tests pass with this patch except for testFaults which fails even without the patch :-)

    opened by kpfleming 0
  • rest api: Post process bugzilla code on HTTP error

    rest api: Post process bugzilla code on HTTP error

    Bugzilla REST API map result codes to HTTP status codes: https://github.com/bugzilla/bugzilla/blob/7581e08f9136ec32219af6c3192e42ff1c8e9691/Bugzilla/WebService/Constants.pm#L262-L287

    But python-bugzilla don't propagate those Bugzilla codes.

    Fixes: https://github.com/python-bugzilla/python-bugzilla/issues/171

    opened by stanislavlevin 0
  • REST API and HTTP errors

    REST API and HTTP errors

    The following query crashes:

    import bugzilla
    
    
    URL = "bugzilla.stage.redhat.com"
    bzapi = bugzilla.Bugzilla(URL, force_rest=True, use_creds=False)
    print(bzapi.logged_in)
    
    Traceback (most recent call last):
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_session.py", line 108, in request
        response.raise_for_status()
      File "/usr/lib/python3/site-packages/requests/models.py", line 1021, in raise_for_status
        raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://bugzilla.stage.redhat.com/rest/user?ids=1
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/src/test.py", line 6, in <module>
        print(bzapi.logged_in)
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/base.py", line 720, in logged_in
        raise e
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/base.py", line 714, in logged_in
        self._backend.user_get({"ids": [1]})
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_backendrest.py", line 182, in user_get
        return self._get("/user", paramdict)
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_backendrest.py", line 63, in _get
        return self._op("GET", *args, **kwargs)
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_backendrest.py", line 58, in _op
        response = self._bugzillasession.request(method, fullurl, data=data,
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_session.py", line 112, in request
        raise type(e)(message).with_traceback(sys.exc_info()[2])
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_session.py", line 108, in request
        response.raise_for_status()
      File "/usr/lib/python3/site-packages/requests/models.py", line 1021, in raise_for_status
        raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://bugzilla.stage.redhat.com/rest/user?ids=1
    

    The problem is that logged_in expects BugzillaError or any other exception having code or faultCode attribute.

    Bugzilla codes are mapped to HTTP status codes: https://github.com/bugzilla/bugzilla/blob/7581e08f9136ec32219af6c3192e42ff1c8e9691/Bugzilla/WebService/Constants.pm#L262-L287

    But this project don't handle such codes on HTTP errors.

    opened by stanislavlevin 0
  • include_fields in bz.getbug with string-named bug instead of id results in IndexError

    include_fields in bz.getbug with string-named bug instead of id results in IndexError

    bz = bugzilla.Bugzilla(url="bugzilla.redhat.com", api_key="key", force_rest=True)
    
    bz.getbug(2135298) # works
    bz.getbug(2135298, include_fields=["id"]) # works
    
    bz.getbug("F37FinalBlocker") # works
    bz.getbug("F37FinalBlocker", include_fields=["id"]) # broken:
    
    ---------------------------------------------------------------------------
    IndexError                                Traceback (most recent call last)
    Input In [9], in <cell line: 0>()
    ----> 1 bz.getbug("F37FinalBlocker", include_fields=["id"])
    
    File /usr/lib/python3.11/site-packages/bugzilla/base.py:1129, in Bugzilla.getbug(self, objid, include_fields, exclude_fields, extra_fields)
       1123 def getbug(self, objid,
       1124            include_fields=None, exclude_fields=None, extra_fields=None):
       1125     """
       1126     Return a Bug object with the full complement of bug data
       1127     already loaded.
       1128     """
    -> 1129     data = self._getbug(objid,
       1130         include_fields=include_fields, exclude_fields=exclude_fields,
       1131         extra_fields=extra_fields)
       1132     return Bug(self, dict=data, autorefresh=self.bug_autorefresh)
    
    File /usr/lib/python3.11/site-packages/bugzilla/base.py:1121, in Bugzilla._getbug(self, objid, **kwargs)
       1112 def _getbug(self, objid, **kwargs):
       1113     """
       1114     Thin wrapper around _getbugs to handle the slight argument tweaks
       1115     for fetching a single bug. The main bit is permissive=False, which
       (...)
       1119     This logic is called from Bug() too
       1120     """
    -> 1121     return self._getbugs([objid], permissive=False, **kwargs)[0]
    
    IndexError: list index out of range
    
    opened by frantisekz 2
Releases(v3.2.0)
Owner
Python Bugzilla Project
Python Bugzilla Project
Projeto Reverse Shell For Python

Use com sabedoria!!! Modo de uso: Linux (inclui Android e Mac): - apt-get update - apt install python3 (ou "python" apenas) - git clone https://github

1 Jan 03, 2022
An awesome Python wrapper for an awesome Docker CLI!

An awesome Python wrapper for an awesome Docker CLI!

Gabriel de Marmiesse 303 Jan 03, 2023
ctree - command line christmas tree

ctree ctree - command line christmas tree It is small python script that prints a christmas tree in terminal. It is colourful and always gives you a d

15 Aug 15, 2022
Tools crack instagram + fb ayok dicoba keburu premium 😁

FITUR INSTALLASI [1] pkg update && pkg upgrade [2] pkg install git [3] pkg install python [4] pkg install python2 [5] pkg install nano [6]

Jeeck 1 Dec 11, 2021
command line tool for frequent nmigen tasks (generate sources, show design)

nmigen-tool command line tool for frequent nmigen tasks (generate sources, show design) Usage: generate verilog: nmigen generate verilog nmigen_librar

Hans Baier 8 Nov 27, 2022
Salesforce object access auditor

Salesforce object access auditor Released as open source by NCC Group Plc - https://www.nccgroup.com/ Developed by Jerome Smith @exploresecurity (with

NCC Group Plc 90 Sep 19, 2022
Simple subcommand CLIs with argparse

multicommand Simple subcommand CLIs with argparse. multicommand uses only the standard library and is ~150 lines of code (modulo comments and whitespa

Andrew Ross 10 Aug 01, 2022
Tstock - Check stocks from the terminal

tstock - Check stocks from the terminal! 📈 tstock is a tool to easily generate stock charts from the command line. Just type tstock aapl to get a 3 m

Gabe Banks 502 Dec 30, 2022
A CLI tool that scans through a directory and organizes all loose files into folders by file type.

Organizer CLI Organizer CLI is a python command line tool that goes through a given directory and organizes all un-folder bound files into folders by

Mulaza Jacinto 6 Dec 14, 2022
A terminal slots programme in PY

PYSlots PyPI and Test PyPI External Links PyPI Test PyPI Install Look directly at the bugs! Version pip install pyslots "Don't look directly at the bu

Luke Batema 4 Nov 30, 2022
CLI to show end-of-life dates for tools and technologies.

Python 3.9+ interface to endoflife.date to show end-of-life dates for tools and technologies.

Hugo van Kemenade 32 Jan 06, 2023
CLI for SQLite Databases with auto-completion and syntax highlighting

litecli Docs A command-line client for SQLite databases that has auto-completion and syntax highlighting. Installation If you already know how to inst

dbcli 1.8k Dec 31, 2022
An open source terminal project made in python

Calamity-Terminal An open source terminal project made in python. Calamity Terminal is a free and open source lightweight terminal. Its made 100% off

1 Mar 08, 2022
xonsh is a Python-powered, cross-platform, Unix-gazing shell

xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt.

xonsh 6.7k Dec 31, 2022
Logic-Sim - A clone of 'Digital Logic Sim' from Sebastian Lague

Logic Simulator This is a clone of 'Digital Logic Sim' from Sebastian Lague. But

Ethan 1 Feb 01, 2022
Doro is a CLI based pomodoro app and countdown timer application built using python.

Doro - CLI based pomodoro app Doro is a CLI based pomodoro app and countdown timer application built using python. Install $ pip install doro Usage Po

Suresh Kumar 14 May 23, 2022
Ipylivebash - Run shell script in Jupyter with live output

ipylivebash ipylivebash is a library to run shell script in Jupyter with live ou

Ben Lau 6 Aug 27, 2022
🖥️ A cross-platform modern shell.

Ergonomica WARNING: master on this repository is not the same as a stable release! Currently, this software is purely experimental, as I am cleaning i

813 Dec 27, 2022
A simple and easy-to-use CLI parse tool.

A simple and easy-to-use CLI parse tool.

AbsentM 1 Mar 04, 2022
A Hikari command handler for people who love ducks.

A Hikari command handler for people who love ducks.

Jeremiah 2 Oct 09, 2022