[Fedora-security-commits] fedora-security/tools/lib/Libexig Bugzilla.pm, 1.5, 1.6 Fedora.pm, 1.6, 1.7

fedora-security-commits at redhat.com fedora-security-commits at redhat.com
Mon Aug 25 06:39:59 UTC 2008


Author: thoger

Update of /cvs/fedora/fedora-security/tools/lib/Libexig
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv5798/tools/lib/Libexig

Modified Files:
	Bugzilla.pm Fedora.pm 
Log Message:
fix handling of bug aliases, which used to break add-tracking-bugs
add add-issue comment hint to be printed by add-tracking-bugs



Index: Bugzilla.pm
===================================================================
RCS file: /cvs/fedora/fedora-security/tools/lib/Libexig/Bugzilla.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Bugzilla.pm	18 Jan 2008 16:00:14 -0000	1.5
+++ Bugzilla.pm	25 Aug 2008 06:39:28 -0000	1.6
@@ -115,19 +115,62 @@
 	my $columns = shift;
 	$columns = [] unless ($columns); # The default set
 
-	my $call = $self->{rpc}->call('bugzilla.runQuery', {
-		'bug_id'	=> $bugs,
-		'bug_status'	=> [],
-		'column_list'	=> $columns,
-	}, @{$self->{creds}});
+	# sort out aliases and bug ids
+	my @bugs_ids;
+	my @bugs_aliases;
+	foreach my $bug (@{ $bugs }) {
+		if ($bug =~ /^[0-9]+$/) {
+			push @bugs_ids, $bug;
+		} else {
+			push @bugs_aliases, $bug;
+		}
+	}
 
-	my $result = $call->result
-		or die $call->faultstring;
+	# query bugs ids and aliases separately
+	my @results;
+	if (scalar(@bugs_ids) > 0) {
+		my $call = $self->{rpc}->call('bugzilla.runQuery', {
+			'bug_id'	=> \@bugs_ids,
+			'bug_status'	=> [],
+			'column_list'	=> $columns,
+		}, @{$self->{creds}});
+
+		my $result = $call->result
+			or die $call->faultstring;
+
+		print STDERR 'Bugzilla answered to ID runQuery: '.Dumper($result)
+			if $self->{debug};
+
+		if (scalar(@bugs_ids) != scalar(@{ $result->{bugs} })) {
+			die "Bugzilla returned unexpected number of results!";
+		}
 
-	print STDERR 'Bugzilla answered to runQuery: '.Dumper($result)
-		if $self->{debug};
+		push @results, @{ $result->{bugs} };
+	}
+
+	if (scalar(@bugs_aliases) > 0) {
+		my $call = $self->{rpc}->call('bugzilla.runQuery', {
+			'bug_status'	=> [],
+			'column_list'	=> $columns,
+			'field0-0-0'	=> 'alias',
+			'type0-0-0'	=> 'anywordssubstr',
+			'value0-0-0'	=> join(" ", @bugs_aliases),
+		}, @{$self->{creds}});
+
+		my $result = $call->result
+			or die $call->faultstring;
+
+		print STDERR 'Bugzilla answered to Alias runQuery: '.Dumper($result)
+			if $self->{debug};
+
+		if (scalar(@bugs_aliases) != scalar(@{ $result->{bugs} })) {
+			die "Bugzilla returned unexpected number of results!";
+		}
+
+		push @results, @{ $result->{bugs} };
+	}
 
-	return $result->{bugs};
+	return \@results;
 }
 
 # Add blockers (unless dryrun) to a bug


Index: Fedora.pm
===================================================================
RCS file: /cvs/fedora/fedora-security/tools/lib/Libexig/Fedora.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Fedora.pm	19 Jun 2008 13:24:29 -0000	1.6
+++ Fedora.pm	25 Aug 2008 06:39:29 -0000	1.7
@@ -133,6 +133,8 @@
 	'devel',	=> 'rawhide',
 );
 
+my $rawhide_version= '10';
+
 sub tracking_bugs
 {
 	my $bugs = shift;
@@ -213,6 +215,9 @@
 	my $bugzilla = shift;
 	my $component = shift;
 
+	my @created_bugs;
+	my @created_versions;
+	
 	my $comment = "Created Fedora tracking bugs for $component:\n\n";
 
 	foreach my $bug (@{$tracking_bugs}) {
@@ -240,9 +245,11 @@
 			}
 
 			$bugzilla->add_comment ($bug_id, $tr_comment);
+
+			push @created_versions, $bug->{'version'};
 		}
-#		# XXX temporary until F9 BZ component is created
-#		else {
+		else {
+#			# XXX temporary until F9 BZ component is created XXX
 #			my $tr_comment = 
 #				'You can eventually use the following link to '.
 #				'create the update request for upcoming Fedora 9: '."\n".
@@ -257,15 +264,26 @@
 #			}
 #
 #			$bugzilla->add_comment ($bug_id, $tr_comment);
-#		}
+
+			push @created_versions, $rawhide_version;
+		}
 
 		$bugzilla->add_blockers ($bug_id, $parent_bugs);
 		$comment .= $bug->{'version'}.": bug #$bug_id\n";
+
+		push @created_bugs, $bug_id;
 	}
 
 	foreach my $bug (@{$parent_bugs}) {
 		$bugzilla->add_private_comment ($bug, $comment);
 	}
 
-	return $comment;
+	# Generate also add-issue command hint
+	my $command_hint= './tools/scripts/add-issue';
+	$command_hint.= " --component '".$tracking_bugs->[0]->{'component'}."'";
+	$command_hint.= " --bugs ".join(',', @created_bugs);
+	$command_hint.= " --versions ".join(',', @created_versions);
+	$command_hint.= " --cve\n";
+
+	return $comment."\n".$command_hint;
 }




More information about the security-commits mailing list