/[secure-testing]/bin/dsa2list
ViewVC logotype

Contents of /bin/dsa2list

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6472 - (hide annotations) (download)
Sun Sep 2 23:42:46 2007 UTC (5 years, 9 months ago) by fw
File size: 3259 byte(s)
* bin/dsa2list: Fix date format
1 fw 3107 #!/usr/bin/python
2    
3 fw 6436 # Reasonably well-formed announcements to the debian-security-announce
4     # mailing list can be piped through this script. The result is an
5     # entry suitable for data/DSA/list.
6    
7 fw 3107 import os
8     import os.path
9     import re
10     import string
11     import sys
12     import time
13     import urllib2
14    
15     def setup_paths():
16     check_file = 'lib/python/debian_support.py'
17     path = os.getcwd()
18     while 1:
19     if os.path.exists("%s/%s" % (path, check_file)):
20     sys.path = [path + '/lib/python'] + sys.path
21     return path
22     idx = string.rfind(path, '/')
23     if idx == -1:
24     raise ImportError, "could not setup paths"
25     path = path[0:idx]
26     os.chdir(setup_paths())
27    
28     import debian_support
29    
30 fw 6436 # DSAs do not contain version numbers with epochs, so they are useless
31     # for our purposes.
32    
33 fw 3107 def fetch_dsc(url):
34     u = urllib2.urlopen(url)
35     assert u.readline()[0] == '-' # OpenPGP cleartext signature header
36    
37     def parse(*regexps):
38     result = [None] * len(regexps)
39     for line in u:
40     for i in range(len(regexps)):
41     match = regexps[i].match(line)
42     if match:
43     result[i] = match.groups()[0]
44     continue
45     if line[0] == '-':
46     break
47     return result
48    
49     (source, version)= parse(re.compile("^Source: (\S+)$"),
50     re.compile("^Version: (\S+)$"))
51     assert source is not None
52     assert version is not None
53     return (source, version)
54    
55 fw 6436 re_title = re.compile(r'^Subject: .*\[DSA (\d+-\d+)\] .* fix(?:es)? (.*)$')
56     re_date = re.compile(r'^([A-Z][a-z][a-z])[a-z]* (\d+)[a-z]+, (\d+)\s+http://.*')
57 fw 3107
58     re_cve = re.compile('(CVE-\d{4}-\d{4})')
59     release_headline_re = re.compile(
60 fw 6436 r'^Debian GNU/Linux [0-9.]+ (?:\(|alias) ([a-z]+).*')
61     dscurl_re = re.compile(r'^\s*(http://\S+\.dsc).*')
62 fw 3107
63 fw 6438 def process_file(file):
64     cve_names = {}
65     package_notes = []
66     release = ''
67     date = ''
68     dsa_name = ''
69     title = ''
70     packages = {}
71     for line in file.readlines():
72     match = re_title.match(line)
73     if match:
74     (dsa_name, title) = match.groups()
75     continue
76 fw 3107
77 fw 6438 match = re_date.match(line)
78     if match:
79     (m, d, y) = match.groups()
80 fw 6472 date = "%02d %s %s" % (int(d), m, y)
81 fw 3107
82 fw 6438 for cve in re_cve.findall(line):
83     cve_names[cve] = True
84 fw 3107
85 fw 6438 match = release_headline_re.match(line)
86     if match:
87     (release,) = match.groups()
88     continue
89 fw 3107
90 fw 6438 match = dscurl_re.match(line)
91     if match:
92     assert release
93     (source, version) = fetch_dsc(match.groups()[0])
94     packages[source] = True
95     package_notes.append((release, source, version))
96 fw 6436
97 fw 6438 assert date
98     assert title
99     packages = packages.keys()
100     packages.sort()
101     print "[%s] DSA-%s %s - %s" % (date, dsa_name, ' '.join(packages), title)
102 fw 6436
103 fw 6438 cve_names = cve_names.keys()
104     if cve_names:
105     cve_names.sort()
106     print "\t{%s}" % (' '.join(cve_names))
107 fw 3107
108 fw 6438 for (release, source, version) in package_notes:
109     print "\t[%s] - %s %s" % (release, source, version)
110 fw 3107
111 fw 6438 if len(sys.argv) == 1:
112     process_file(sys.stdin)
113     else:
114     for x in sys.argv[1:]:
115     process_file(file(x))

  ViewVC Help
Powered by ViewVC 1.1.5