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

Contents of /bin/updatelist

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2467 - (show annotations) (download)
Wed Oct 19 23:53:49 2005 UTC (7 years, 8 months ago) by joeyh
File size: 3048 byte(s)
update for slight html changes (really should use the xml..)
1 #!/usr/bin/perl
2 my $html=shift;
3 my $dsa_list=shift;
4 my $dtsa_list=shift;
5 my $our_list=shift;
6
7 my %cves;
8
9 sub read_dsa {
10 my $list=shift;
11
12 open (DSA, "<$list") || die "$list: $!\n";
13 my $dsa;
14 while (<DSA>) {
15 if (/^\[/) {
16 ($dsa)=m/(DT?SA-.*?) /;
17 }
18 if (/\{\s*(CVE)/) {
19 my ($cvelist)=m/\{(.*)\}/;
20 foreach my $cve (split ' ', $cvelist) {
21 next unless $cve=~/^CVE-\d+/;
22 $cves{$cve}{cve}=$cve;
23 push @{$cves{$cve}{dsa}}, $dsa;
24 }
25 }
26 }
27 close DSA;
28 }
29 read_dsa($dsa_list);
30 read_dsa($dtsa_list);
31
32 my %listedcves;
33
34 open (HTML, "<$html") || die "$html: $!\n";
35 my $cve;
36 while (<HTML>) {
37 if (m!<b>Name:\s+(CVE-\d+-\d+)</b>!) {
38 $cve=$1;
39 $cves{$cve}{cve}=$cve;
40 $listedcves{$cve}=1;
41 }
42 if (m!\*\*\s+RESERVED\s+\*\*!) {
43 $cves{$cve}{reserved}=1;
44
45 }
46 if (m!\*\*\s+REJECT\s+\*\*!) {
47 $cves{$cve}{rejected}=1;
48 }
49 if (m!Description:\s*</b><br>\s*(.*)! &&
50 ! m!\*\*\s+RESERVED\s+\*\*! && ! m!\*\*\s+REJECT\s+\*\*!) {
51 my $desc;
52 $desc=$1;
53 if (! length $desc) {
54 $desc=<HTML>;
55 chomp $desc;
56 }
57 $cves{$cve}{description}="($desc ...)";
58 }
59 }
60 close HTML;
61
62 my $stopped=0;
63 my @out;
64
65 sub docve {
66 my $cve=shift;
67
68 push @out, "$cve".(length $cves{$cve}{description} ? " ".$cves{$cve}{description} : "")."\n";
69 if ($cves{$cve}{reserved}) {
70 push @out, "\tRESERVED\n";
71 }
72 if ($cves{$cve}{rejected}) {
73 push @out, "\tREJECTED\n";
74 }
75 if ($cves{$cve}{dsa}) {
76 push @out, "\t{".join(" ", @{$cves{$cve}{dsa}})."}\n";
77 }
78 if ($cves{$cve}{notes}) {
79 foreach (@{$cves{$cve}{notes}}) {
80 push @out, "\t$_\n";
81 }
82 }
83 if (! $cves{$cve}{reserved} && ! $cves{$cve}{rejected} &&
84 ! $cves{$cve}{dsa} && ! $cves{$cve}{notes} &&
85 ! $stopped) {
86 push @out, "\tTODO: check\n";
87 }
88
89 delete $cves{$cve};
90 }
91
92 open (IN, "<$our_list") || die "$our_list: $!\n";
93 my $cve;
94 while (<IN>) {
95 chomp;
96 if (/^(CVE-(?:[0-9]+|[A-Z]+)-(?:[0-9]+|[A-Z]+))\s*(.*)/) {
97 my $desc=$2;
98 docve($cve) if $cve;
99 $cve=$1;
100 if (length $desc && $desc !~ /^\(.*\)$/ &&
101 (! exists $cves{$cve}{description} ||
102 ! length $cves{$cve}{description})) {
103 $cves{$cve}{description}=$desc;
104 }
105 }
106 elsif (/^\s+(RESERVED|REJECTED)\s*$/) {
107 # skip it
108 }
109 elsif (/^\s+NOTE: covered by DT?SA.*/) {
110 # skip it (old form)
111 }
112 elsif (/^\s+{DT?SA.*/) {
113 # skip
114 }
115 elsif (/^\s+(.*)/ && $cve) {
116 push @{$cves{$cve}{notes}}, $1;
117 }
118 elsif (/^STOP/) {
119 docve($cve) if $cve;
120 push @out, "$_\n";
121 $stopped=1;
122 $cve='';
123 }
124 else {
125 docve($cve) if $cve;
126 push @out, "$_\n" if length $_;
127 $cve='';
128 }
129 }
130 close IN;
131 docve($cve) if $cve;
132
133 foreach my $cve (reverse sort { $cves{$a}{cve} cmp $cves{$b}{cve} } keys %cves) {
134 next unless $listedcves{$cve};
135 print $cve.(length $cves{$cve}{description} ? " ".$cves{$cve}{description} : "")."\n";
136 if ($cves{$cve}{reserved}) {
137 print "\tRESERVED\n";
138 }
139 if ($cves{$cve}{rejected}) {
140 print "\tREJECTED\n";
141 }
142 if ($cves{$cve}{dsa}) {
143 print "\t{".join(" ", @{$cves{$cve}{dsa}})."}\n";
144 }
145 if (!$cves{$cve}{reserved} || $cves{$cve}{rejected} || $cves{$cve}{dsa}) {
146 print "\tTODO: check\n";
147 }
148 }
149
150 print @out;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5