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

Contents of /bin/checklist

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1772 - (show annotations) (download)
Thu Sep 1 20:24:57 2005 UTC (7 years, 8 months ago) by joeyh
File size: 9506 byte(s)
one more warning
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-security-updates/dists/testing/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", "unknown");
66 my %colormap=(
67 high => "#FF0000",
68 medium => "#FF9999",
69 low => "#FFFFFF",
70 unknown => "#FFFF00"
71 );
72
73 my $unprop = my $unprop_all = my $unfixed = my $todos = my $fixedsta = 0;
74
75 # Add an item into the data array.
76 sub record {
77 my ($package, $condition, $item, $urgency)=@_;
78
79 if (! defined $item) {
80 $item='';
81 }
82
83 if ($html) {
84 $condition=~s{bug #(\d+)}{<a href="http://bugs.debian.org/$1">bug #$1</a>}g;
85 $condition=~s{unfixed}{<b>unfixed</b>}g;
86 $item=~s#((?:CAN|CVE)-\d+-\d+)#<a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=$1">$1</a>#g;
87 }
88
89 push @{$data{$package}{$condition}}, {item => $item, urgency => $urgency};
90 }
91
92 foreach my $list (@ARGV) {
93 # Each of the @ARGVs we've got passed need parsing. So lets do that
94
95 # If it's a directory, set the file to list, cause we need that.
96 if (-d $list) {
97 $list="$list/list";
98 }
99
100 my $id;
101 open (IN, $list) || die "open $list: $!";
102 while (<IN>) {
103 print STDERR "line: $_" if $debug;
104 chomp;
105 if (/\s+TODO/) { # It's a todo item. Add it to the count, and ignore it
106 $todos++;
107 }
108 elsif (/^\[/) { # Checking adv. number for a line starting with [ : Set $id to it
109 ($id)=m/((?:DSA|DTSA|CAN|CVE)-[^\s]+) /;
110 }
111 elsif (/^((?:DSA|DTSA|CAN|CVE)-[^\s]+)/) { # Check for a line with an advisory at the start : Set $id to it
112 $id=$1;
113 }
114 elsif (/^\s+[!-]\s+(\S+)\s+(.*?)\s*$/) { # Deal with the rest of the lines
115 my $package=$1; # We know which package it is.
116 my $rest=$2;
117 my $version;
118 my $notes;
119 if ($rest=~/([^\(\s]+)\s+\((.*)\)/) {
120 $version=$1;
121 $notes=$2;
122 }
123 elsif ($rest=~/\((.*)\)/) {
124 $version="";
125 $notes=$1;
126 }
127 else {
128 $version=$rest;
129 $notes="";
130 }
131
132 # by now, we also have the version that's affected by the security problem.
133 # This is stored in $version
134
135 my @notes=split(/\s*;\s+/, $notes);
136
137 # Fetch the urgency, if we can.
138 my $urgency="unknown";
139 foreach my $u (@urgencies) {
140 if (grep { $_ eq $u } @notes) {
141 $urgency=$u;
142 @notes = grep { $_ ne $u } @notes;
143 last;
144 }
145 }
146
147 # It's a kernel. Add it to the list of kernels that need to be looked at.
148 if ($package=~/kernel-source-([0-9.]+)/) {
149 my $kernversion=$1;
150 if (exists $needkernel{$kernversion} &&
151 length $version &&
152 system("dpkg --compare-versions $needkernel{$kernversion} lt $version") != 0) {
153 $needkernel{$kernversion}=$version;
154 }
155 }
156
157 # Fire up madison.
158 my @maddy;
159 for (1..5) {
160 @maddy=`madison -s '$suite' '$package'`;
161 if ($? & 127 || ($? >> 8 != 0 && $? >> 8 != 1)) {
162 # good old unrelaible newraff,
163 # home of our archive..
164 next;
165 }
166 last;
167 }
168 if ($? & 127) {
169 record($package, "<em>[madison segfaulted 5 times in a row.. Medic!]</em>", $id);
170 }
171 elsif ($? >> 8 != 0 && $? >> 8 != 1) {
172 record($package, "<em>[madison exited with ".($? >> 8)."]</em>", $id);
173 }
174 if (! @maddy) {
175 next;
176 }
177
178 if (grep { $_ eq 'unfixed' || $_ eq 'pending' } @notes) {
179 record($package, '('.join("; ", @notes).')', $id, $urgency);
180 $unfixed++;
181 # It's not been fixed!
182 }
183 else {
184 foreach my $maddy (@maddy) {
185 my @fields = split(/\s*\|\s*/, $maddy);
186 my $havver=$fields[1]; # It's this version in the archive I'm checking.
187 my $arches=$fields[3];
188 $version=~s/\s+//; # strip whitespace
189 $arches=~s/\s+$//;
190 # Is the version in the archive the same or newer than the fix?
191 my $cmp=system("dpkg --compare-versions '$havver' '>=' '$version'");
192 if ($cmp != 0){ # No, so the archive is vulnerable.
193 my $starchive = "";
194
195 # Does the version exist in the secure-testing archive?
196 my $staversion = `zcat $stasources |grep-dctrl -F Package -e ^$package\$ -s Version -`;
197 chomp $staversion;
198 $staversion=~s/Version: //;
199 $staversion=~s/\s+//;
200 if (length ($staversion)) {
201 # Yes, but what version is in s-t?
202 my $stacmp = system("dpkg --compare-versions '$staversion' '>=' '$version'");
203 if ($stacmp == 0){
204 # Well, the version in the s-t archive fixes the issue
205 # but it's still vulnerable in the main archive
206 $starchive = " (fixed in $staversion in the secure-testing archive)";
207 $fixedsta++;
208 }
209 }
210
211 if ($html && $suite eq 'testing') {
212 $havver='<a href="http://bjorn.haxx.se/debian/testing.pl?package='.uri_escape($package).'">'.$havver.'</a>';
213 }
214 record($package, "$version needed, have $havver".(@maddy > 1 ? " [$arches]" : "").$starchive, $id, $urgency);
215 $unprop++;
216 $unprop_all++ unless @maddy > 1;
217 }
218 }
219 }
220 }
221 }
222 }
223
224
225 foreach my $package (sort keys %data) {
226 foreach my $condition (sort keys %{$data{$package}}) {
227 print OUT "<li>" if $html;
228 print OUT "$package $condition for ";
229 my $items=0;
230 foreach my $i (sort @{$data{$package}{$condition}}) {
231 print OUT ", " if $items > 0;
232
233 if ($html) {
234 my $color=$colormap{$i->{urgency}};
235 print OUT "<span style=\"background:$color\">";
236 }
237 print OUT $i->{item};
238 if ($html) {
239 print OUT "</span>";
240 }
241
242 $items++;
243 }
244 print OUT "\n";
245 }
246 }
247
248 my %needkern;
249
250 foreach my $version (sort keys %needkernel) {
251 my %images;
252
253 if (defined $needkern{$version} && $needkern{$version} eq "0") {
254 next;
255 }
256
257 my @dctrl;
258 if (defined $sources && length $sources) {
259 my $cat=($sources=~/\.gz/) ? "zcat" : "cat";
260 @dctrl=`$cat $sources | grep-dctrl -F Binary kernel-image-$version -s Package,Build-Depends -`;
261 }
262
263 my $package="";
264 my $haveversion;
265
266 foreach my $line (@dctrl) {
267 chomp $line;
268 if ($line=~/Package:\s*(\S+)/) {
269 $package=$1;
270 $haveversion="0";
271 } elsif ($line=~/Build-Depends/) {
272 if ($line=~/kernel-tree-$version-([^,\s]+)/) {
273 $haveversion="$version-$1";
274 } elsif ($line=~/kernel-source-$version\s+\(>?=\s*([^\s\)]+)\)/) {
275 $haveversion="$1";
276 }
277 } else {
278 if ($package=~/linux-kernel-di/ || $package eq "") {
279 next;
280 }
281 $images{$package}=$haveversion;
282 $package="";
283 }
284 }
285
286 foreach my $package (sort keys %images) {
287 if ($images{$package} eq "0") {
288 print OUT "<li>" if ($html && $list_unknown);
289 print OUT "$package built from kernel-source-$version $needkernel{$version} needed, current version unknown\n" if $list_unknown;
290 } elsif (!system("dpkg --compare-versions $needkernel{$version} gt $images{$package}")) {
291 print OUT "<li>" if $html;
292 print OUT "$package built from kernel-source-$version $needkernel{$version} needed, have $images{$package}\n";
293 $need_rebuild++;
294 }
295 }
296
297
298 }
299
300
301 if ($html) {
302 print OUT "</ul>\n";
303 print OUT "<hr>\n";
304 print OUT "Key: ";
305 foreach my $keyline (@urgencies) {
306 print OUT "<span style=\"border: 1px dashed; background:".$colormap{$keyline}."\">&nbsp;$keyline&nbsp;</span> ";
307 }
308 print OUT "<br>";
309 print OUT "Total holes unfixed: $unfixed<br>\n";
310 print OUT "Total holes fixed in unstable but not $suite: $unprop_all ($fixedsta fixed in secure-testing archive)";
311 if ($unprop_all != $unprop) {
312 print OUT " (+".($unprop - $unprop_all)." on some arches)";
313 }
314 print OUT "<br>\n";
315 print OUT "Total number of kernel image packages not up to date: $need_rebuild<br>\n";
316 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";
317 print OUT "Maintained by the <a href=\"http://secure-testing.debian.net/\">testing security team</a><br>\n";
318 print OUT "Last update: ".`date`."<br>\n";
319 print OUT "</html>\n";
320 }
321
322 close OUT;
323 if (defined $output) {
324 rename("$output.tmp.$$", $output) || die "rename: $!";
325 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5