summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBjoern Tropf <asym@gentoo.org>2009-11-14 12:16:25 +0100
committerBjoern Tropf <asym@gentoo.org>2009-11-14 12:16:25 +0100
commitf12b7f41c2dff37eebedf6027cf5aa33a5994258 (patch)
treef92e712abc6dd8f4ec7b14b33e90ba96f7bba425 /lib
parentFix some bugs (diff)
downloadkernel-check-f12b7f41c2dff37eebedf6027cf5aa33a5994258.tar.gz
kernel-check-f12b7f41c2dff37eebedf6027cf5aa33a5994258.tar.bz2
kernel-check-f12b7f41c2dff37eebedf6027cf5aa33a5994258.zip
Implement a NOCVE dictionary
Modify BUG_ON to support exception messages Fix small typo
Diffstat (limited to 'lib')
-rw-r--r--lib/kernellib.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/kernellib.py b/lib/kernellib.py
index bc979cd..6f91ce5 100644
--- a/lib/kernellib.py
+++ b/lib/kernellib.py
@@ -58,10 +58,10 @@ DIR = {
'nvd' : os.path.join(FILEPATH, 'tmp', 'nvd')
}
-def BUG_ON(msg):
+def BUG_ON(msg, e):
if DEBUG:
- print 'DEBUG line %s in %s(): %s' % (inspect.stack()[1][2],
- inspect.stack()[1][3], msg)
+ print 'DEBUG line %s in %s(): %s -> %s' % (inspect.stack()[1][2],
+ inspect.stack()[1][3], msg, e)
class Evaluation:
@@ -393,8 +393,8 @@ def parse_cve_files(directory):
if cve_file is not None:
files.append(cve_file)
- except AttributeError:
- pass
+ except AttributeError, e:
+ BUG_ON(item, e)
return files
@@ -519,7 +519,8 @@ def read_cve_file(directory, bugid):
with open(filename, 'r+') as xml_data:
memory_map = mmap.mmap(xml_data.fileno(), 0)
root = xml.etree.cElementTree.parse(memory_map).getroot()
- except IOError:
+ except IOError, e:
+ BUG_ON(filename, e)
return None
bugroot = root.find('bug')
@@ -539,10 +540,16 @@ def read_cve_file(directory, bugid):
for item in root:
if item.tag == 'cve':
cve = Cve(item.find('cve').text)
+ if cve is None:
+ return None
for elem in ['desc', 'published', 'refs',
'severity', 'score', 'vector']:
- setattr(cve, elem, item.find(elem).text)
+ element = item.find(elem)
+ if element is not None:
+ setattr(cve, elem, item.find(elem).text)
+ else:
+ BUG_ON(filename, '(%s, \'No such element\')' % elem)
cves.append(cve)
vul.cves = cves