diff options
Diffstat (limited to 'tools/cron.py')
-rwxr-xr-x | tools/cron.py | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/tools/cron.py b/tools/cron.py index ecea3de..2287922 100755 --- a/tools/cron.py +++ b/tools/cron.py @@ -37,7 +37,16 @@ CONST = { 'portdir' : portage.settings['PORTDIR'] } -NOCVE = { +PENDING = { + 'published' : '0000-00-00', + 'desc' : 'Pending', #TODO + 'severity' : 'Low', + 'vector' : '()', + 'score' : '0.0', + 'refs' : et.Element('refs') +} + +NOMATCH = { 'cve' : 'GENERIC-MAP-NOMATCH', 'published' : '0000-00-00', 'desc' : 'This GENERIC identifier is not specific to any ' \ @@ -53,8 +62,8 @@ NOCVE = { PARAM = { 'delay' : 0.2, - 'skip' : False, - 'logfile' : os.path.join(CONST['filepath'], 'cron.log'), + 'skip' : True, + 'logfile' : False, #os.path.join(CONST['filepath'], 'cron.log'), 'tmpdir' : os.path.join(CONST['filepath'], 'tmp'), 'bugdir' : os.path.join(CONST['filepath'], 'tmp', 'bug'), 'nvddir' : os.path.join(CONST['filepath'], 'tmp', 'nvd'), @@ -142,15 +151,17 @@ def main(argv): vul = parse_bz_dict(PARAM['bugdir'], item) for cve in vul['cvelist']: - if cve == NOCVE['cve']: - vul['cves'] = [NOCVE['cve']] + if cve == NOMATCH['cve']: + vul['cves'] = [NOMATCH['cve']] if len(vul['cvelist']) > 1: - raise CronError('\'Nocve\' and valid cve: ' + item) + logging.error('\'Nomatch\' and valid cve: ' + item) else: try: vul['cves'].append(nvd_dict[cve]) except KeyError: - raise CronError('No Nvd entry: ' + cve) + logging.error('No Nvd entry: ' + cve) + vul['cves'].append(cve) + vul['pending'] = True write_xml_file(PARAM['outdir'], vul) created_files += 1 @@ -255,7 +266,7 @@ def parse_bz_dict(directory, bugid): string = string.replace('CAN', 'CVE') if string in REGEX['m_nomatch'].findall(string): - cvelist = [NOCVE['cve']] + cvelist = [NOMATCH['cve']] for (year, split_cves) in REGEX['grp_all'].findall(string): for cve in REGEX['grp_split'].findall(split_cves): @@ -272,10 +283,11 @@ def parse_bz_dict(directory, bugid): 'reporter' : root.find('reporter').text.lower(), 'reported' : root.find('creation_ts').text, 'status' : root.find('bug_status').text.lower(), + 'pending' : False; } for item in vul['cvelist']: - if item != NOCVE['cve']: + if item != NOMATCH['cve']: if item not in CVES: CVES[item] = vul.bugid else: @@ -390,20 +402,33 @@ def write_xml_file(directory, vul): for cve in vul['cves']: cveroot = et.SubElement(root, 'cve') - if cve == NOCVE['cve']: + if cve == NOMATCH['cve']: for element in CONST['cveorder']: if element == 'refs': - cveroot.append(NOCVE[element]) + cveroot.append(NOMATCH[element]) else: node = et.SubElement(cveroot, element) - node.text = NOCVE[element] + node.text = NOMATCH[element] else: - for element in CONST['cveorder']: - if element == 'refs': - cveroot.append(cve[element]) - else: - node = et.SubElement(cveroot, element) - node.text = cve[element] + if vul['pending']: + for element in CONST['cveorder']: + if element == 'refs': + cveroot.append(PENDING[element]) + else: + if element == 'cve': + node = et.SubElement(cveroot, element) + node.text = cve + else: + node = et.SubElement(cveroot, element) + node.text = PENDING[element] + + else: + for element in CONST['cveorder']: + if element == 'refs': + cveroot.append(cve[element]) + else: + node = et.SubElement(cveroot, element) + node.text = cve[element] with open(filename, 'w') as xmlout: __indent__(root) |