--- ./src/glsa-check/glsa-check 2005-07-10 11:25:59.000000000 -0400 +++ ./src/glsa-check/glsa-check 2005-07-10 14:23:57.000000000 -0400 @@ -11,7 +11,7 @@ __program__ = "glsa-check" __author__ = "Marius Mauch " -__version__ = "0.5" +__version__ = "0.5.1" optionmap = [ ["-l", "--list", "list all unapplied GLSA"], @@ -24,22 +24,18 @@ ["-h", "--help", "show this help message"], ["-V", "--version", "some information about this tool"], ["-v", "--verbose", "print more messages (option)"], +["-q", "--quiet", "don't print startup message"], +["-c", "--cve", "print startup message"], ] -# print a warning as this is beta code -sys.stderr.write("WARNING: This tool is completely new and not very tested, so it should not be\n") -sys.stderr.write("used on production systems. It's mainly a test tool for the new GLSA release\n") -sys.stderr.write("and distribution system, it's functionality will later be merged into emerge\n") -sys.stderr.write("and equery.\n") -sys.stderr.write("Please read http://www.gentoo.org/proj/en/portage/glsa-integration.xml\n") -sys.stderr.write("before using this tool AND before reporting a bug.\n\n") - # option parsing +quiet = False +cve = False args = [] params = [] try: - args, params = getopt(sys.argv[1:], "dplfchinvVt", \ - ["dump", "print", "list", "pretend", "fix", "inject", "help", "info", "version", "test", "nocolor"]) + args, params = getopt(sys.argv[1:], "dplfchinvVtqc", \ + ["dump", "print", "list", "pretend", "fix", "inject", "help", "info", "version", "test", "nocolor", "quiet", "cve"]) args = [a for a,b in args] for option in ["--nocolor", "-n"]: @@ -52,6 +48,17 @@ if option in args: verbose = True args.remove(option) + + for option in ["--quiet", "-q"]: + if option in args: + quiet = True + verbose = False + args.remove(option) + + for option in ["--cve", "-c"]: + if option in args: + cve = True + args.remove(option) # sanity checking if len(args) <= 0: @@ -71,6 +78,16 @@ print "unknown option given:", e mode = "help" + +# print a warning as this is beta code +if quiet == False: + sys.stderr.write("WARNING: This tool is completely new and not very tested, so it should not be\n") + sys.stderr.write("used on production systems. It's mainly a test tool for the new GLSA release\n") + sys.stderr.write("and distribution system, it's functionality will later be merged into emerge\n") + sys.stderr.write("and equery.\n") + sys.stderr.write("Please read http://www.gentoo.org/proj/en/portage/glsa-integration.xml\n") + sys.stderr.write("before using this tool AND before reporting a bug.\n\n") + # we need a set of glsa for most operation modes if len(params) <= 0 and mode in ["fix", "test", "pretend", "dump", "inject"]: print @@ -129,10 +146,13 @@ todolist = [e for e in completelist if e not in checklist] glsalist = [] +new_only = False if "new" in params: + new_only = True glsalist = todolist params.remove("new") if "all" in params: + new_only = False glsalist = completelist params.remove("all") @@ -146,10 +166,11 @@ # list short information for given or new GLSA if mode == "list": - print white("[A]")+" means this GLSA was already applied," - print green("[U]")+" means the system is not affected and" - print red("[N]")+" indicates that the system might be affected." - print + if not (quiet): + print white("[A]")+" means this GLSA was already applied," + print green("[U]")+" means the system is not affected and" + print red("[N]")+" indicates that the system might be affected." + print for myid in glsalist: try: myglsa = Glsa(myid, glsaconfig) @@ -157,21 +178,31 @@ if verbose: print "invalid GLSA: %s (error message was: %s)" % (myid, e) continue + vuln = False if myglsa.isApplied(): status = "[A]" color = white elif myglsa.isVulnerable(): + vuln = True status = "[N]" color = red else: status = "[U]" color = green + if (new_only and not vuln): + continue; print color(myglsa.nr), color(status), myglsa.title, "(", for pkg in myglsa.packages.keys()[:3]: print pkg, if len(myglsa.packages) > 3: print "...", - print ")" + print ")", + if cve: + for ref in myglsa.references: + if ref[0:4] == "CAN-": + print ref[0:13], + print + sys.exit(0) # dump, fix, inject and fix are nearly the same code, only the glsa method call differs