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

Diff of /bin/updatelist

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

revision 2457 by joeyh, Mon Oct 17 22:24:52 2005 UTC revision 2458 by joeyh, Wed Oct 19 22:54:03 2005 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl
2  my $full_can_html=shift;  my $html=shift;
3  my $dsa_list=shift;  my $dsa_list=shift;
4  my $dtsa_list=shift;  my $dtsa_list=shift;
5  my $our_list=shift;  my $our_list=shift;
6    
7  my %cans;  my %cves;
8    
9  sub read_dsa {  sub read_dsa {
10          my $list=shift;          my $list=shift;
# Line 15  sub read_dsa { Line 15  sub read_dsa {
15                  if (/^\[/) {                  if (/^\[/) {
16                          ($dsa)=m/(DT?SA-.*?) /;                          ($dsa)=m/(DT?SA-.*?) /;
17                  }                  }
18                  if (/\{\s*(CAN|CVE)/) {                  if (/\{\s*(CVE)/) {
19                          my ($canlist)=m/\{(.*)\}/;                          my ($cvelist)=m/\{(.*)\}/;
20                          foreach my $can (split ' ', $canlist) {                          foreach my $cve (split ' ', $cvelist) {
21                                  $can=~s/CVE-/CAN-/g;                                  next unless $cve=~/^CVE-\d+/;
22                                  next unless $can=~/^CAN-\d+/;                                  $cves{$cve}{cve}=$cve;
23                                  $cans{$can}{can}=$can;                                  push @{$cves{$cve}{dsa}}, $dsa;
                                 push @{$cans{$can}{dsa}}, $dsa;  
                                 $can=~s/CAN-/CVE-/g;  
                                 $cans{$can}{can}=$can;  
                                 push @{$cans{$can}{dsa}}, $dsa;  
24                          }                          }
25                  }                  }
26          }          }
# Line 33  sub read_dsa { Line 29  sub read_dsa {
29  read_dsa($dsa_list);  read_dsa($dsa_list);
30  read_dsa($dtsa_list);  read_dsa($dtsa_list);
31    
32  my %listedcans;  my %listedcves;
33    
34  open (FULL_CAN, "<$full_can_html") || die "$full_can_html: $!\n";  open (HTML, "<$html") || die "$html: $!\n";
35  my $can;  my $cve;
36  while (<FULL_CAN>) {  while (<HTML>) {
37          if (m!<b>(CAN-\d+-\d+)</b>!) {          if (m!<b>(CVE-\d+-\d+)</b>!) {
38                  $can=$1;                  $cve=$1;
39                  $cans{$can}{can}=$can;                  $cves{$cve}{cve}=$cve;
40                  $listedcans{$can}=1;                  $listedcves{$cve}=1;
         }  
         elsif (m!<b>(CVE-\d+-\d+)</b>!) {  
                 $can=$1;  
                 $cans{$can}{can}=$can;  
                 $listedcans{$can}=1;  
41          }          }
42          if (m!\*\*\s+RESERVED\s+\*\*!) {          if (m!\*\*\s+RESERVED\s+\*\*!) {
43                  $cans{$can}{reserved}=1;                  $cves{$cve}{reserved}=1;
44    
45          }          }
46          if (m!\*\*\s+REJECT\s+\*\*!) {          if (m!\*\*\s+REJECT\s+\*\*!) {
47                  $cans{$can}{rejected}=1;                  $cves{$cve}{rejected}=1;
48          }          }
49          if (m!Description:\s*</b><br>\s*(.*)! &&          if (m!Description:\s*</b><br>\s*(.*)! &&
50                  ! m!\*\*\s+RESERVED\s+\*\*! && ! m!\*\*\s+REJECT\s+\*\*!) {                  ! m!\*\*\s+RESERVED\s+\*\*! && ! m!\*\*\s+REJECT\s+\*\*!) {
51                  $cans{$can}{description}="($1 ...)";                  $cves{$cve}{description}="($1 ...)";
52          }          }
53  }  }
54  close FULL_CAN;  close HTML;
55    
56  my $stopped=0;  my $stopped=0;
57  my @out;  my @out;
58    
59  sub docan {  sub docve {
60          my $can=shift;          my $cve=shift;
61    
62          push @out, "$can".(length $cans{$can}{description} ? " ".$cans{$can}{description} : "")."\n";          push @out, "$cve".(length $cves{$cve}{description} ? " ".$cves{$cve}{description} : "")."\n";
63          if ($cans{$can}{reserved}) {          if ($cves{$cve}{reserved}) {
64                  push @out, "\tRESERVED\n";                  push @out, "\tRESERVED\n";
65          }          }
66          if ($cans{$can}{rejected}) {          if ($cves{$cve}{rejected}) {
67                  push @out, "\tREJECTED\n";                  push @out, "\tREJECTED\n";
68          }          }
69          if ($cans{$can}{dsa}) {          if ($cves{$cve}{dsa}) {
70                  push @out, "\t{".join(" ", @{$cans{$can}{dsa}})."}\n";                  push @out, "\t{".join(" ", @{$cves{$cve}{dsa}})."}\n";
71          }          }
72          if ($cans{$can}{notes}) {          if ($cves{$cve}{notes}) {
73                  foreach (@{$cans{$can}{notes}}) {                  foreach (@{$cves{$cve}{notes}}) {
74                          push @out, "\t$_\n";                          push @out, "\t$_\n";
75                  }                  }
76          }          }
77          if (! $cans{$can}{reserved} && ! $cans{$can}{rejected} &&          if (! $cves{$cve}{reserved} && ! $cves{$cve}{rejected} &&
78              ! $cans{$can}{dsa} && ! $cans{$can}{notes} &&              ! $cves{$cve}{dsa} && ! $cves{$cve}{notes} &&
79              ! $stopped) {              ! $stopped) {
80                  push @out, "\tTODO: check\n";                  push @out, "\tTODO: check\n";
81          }          }
82    
83          delete $cans{$can};          delete $cves{$cve};
84  }  }
85    
86  open (IN, "<$our_list") || die "$our_list: $!\n";  open (IN, "<$our_list") || die "$our_list: $!\n";
87  my $can;  my $cve;
88  while (<IN>) {  while (<IN>) {
89          chomp;          chomp;
90          if (/^((?:CAN|CVE)-(?:[0-9]+|[A-Z]+)-(?:[0-9]+|[A-Z]+))\s*(.*)/) {          if (/^(CVE-(?:[0-9]+|[A-Z]+)-(?:[0-9]+|[A-Z]+))\s*(.*)/) {
91                  my $desc=$2;                  my $desc=$2;
92                  docan($can) if $can;                  docve($cve) if $cve;
93                  $can=$1;                  $cve=$1;
94                  if (length $desc && $desc !~ /^\(.*\)$/ &&                  if (length $desc && $desc !~ /^\(.*\)$/ &&
95                      (! exists $cans{$can}{description} ||                      (! exists $cves{$cve}{description} ||
96                       ! length $cans{$can}{description})) {                       ! length $cves{$cve}{description})) {
97                          $cans{$can}{description}=$desc;                          $cves{$cve}{description}=$desc;
98                  }                  }
99          }          }
100          elsif (/^\s+(RESERVED|REJECTED)\s*$/) {          elsif (/^\s+(RESERVED|REJECTED)\s*$/) {
# Line 115  while (<IN>) { Line 106  while (<IN>) {
106          elsif (/^\s+{DT?SA.*/) {          elsif (/^\s+{DT?SA.*/) {
107                  # skip                  # skip
108          }          }
109          elsif (/^\s+(.*)/ && $can) {          elsif (/^\s+(.*)/ && $cve) {
110                  push @{$cans{$can}{notes}}, $1;                  push @{$cves{$cve}{notes}}, $1;
111          }          }
112          elsif (/^STOP/) {          elsif (/^STOP/) {
113                  docan($can) if $can;                  docve($cve) if $cve;
114                  push @out, "$_\n";                  push @out, "$_\n";
115                  $stopped=1;                  $stopped=1;
116                  $can='';                  $cve='';
117          }          }
118          else {          else {
119                  docan($can) if $can;                  docve($cve) if $cve;
120                  push @out, "$_\n" if length $_;                  push @out, "$_\n" if length $_;
121                  $can='';                  $cve='';
122          }          }
123  }  }
124  close IN;  close IN;
125  docan($can) if $can;  docve($cve) if $cve;
126    
127  foreach my $can (reverse sort { $cans{$a}{can} cmp $cans{$b}{can} } keys %cans) {  foreach my $cve (reverse sort { $cves{$a}{cve} cmp $cves{$b}{cve} } keys %cves) {
128          next unless $listedcans{$can};          next unless $listedcves{$cve};
129          print $can.(length $cans{$can}{description} ? " ".$cans{$can}{description} : "")."\n";          print $cve.(length $cves{$cve}{description} ? " ".$cves{$cve}{description} : "")."\n";
130          if ($cans{$can}{reserved}) {          if ($cves{$cve}{reserved}) {
131                  print "\tRESERVED\n";                  print "\tRESERVED\n";
132          }          }
133          if ($cans{$can}{rejected}) {          if ($cves{$cve}{rejected}) {
134                  print "\tREJECTED\n";                  print "\tREJECTED\n";
135          }          }
136          if ($cans{$can}{dsa}) {          if ($cves{$cve}{dsa}) {
137                  print "\t{".join(" ", @{$cans{$can}{dsa}})."}\n";                  print "\t{".join(" ", @{$cves{$cve}{dsa}})."}\n";
138          }          }
139          if (!$cans{$can}{reserved} || $cans{$can}{rejected} || $cans{$can}{dsa}) {          if (!$cves{$cve}{reserved} || $cves{$cve}{rejected} || $cves{$cve}{dsa}) {
140                  print "\tTODO: check\n";                  print "\tTODO: check\n";
141          }          }
142  }  }

Legend:
Removed from v.2457  
changed lines
  Added in v.2458

  ViewVC Help
Powered by ViewVC 1.1.5