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

Diff of /bin/checklist

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

revision 1762 by neilm, Wed Aug 31 16:53:15 2005 UTC revision 1763 by neilm, Thu Sep 1 17:50:06 2005 UTC
# Line 15  if (! GetOptions( Line 15  if (! GetOptions(
15                  "html" => \$html,                  "html" => \$html,
16                  "debug" => \$debug,                  "debug" => \$debug,
17                  "suite=s" => \$suite,                  "suite=s" => \$suite,
18                    "sta=s" => \$sta,
19                  "output=s", \$output)                  "output=s", \$output)
20      || ! @ARGV) {      || ! @ARGV) {
21          die "usage: $0 [--suite suite] [--html] [--output=file] [--debug] advisorylist dtsalist...\n";          die "usage: $0 [--suite suite] [--sta sta-mirror] [--html] [--output=file] [--debug] list ...\n";
22  }  }
23    
24    my $sta = "http://secure-testing.debian.net/debian-security-updates/dists/testing/security-updates/main/source/Sources.gz";
25    
26    system("wget -q -O /tmp/Sources.sta.gz $sta");
27    
28  if (defined $output) {  if (defined $output) {
29          open (OUT, ">$output.tmp.$$") || die "output.tmp.$$: $!";          open (OUT, ">$output.tmp.$$") || die "output.tmp.$$: $!"; # Set the output to a file
30  }  }
31  else {  else {
32          open (OUT, ">&STDOUT");          open (OUT, ">&STDOUT"); # Set the output to stdout
33  }  }
34    
35  if ($html) {  if ($html) { # It's HTML, so we need a header
36          print OUT "<html><title>$suite security issues</title>\n";          print OUT "<html><title>$suite security issues</title>\n";
37          if ($suite ne 'testing' && $suite ne 'unstable') {  
38            # This is being run against something it's not meant to be, so print a warning
39            if ($suite ne 'testing' && $suite ne 'unstable') {
40                  print OUT <<"EOF";                  print OUT <<"EOF";
41  <p>  <p>
42  <em>Warning:</em> This page is the result of running the testing security  <em>Warning:</em> This page is the result of running the testing security
# Line 45  EOF Line 52  EOF
52    
53    
54  my %data;  my %data;
55    my %advlist;
56  my %needkernel=qw/2.4.27 0 2.6.11 0/;  my %needkernel=qw/2.4.27 0 2.6.11 0/;
57  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
58  my $sources=$ENV{SOURCES_FILE};  my $sources=$ENV{SOURCES_FILE};
59  my $need_rebuild=0;  my $need_rebuild=0;
60    
61    # Set some colours for the urgency types
62  my @urgencies=("high", "medium", "low", "unknown");  my @urgencies=("high", "medium", "low", "unknown");
63  my %colormap=(  my %colormap=(
64          high => "#FF0000",          high => "#FF0000",
# Line 58  my %colormap=( Line 67  my %colormap=(
67          unknown => "#FFFF00"          unknown => "#FFFF00"
68  );  );
69    
70  my $unprop = my $unprop_all = my $unfixed = my $todos = 0;  my $unprop = my $unprop_all = my $unfixed = my $todos = my $fixedsta = 0;
71    
72    # Add an item into the data array.
73  sub record {  sub record {
74          my ($package, $condition, $item, $urgency)=@_;          my ($package, $condition, $item, $urgency)=@_;
75    
# Line 72  sub record { Line 82  sub record {
82          push @{$data{$package}{$condition}}, {item => $item, urgency => $urgency};          push @{$data{$package}{$condition}}, {item => $item, urgency => $urgency};
83  }  }
84    
85  die ("No DTSA list specified") if (! length @ARGV[1]);  foreach my $list (@ARGV) {
86  my $dtsalist = @ARGV[1];          # Each of the @ARGVs we've got passed need parsing. So lets do that
87  foreach my $list (@ARGV[0]) {  
88            # If it's a directory, set the file to list, cause we need that.
89          if (-d $list) {          if (-d $list) {
90                  $list="$list/list";                  $list="$list/list";
91          }          }
# Line 83  foreach my $list (@ARGV[0]) { Line 94  foreach my $list (@ARGV[0]) {
94          while (<IN>) {          while (<IN>) {
95                  print STDERR "line: $_" if $debug;                  print STDERR "line: $_" if $debug;
96                  chomp;                  chomp;
97                  if (/^\[/) {                  if (/\s+TODO/) { # It's a todo item. Add it to the count, and ignore it
98                            $todos++;
99                    }
100                    elsif (/^\[/) { # Checking adv. number for a line starting with [ : Set $id to it
101                          ($id)=m/((?:DSA|DTSA|CAN|CVE)-[^\s]+) /;                          ($id)=m/((?:DSA|DTSA|CAN|CVE)-[^\s]+) /;
102                  }                  }
103                  elsif (/^((?:DSA|DTSA|CAN|CVE)-[^\s]+)/) {                  elsif (/^((?:DSA|DTSA|CAN|CVE)-[^\s]+)/) { # Check for a line with an advisory at the start : Set $id to it
104                          $id=$1;                          $id=$1;
105                  }                  }
106                  elsif (/^\s+[!-]\s+(\S+)\s+(.*?)\s*$/) {                  elsif (/^\s+[!-]\s+(\S+)\s+(.*?)\s*$/) { # Deal with the rest of the lines
107                          my $package=$1;                          my $package=$1; # We know which package it is.
108                          my $rest=$2;                          my $rest=$2;
109                          my $version;                          my $version;
110                          my $notes;                          my $notes;
111                          if ($rest=~/([^\(\s]+)\s+\((.*)\)/) {                          if ($rest=~/([^\(\s]+)\s+\((.*)\)/) {
# Line 106  foreach my $list (@ARGV[0]) { Line 120  foreach my $list (@ARGV[0]) {
120                                  $version=$rest;                                  $version=$rest;
121                                  $notes="";                                  $notes="";
122                          }                          }
123    
124                            # by now, we also have the version that's affected by the security problem.
125                            # This is stored in $version
126    
127                          my @notes=split(/\s*;\s+/, $notes);                          my @notes=split(/\s*;\s+/, $notes);
128    
129                            # Fetch the urgency, if we can.
130                          my $urgency="unknown";                          my $urgency="unknown";
131                          foreach my $u (@urgencies) {                          foreach my $u (@urgencies) {
132                                  if (grep { $_ eq $u } @notes) {                                  if (grep { $_ eq $u } @notes) {
# Line 116  foreach my $list (@ARGV[0]) { Line 135  foreach my $list (@ARGV[0]) {
135                                          last;                                          last;
136                                  }                                  }
137                          }                          }
138    
139                            # It's a kernel. Add it to the list of kernels that need to be looked at.
140                          if ($package=~/kernel-source-([0-9.]+)/) {                          if ($package=~/kernel-source-([0-9.]+)/) {
141                                  my $kernversion=$1;                                  my $kernversion=$1;
142                                  if (exists $needkernel{$kernversion} &&                                  if (exists $needkernel{$kernversion} &&
# Line 126  foreach my $list (@ARGV[0]) { Line 146  foreach my $list (@ARGV[0]) {
146                                  }                                  }
147                          }                          }
148    
149                            # Fire up madison.
150                          my @maddy;                          my @maddy;
151                          for (1..5) {                          for (1..5) {
152                                  @maddy=`madison -s '$suite' '$package'`;                                  @maddy=`madison -s '$suite' '$package'`;
# Line 149  foreach my $list (@ARGV[0]) { Line 170  foreach my $list (@ARGV[0]) {
170                          if (grep { $_ eq 'unfixed' || $_ eq 'pending' } @notes) {                          if (grep { $_ eq 'unfixed' || $_ eq 'pending' } @notes) {
171                                  record($package, '('.join("; ", @notes).')', $id, $urgency);                                  record($package, '('.join("; ", @notes).')', $id, $urgency);
172                                  $unfixed++;                                  $unfixed++;
173                                    # It's not been fixed!
174                          }                          }
175                          else {                          else {
176                                  foreach my $maddy (@maddy) {                                  foreach my $maddy (@maddy) {
177                                          my @fields = split(/\s*\|\s*/, $maddy);                                          my @fields = split(/\s*\|\s*/, $maddy);
178                                          my $havver=$fields[1];                                          my $havver=$fields[1]; # It's this version in the archive I'm checking.
179                                          my $arches=$fields[3];                                          my $arches=$fields[3];
                                         my $dtsacmp=1;  
180                                          $version=~s/\s+//; # strip whitespace                                          $version=~s/\s+//; # strip whitespace
181                                          $arches=~s/\s+$//;                                          $arches=~s/\s+$//;
182                                          my $cmp=system("dpkg --compare-versions '$havver' '>=' '$version'");                                          my $starchive = "";
183    
184                                          my $dtsaver = `grep "\\- $package" $dtsalist|awk '{print \$3}'`;                                          # Is the version in the archive greater than the version that's vulnerable?
185                                          chomp $dtsaver;                                          my $cmp=system("dpkg --compare-versions '$havver' '>=' '$version'");
186                                          if (length($dtsaver)) {                                          if ($cmp != 0){ # No, so the archive is vulnerable.
                                                 my $hdcmp=system("dpkg --compare-versions '$havver' '>=' '$dtsaver'");  
                                                 if ($hdcmp != 0 && $vdcmp == 0) {  
                                                         record($package, "have $dtsaver in secure-testing archive, but $havver is in main archive",$id, $urgency);  
                                                 }  
                                                 $dtsacmp = 0;  
                                         }  
187    
188                                          if ($cmp != 0 && $dtsacmp !=0) {                                                  # Does the version exist in the secure-testing archive?
189                                                    my $staversion = `zcat /tmp/Sources.sta.gz |grep-dctrl -F Package -e ^$package\$ -s Version -`;
190                                                    chomp $staversion;
191                                                    $staversion=~s/Version: //;
192                                                    $staversion=~s/\s+//;
193                                                    if (length ($staversion)) {
194                                                            # Yes, but what version is in s-t?
195                                                            my $stacmp = system("dpkg --compare-versions '$staversion' '>=' '$version'");
196                                                            if ($stacmp == 0){
197                                                                    # Well, the version in the s-t archive fixes the issue
198                                                                    # but it's still vulnerable in the main archive
199                                                                    $starchive = " (fixed in $staversion in the secure-testing archive)";
200                                                                    $fixedsta++;
201                                                            }
202                                                    }
203    
204                                                  if ($html && $suite eq 'testing') {                                                  if ($html && $suite eq 'testing') {
205                                                          $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>';
206                                                  }                                                  }
207                                                  record($package, "$version needed, have $havver".(@maddy > 1 ? " [$arches]" : ""), $id, $urgency);                                                  record($package, "$version needed, have $havver".(@maddy > 1 ? " [$arches]" : "").$starchive, $id, $urgency);
208                                                  $unprop++;                                                  $unprop++;
209                                                  $unprop_all++ unless @maddy > 1;                                                  $unprop_all++ unless @maddy > 1;
210                                          }                                          }
211                                  }                                  }
212                          }                          }
213                  }                  }
                 elsif (/\s+TODO/) {  
                         $todos++;  
                 }  
214          }          }
215  }  }
216    
# Line 265  foreach my $version (sort keys %needkern Line 292  foreach my $version (sort keys %needkern
292  if ($html) {  if ($html) {
293          print OUT "</ul>\n";          print OUT "</ul>\n";
294          print OUT "<hr>\n";          print OUT "<hr>\n";
295            print OUT "Key: ";
296            foreach $keyline (@urgencies) {
297                    print OUT "<span style=\"border: 1px dashed; background:".$colormap{$keyline}."\">&nbsp;$keyline&nbsp;</span> ";
298            }
299            print OUT "<br>";
300          print OUT "Total holes unfixed: $unfixed<br>\n";          print OUT "Total holes unfixed: $unfixed<br>\n";
301          print OUT "Total holes fixed in unstable but not $suite: $unprop_all";          print OUT "Total holes fixed in unstable but not $suite: $unprop_all ($fixedsta fixed in secure-testing archive)";
302          if ($unprop_all != $unprop) {          if ($unprop_all != $unprop) {
303                  print OUT " (+".($unprop - $unprop_all)." on some arches)";                  print OUT " (+".($unprop - $unprop_all)." on some arches)";
304          }          }

Legend:
Removed from v.1762  
changed lines
  Added in v.1763

  ViewVC Help
Powered by ViewVC 1.1.5