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