diff options
Diffstat (limited to 'tools/cron.py')
-rwxr-xr-x | tools/cron.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/tools/cron.py b/tools/cron.py index 01e04af..196de31 100755 --- a/tools/cron.py +++ b/tools/cron.py @@ -117,19 +117,19 @@ def main(argv): receive_file(DIR['bug'], [BZURL, 'show_bug.cgi?ctype=xml&id='], item) - vul = parse_bugzilla_dict(DIR['bug'], item) + vul = parse_bz_dict(DIR['bug'], item) for cve in vul['cvelist']: if cve == NOCVE: vul['cves'] = [NOCVE] - break; #TODO + break #TODO Raise exception instead of break else: try: vul['cves'].append(nvd_dict[cve]) except KeyError: raise CronError('No Nvd entry: ' + cve) - write_cve_file(DIR['out'], vul) + write_xml_file(DIR['out'], vul) created_files += 1 time.sleep(DELAY) @@ -201,13 +201,12 @@ def parse_nvd_dict(directory): bugref.text = 'Gentoo %s' % cve['cve'] cve['refs'] = reftree - nvd[cve['cve']] = cve return nvd -def parse_bugzilla_dict(directory, bugid): - 'Returns a vulnerability class containing information about a bug' +def parse_bz_dict(directory, bugid): + 'Returns a list containing information about a bug' filename = os.path.join(directory, bugid) @@ -258,11 +257,11 @@ def parse_bugzilla_dict(directory, bugid): pass try: - wb = root.find('status_whiteboard').text; - vul['affected'] = interval_from_whiteboard(wb) + whiteboard = root.find('status_whiteboard').text; + vul['affected'] = interval_from_wb(whiteboard) if vul['affected'] == None: - raise CronError('Invalid whiteboard: ' + wb) + raise CronError('Invalid whiteboard: ' + whiteboard) except AttributeError: raise CronError('Empty whiteboard') @@ -270,7 +269,7 @@ def parse_bugzilla_dict(directory, bugid): return vul -def interval_from_whiteboard(whiteboard): +def interval_from_wb(whiteboard): 'Returns a list of intervals within a whiteboard string' upper_inc = None @@ -334,7 +333,7 @@ def interval_from_whiteboard(whiteboard): return affected -def write_cve_file(directory, vul): +def write_xml_file(directory, vul): 'Write a bug file containing all important information for kernel-check' filename = os.path.join(directory, vul['bugid'] + '.xml') @@ -346,17 +345,17 @@ def write_cve_file(directory, vul): if element == 'affected': affectedroot = et.SubElement(bugroot, 'affected') for item in vul['affected']: - intnode = et.Element('interval') - intnode.set('source', item['name']) + intnode = et.Element('interval') + intnode.set('source', item['name']) - affectedroot.append(intnode) + affectedroot.append(intnode) - for i in ('lower', 'upper'): - if item[i]: - node = et.SubElement(intnode, i) - node.text = item[i] - node.set('inclusive', - str(item[i + '_inc']).lower()) + for interval in ('lower', 'upper'): + if item[interval]: + node = et.SubElement(intnode, interval) + node.text = item[i] + node.set('inclusive', + str(item[interval + '_inc']).lower()) else: node = et.SubElement(bugroot, element) node.text = vul[element] |