From 2476aa8ce02a8b57c7945f9ddb28e7a343da2157 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 20 Oct 2005 00:40:22 +0000 Subject: add a program to manage usertags in the bts git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@2468 e39458fd-73e7-0310-bf30-c45bca0a0e42 --- bin/bts-update | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 bin/bts-update (limited to 'bin/bts-update') diff --git a/bin/bts-update b/bin/bts-update new file mode 100755 index 0000000000..483d4e2eae --- /dev/null +++ b/bin/bts-update @@ -0,0 +1,87 @@ +#!/usr/bin/perl +use warnings; +use strict; + +my $user="debian-security\@lists.debian.org"; +my $list=shift; +my $oldlist="$list.old"; + +if (! -e $list) { + die "$list does not exist\n"; +} +if (! -e $oldlist) { + die "$oldlist does not exist (touch it if running for first time)\n"; +} + +my %old = processlist($oldlist); +my %new = processlist($list); + +# Build up a list of changes between the two lists. +my @changes; + +# Remove anything that is on both lists from both, +# so the lists only contain changes. +foreach my $bug (keys %old) { + foreach my $cve (keys %{$old{$bug}}) { + if (exists $new{$bug} && exists $new{$bug}{$cve}) { + delete $new{$bug}{$cve}; + delete $old{$bug}{$cve}; + } + } +} + +# Add tags for all new stuff. +foreach my $bug (keys %new) { + foreach my $cve (keys %{$new{$bug}}) { + push @changes, "usertag $bug + $cve" + unless $cve =~ /CVE-\d+-XXXX/; + push @changes, "usertag $bug + tracked"; + } +} + +# Remove tags for all old stuff. +foreach my $bug (keys %old) { + foreach my $cve (keys %{$old{$bug}}) { + push @changes, "usertag $bug - $cve" + unless $cve =~ /CVE-\d+-XXXX/; + push @changes, "usertag $bug - tracked"; + } +} + +if (system("cp", $list, $oldlist) != 0) { + die "failed to copy $list to $oldlist, didn't send any mail"; +} + +if (@changes) { + open(MAIL, "| mail -s \"CVE usertag update\" control\@bugs.debian.org"); + #open(MAIL, ">&STDOUT"); + print MAIL "user $user\n"; + print MAIL "$_\n" foreach @changes; + close MAIL; +} +print int(@changes)." tags changed\n"; + +sub processlist { + my $list=shift; + my %ret; + + open (IN, $list) || die "read $list: $!\n"; + my $cve; + while () { + chomp; + if (/^(CVE-(?:[0-9]+|[A-Z]+)-(?:[0-9]+|[A-Z]+))\s*(.*)/) { + $cve=$1; + } + elsif (/\s+-\s+.*\((.*)\)/) { + my @notes=split(/\s*;\s+/, $1); + foreach my $note (@notes) { + if (/bug #(\d+)/) { + $ret{$1}{$cve}=1; + } + } + } + } + close IN; + + return %ret; +} -- cgit v1.2.3