Lines 6-11
Link Here
|
6 |
import os,string,sys |
6 |
import os,string,sys |
7 |
sys.path.insert(0, "/usr/lib/gentoolkit/pym") |
7 |
sys.path.insert(0, "/usr/lib/gentoolkit/pym") |
8 |
from getopt import getopt,GetoptError |
8 |
from getopt import getopt,GetoptError |
|
|
9 |
sys.path.append("/usr/lib/portage/pym") |
10 |
from output import * |
9 |
|
11 |
|
10 |
__program__ = "glsa-check" |
12 |
__program__ = "glsa-check" |
11 |
__author__ = "Marius Mauch <genone@gentoo.org>" |
13 |
__author__ = "Marius Mauch <genone@gentoo.org>" |
Lines 13-18
Link Here
|
13 |
|
15 |
|
14 |
optionmap = [ |
16 |
optionmap = [ |
15 |
["-l", "--list", "list all unapplied GLSA"], |
17 |
["-l", "--list", "list all unapplied GLSA"], |
|
|
18 |
["-s", "--show", "show which GLSA might need to be applied"], |
16 |
["-d", "--dump", "--print", "show all information about the given GLSA"], |
19 |
["-d", "--dump", "--print", "show all information about the given GLSA"], |
17 |
["-t", "--test", "test if this system is affected by the given GLSA"], |
20 |
["-t", "--test", "test if this system is affected by the given GLSA"], |
18 |
["-p", "--pretend", "show the necessary commands to apply this GLSA"], |
21 |
["-p", "--pretend", "show the necessary commands to apply this GLSA"], |
Lines 34-41
Link Here
|
34 |
args = [] |
37 |
args = [] |
35 |
params = [] |
38 |
params = [] |
36 |
try: |
39 |
try: |
37 |
args, params = getopt(sys.argv[1:], "dplfchivt", \ |
40 |
args, params = getopt(sys.argv[1:], "dplfchivts", \ |
38 |
["dump", "print", "list", "pretend", "fix", "inject", "help", "info", "version", "test"]) |
41 |
["dump", "print", "list", "pretend", "fix", "inject", "help", "info", "version", "test", "show"]) |
39 |
args = [a for a,b in args] |
42 |
args = [a for a,b in args] |
40 |
|
43 |
|
41 |
# sanity checking |
44 |
# sanity checking |
Lines 65-70
Link Here
|
65 |
mode = "help" |
68 |
mode = "help" |
66 |
elif len(params) <= 0 and mode == "list": |
69 |
elif len(params) <= 0 and mode == "list": |
67 |
params.append("new") |
70 |
params.append("new") |
|
|
71 |
elif len(params) <= 0 and mode == "show": |
72 |
params.append("new") |
68 |
|
73 |
|
69 |
# show help message |
74 |
# show help message |
70 |
if mode == "help": |
75 |
if mode == "help": |
Lines 76-82
Link Here
|
76 |
for o in m[2:-1]: |
81 |
for o in m[2:-1]: |
77 |
print "\t" + o |
82 |
print "\t" + o |
78 |
print |
83 |
print |
79 |
print "glsa-list can contain an arbitrary number of GLSA ids, " |
84 |
print "<option> can be any SINGLE one from the list above, " |
|
|
85 |
print "[glsa-list] can contain an arbitrary number of GLSA ids, " |
80 |
print "filenames containing GLSAs or the special identifiers " |
86 |
print "filenames containing GLSAs or the special identifiers " |
81 |
print "'all' and 'new'" |
87 |
print "'all' and 'new'" |
82 |
print |
88 |
print |
Lines 123-131
Link Here
|
123 |
|
129 |
|
124 |
# list short information for given or new GLSA |
130 |
# list short information for given or new GLSA |
125 |
if mode == "list": |
131 |
if mode == "list": |
126 |
print "[A] means this GLSA was already applied," |
132 |
print "[OK] means this GLSA was already applied," |
127 |
print "[U] means the system is not affected and" |
133 |
print "[NA] means the system is not affected and" |
128 |
print "[N] indicates that the system might be affected." |
134 |
print "[!!] indicates that the system might be affected." |
129 |
print |
135 |
print |
130 |
for myid in glsalist: |
136 |
for myid in glsalist: |
131 |
try: |
137 |
try: |
Lines 134-144
Link Here
|
134 |
#print "invalid GLSA: %s (error message was: %s)" % (myid, e) |
140 |
#print "invalid GLSA: %s (error message was: %s)" % (myid, e) |
135 |
continue |
141 |
continue |
136 |
if myglsa.isApplied(): |
142 |
if myglsa.isApplied(): |
137 |
status = "[A]" |
143 |
status = "[%s]" % (darkgreen("OK")) |
138 |
elif myglsa.isVulnerable(): |
144 |
elif myglsa.isVulnerable(): |
139 |
status = "[N]" |
145 |
status = "[%s]" % (red("!!")) |
140 |
else: |
146 |
else: |
141 |
status = "[U]" |
147 |
status = "[%s]" % (green("NA")) |
142 |
print myglsa.nr, status, myglsa.title, "(", |
148 |
print myglsa.nr, status, myglsa.title, "(", |
143 |
for pkg in myglsa.packages.keys()[:3]: |
149 |
for pkg in myglsa.packages.keys()[:3]: |
144 |
print pkg, |
150 |
print pkg, |
Lines 146-151
Link Here
|
146 |
print "...", |
152 |
print "...", |
147 |
print ")" |
153 |
print ")" |
148 |
sys.exit(0) |
154 |
sys.exit(0) |
|
|
155 |
# show only dangerous packages |
156 |
if mode == "show": |
157 |
for myid in glsalist: |
158 |
try: |
159 |
myglsa = Glsa(myid, glsaconfig) |
160 |
except GlsaTypeException, e: |
161 |
#print "invalid GLSA: %s (error message was: %s)" % (myid, e) |
162 |
continue |
163 |
if ((not myglsa.isApplied()) and myglsa.isVulnerable()): |
164 |
status = "[%s]" % (red("!!")) |
165 |
print myglsa.nr, status, myglsa.title, "(", |
166 |
for pkg in myglsa.packages.keys()[:3]: |
167 |
print pkg, |
168 |
if len(myglsa.packages) > 3: |
169 |
print "...", |
170 |
print ")" |
171 |
sys.exit(0) |
149 |
|
172 |
|
150 |
# dump, fix, inject and fix are nearly the same code, only the glsa method call differs |
173 |
# dump, fix, inject and fix are nearly the same code, only the glsa method call differs |
151 |
if mode in ["dump", "fix", "inject", "pretend"]: |
174 |
if mode in ["dump", "fix", "inject", "pretend"]: |