oeaudit: Add -f option to fetch an auditfile from FreeBSD
authorHolger Hans Peter Freyther <zecke@selfish.org>
Tue, 23 Mar 2010 09:21:35 +0000 (10:21 +0100)
committerHolger Hans Peter Freyther <zecke@selfish.org>
Tue, 23 Mar 2010 09:28:20 +0000 (10:28 +0100)
contrib/oeaudit/oe_audit.py

index 018547a..13e53be 100755 (executable)
@@ -82,6 +82,8 @@ def handle_options(args):
                       action = "store", dest = "oe_available", default = None)
     parser.add_option("-b", "--buggy", help = "Write out unmaped packets",
                       action = "store", dest = "buggy", default = "not_in_oe.bugs")
+    parser.add_option("-f", "--fetch", help = "Fetch a new auditfile",
+                     action = "store_true", dest = "fetch", default = False)
 
     options, args = parser.parse_args(args)
     return options
@@ -89,6 +91,16 @@ def handle_options(args):
 # read the input data
 import sys
 opts = handle_options(sys.argv)
+
+if opts.fetch:
+    import os
+    print "Fetching new auditfile with wget and unpacking to the local directory"
+    os.system("(rm auditfile.tbz || true) && wget -c http://ports.freebsd.org/auditfile.tbz; tar xjf auditfile.tbz auditfile && rm auditfile.tbz")
+
+if not opts.oe_available or not opts.freebsd_auditfile:
+    print "You need to specific -a and -p."
+    sys.exit(0)
+
 oe_packages = oe.read_available(opts.oe_available)
 freebsd_vuln = freebsd.read_auditfile(opts.freebsd_auditfile)
 buggy = open(opts.buggy, "w+")