Beispiel #1
0
 def __init__(self, config):
     self.api_url = config["bugzilla"]["url"]
     self.bz_url = bz_url_from_api_url(self.api_url)
     self.bugzilla = bugsy.Bugsy(bugzilla_url=self.api_url,
                                 api_key=config["bugzilla"]["apikey"])
     if "flags" not in self.bugzilla.DEFAULT_SEARCH:
         self.bugzilla.DEFAULT_SEARCH += ["flags"]
def _intermittent_bugs(seven_days_ago, today):
    bugzilla = bugsy.Bugsy()
    return bugzilla.search_for\
                   .keywords("intermittent-failure")\
                   .change_history_fields(['bug_status'], 'Resolved')\
                   .timeframe(seven_days_ago, today)\
                   .search()
def checkin_needed_count():
    bugzilla = bugsy.Bugsy()
    bugs = bugzilla.search_for\
                   .keywords("checkin-needed")\
                   .search()

    return len(bugs)
Beispiel #4
0
def loginToBugzilla(useSystem, username, apikey):
    bugzillaUrl = DEFAULTS[useSystem]["bugzillaRest"]

    print "Logging into bugzilla %s..." % bugzillaUrl

    bugzilla = bugsy.Bugsy(username=username,
                           api_key=apikey,
                           bugzilla_url=bugzillaUrl)

    print "Done..."

    return bugzilla
def intermittent_count_closed_last_week():
    tday = datetime.date.today()
    tday_minus_7 = tday - datetime.timedelta(days=7)
    today = '%s-%s-%s' %(tday.year, tday.month if tday.month >= 10 else '0%s' % tday.month, tday.day)
    seven_days_ago = '%s-%s-%s' %(tday_minus_7.year, tday_minus_7.month if tday_minus_7.month >= 10 else '0%s' % tday_minus_7.month, tday_minus_7.day)
    bugzilla = bugsy.Bugsy()
    bugs = bugzilla.search_for\
                   .keywords("intermittent-failure")\
                   .change_history_fields(['bug_status'], 'Resolved')\
                   .timeframe(seven_days_ago, today)\
                   .search()

    return len(bugs)
def intermittent_opened_count_last_week():
    tday = datetime.date.today()
    tday_minus_7 = tday - datetime.timedelta(days=7)
    today = '%s-%s-%s' % (tday.year, tday.month if tday.month >= 10 else
                          '0%s' % tday.month, tday.day)
    seven_days_ago = '%s-%s-%s' % (tday_minus_7.year, tday_minus_7.month
                                   if tday_minus_7.month >= 10 else '0%s' %
                                   tday_minus_7.month, tday_minus_7.day)
    bugzilla = bugsy.Bugsy()
    bugs = bugzilla.search_for\
                   .keywords("intermittent-failure")\
                   .change_history_fields(['[Bug creation]'])\
                   .timeframe(seven_days_ago, today)\
                   .search()

    for bug in bugs:
        if bug.product == 'Thunderbird':
            bugs.remove(bug)
    return len(bugs)
    def __init__(self, base_url, username, password):
        base_url = base_url.rstrip('/')

        self.base_url = base_url
        self.username = username
        self.password = password

        self.xmlrpc_url = base_url + '/xmlrpc.cgi'
        rest_url = base_url + '/rest'

        transport, proxy = create_xmlrpc_proxy(self.xmlrpc_url, username,
                                               password)
        self.proxy = proxy

        userid, cookie = transport.bugzilla_cookies()
        assert userid
        assert cookie

        client = bugsy.Bugsy(username=username, userid=userid, cookie=cookie,
                             bugzilla_url=rest_url)

        self.client = client
Beispiel #8
0
def main(arguments):
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--config-file', required=True)
    parser.add_argument(
        '-u',
        '--users-file',
        help=
        "You can specify users mapping, by default it will split email and use first part of it\"[email protected] = user123\""
    )
    parser.add_argument(
        '-s',
        '--status-file',
        help="You can specify status mapping. \"new_status=old_status\"")
    args = parser.parse_args(arguments)

    settings = configparser.ConfigParser()
    settings.read(args.config_file)
    has_user_mapping = (args.users_file if args.users_file else None)
    has_status_mapping = (args.status_file if args.status_file else None)

    if has_user_mapping:
        print("Will be using user mapping file %s" % args.users_file)
    if has_status_mapping:
        print("Will be using status mapping file %s" % args.status_file)

    # Connect to Bugzilla
    bz_url = settings.get('bugzilla', 'url')
    bz_user = settings.get('bugzilla', 'user')
    bz_pass = settings.get('bugzilla', 'pass')

    # Jira settings
    jira_key = settings.get('jira', 'key')
    jira_default_type = settings.get('jira', 'def_type')
    jira_default_status = settings.get('jira', 'def_status')
    jira_default_user = settings.get('jira', 'def_user')

    # CSV settings
    csv_filename = settings.get('csv', 'filename')
    csv_time_format = settings.get('csv', 'format')
    csv_max_comment = settings.get('csv', 'max_comment')
    csv_max_attachment = settings.get('csv', 'max_attachment')
    csv_advanced_attachment = settings.get('csv', 'advanced_attachment')

    # Check if csv export file does not exists
    if os.path.isfile(csv_filename):
        os.remove(csv_filename)

    bzapi = bugsy.Bugsy(username=str(bz_user),
                        password=str(bz_pass),
                        bugzilla_url=str(bz_url + "/rest"))

    titles = [
        "Issue Id", "Category", "Summary", "Description", "Date Created",
        "Date Modified", "Priority", "Issue type", "Status", "Resolution",
        "Reporter", "Assignee", "OS", "Label"
    ]
    max_attachments = max_comments = 0
    # Obtain Bugzilla bug from gotten products
    extra_search = [
        "creation_time", "last_change_time", "creator", "assigned_to",
        "priority"
    ]
    bugs = bzapi.search_for.include_fields(extra_search).search()
    print("Got total of %s issues" % len(bugs))

    print("Pre-fill titles of Comments and Attachments to csv")
    print("Adding %s comments and %s attachments" %
          (csv_max_comment, csv_max_attachment))
    titles = append_array(titles, "Comments", int(csv_max_comment))
    titles = append_array(titles, "Attachment", int(csv_max_attachment))
    with open(csv_filename, 'a', encoding='utf-8') as csvFile:
        writer = csv.writer(csvFile,
                            delimiter=",",
                            quotechar='\"',
                            quoting=csv.QUOTE_ALL)
        writer.writerow(titles)

    for bug in bugs:
        # bug is object of Bugs more info: https://bugsy.readthedocs.io/en/latest/bug.html#bugsy.Bug.id
        _raw = bug.to_dict()
        row = [
            "%s-%s" % (str(jira_key).upper(), bug.id), bug.product,
            bug.summary, bug.summary,
            str(
                datetime.strptime(
                    _raw.get('creation_time')[:-1],
                    '%Y-%m-%dT%H:%M:%S').strftime(csv_time_format)),
            str(
                datetime.strptime(
                    _raw.get('last_change_time')[:-1],
                    '%Y-%m-%dT%H:%M:%S').strftime(csv_time_format)),
            _raw.get('priority'), jira_default_type,
            map_status(bug.status,
                       mapping_file=has_status_mapping,
                       default=str(jira_default_status)), bug.resolution,
            map_users(_raw.get('creator'),
                      mapping_file=has_user_mapping,
                      default=jira_default_user),
            map_users(_raw.get('assigned_to'),
                      mapping_file=has_user_mapping,
                      default=jira_default_user), bug.OS, bug.component
        ]

        comments = bug.get_comments()
        if len(comments) > max_comments:
            max_comments = len(comments)

        # there is specific way jira handle comments
        for comment in comments:
            time = str(comment.creation_time.strftime(csv_time_format))
            row.append("%s;%s; %s" %
                       (time,
                        map_users(comment.creator,
                                  mapping_file=has_user_mapping,
                                  default=jira_default_user), comment.text))

        # Jira require you to fill other comment columns empty
        row = append_array(row, "", int(csv_max_comment) - len(comments))

        # Bugsy just added attachment support, but there wasn't enough documentation, so I use raw data
        attachments = bug.get_attachments()
        if len(attachments) > max_attachments:
            max_attachments = len(attachments)

        # there is specific way jira handle attachments
        for attach in attachments:
            attach = attach.to_dict()
            url = "%s/attachment.cgi?id=%s" % (bz_url, attach.get('id'))
            if bool(csv_advanced_attachment):
                time = str(
                    attach.get('creation_time').strftime(csv_time_format))
                row.append("%s;%s;%s;%s" %
                           (time,
                            map_users(attach.get('creator'),
                                      mapping_file=has_user_mapping,
                                      default=jira_default_user),
                            attach.get('file_name'), url))
            else:
                row.append(url)

        # jira require to pre-fill empty columns
        row = append_array(row, "", int(csv_max_attachment) - len(attachments))

        print("Writing bug #%s to csv" % bug.id)
        with open(csv_filename, 'a', encoding='utf-8') as csvFile:
            writer = csv.writer(csvFile,
                                delimiter=",",
                                quotechar='\"',
                                quoting=csv.QUOTE_ALL)
            writer.writerow(row)

    print("Got max comments: %s" % max_comments)
    print("Got max attachments: %s" % max_attachments)
Beispiel #9
0
import bugsy
bz = bugsy.Bugsy("username", "password",
                 "https://bugzilla-dev.allizom.org/rest")

# Create a new bug with a comment 0 set.
bug = bugsy.Bug()
bug.summary = "I love cheese"
bug.add_comment('I do love sausages too')
bz.put(bug)

# Add another comment to that bug.
bug.add_comment('I do love eggs too')

# Add a comment to an existing bug for whom we don't
# have a bug object (and don't wish to fetch it).
bug = bz.get(123456)
bug.add_comment("I love cheese")
2) Use the above given commandline to test out on local machine.
   Yes, --dry-run is there for testing the above cli output generated.

3) Remove the --dry-run parameter and actually trigger intermittents via trigger.py script.
"""
import logging
import os

from argparse import ArgumentParser

import bugsy

from mozci.mozci import query_repo_name_from_buildername
from mozci.utils.misc import setup_logging

bugzilla = bugsy.Bugsy()
LOG = setup_logging()


def main():
    global LOG

    options = parse_args()
    bugs = []
    assert options.bug_no or options.test_name, \
        "Either call this with --bug-no or with --test-name"

    if options.debug:
        LOG = setup_logging(logging.DEBUG)

    if options.bug_no:
import bugsy

bugzilla = bugsy.Bugsy(username="******", api_key="c3pW7PACOXcRA7MCUAVAvAldwbszSoD3LjFUbrji",
bugzilla_url="https://bugzilla.mozilla.org/rest", password="******")
bug = bugzilla.get(1572368)
print (bug.summary)
print (type(bug))
#x = bug.to_dict
print (bug.status, bug.product, bug.version,bug.to_dict()) # bug.depends_on.count)

Beispiel #12
0
import bugsy
bz = bugsy.Bugsy("someUser", "theirPassword",
                 "https://bugzilla-dev.allizom.org/rest")
bug = bugsy.Bug()
bug.summary = "I love cheese"
bug.add_comment('I do love sausages')
bz.put(bug)
Beispiel #13
0
#!/usr/bin/env python

import bugsy

bugzilla = bugsy.Bugsy(api_key='REDACTED')
bugs = bugzilla.search_for\
        .product('Foo')\
        .search()

for bug in bugs:
    print(str(bug.id) + " " + bug.summary)
Beispiel #14
0
#!/usr/bin/env python
import bugsy
import getpass
import json
from datetime import datetime, timedelta

api_key = getpass.getpass("Enter Bugzilla API Key: ")
bugzilla = bugsy.Bugsy(api_key=api_key)

today = str(datetime.today()).split(" ")[0]
month_ago = str(datetime.today() - timedelta(days=30)).split(" ")[0]
two_month_ago = str(datetime.today() - timedelta(days=60)).split(" ")[0]

# Get Vulnerability Assessment Metrics Data
va_bugs = bugzilla.search_for\
    .product('Enterprise Information Security')\
    .component('Vulnerability Assessment')\
    .search()

va_metrics = []

for bug in va_bugs:
    raw_whiteboard = bug._bug['whiteboard']

    if raw_whiteboard:
        whiteboard = dict(x.split('=') for x in raw_whiteboard.split(' '))
    else:
        whiteboard = ""

    va_metrics.append({
        'id': bug.id,
Beispiel #15
0
 def __init__(self, config):
     self.api_url = config["bugzilla"]["url"]
     self.bz_url = bz_url_from_api_url(self.api_url)
     self.bugzilla = bugsy.Bugsy(bugzilla_url=self.api_url,
                                 api_key=config["bugzilla"]["apikey"])
Beispiel #16
0
'''
Akond Rahman
Sep 27, 2017
to get bugzilla reports' text
and check for secuirty key words
'''
#import bugzilla
import numpy as np
import bugsy
import utility
bugzilla_obj = bugsy.Bugsy(api_key="mWYEjiA4nOsii23LqFSuhotZyXJic5hRmMc5bFdm")
bugzilla_file_name = 'moz.bug.ids.txt'
sec_kw_file_name   = 'sec.kws.txt'
not_exist_list = [10179904, 10131433, 1021152, 1021519, 1037104, 1041577, 1060410]

counter = 0
if __name__=='__main__':
   bugID2Dump  = []
   bugMSG2Dump = []
   #bug_obj = bugzilla.Bugzilla(url="https://bugzilla.mozilla.org/rest/", api_key="mWYEjiA4nOsii23LqFSuhotZyXJic5hRmMc5bFdm")
   #URL = "https://partner-bugzilla.redhat.com"
   #bug_obj = bugzilla.Bugzilla(URL, api_key="mWYEjiA4nOsii23LqFSuhotZyXJic5hRmMc5bFdm")

   with open(bugzilla_file_name) as f:
        content = f.readlines()
   with open(sec_kw_file_name) as f_:
        sec_kw_content = f_.readlines()
   sec_kw_content = [sec_kw.strip() for sec_kw in sec_kw_content]
   sec_kw_content = [sec_kw.lower() for sec_kw in sec_kw_content]
   bug_ids = [x.strip() for x in content]
   bug_ids = np.unique(bug_ids)