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

Contents of /bin/updatelist

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5001 - (hide annotations) (download)
Wed Nov 22 22:42:18 2006 UTC (6 years, 6 months ago) by stef-guest
File size: 3007 byte(s)
- bugfix: we need to add "TODO: check" even if the CVE was know from a DSA before appearing at mitre
- use gzipped version of allitems.html to save bandwidth
1 joeyh 2 #!/usr/bin/perl
2 joeyh 2458 my $html=shift;
3 joeyh 2 my $dsa_list=shift;
4 joeyh 1660 my $dtsa_list=shift;
5 joeyh 159 my $our_list=shift;
6 joeyh 2
7 joeyh 2458 my %cves;
8 joeyh 2
9 joeyh 1660 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 joeyh 2 }
18 joeyh 2458 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 joeyh 1660 }
25     }
26 joeyh 2 }
27 joeyh 1660 close DSA;
28 joeyh 2 }
29 joeyh 1660 read_dsa($dsa_list);
30     read_dsa($dtsa_list);
31 joeyh 2
32 joeyh 2458 my %listedcves;
33 joeyh 29
34 joeyh 2458 open (HTML, "<$html") || die "$html: $!\n";
35     my $cve;
36     while (<HTML>) {
37 joeyh 2467 if (m!<b>Name:\s+(CVE-\d+-\d+)</b>!) {
38 joeyh 2458 $cve=$1;
39     $cves{$cve}{cve}=$cve;
40     $listedcves{$cve}=1;
41 joeyh 2 }
42     if (m!\*\*\s+RESERVED\s+\*\*!) {
43 joeyh 2458 $cves{$cve}{reserved}=1;
44 joeyh 2
45     }
46     if (m!\*\*\s+REJECT\s+\*\*!) {
47 joeyh 2458 $cves{$cve}{rejected}=1;
48 joeyh 2 }
49 joeyh 200 if (m!Description:\s*</b><br>\s*(.*)! &&
50     ! m!\*\*\s+RESERVED\s+\*\*! && ! m!\*\*\s+REJECT\s+\*\*!) {
51 joeyh 2467 my $desc;
52     $desc=$1;
53     if (! length $desc) {
54     $desc=<HTML>;
55     chomp $desc;
56     }
57     $cves{$cve}{description}="($desc ...)";
58 joeyh 200 }
59 joeyh 2 }
60 joeyh 2458 close HTML;
61 joeyh 159
62 joeyh 161 my $stopped=0;
63     my @out;
64    
65 joeyh 2458 sub docve {
66     my $cve=shift;
67 joeyh 161
68 joeyh 2458 push @out, "$cve".(length $cves{$cve}{description} ? " ".$cves{$cve}{description} : "")."\n";
69     if ($cves{$cve}{reserved}) {
70 joeyh 2161 push @out, "\tRESERVED\n";
71 joeyh 161 }
72 joeyh 2458 if ($cves{$cve}{rejected}) {
73 joeyh 2161 push @out, "\tREJECTED\n";
74 joeyh 161 }
75 joeyh 2458 if ($cves{$cve}{dsa}) {
76     push @out, "\t{".join(" ", @{$cves{$cve}{dsa}})."}\n";
77 joeyh 161 }
78 joeyh 2458 if ($cves{$cve}{notes}) {
79     foreach (@{$cves{$cve}{notes}}) {
80 joeyh 161 push @out, "\t$_\n";
81     }
82     }
83 joeyh 2458 if (! $cves{$cve}{reserved} && ! $cves{$cve}{rejected} &&
84 stef-guest 5001 ! $cves{$cve}{notes} &&
85 joeyh 161 ! $stopped) {
86     push @out, "\tTODO: check\n";
87     }
88    
89 joeyh 2458 delete $cves{$cve};
90 joeyh 161 }
91    
92 joeyh 159 open (IN, "<$our_list") || die "$our_list: $!\n";
93 joeyh 2458 my $cve;
94 joeyh 159 while (<IN>) {
95     chomp;
96 joeyh 2458 if (/^(CVE-(?:[0-9]+|[A-Z]+)-(?:[0-9]+|[A-Z]+))\s*(.*)/) {
97 joeyh 200 my $desc=$2;
98 joeyh 2458 docve($cve) if $cve;
99     $cve=$1;
100 joeyh 1241 if (length $desc && $desc !~ /^\(.*\)$/ &&
101 joeyh 2458 (! exists $cves{$cve}{description} ||
102     ! length $cves{$cve}{description})) {
103     $cves{$cve}{description}=$desc;
104 joeyh 1241 }
105 joeyh 2 }
106 joeyh 2168 elsif (/^\s+(RESERVED|REJECTED)\s*$/) {
107 joeyh 159 # skip it
108 joeyh 2 }
109 joeyh 1660 elsif (/^\s+NOTE: covered by DT?SA.*/) {
110 joeyh 159 # skip it (old form)
111 joeyh 2 }
112 joeyh 1660 elsif (/^\s+{DT?SA.*/) {
113 joeyh 161 # skip
114     }
115 joeyh 2458 elsif (/^\s+(.*)/ && $cve) {
116     push @{$cves{$cve}{notes}}, $1;
117 joeyh 159 }
118     elsif (/^STOP/) {
119 joeyh 2458 docve($cve) if $cve;
120 joeyh 161 push @out, "$_\n";
121     $stopped=1;
122 joeyh 2458 $cve='';
123 joeyh 159 }
124     else {
125 joeyh 2458 docve($cve) if $cve;
126 joeyh 161 push @out, "$_\n" if length $_;
127 joeyh 2458 $cve='';
128 joeyh 159 }
129 joeyh 2 }
130 joeyh 161 close IN;
131 joeyh 2458 docve($cve) if $cve;
132 joeyh 161
133 joeyh 2458 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 joeyh 2431 print "\tRESERVED\n";
138 joeyh 161 }
139 joeyh 2458 if ($cves{$cve}{rejected}) {
140 joeyh 2431 print "\tREJECTED\n";
141 joeyh 161 }
142 joeyh 2458 if ($cves{$cve}{dsa}) {
143     print "\t{".join(" ", @{$cves{$cve}{dsa}})."}\n";
144 joeyh 161 }
145 stef-guest 5001 if (!$cves{$cve}{reserved} || $cves{$cve}{rejected} ) {
146 joeyh 161 print "\tTODO: check\n";
147     }
148 joeyh 159 }
149 joeyh 161
150     print @out;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5