[Secure-testing-commits] r2468 - bin

Joey Hess joeyh at costa.debian.org
Thu Oct 20 00:40:23 UTC 2005


Author: joeyh
Date: 2005-10-20 00:40:22 +0000 (Thu, 20 Oct 2005)
New Revision: 2468

Added:
   bin/bts-update
Log:
add a program to manage usertags in the bts


Added: bin/bts-update
===================================================================
--- bin/bts-update	2005-10-19 23:53:49 UTC (rev 2467)
+++ bin/bts-update	2005-10-20 00:40:22 UTC (rev 2468)
@@ -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;
+}


Property changes on: bin/bts-update
___________________________________________________________________
Name: svn:executable
   + *




More information about the Secure-testing-commits mailing list