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

Diff of /bin/checklist

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.735  
changed lines
  Added in v.1765

  ViewVC Help
Powered by ViewVC 1.1.5