summaryrefslogtreecommitdiffstats
path: root/bin/bts-update
diff options
context:
space:
mode:
authorJoey Hess <joeyh@debian.org>2005-10-20 00:40:22 +0000
committerJoey Hess <joeyh@debian.org>2005-10-20 00:40:22 +0000
commit2476aa8ce02a8b57c7945f9ddb28e7a343da2157 (patch)
treef647104962c63cd447ccb7109785df130cb2b6bb /bin/bts-update
parente10b392e8d7efde08d323c9f95ff1fce572ccf32 (diff)
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
Diffstat (limited to 'bin/bts-update')
-rwxr-xr-xbin/bts-update87
1 files changed, 87 insertions, 0 deletions
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 (<IN>) {
+ 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;
+}

© 2014-2024 Faster IT GmbH | imprint | privacy policy