/[secure-testing]/bin/bts-update
ViewVC logotype

Contents of /bin/bts-update

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2471 - (hide annotations) (download)
Thu Oct 20 04:58:38 2005 UTC (7 years, 7 months ago) by joeyh
File size: 1977 byte(s)
fix a bug in processing of multiple bugs in one line
1 joeyh 2468 #!/usr/bin/perl
2     use warnings;
3     use strict;
4    
5     my $user="debian-security\@lists.debian.org";
6     my $list=shift;
7     my $oldlist="$list.old";
8    
9     if (! -e $list) {
10     die "$list does not exist\n";
11     }
12     if (! -e $oldlist) {
13     die "$oldlist does not exist (touch it if running for first time)\n";
14     }
15    
16     my %old = processlist($oldlist);
17     my %new = processlist($list);
18    
19     # Build up a list of changes between the two lists.
20     my @changes;
21    
22     # Remove anything that is on both lists from both,
23     # so the lists only contain changes.
24     foreach my $bug (keys %old) {
25     foreach my $cve (keys %{$old{$bug}}) {
26     if (exists $new{$bug} && exists $new{$bug}{$cve}) {
27     delete $new{$bug}{$cve};
28     delete $old{$bug}{$cve};
29     }
30     }
31     }
32    
33     # Add tags for all new stuff.
34     foreach my $bug (keys %new) {
35     foreach my $cve (keys %{$new{$bug}}) {
36     push @changes, "usertag $bug + $cve"
37     unless $cve =~ /CVE-\d+-XXXX/;
38     push @changes, "usertag $bug + tracked";
39     }
40     }
41    
42     # Remove tags for all old stuff.
43     foreach my $bug (keys %old) {
44     foreach my $cve (keys %{$old{$bug}}) {
45     push @changes, "usertag $bug - $cve"
46     unless $cve =~ /CVE-\d+-XXXX/;
47     push @changes, "usertag $bug - tracked";
48     }
49     }
50    
51     if (system("cp", $list, $oldlist) != 0) {
52     die "failed to copy $list to $oldlist, didn't send any mail";
53     }
54    
55     if (@changes) {
56     open(MAIL, "| mail -s \"CVE usertag update\" control\@bugs.debian.org");
57     #open(MAIL, ">&STDOUT");
58     print MAIL "user $user\n";
59     print MAIL "$_\n" foreach @changes;
60     close MAIL;
61     }
62     print int(@changes)." tags changed\n";
63    
64     sub processlist {
65     my $list=shift;
66     my %ret;
67    
68     open (IN, $list) || die "read $list: $!\n";
69     my $cve;
70     while (<IN>) {
71     chomp;
72     if (/^(CVE-(?:[0-9]+|[A-Z]+)-(?:[0-9]+|[A-Z]+))\s*(.*)/) {
73     $cve=$1;
74     }
75     elsif (/\s+-\s+.*\((.*)\)/) {
76     my @notes=split(/\s*;\s+/, $1);
77     foreach my $note (@notes) {
78 joeyh 2471 if ($note =~ /bug #(\d+)/) {
79     if (! defined $cve) {
80     print STDERR "no cve for bug at line $.!\n";
81     next;
82     }
83 joeyh 2468 $ret{$1}{$cve}=1;
84     }
85     }
86     }
87     }
88     close IN;
89    
90     return %ret;
91     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5