1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# kernel-check.py -- Kernel security information
# Copyright (C) 2009 Bjoern Tropf <asymmail@googemail.com>
# Copyright (C) 2009 Robert Buchholz <rbu@gentoo.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import getopt
import os
import sys
import time
import kernellib as lib
def main(argv):
'Main function'
DELAY = 0
SKIP = False
folder = {
'bug' : os.path.join('tmp', 'bug'),
'tree' : '/usr/portage',
'nvd' : os.path.join('tmp', 'nvd'),
'temp' : 'tmp',
'out' : 'out'
}
try:
opts, args = getopt.getopt(argv, 'd:fh:st:v', ['delay=', 'force', 'help', 'skip', 'tree=', 'verbose'])
except getopt.GetoptError:
usage()
for opt, arg in opts:
if opt in ('-d', '--delay'):
try:
DELAY = int(arg)
except ValueError:
pass
elif opt in ('-f', '--force'):
lib.FORCE = True
elif opt in ('-h', '--help'):
usage()
elif opt in ('-s', '--skip'):
SKIP = True
elif opt in ('-t', '--tree'):
if os.access(os.path.dirname(arg) , os.W_OK) and os.path.isdir(arg):
env['tree'] = arg
elif opt in ('-v', '--verbose'):
lib.VERBOSE = True
for directory in folder:
if not os.path.isdir(folder[directory]):
os.makedirs(folder[directory])
#lib.parse_genpatches_list(folder['tree'])
print('Receiving the latest xml file from the nvd...')
lib.receive_nvd_recent(folder['nvd'])
if not SKIP:
print('Receiving earlier xml files from the nvd...')
lib.receive_nvd_all(folder['nvd'])
print('Creating the nvd dictionary...')
nvd_dict = lib.parse_nvd_dict(folder['nvd'])
print('Receiving the kernel bug list from bugzilla...')
lib.receive_bugzilla_list(folder['temp'])
print('Creating the xml files...')
buglist = lib.parse_bugzilla_list(os.path.join(folder['temp'], 'list.xml'))
for item in buglist:
lib.receive_bugzilla_bug(folder['bug'], item)
bug_dict = lib.parse_bugzilla_dict(folder['bug'], item)
lib.write_cve_file(folder['out'], item, bug_dict, nvd_dict)
time.sleep(DELAY)
def usage():
'Prints the usage screen'
print 'Usage: ' + sys.argv[0][:-3] + ' [OPTION]...'
print 'Kernel security information\r\n'
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 ' -t, --tree [dir] set the portage path'
print ' -s, --skip skip update of earlier xml files'
print ' -v, --verbose display debugging information'
print '\r\nVersion: 0.3'
print 'Copyright (C) 2009 Bjoern Tropf <asymmail@googemail.com>'
print 'Copyright (C) 2009 Robert Buchholz <rbu@gentoo.org>'
sys.exit()
if __name__ == '__main__':
main(sys.argv[1:])
|