summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'collector.py')
-rwxr-xr-xcollector.py123
1 files changed, 0 insertions, 123 deletions
diff --git a/collector.py b/collector.py
deleted file mode 100755
index 30f3272..0000000
--- a/collector.py
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/usr/bin/env python
-# kernel-check -- Kernel security information
-# Copyright 2009-2009 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-import getopt
-import os
-import sys
-import time
-
-import kernellib as lib
-
-
-def main(argv):
- 'Main function'
-
- try:
- opts, args = getopt.getopt(argv, 'd:fh:sv',
- ['delay=', 'force', 'help', 'skip', 'verbose'])
- except getopt.GetoptError:
- usage()
- return
-
- for opt, arg in opts:
- if opt in ('-d', '--delay'):
- if arg.isdigit():
- lib.DELAY = int(arg)
- elif opt in ('-f', '--force'):
- lib.FORCE = True
- elif opt in ('-h', '--help'):
- usage()
- return
- elif opt in ('-s', '--skip'):
- lib.SKIP = True
- elif opt in ('-v', '--verbose'):
- lib.VERBOSE = True
-
- for directory in lib.DIR:
- if not os.path.isdir(lib.DIR[directory]):
- os.makedirs(lib.DIR[directory])
-
- print 'Reading available genpatches...'
- try:
- read_patches = lib.read_genpatch_file(lib.DIR['out'])
- except IOError:
- read_patches = list()
-
- print 'Parsing genpatches from portage...'
- found_patches = lib.parse_genpatch_list(lib.PORTDIR)
-
- new_patches = 0
- for item in found_patches:
- if item not in read_patches:
- read_patches.append(item)
- new_patches += 1
-
- if (new_patches):
- lib.write_genpatch_file(lib.DIR['out'], read_patches)
- print 'Added %i new genpatches!' % new_patches
-
- print '\nReceiving the latest xml file from the nvd...'
- lib.receive_nvd_recent(lib.DIR['nvd'])
-
- if not lib.SKIP:
- print 'Receiving earlier xml files from the nvd...'
- lib.receive_nvd_all(lib.DIR['nvd'])
-
- print 'Creating the nvd dictionary...'
- nvd_dict = lib.parse_nvd_dict(lib.DIR['nvd'])
-
- print 'Receiving the kernel vulnerability list from bugzilla...'
- lib.receive_bugzilla_list(lib.DIR['tmp'])
-
- buglist = lib.parse_bugzilla_list(lib.DIR['tmp'])
- print 'Found %i kernel vulnerabilities!' % len(buglist)
-
- print '\nCreating the xml files...'
-
- created_files = 0
- for item in buglist:
- try:
- lib.receive_bugzilla_bug(lib.DIR['bug'], item)
- vul = lib.parse_bugzilla_dict(lib.DIR['bug'], item)
- vul = lib.search_nvd_dict(nvd_dict, vul)
- lib.write_cve_file(lib.DIR['out'], vul)
-
- created_files += 1
- time.sleep(lib.DELAY)
-
- except lib.InvalidWhiteboardError, e:
- print '\n[%s] Invalid whiteboard' % item
- print '%s' % e.value
-
- except lib.InvalidCveError, e:
- print '\n[%s] Invalid CVE' % item
- print '%s' % e.value
-
- except lib.NvdEntryError, e:
- print '\n[%s] No Nvd Entry' % item
- print '%s' % e.value
-
- except lib.CveDuplicateError, e:
- print '\n[%s] CVE Duplicate' % item
- print '%s' % e.value
-
- print '\nCreated %i xml files!' % created_files
-
-
-def usage():
- 'Prints the usage screen'
-
- print 'Usage: %s [OPTION]...' % sys.argv[0][:-3]
- print 'Kernel security information %s\r\n' % lib.VERSION
- print ' -d, --delay [ticks] add delay to xml file creation'
- print ' -f, --force force update of xml files'
- print ' -h, --help display help information'
- print ' -s, --skip skip update of prior nvd files'
- print ' -v, --verbose display additional information'
-
-
-if __name__ == '__main__':
- main(sys.argv[1:])
-