diff options
Diffstat (limited to 'pym/kernelcheck/lib/kernellib.py')
-rw-r--r-- | pym/kernelcheck/lib/kernellib.py | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/pym/kernelcheck/lib/kernellib.py b/pym/kernelcheck/lib/kernellib.py index 515511b..6aa3270 100644 --- a/pym/kernelcheck/lib/kernellib.py +++ b/pym/kernelcheck/lib/kernellib.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# kernel-check -- Kernel security information +# kernel-check -- Gentoo Kernel Security # Copyright 2009-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 @@ -24,6 +24,7 @@ ARCHES = [ ] REGEX = { + 'argument' : re.compile(r'(CVE-(\d{4})-(\d{4}))|(\d{5,7})'), 'gp_version' : re.compile(r'(?<=K_GENPATCHES_VER\=\").+(?=\")'), 'gp_want' : re.compile(r'(?<=K_WANT_GENPATCHES\=\").+(?=\")'), 'k_version' : re.compile(r'^((?:\d{1,2}\.){0,4}\d{1,2})(-.*)?$'), @@ -74,11 +75,30 @@ class Evaluation: arch = int() affected = list() unaffected = list() + avg_cvss = float() + low = int() + medium = int() + high = int() def __init__(self): self.affected = list() self.unaffected = list() + def __repr__(self): + severity = str() + if self.high is not 0: + severity += '%s high' % self.high + if self.medium is not 0: + if self.high is not 0: + severity += ', ' + severity += '%s medium' % self.medium + if self.low is not 0: + if self.high is not 0 or self.medium is not 0: + severity += ', ' + severity += '%s low' % self.low + + return severity + class Comparison: #TODO Check if deprecated """Comparison class @@ -418,6 +438,8 @@ def eval_cve_files(directory, kernel, arch, spin=None): if not files: return None + cve_amount = int() + cvss_score = int() evaluation = Evaluation() for item in files: @@ -435,9 +457,20 @@ def eval_cve_files(directory, kernel, arch, spin=None): if is_affected(item.affected, kernel, item): evaluation.affected.append(item) + for cve in item.cves: + if cve.severity == 'Low': + evaluation.low += 1 + if cve.severity == 'Medium': + evaluation.medium += 1 + if cve.severity == 'High': + evaluation.high += 1 + cve_amount += 1 + cvss_score += float(cve.score) else: evaluation.unaffected.append(item) + evaluation.avg_cvss = cvss_score / cve_amount + return evaluation #TODO Remove item @@ -614,3 +647,25 @@ def all_version(source): return versions +def gather_configuration(): + "" + + config = dict() + mmap_min_addr = str() + modules = str() + + try: + mmap_min_addr = open('/proc/sys/vm/mmap_min_addr').read().strip() + except: + mmap_min_addr = '?' + config['Mmap_min_addr'] = mmap_min_addr + + try: + for line in open('/proc/modules').readlines(): + modules += '%s ' % line.split(' ')[0] + except: + modules = '?' + config['Loaded modules'] = modules + + return config + |