diff options
author | 2009-12-02 16:31:17 +0100 | |
---|---|---|
committer | 2009-12-02 16:31:17 +0100 | |
commit | 75ad863b111a0f1de113fe730036be4330e59ce0 (patch) | |
tree | 9302fcc58a444a047db5663fb595b58a03d0aad8 | |
parent | kernel-check 0.3.13 (diff) | |
download | kernel-check-75ad863b111a0f1de113fe730036be4330e59ce0.tar.gz kernel-check-75ad863b111a0f1de113fe730036be4330e59ce0.tar.bz2 kernel-check-75ad863b111a0f1de113fe730036be4330e59ce0.zip |
Fix several bugs
-rwxr-xr-x | pym/kernelcheck/kernelcheck.py | 31 | ||||
-rw-r--r-- | pym/kernelcheck/lib/kernellib.py | 14 |
2 files changed, 26 insertions, 19 deletions
diff --git a/pym/kernelcheck/kernelcheck.py b/pym/kernelcheck/kernelcheck.py index bf3d6ca..2487f02 100755 --- a/pym/kernelcheck/kernelcheck.py +++ b/pym/kernelcheck/kernelcheck.py @@ -4,7 +4,7 @@ # Distributed under the terms of the GNU General Public License v2 from portage.output import blue, bold, colorize, EOutput, darkgreen #FIXME -from _emerge.stdout_spinner import stdout_spinner +#from _emerge.stdout_spinner import stdout_spinner #TODO from _emerge.userquery import userquery import getopt @@ -67,7 +67,7 @@ def main(argv): return information['Kernel source'] = kernel.source - information['Kernel version'] = '%s%s' % (kernel.version, kernel.revision) + information['Kernel version'] = '%s-%s' % (kernel.version, kernel.revision) kernel.genpatch = lib.get_genpatch(lib.PORTDIR, kernel) @@ -87,9 +87,7 @@ def main(argv): return info(bold('Information:')) - for item in information.keys(): - print ' %s%s : %s' % (darkgreen(item), ' ' * (14 - len(item)), - information[item]) + print_items(information) min_addr = str() #TODO move to kernellib try: @@ -110,9 +108,7 @@ def main(argv): print '' info(bold('Configuration:')) - for item in configuration.keys(): - print ' %s%s : %s' % (darkgreen(item), ' ' * (14 - len(item)), - configuration[item]) + print_items(configuration) print '\nDetermining vulnerabilities... done!' #TODO #spin print '' @@ -172,6 +168,18 @@ def main(argv): else: print 'Not implemented yet ;)' +def print_items(category): + 'Indents and prints items' + + for item in category.keys(): + for i, string in enumerate(textwrap.wrap('%s' % category[item], + (term[1] - 23))): + if i is 0: + print ' %s%s : %s' % (darkgreen(item), + ' ' * (14 - len(item)), string) + else: + print '%s%s' % (' ' * 23, string) + def print_summary(vullist): 'Prints the vulnerability summary' @@ -194,9 +202,10 @@ def print_summary(vullist): cve_text = str() cve_area = str() - if 'AV:L' in cve.vector or 'AV:A' in cve.vector: + if 'AV:L' in cve.vector: cve_area += colorize('WARN', 'local') - else: + + if 'AV:A' in cve.vector or 'AV:N' in cve.vector: cve_area += colorize('BAD', 'network') if 'C:P' in cve.vector or 'C:C' in cve.vector: @@ -211,7 +220,7 @@ def print_summary(vullist): if ('C:P' in cve.vector or 'C:C' in cve.vector) \ and ('I:P' in cve.vector or 'I:C' in cve.vector) \ and ('A:P' in cve.vector or 'A:C' in cve.vector): - cve_text = ' -security' #TODO find a better way + cve_text = ' -complete' first_text = textwrap.wrap(cve.desc, term[1] - 44)[0] print '[%s %26s] %s CVSS="%s %s%s"' % (darkgreen('bugid'), diff --git a/pym/kernelcheck/lib/kernellib.py b/pym/kernelcheck/lib/kernellib.py index f733b73..b1ed7fb 100644 --- a/pym/kernelcheck/lib/kernellib.py +++ b/pym/kernelcheck/lib/kernellib.py @@ -60,7 +60,7 @@ DIR = { def BUG_ON(msg, e): if DEBUG: - print 'DEBUG line %s in %s(): %s -> %s' % (inspect.stack()[1][2], + print '[DEBUG] line %s in %s(): %s -> %s' % (inspect.stack()[1][2], inspect.stack()[1][3], msg, e) @@ -310,7 +310,7 @@ def is_in_interval(interval, kernel, bugid=None): return False else: - BUG_ON(interval.name + ' ' + bugid.bugid) + BUG_ON(interval.name, bugid.bugid) return False for item in ['lower', 'upper']: @@ -319,7 +319,7 @@ def is_in_interval(interval, kernel, bugid=None): if result == None: BUG_ON('Could not compare %s and %s' % - (getattr(interval, item),version)) + (getattr(interval, item),version), bugid) if result == 0 and not getattr(interval, item + '_i'): return False @@ -426,8 +426,7 @@ def eval_cve_files(directory, kernel, arch, spin=None): evaluation.read += 1 if item.arch not in ARCHES: - BUG_ON('[Error] Wrong architecture %s in bugid: %s' % - (item.arch, item.bugid)) + BUG_ON('[Error] Wrong architecture %s' % item.arch, item.bugid) if item.arch != arch and item.arch != 'all': evaluation.unaffected.append(item) @@ -495,7 +494,7 @@ def compare_evaluation(kernel, compare): comparison = Comparison() if kernel.read != compare.read or kernel.arch != compare.arch: - BUG_ON('Kernels do not match: %s %s' % (kernel1.read, kernel2.read)) + BUG_ON('Kernels do not match: %s' % kernel1.read, kernel2.read) return for item in kernel.affected: @@ -587,8 +586,7 @@ def extract_version(release): elif elem in KERNEL_TYPES: kernel.source = elem elif elem != '': - BUG_ON('[Error] Dropping unknown version component \'%s\', \ - probably local tag.' % elem) + BUG_ON('Dropping unknown version component', elem) return kernel |