summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Tropf <asym@gentoo.org>2009-10-31 13:19:44 +0100
committerBjoern Tropf <asym@gentoo.org>2009-10-31 13:19:44 +0100
commitc10e112fc6bb760e9fcc0f8835c8639291cba93d (patch)
treef1be5621c80dbd897c906b532e4e0d3ef96a924e
parentLarge restructuration (diff)
downloadkernel-check-c10e112fc6bb760e9fcc0f8835c8639291cba93d.tar.gz
kernel-check-c10e112fc6bb760e9fcc0f8835c8639291cba93d.tar.bz2
kernel-check-c10e112fc6bb760e9fcc0f8835c8639291cba93d.zip
Cleanup #1
-rwxr-xr-xkernel-check.py5
-rw-r--r--[-rwxr-xr-x]lib/guidexml.py0
-rw-r--r--[-rwxr-xr-x]lib/kernellib.py30
-rwxr-xr-xtools/cron.py39
4 files changed, 24 insertions, 50 deletions
diff --git a/kernel-check.py b/kernel-check.py
index a6d6051..ffa8a53 100755
--- a/kernel-check.py
+++ b/kernel-check.py
@@ -61,10 +61,7 @@ def main(argv):
(kernel.version, kernel.revision))))
info('Kernel source : %s' % color('GOOD', kernel.source))
-
- genpatches = lib.parse_genpatch_list(lib.PORTDIR)
-
- kernel.genpatch = lib.get_genpatch(genpatches, kernel)
+ kernel.genpatch = lib.get_genpatch(lib.PORTDIR, kernel)
if kernel.genpatch is not None:
info('Gen(too)patch : %s' % color('GOOD', '%s %s' %
diff --git a/lib/guidexml.py b/lib/guidexml.py
index d6babb8..d6babb8 100755..100644
--- a/lib/guidexml.py
+++ b/lib/guidexml.py
diff --git a/lib/kernellib.py b/lib/kernellib.py
index d320c20..0bc4044 100755..100644
--- a/lib/kernellib.py
+++ b/lib/kernellib.py
@@ -23,9 +23,6 @@ ARCHES = [
'x86-fbsd'
]
-BUGORDER = ['bugid', 'reporter', 'reported', 'status', 'arch', 'affected']
-CVEORDER = ['cve', 'published', 'desc', 'severity', 'vector', 'score', 'refs']
-
REGEX = {
'gp_version' : re.compile(r'(?<=K_GENPATCHES_VER\=\").+(?=\")'),
'gp_want' : re.compile(r'(?<=K_WANT_GENPATCHES\=\").+(?=\")'),
@@ -51,17 +48,7 @@ KERNEL_TYPES = [
]
VERSION = '0.3.9'
-NOCVE = 'GENERIC-MAP-NOMATCH'
-NOCVEDESC = 'This GENERIC identifier is not specific to any vulnerability. '\
- 'GENERIC-MAP-NOMATCH is used by products, databases, and ' \
- 'services to specify when a particular vulnerability element ' \
- 'does not map to a corresponding CVE entry.'
-CVES = dict()
DEBUG = False
-VERBOSE = False
-FORCE = False
-SKIP = False
-DELAY = 0
FILEPATH = os.path.dirname(os.path.realpath(__file__))
PORTDIR = portage.settings['PORTDIR']
DIR = {
@@ -353,8 +340,8 @@ def is_in_interval(interval, kernel, bugid=None):
return True
-#TODO Add inline get_genpatch
-def parse_genpatch_list(directory):
+
+def get_genpatch(directory, kernel):
'Returns a list containing all genpatches from portage'
patches = list()
@@ -367,17 +354,8 @@ def parse_genpatch_list(directory):
genpatch = extract_genpatch(ebuild, directory, sources)
if genpatch is not None:
- patches.append(genpatch)
-
- return patches
-
-
-def get_genpatch(patches, kernel):
- 'Returns the genpatch for a specific kernel'
-
- for item in patches:
- if item.kernel == kernel:
- return item
+ if genpatch.kernel == kernel:
+ return genpatch
return None
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]