Author: fw
Date: 2007-08-30 09:51:23 +0000 (Thu, 30 Aug 2007)
New Revision: 6436
Modified:
bin/dsa2list
Log:
* bin/dsa2list:
New version that processes postings to debian-security-announce
Modified: bin/dsa2list
==================================================================---
bin/dsa2list 2007-08-30 09:44:16 UTC (rev 6435)
+++ bin/dsa2list 2007-08-30 09:51:23 UTC (rev 6436)
@@ -1,5 +1,9 @@
#!/usr/bin/python
+# Reasonably well-formed announcements to the debian-security-announce
+# mailing list can be piped through this script. The result is an
+# entry suitable for data/DSA/list.
+
import os
import os.path
import re
@@ -23,6 +27,9 @@
import debian_support
+# DSAs do not contain version numbers with epochs, so they are useless
+# for our purposes.
+
def fetch_dsc(url):
u = urllib2.urlopen(url)
assert u.readline()[0] == ''-'' # OpenPGP cleartext
signature header
@@ -45,65 +52,56 @@
assert version is not None
return (source, version)
-re_title = re.compile(r''<h2>(DSA-\d+-\d+) (\S+) --
(.*)</h2>'')
-re_date = re.compile(r''^\s+<dd>(\d\d [A-Z][a-z][a-z]
\d{4})</dd>$'')
+re_title = re.compile(r''^Subject: .*\[DSA (\d+-\d+)\] .* fix(?:es)?
(.*)$'')
+re_date = re.compile(r''^([A-Z][a-z][a-z])[a-z]* (\d+)[a-z]+,
(\d+)\s+http://.*'')
re_cve = re.compile(''(CVE-\d{4}-\d{4})'')
release_headline_re = re.compile(
- r''.*<h3>Debian GNU/Linux \S+
\(([a-z]+)\)</h3>.*'')
-dscurl_re =
re.compile(r''.*"(http://[^">]+\.dsc)".*'')
+ r''^Debian GNU/Linux [0-9.]+ (?:\(|alias) ([a-z]+).*'')
+dscurl_re = re.compile(r''^\s*(http://\S+\.dsc).*'')
-if len(sys.argv) <> 2:
- print "usage: dsa2list DSA-NUMBER"
+if len(sys.argv) > 1:
+ print "usage: dsa2list < MESSAGE"
sys.exit(1)
-try:
- dsa_number = int(sys.argv[1])
-except ValueError:
- print `sys.argv[1]`, "is not an integer"
- sys.exit(1)
-
cve_names = {}
package_notes = []
-for year in range(0, 6):
- try:
- url = "http://www.debian.org/security/%d/dsa-%d" % \
- ((time.gmtime().tm_year - year), dsa_number)
- u = urllib2.urlopen(url)
- except urllib2.HTTPError:
+release = ''''
+date = ''''
+dsa_name = ''''
+title = ''''
+packages = {}
+for line in sys.stdin.readlines():
+ match = re_title.match(line)
+ if match:
+ (dsa_name, title) = match.groups()
continue
- title = ''''
- release = ''''
- date = ''''
- for line in u.readlines():
- match = re_title.match(line)
- if match:
- title = "%s %s - %s" % match.groups()
- continue
+ match = re_date.match(line)
+ if match:
+ (m, d, y) = match.groups()
+ date = "%s %s %s" % (d, m, y)
- match = re_date.match(line)
- if match:
- (date,) = match.groups()
-
- for cve in re_cve.findall(line):
- cve_names[cve] = True
-
- match = release_headline_re.match(line)
- if match:
- (release,) = match.groups()
- continue
-
- match = dscurl_re.match(line)
- if match:
- assert release
- (source, version) = fetch_dsc(match.groups()[0])
- package_notes.append((release, source, version))
- break
+ for cve in re_cve.findall(line):
+ cve_names[cve] = True
+ match = release_headline_re.match(line)
+ if match:
+ (release,) = match.groups()
+ continue
+
+ match = dscurl_re.match(line)
+ if match:
+ assert release
+ (source, version) = fetch_dsc(match.groups()[0])
+ packages[source] = True
+ package_notes.append((release, source, version))
+
assert date
assert title
-print "[%s] %s" % (date, title)
+packages = packages.keys()
+packages.sort()
+print "[%s] DSA-%s %s - %s" % (date, dsa_name, ''
''.join(packages), title)
cve_names = cve_names.keys()
if cve_names: