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

Contents of /bin/checklist

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2305 - (show annotations) (download)
Tue Oct 4 20:18:37 2005 UTC (7 years, 7 months ago) by joeyh
File size: 9740 byte(s)
support <removed>
1 #!/usr/bin/perl
2 # Must run on a machine with madison.
3 #
4 # To check for un-updated binary kernel packages, also needs grep-dctrl
5 # and a Sources file for the distribution. Set the location of the Sources
6 # file in SOURCES_FILE in the environment.
7 use warnings;
8 use strict;
9 use URI::Escape;
10 use Getopt::Long;
11
12 my $html=0;
13 my $debug=0;
14 my $suite="testing";
15 my $sta="http://secure-testing.debian.net/debian-secure-testing/dists/etch/security-updates/main/source/Sources.gz";
16 my $output;
17 if (! GetOptions(
18 "html" => \$html,
19 "debug" => \$debug,
20 "suite=s" => \$suite,
21 "sta=s" => \$sta,
22 "output=s", \$output)
23 || ! @ARGV) {
24 die "usage: $0 [--suite suite] [--sta sta-mirror] [--html] [--output=file] [--debug] list ...\n";
25 }
26
27 my $stasources=`tempfile`;
28 chomp $stasources;
29 system("wget -q -O $stasources $sta");
30
31 if (defined $output) {
32 open (OUT, ">$output.tmp.$$") || die "output.tmp.$$: $!"; # Set the output to a file
33 }
34 else {
35 open (OUT, ">&STDOUT"); # Set the output to stdout
36 }
37
38 if ($html) { # It's HTML, so we need a header
39 print OUT "<html><title>$suite security issues</title>\n";
40
41 # This is being run against something it's not meant to be, so print a warning
42 if ($suite ne 'testing' && $suite ne 'unstable') {
43 print OUT <<"EOF";
44 <p>
45 <em>Warning:</em> This page is the result of running the testing security
46 check script against the $suite distribution. As data is only gathered for
47 the testing distribution, results may be innacurate if a package has
48 changed its name, if a vulnerability affects $suite and not testing, or if a
49 vulnerability has been fixed in $suite by the security team.
50 </p>
51 EOF
52 }
53 print OUT "<ul>\n";
54 }
55
56
57 my %data;
58 my %advlist;
59 my %needkernel=qw/2.4.27 0 2.6.11 0/;
60 my $list_unknown=1; #set to 1 to display kernel images with unknown source version
61 my $sources=$ENV{SOURCES_FILE};
62 my $need_rebuild=0;
63
64 # Set some colours for the urgency types
65 my @urgencies=("high", "medium", "low", "unimportant", "unknown", "fixed");
66 my %colormap=(
67 high => "#FF0000",
68 medium => "#FF9999",
69 low => "#FFFFFF",
70 unknown => "#FFFF00",
71 fixed => "#00FF00",
72 );
73
74 my $unprop = my $unprop_all = my $unfixed = my $todos = my $fixedsta = 0;
75
76 # Add an item into the data array.
77 sub record {
78 my ($package, $condition, $item, $urgency)=@_;
79
80 if (! defined $item) {
81 $item='';
82 }
83
84 if ($html) {
85 $condition=~s{bug #(\d+)}{<a href="http://bugs.debian.org/$1">bug #$1</a>}g;
86 $condition=~s{unfixed}{<b>unfixed</b>}g;
87 $item=~s#((?:CAN|CVE)-\d+-\d+)#<a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=$1">$1</a>#g;
88 $item=~s#(DTSA-\d+-\d+)#<a href="http://secure-testing-master.debian.net/DTSA/$1.html">$1</a>#g;
89 }
90
91 push @{$data{$package}{$condition}}, {item => $item, urgency => $urgency};
92 }
93
94 foreach my $list (@ARGV) {
95 # Each of the @ARGVs we've got passed need parsing. So lets do that
96
97 # If it's a directory, set the file to list, cause we need that.
98 if (-d $list) {
99 $list="$list/list";
100 }
101
102 my $id;
103 open (IN, $list) || die "open $list: $!";
104 while (<IN>) {
105 print STDERR "line: $_" if $debug;
106 chomp;
107 if (/\s+TODO/) { # It's a todo item. Add it to the count, and ignore it
108 $todos++;
109 }
110 elsif (/^\[/) { # Checking adv. number for a line starting with [ : Set $id to it
111 ($id)=m/((?:DSA|DTSA|CAN|CVE)-[^\s]+) /;
112 }
113 elsif (/^((?:DSA|DTSA|CAN|CVE)-[^\s]+)/) { # Check for a line with an advisory at the start : Set $id to it
114 $id=$1;
115 }
116 elsif (/^\s+[!-]\s+(\S+)\s+(.*?)\s*$/) { # Deal with the rest of the lines
117 my $package=$1; # We know which package it is.
118 my $rest=$2;
119 my $version;
120 my $notes;
121 if ($rest=~/([^\(\s]+)\s+\((.*)\)/) {
122 $version=$1;
123 $notes=$2;
124 }
125 elsif ($rest=~/\((.*)\)/) {
126 $version="";
127 $notes=$1;
128 }
129 else {
130 $version=$rest;
131 $notes="";
132 }
133
134 # by now, we also have the version that's affected by the security problem.
135 # This is stored in $version
136 next if $version eq '<not-affected>' || $version eq '<removed>';
137
138 my @notes=split(/\s*;\s+/, $notes);
139
140 # Fetch the urgency, if we can.
141 my $urgency="unknown";
142 foreach my $u (@urgencies) {
143 if (grep { $_ eq $u } @notes) {
144 $urgency=$u;
145 @notes = grep { $_ ne $u } @notes;
146 last;
147 }
148 }
149 next if $urgency eq 'unimportant';
150
151 # It's a kernel. Add it to the list of kernels that need to be looked at.
152 if ($package=~/kernel-source-([0-9.]+)/) {
153 my $kernversion=$1;
154 if (exists $needkernel{$kernversion} &&
155 length $version &&
156 system("dpkg --compare-versions $needkernel{$kernversion} lt $version") != 0) {
157 $needkernel{$kernversion}=$version;
158 }
159 }
160
161 # Fire up madison.
162 my @maddy;
163 for (1..5) {
164 @maddy=`madison -s '$suite' '$package'`;
165 if ($? & 127 || ($? >> 8 != 0 && $? >> 8 != 1)) {
166 # good old unrelaible newraff,
167 # home of our archive..
168 next;
169 }
170 last;
171 }
172 if ($? & 127) {
173 record($package, "<em>[madison segfaulted 5 times in a row.. Medic!]</em>", $id);
174 }
175 elsif ($? >> 8 != 0 && $? >> 8 != 1) {
176 record($package, "<em>[madison exited with ".($? >> 8)."]</em>", $id);
177 }
178 if (! @maddy) {
179 next;
180 }
181
182 if ($version eq '<unfixed>' || grep { $_ eq 'pending' } @notes) {
183 record($package, '('.join("; ", "unfixed", @notes).')', $id, $urgency);
184 $unfixed++;
185 # It's not been fixed!
186 }
187 else {
188 foreach my $maddy (@maddy) {
189 my @fields = split(/\s*\|\s*/, $maddy);
190 my $havver=$fields[1]; # It's this version in the archive I'm checking.
191 my $arches=$fields[3];
192 $version=~s/\s+//; # strip whitespace
193 $arches=~s/\s+$//;
194 # Is the version in the archive the same or newer than the fix?
195 my $cmp=system("dpkg --compare-versions '$havver' '>=' '$version'");
196 if ($cmp != 0){ # No, so the archive is vulnerable.
197 # Does the version exist in the secure-testing archive?
198 my $staversion = `zcat $stasources |grep-dctrl -F Package -e ^$package\$ -s Version -`;
199 chomp $staversion;
200 $staversion=~s/Version: //;
201 $staversion=~s/\s+//;
202 if (length ($staversion)) {
203 # Yes, but what version is in s-t?
204 my $stacmp = system("dpkg --compare-versions '$staversion' '>=' '$version'");
205 if ($stacmp == 0){
206 # Well, the version in the s-t archive fixes the issue
207 # but it's still vulnerable in the main archive
208 $urgency='fixed';
209 $fixedsta++;
210 }
211 }
212
213 if ($html && $suite eq 'testing') {
214 $havver='<a href="http://bjorn.haxx.se/debian/testing.pl?package='.uri_escape($package).'">'.$havver.'</a>';
215 }
216 record($package, "$version needed, have $havver".(@maddy > 1 ? " [$arches]" : ""), $id, $urgency);
217 $unprop++;
218 $unprop_all++ unless @maddy > 1;
219 }
220 }
221 }
222 }
223 }
224 }
225
226
227 foreach my $package (sort keys %data) {
228 foreach my $condition (sort keys %{$data{$package}}) {
229 print OUT "<li>" if $html;
230 print OUT "$package $condition for ";
231 my $items=0;
232 foreach my $i (sort @{$data{$package}{$condition}}) {
233 print OUT ", " if $items > 0;
234
235 if ($html) {
236 my $color=$colormap{$i->{urgency}};
237 print OUT "<span style=\"background:$color\">";
238 }
239 print OUT $i->{item};
240 if ($html) {
241 print OUT "</span>";
242 }
243
244 $items++;
245 }
246 print OUT "\n";
247 }
248 }
249
250 my %needkern;
251
252 foreach my $version (sort keys %needkernel) {
253 my %images;
254
255 if (defined $needkern{$version} && $needkern{$version} eq "0") {
256 next;
257 }
258
259 my @dctrl;
260 if (defined $sources && length $sources) {
261 my $cat=($sources=~/\.gz/) ? "zcat" : "cat";
262 @dctrl=`$cat $sources | grep-dctrl -F Binary kernel-image-$version -s Package,Build-Depends -`;
263 }
264
265 my $package="";
266 my $haveversion;
267
268 foreach my $line (@dctrl) {
269 chomp $line;
270 if ($line=~/Package:\s*(\S+)/) {
271 $package=$1;
272 $haveversion="0";
273 } elsif ($line=~/Build-Depends/) {
274 if ($line=~/kernel-tree-$version-([^,\s]+)/) {
275 $haveversion="$version-$1";
276 } elsif ($line=~/kernel-source-$version\s+\(>?=\s*([^\s\)]+)\)/) {
277 $haveversion="$1";
278 }
279 } else {
280 if ($package=~/linux-kernel-di/ || $package eq "") {
281 next;
282 }
283 $images{$package}=$haveversion;
284 $package="";
285 }
286 }
287
288 foreach my $package (sort keys %images) {
289 if ($images{$package} eq "0") {
290 print OUT "<li>" if ($html && $list_unknown);
291 print OUT "$package built from kernel-source-$version $needkernel{$version} needed, current version unknown\n" if $list_unknown;
292 } elsif (!system("dpkg --compare-versions $needkernel{$version} gt $images{$package}")) {
293 print OUT "<li>" if $html;
294 print OUT "$package built from kernel-source-$version $needkernel{$version} needed, have $images{$package}\n";
295 $need_rebuild++;
296 }
297 }
298
299
300 }
301
302
303 if ($html) {
304 print OUT "</ul>\n";
305 print OUT "<hr>\n";
306 print OUT "Key: ";
307 foreach my $keyline (@urgencies) {
308 next if $keyline eq 'unimportant';
309 print OUT "<span style=\"border: 1px dashed; background:".$colormap{$keyline}."\">&nbsp;$keyline&nbsp;</span> ";
310 }
311 print OUT "<br>";
312 print OUT "Total holes unfixed: $unfixed<br>\n";
313 print OUT "Total holes fixed in unstable but not $suite: $unprop_all ($fixedsta fixed in secure-testing archive)";
314 if ($unprop_all != $unprop) {
315 print OUT " (+".($unprop - $unprop_all)." on some arches)";
316 }
317 print OUT "<br>\n";
318 print OUT "Total number of kernel image packages not up to date: $need_rebuild<br>\n";
319 print OUT "Number of TODO lines in <a href=\"http://svn.debian.org/wsvn/secure-testing/data/?rev=0&sc=0\">records</a>: $todos<br>\n";
320 print OUT "Maintained by the <a href=\"http://secure-testing-master.debian.net/\">testing security team</a><br>\n";
321 print OUT "Last update: ".`date`."<br>\n";
322 print OUT "</html>\n";
323 }
324
325 close OUT;
326 if (defined $output) {
327 rename("$output.tmp.$$", $output) || die "rename: $!";
328 }
329 unlink $stasources;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5