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

Diff of /bin/checklist

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

revision 1766 by joeyh, Thu Sep 1 19:31:46 2005 UTC revision 7489 by nion, Mon Dec 3 22:33:14 2007 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl
2  # Must run on a machine with madison.  # Must run on a machine with dak ls.
3  #  #
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
# Line 12  use Getopt::Long; Line 12  use Getopt::Long;
12  my $html=0;  my $html=0;
13  my $debug=0;  my $debug=0;
14  my $suite="testing";  my $suite="testing";
15  my $sta="http://secure-testing.debian.net/debian-security-updates/dists/testing/security-updates/main/source/Sources.gz";  my $sta="http://security.debian.org/debian-security/dists/testing/updates/main/source/Sources.gz";
16  my $output;  my $output;
17  if (! GetOptions(  if (! GetOptions(
18                  "html" => \$html,                  "html" => \$html,
# Line 37  else { Line 37  else {
37    
38  if ($html) { # It's HTML, so we need a header  if ($html) { # It's HTML, so we need a header
39          print OUT "<html><title>$suite security issues</title>\n";          print OUT "<html><title>$suite security issues</title>\n";
40            print OUT <<"EOF";
41    <p><b>Note:</b>The information in the <a href="http://idssi.enyo.de/tracker">Security
42    Bug Tracker</a> is more detailed and likely more accurate.
43    </p>
44    EOF
45    
46    
47          # This is being run against something it's not meant to be, so print a warning          # This is being run against something it's not meant to be, so print a warning
48          if ($suite ne 'testing' && $suite ne 'unstable') {          if ($suite ne 'testing' && $suite ne 'unstable') {
# Line 46  if ($html) { # It's HTML, so we need a h Line 52  if ($html) { # It's HTML, so we need a h
52  check script against the $suite distribution. As data is only gathered for  check script against the $suite distribution. As data is only gathered for
53  the testing distribution, results may be innacurate if a package has  the testing distribution, results may be innacurate if a package has
54  changed its name, if a vulnerability affects $suite and not testing, or if a  changed its name, if a vulnerability affects $suite and not testing, or if a
55  vulnerability has been fixed in $suite by the $suite security team.  vulnerability has been fixed in $suite by the security team.
56  </p>  </p>
57  EOF  EOF
58          }          }
# Line 62  my $sources=$ENV{SOURCES_FILE}; Line 68  my $sources=$ENV{SOURCES_FILE};
68  my $need_rebuild=0;  my $need_rebuild=0;
69    
70  # Set some colours for the urgency types  # Set some colours for the urgency types
71  my @urgencies=("high", "medium", "low", "unknown");  my @urgencies=("high", "medium", "low", "unimportant", "unknown", "fixed");
72  my %colormap=(  my %colormap=(
73          high => "#FF0000",          high => "#FF0000",
74          medium => "#FF9999",          medium => "#FF9999",
75          low => "#FFFFFF",          low => "#FFFFFF",
76          unknown => "#FFFF00"          unknown => "#FFFF00",
77            fixed => "#00FF00",
78  );  );
79    
80  my $unprop = my $unprop_all = my $unfixed = my $todos = my $fixedsta = 0;  my $unprop = my $unprop_all = my $unfixed = my $todos = my $fixedsta = 0;
# Line 75  my $unprop = my $unprop_all = my $unfixe Line 82  my $unprop = my $unprop_all = my $unfixe
82  # Add an item into the data array.  # Add an item into the data array.
83  sub record {  sub record {
84          my ($package, $condition, $item, $urgency)=@_;          my ($package, $condition, $item, $urgency)=@_;
85    
86            if (! defined $item) {
87                    $item='';
88            }
89    
90          if ($html) {          if ($html) {
91                  $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;
92                  $condition=~s{unfixed}{<b>unfixed</b>}g;                  $condition=~s{unfixed}{<b>unfixed</b>}g;
93                  $item=~s#((?:CAN|CVE)-\d+-\d+)#<a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=$1">$1</a>#g;                  $item=~s#(CVE-\d+-\d+)#<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=$1">$1</a>#g;
94                    $item=~s#(DTSA-\d+-\d+)#<a href="http://testing-security.debian.net/DTSA/$1.html">$1</a>#g;
95          }          }
96    
97          push @{$data{$package}{$condition}}, {item => $item, urgency => $urgency};          push @{$data{$package}{$condition}}, {item => $item, urgency => $urgency};
# Line 93  foreach my $list (@ARGV) { Line 105  foreach my $list (@ARGV) {
105                  $list="$list/list";                  $list="$list/list";
106          }          }
107    
108            my $id;
109          open (IN, $list) || die "open $list: $!";          open (IN, $list) || die "open $list: $!";
110          while (<IN>) {          while (<IN>) {
                 my $id;  
111                  print STDERR "line: $_" if $debug;                  print STDERR "line: $_" if $debug;
112                  chomp;                  chomp;
113                  if (/\s+TODO/) { # It's a todo item. Add it to the count, and ignore it                  if (/\s+TODO/) { # It's a todo item. Add it to the count, and ignore it
114                          $todos++;                          $todos++;
115                  }                  }
116                  elsif (/^\[/) { # Checking adv. number for a line starting with [ : Set $id to it                  elsif (/^\[/) { # Checking adv. number for a line starting with [ : Set $id to it
117                          ($id)=m/((?:DSA|DTSA|CAN|CVE)-[^\s]+) /;                          ($id)=m/((?:DSA|DTSA|CVE)-[^\s]+) /;
118                  }                  }
119                  elsif (/^((?:DSA|DTSA|CAN|CVE)-[^\s]+)/) { # Check for a line with an advisory at the start : Set $id to it                  elsif (/^((?:DSA|DTSA|CVE)-[^\s]+)/) { # Check for a line with an advisory at the start : Set $id to it
120                          $id=$1;                          $id=$1;
121                  }                  }
122                  elsif (/^\s+[!-]\s+(\S+)\s+(.*?)\s*$/) { # Deal with the rest of the lines                  elsif (/^\s+\[\w+\]\s+/) { # line tagged with a debian codename
123                            next; # don't handle these for now
124                    }
125                    elsif (/^\s+(?:\[\w+\]\s+)?[!-]\s+(\S+)\s+(.*?)\s*$/) { # Deal with the rest of the lines
126                          my $package=$1; # We know which package it is.                          my $package=$1; # We know which package it is.
127                          my $rest=$2;                          my $rest=$2;
128                          my $version;                          my $version;
# Line 127  foreach my $list (@ARGV) { Line 142  foreach my $list (@ARGV) {
142    
143                          # by now, we also have the version that's affected by the security problem.                          # by now, we also have the version that's affected by the security problem.
144                          # This is stored in $version                          # This is stored in $version
145                            next if $version eq '<not-affected>' || $version eq '<removed>' || $version eq '<no-dsa>';
146    
147                          my @notes=split(/\s*;\s+/, $notes);                          my @notes=split(/\s*;\s+/, $notes);
148    
149                          # Fetch the urgency, if we can.                          # Fetch the urgency, if we can.
# Line 139  foreach my $list (@ARGV) { Line 155  foreach my $list (@ARGV) {
155                                          last;                                          last;
156                                  }                                  }
157                          }                          }
158                            next if $urgency eq 'unimportant';
159    
160                          # It's a kernel. Add it to the list of kernels that need to be looked at.                          # It's a kernel. Add it to the list of kernels that need to be looked at.
161                          if ($package=~/kernel-source-([0-9.]+)/) {                          if ($package=~/kernel-source-([0-9.]+)/ && $version ne '<unfixed>') {
162                                  my $kernversion=$1;                                  my $kernversion=$1;
163                                  if (exists $needkernel{$kernversion} &&                                  if (exists $needkernel{$kernversion} &&
164                                      length $version &&                                      length $version &&
# Line 150  foreach my $list (@ARGV) { Line 167  foreach my $list (@ARGV) {
167                                  }                                  }
168                          }                          }
169    
170                          # Fire up madison.                          # Fire up dak ls.
171                          my @maddy;                          my @maddy;
172                          for (1..5) {                          for (1..5) {
173                                  @maddy=`madison -s '$suite' '$package'`;                                  @maddy=`dak ls -s '$suite' '$package'`;
174                                  if ($? & 127 || ($? >> 8 != 0 && $? >> 8 != 1)) {                                  if ($? & 127 || ($? >> 8 != 0 && $? >> 8 != 1)) {
175                                          # good old unrelaible newraff,                                          # good old unrelaible newraff,
176                                          # home of our archive..                                          # home of our archive..
# Line 162  foreach my $list (@ARGV) { Line 179  foreach my $list (@ARGV) {
179                                  last;                                  last;
180                          }                          }
181                          if ($? & 127) {                          if ($? & 127) {
182                                  record($package, "<em>[madison segfaulted 5 times in a row.. Medic!]</em>", $id);                                  record($package, "<em>[dak ls segfaulted 5 times in a row.. Medic!]</em>", $id);
183                          }                          }
184                          elsif ($? >> 8 != 0 && $? >> 8 != 1) {                          elsif ($? >> 8 != 0 && $? >> 8 != 1) {
185                                  record($package, "<em>[madison exited with ".($? >> 8)."]</em>", $id);                                  record($package, "<em>[dak ls exited with ".($? >> 8)."]</em>", $id);
186                          }                          }
187                          if (! @maddy) {                          if (! @maddy) {
188                                  next;                                  next;
189                          }                          }
190    
191                          if (grep { $_ eq 'unfixed' || $_ eq 'pending' } @notes) {                          if ($version eq '<unfixed>' || grep { $_ eq 'pending' } @notes) {
192                                  record($package, '('.join("; ", @notes).')', $id, $urgency);                                  record($package, '('.join("; ", "unfixed", @notes).')', $id, $urgency);
193                                  $unfixed++;                                  $unfixed++;
194                                  # It's not been fixed!                                  # It's not been fixed!
195                          }                          }
# Line 183  foreach my $list (@ARGV) { Line 200  foreach my $list (@ARGV) {
200                                          my $arches=$fields[3];                                          my $arches=$fields[3];
201                                          $version=~s/\s+//; # strip whitespace                                          $version=~s/\s+//; # strip whitespace
202                                          $arches=~s/\s+$//;                                          $arches=~s/\s+$//;
203                                          # Is the version in the archive greater than the version that's vulnerable?                                          next if $arches eq 'hurd-i386';
204                                            # Is the version in the archive the same or newer than the fix?
205                                          my $cmp=system("dpkg --compare-versions '$havver' '>=' '$version'");                                          my $cmp=system("dpkg --compare-versions '$havver' '>=' '$version'");
206                                          if ($cmp != 0){ # No, so the archive is vulnerable.                                          if ($cmp != 0){ # No, so the archive is vulnerable.
                                                 my $starchive = "";  
   
207                                                  # Does the version exist in the secure-testing archive?                                                  # Does the version exist in the secure-testing archive?
208                                                  my $staversion = `zcat $stasources |grep-dctrl -F Package -e ^$package\$ -s Version -`;                                                  my $staversion = `zcat $stasources |grep-dctrl -F Package -e ^$package\$ -s Version -`;
209                                                  chomp $staversion;                                                  chomp $staversion;
# Line 199  foreach my $list (@ARGV) { Line 215  foreach my $list (@ARGV) {
215                                                          if ($stacmp == 0){                                                          if ($stacmp == 0){
216                                                                  # Well, the version in the s-t archive fixes the issue                                                                  # Well, the version in the s-t archive fixes the issue
217                                                                  # but it's still vulnerable in the main archive                                                                  # but it's still vulnerable in the main archive
218                                                                  $starchive = " (fixed in $staversion in the secure-testing archive)";                                                                  $urgency='fixed';
219                                                                  $fixedsta++;                                                                  $fixedsta++;
220                                                          }                                                          }
221                                                  }                                                  }
# Line 207  foreach my $list (@ARGV) { Line 223  foreach my $list (@ARGV) {
223                                                  if ($html && $suite eq 'testing') {                                                  if ($html && $suite eq 'testing') {
224                                                          $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>';
225                                                  }                                                  }
226                                                  record($package, "$version needed, have $havver".(@maddy > 1 ? " [$arches]" : "").$starchive, $id, $urgency);                                                  record($package, "$version needed, have $havver".(@maddy > 1 ? " [$arches]" : ""), $id, $urgency);
227                                                  $unprop++;                                                  $unprop++;
228                                                  $unprop_all++ unless @maddy > 1;                                                  $unprop_all++ unless @maddy > 1;
229                                          }                                          }
# Line 246  my %needkern; Line 262  my %needkern;
262  foreach my $version (sort keys %needkernel) {  foreach my $version (sort keys %needkernel) {
263          my %images;          my %images;
264    
265          if ($needkern{$version} eq "0") {          if (defined $needkern{$version} && $needkern{$version} eq "0") {
266                  next;                  next;
267          }          }
268    
# Line 260  foreach my $version (sort keys %needkern Line 276  foreach my $version (sort keys %needkern
276          my $haveversion;          my $haveversion;
277    
278          foreach my $line (@dctrl) {          foreach my $line (@dctrl) {
279                  chomp;                  chomp $line;
280                  if ($line=~/Package:\s*(\S+)/) {                  if ($line=~/Package:\s*(\S+)/) {
281                          $package=$1;                          $package=$1;
282                          $haveversion="0";                          $haveversion="0";
# Line 284  foreach my $version (sort keys %needkern Line 300  foreach my $version (sort keys %needkern
300                          print OUT "<li>" if ($html && $list_unknown);                          print OUT "<li>" if ($html && $list_unknown);
301                          print OUT "$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;
302                  } elsif (!system("dpkg --compare-versions $needkernel{$version} gt $images{$package}")) {                  } elsif (!system("dpkg --compare-versions $needkernel{$version} gt $images{$package}")) {
303                  print OUT "<li>" if $html;                          print OUT "<li>" if $html;
304                          print OUT "$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";
305                          $need_rebuild++;                          $need_rebuild++;
306                  }                  }
# Line 299  if ($html) { Line 315  if ($html) {
315          print OUT "<hr>\n";          print OUT "<hr>\n";
316          print OUT "Key: ";          print OUT "Key: ";
317          foreach my $keyline (@urgencies) {          foreach my $keyline (@urgencies) {
318                    next if $keyline eq 'unimportant';
319                  print OUT "<span style=\"border: 1px dashed; background:".$colormap{$keyline}."\">&nbsp;$keyline&nbsp;</span> ";                  print OUT "<span style=\"border: 1px dashed; background:".$colormap{$keyline}."\">&nbsp;$keyline&nbsp;</span> ";
320          }          }
321          print OUT "<br>";          print OUT "<br>";
322          print OUT "Total holes unfixed: $unfixed<br>\n";          print OUT "Total holes unfixed: $unfixed<br>\n";
323          print OUT "Total holes fixed in unstable but not $suite: $unprop_all ($fixedsta fixed in secure-testing archive)";          print OUT "Total holes fixed in unstable (or experimental) but not $suite: $unprop_all ($fixedsta fixed in secure-testing archive)";
324          if ($unprop_all != $unprop) {          if ($unprop_all != $unprop) {
325                  print OUT " (+".($unprop - $unprop_all)." on some arches)";                  print OUT " (+".($unprop - $unprop_all)." on some arches)";
326          }          }
327          print OUT "<br>\n";          print OUT "<br>\n";
328          print OUT "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";
329          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";          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";
330          print OUT "Maintained by the <a href=\"http://secure-testing.debian.net/\">testing security team</a><br>\n";          print OUT "Maintained by the <a href=\"http://testing-security.debian.net/\">testing security team</a><br>\n";
331          print OUT "Last update: ".`date`."<br>\n";          print OUT "Last update: ".`date`."<br>\n";
332          print OUT "</html>\n";          print OUT "</html>\n";
333  }  }
# Line 319  close OUT; Line 336  close OUT;
336  if (defined $output) {  if (defined $output) {
337          rename("$output.tmp.$$", $output) || die "rename: $!";          rename("$output.tmp.$$", $output) || die "rename: $!";
338  }  }
339    unlink $stasources;

Legend:
Removed from v.1766  
changed lines
  Added in v.7489

  ViewVC Help
Powered by ViewVC 1.1.5