summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Tropf <asymmail@googlemail.com>2009-06-13 15:41:48 +0200
committerBjoern Tropf <asymmail@googlemail.com>2009-06-13 15:41:48 +0200
commitcda726f630fe2f6c52b8e3627bc3161b4d98673b (patch)
tree1fa4e92a9c1fde283c68a62a5c7ee7c9e65c69e0
parentFix several TODOs (diff)
downloadkernel-check-cda726f630fe2f6c52b8e3627bc3161b4d98673b.tar.gz
kernel-check-cda726f630fe2f6c52b8e3627bc3161b4d98673b.tar.bz2
kernel-check-cda726f630fe2f6c52b8e3627bc3161b4d98673b.zip
Implement read_cve_file()
-rw-r--r--TODO1
-rwxr-xr-xcollector.py3
-rwxr-xr-xkernellib.py56
3 files changed, 28 insertions, 32 deletions
diff --git a/TODO b/TODO
index 44648c9..7238aaa 100644
--- a/TODO
+++ b/TODO
@@ -5,6 +5,7 @@ Todo
- Rename functions
- Rework interval class and from_whiteboard()
- Implement from_xml in interval_class
+- Rework cves.refs
Clean code
==========
diff --git a/collector.py b/collector.py
index 4fc76ec..0a419c5 100755
--- a/collector.py
+++ b/collector.py
@@ -37,7 +37,8 @@ def main(argv):
'out' : 'out'
}
- #lib.read_cve_file(folder['out'], '158783')
+ #abc = lib.read_cve_file(folder['out'], '158783')
+ #print type(abc.cves[0].cve)
#return
try:
diff --git a/kernellib.py b/kernellib.py
index 0cb7c47..7ab29a4 100755
--- a/kernellib.py
+++ b/kernellib.py
@@ -29,7 +29,7 @@ import re
import urllib
BUGORDER = ['bugid', 'reporter', 'reported', 'arch', 'affected']
-CVEORDER = ['published', 'desc', 'severity', 'vector', 'score', 'refs']
+CVEORDER = ['cve', 'published', 'desc', 'severity', 'vector', 'score', 'refs']
REGEX = {
'bugzilla' : re.compile(r'(?<=bug.cgi\?id=)\d*'),
@@ -463,36 +463,30 @@ def read_cve_file(directory, bugid):
memory_map = mmap.mmap(xml_data.fileno(), 0)
root = et.parse(memory_map).getroot()
- for tree in root:
- if tree.tag == 'bug':
- for item in tree:
- if item.tag == 'bugid':
- bugid = item.text
- elif item.tag == 'reporter':
- reporter = item.text
- elif item.tag == 'reported':
- reported = item.text
- elif item.tag == 'arch':
- arch = item.text
-
- """
- print item.tag
- print item.text
- for item in tree:
- print item
-
- cve = Cve()
- bugid
-
- self.cvelist = cvelist
- self.bugid = bugid
- self.reporter = reporter
- self.reported = reported
- self.arch = arch
- self.interval = interval
- self.cves = cves
- """
- return
+ bug = root.find('bug')
+
+ vul = Vulnerability(bug.find('bugid').text)
+ vul.arch = bug.find('arch').text
+ #vul.interval = from_xml()
+ vul.reported = bug.find('reported').text
+ vul.reporter = bug.find('reporter').text
+
+ cves = list()
+
+ for item in root:
+ if item.tag == 'cve':
+ cve = Cve(item.find('cve').text)
+ cve.desc = item.find('desc').text
+ cve.published = item.find('published').text
+ cve.refs = item.find('refs').text #FIXME
+ cve.severity = item.find('severity').text
+ cve.score = item.find('score').text
+ cve.severity = item.find('vector').text
+
+ cves.append(cve)
+ vul.cves = cves
+
+ return vul
def write_cve_file(directory, vul):