/[secure-testing]/bin/mass-bug-filer
ViewVC logotype

Contents of /bin/mass-bug-filer

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6009 - (show annotations) (download)
Sat Jun 16 10:41:23 2007 UTC (5 years, 11 months ago) by fw
File size: 1830 byte(s)
* bin/mass-bug-filer:
  Small script to file security bugs, with a few sanity checks.
1 #!/usr/bin/python
2
3 import sys
4 import apt
5 import apt_pkg
6 import os
7 import re
8
9 if len(sys.argv) < 3:
10 print >>sys.stderr, "usage: %s FILE PACKAGE..." % sys.argv[0]
11 sys.exit(1)
12
13 message_file = file(sys.argv[1])
14 packages = sys.argv[2:]
15
16 cache = apt.Cache()
17 errors = False
18 for p in packages:
19 if not cache.has_key(p):
20 print >>sys.stderr, "error: no such package:", p
21 errors = True
22 if errors:
23 sys.exit(2)
24
25 h_subject = None
26 h_to = 'submit@bugs.debian.org'
27 h_bug = {'Severity' : 'grave',
28 'Tags' : 'security'}
29 re_header = re.compile('^([a-zA-Z0-9-]+):\s*(\S.*?)\s*$')
30 source_lines = message_file.readlines()
31 state = 0
32 body = []
33 for line in source_lines:
34 if state == 1:
35 body.append(line)
36 continue
37
38 if line == '\n':
39 if h_subject is None:
40 print >>sys.stderr, "error: missing Subject header"
41 sys.exit(2)
42 state = 1
43 continue
44
45 # state == 0
46 match = re_header.match(line)
47 if match is None:
48 print >>sys.stderr, "error: invalid line:", line
49 sys.exit(2)
50 (k, v) = match.groups()
51 if k == "Subject":
52 h_subject = v
53 continue
54 if h_bug.has_key(k):
55 h_bug[k] = v
56 continue
57 print >>sys.stderr, "error: invalid header field:", k
58 sys.exit(2)
59
60 def make_message(pkg):
61 yield "To: %s\nSubject: %s\n\n" % (h_to, h_subject)
62 yield "Package: %s\n" % pkg
63 for x in h_bug.iteritems():
64 yield "%s: %s\n" % x
65 yield "\n"
66 for x in body:
67 yield x
68
69 def sendmail(lines):
70 p = os.popen("/usr/lib/sendmail -oee -i -t", "w")
71 closed = False
72 try:
73 for x in lines:
74 p.write(x)
75 finally:
76 p.close()
77
78 for p in packages:
79 sendmail(make_message(p))
80
81 for p in packages:
82 print "\t- %s <unfixed> (bug filed)" % p
83
84
85

  ViewVC Help
Powered by ViewVC 1.1.5