summaryrefslogtreecommitdiffstats
path: root/bin/mass-bug-filer
diff options
context:
space:
mode:
authorFlorian Weimer <fw@deneb.enyo.de>2007-06-16 10:41:23 +0000
committerFlorian Weimer <fw@deneb.enyo.de>2007-06-16 10:41:23 +0000
commita42c5e03184c7a19c2baa62743a9532f014cb81a (patch)
treeb2fe1c24253c00c52c84ac90ad4ed9af82db2951 /bin/mass-bug-filer
parent524b64413c2974618c8ec9b8931d23c25ca4531a (diff)
* bin/mass-bug-filer:
Small script to file security bugs, with a few sanity checks. git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@6009 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'bin/mass-bug-filer')
-rw-r--r--bin/mass-bug-filer85
1 files changed, 85 insertions, 0 deletions
diff --git a/bin/mass-bug-filer b/bin/mass-bug-filer
new file mode 100644
index 0000000000..5987b12f7f
--- /dev/null
+++ b/bin/mass-bug-filer
@@ -0,0 +1,85 @@
+#!/usr/bin/python
+
+import sys
+import apt
+import apt_pkg
+import os
+import re
+
+if len(sys.argv) < 3:
+ print >>sys.stderr, "usage: %s FILE PACKAGE..." % sys.argv[0]
+ sys.exit(1)
+
+message_file = file(sys.argv[1])
+packages = sys.argv[2:]
+
+cache = apt.Cache()
+errors = False
+for p in packages:
+ if not cache.has_key(p):
+ print >>sys.stderr, "error: no such package:", p
+ errors = True
+if errors:
+ sys.exit(2)
+
+h_subject = None
+h_to = 'submit@bugs.debian.org'
+h_bug = {'Severity' : 'grave',
+ 'Tags' : 'security'}
+re_header = re.compile('^([a-zA-Z0-9-]+):\s*(\S.*?)\s*$')
+source_lines = message_file.readlines()
+state = 0
+body = []
+for line in source_lines:
+ if state == 1:
+ body.append(line)
+ continue
+
+ if line == '\n':
+ if h_subject is None:
+ print >>sys.stderr, "error: missing Subject header"
+ sys.exit(2)
+ state = 1
+ continue
+
+ # state == 0
+ match = re_header.match(line)
+ if match is None:
+ print >>sys.stderr, "error: invalid line:", line
+ sys.exit(2)
+ (k, v) = match.groups()
+ if k == "Subject":
+ h_subject = v
+ continue
+ if h_bug.has_key(k):
+ h_bug[k] = v
+ continue
+ print >>sys.stderr, "error: invalid header field:", k
+ sys.exit(2)
+
+def make_message(pkg):
+ yield "To: %s\nSubject: %s\n\n" % (h_to, h_subject)
+ yield "Package: %s\n" % pkg
+ for x in h_bug.iteritems():
+ yield "%s: %s\n" % x
+ yield "\n"
+ for x in body:
+ yield x
+
+def sendmail(lines):
+ p = os.popen("/usr/lib/sendmail -oee -i -t", "w")
+ closed = False
+ try:
+ for x in lines:
+ p.write(x)
+ finally:
+ p.close()
+
+for p in packages:
+ sendmail(make_message(p))
+
+for p in packages:
+ print "\t- %s <unfixed> (bug filed)" % p
+
+
+

© 2014-2024 Faster IT GmbH | imprint | privacy policy