From fedora-security-commits at redhat.com Mon Aug 25 06:39:59 2008 From: fedora-security-commits at redhat.com (fedora-security-commits at redhat.com) Date: Mon, 25 Aug 2008 06:39:59 +0000 (UTC) Subject: [Fedora-security-commits] fedora-security/tools/lib/Libexig Bugzilla.pm, 1.5, 1.6 Fedora.pm, 1.6, 1.7 Message-ID: <20080825063959.3FA9570104@cvs1.fedora.phx.redhat.com> 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; } From fedora-security-commits at redhat.com Tue Aug 26 06:38:22 2008 From: fedora-security-commits at redhat.com (fedora-security-commits at redhat.com) Date: Tue, 26 Aug 2008 06:38:22 +0000 (UTC) Subject: [Fedora-security-commits] fedora-security/tools/scripts check-updates, 1.5, 1.6 Message-ID: <20080826063822.2D95E7010B@cvs1.fedora.phx.redhat.com> Author: thoger Update of /cvs/fedora/fedora-security/tools/scripts In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv11622/tools/scripts Modified Files: check-updates Log Message: fix check-updates to work with new bodhi JSON output, no more text blob parsing Index: check-updates =================================================================== RCS file: /cvs/fedora/fedora-security/tools/scripts/check-updates,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- check-updates 25 Apr 2008 13:12:25 -0000 1.5 +++ check-updates 26 Aug 2008 06:37:52 -0000 1.6 @@ -10,6 +10,8 @@ use Libexig::Audit; use Libexig::Bodhi; +use Data::Dumper; + my $debug= 1; # Parse the audit file @@ -46,22 +48,29 @@ # Go through the updates foreach my $u (Libexig::Bodhi::get_updates ($entry->{component})) { + # pre-process update info structure for easier look-up + map { + $u->{'_bugs_hash'}->{$_->{'bz_id'}}= $_ + } @{ $u->{'bugs'} }; + map { + $u->{'_builds_hash'}->{$_->{'package'}->{'name'}}->{$_->{'nvr'}}= $_ + } @{ $u->{'builds'} }; if ( # See if the VULNERABLE bug was referenced by an update (defined($entry->{'bug'}) && - defined($u->{'_Bugs'}->{$entry->{bug}}) ) || + defined($u->{'_bugs_hash'}->{$entry->{'bug'}}) ) || # See if since Update ID was found (defined($update_id) && - defined($u->{'Update ID'}) && - $u->{'Update ID'} eq $update_id ) || + defined($u->{'updateid'}) && + $u->{'updateid'} eq $update_id ) || # See if since NVR was found - # TODO: check also higher NVRs to deal with obsoleted update - # requests? + # TODO: check also higher NVRs to deal with obsoleted update requests? (defined($update_nvr) && - scalar(grep($_ eq $update_nvr, @{ $u->{'_NVRs'} })) > 0) + defined($u->{'_builds_hash'}->{$entry->{'component'}}) && + defined($u->{'_builds_hash'}->{$entry->{'component'}}->{$update_nvr}) ) ) { ; # update was found, do nothing } else { @@ -69,23 +78,23 @@ } if ($debug) { - print " -> Found: ", grep(/^$entry->{component}-/, @{ $u->{'_NVRs'} }); + print " -> Found: ", keys(%{ $u->{'_builds_hash'}->{$entry->{'component'}} }); } # Modify the line accordingly - if (defined($u->{'Update ID'})) { - $entry->{'since'}= $u->{'Update ID'}; + if (defined($u->{'updateid'})) { + $entry->{'since'}= $u->{'updateid'}; if ($debug) { - print " ($u->{'Update ID'})"; + print " ($u->{'updateid'})"; } } - if ($u->{'Status'} eq 'stable') { - $entry->{status}= 'fixed'; + if ($u->{'status'} eq 'stable') { + $entry->{'status'}= 'fixed'; } Libexig::Audit::update_entry ($entry); if ($debug) { - print " - status: $u->{'Status'}\n"; + print " - status: $u->{'status'}\n"; } last; From fedora-security-commits at redhat.com Tue Aug 26 06:38:22 2008 From: fedora-security-commits at redhat.com (fedora-security-commits at redhat.com) Date: Tue, 26 Aug 2008 06:38:22 +0000 (UTC) Subject: [Fedora-security-commits] fedora-security/tools/lib/Libexig Bodhi.pm, 1.3, 1.4 Message-ID: <20080826063822.1B6B17010B@cvs1.fedora.phx.redhat.com> Author: thoger Update of /cvs/fedora/fedora-security/tools/lib/Libexig In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv11622/tools/lib/Libexig Modified Files: Bodhi.pm Log Message: fix check-updates to work with new bodhi JSON output, no more text blob parsing Index: Bodhi.pm =================================================================== RCS file: /cvs/fedora/fedora-security/tools/lib/Libexig/Bodhi.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Bodhi.pm 14 Jan 2008 16:33:12 -0000 1.3 +++ Bodhi.pm 26 Aug 2008 06:37:51 -0000 1.4 @@ -5,9 +5,12 @@ package Libexig::Bodhi; use JSON; +use Data::Dumper; # Convert the text blob from bodhi to a hash, # dissect some multipart values +# +# XXX No longer needed with bodhi 0.5.x XXX sub update_to_hashref { my @lines = split /\n/, shift; @@ -89,19 +92,13 @@ sub get_updates { my $pkg = shift or die 'No package name supplied'; - my @retval; - # Get updates $json = `wget --post-data 'package=$pkg&tg_paginate_limit=0' -qO - \\ 'https://admin.fedoraproject.org/updates/list?tg_format=json'`; - $obj = jsonToObj ($json); - - foreach my $update (@{$obj->{'updates'}}) { - push @retval, update_to_hashref ($update); - } + $obj = jsonToObj ($json, {unmapping => 1}); - return @retval; + return @{$obj->{'updates'}}; } 1; From fedora-security-commits at redhat.com Tue Aug 26 11:31:46 2008 From: fedora-security-commits at redhat.com (fedora-security-commits at redhat.com) Date: Tue, 26 Aug 2008 11:31:46 +0000 (UTC) Subject: [Fedora-security-commits] fedora-security/tools/scripts add-tracking-bugs, 1.3, 1.4 Message-ID: <20080826113146.629AB7010B@cvs1.fedora.phx.redhat.com> Author: thoger Update of /cvs/fedora/fedora-security/tools/scripts In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv19727/tools/scripts Modified Files: add-tracking-bugs Log Message: new bodhi still does not handle bug aliases, so resolve aliases to ids locally Index: add-tracking-bugs =================================================================== RCS file: /cvs/fedora/fedora-security/tools/scripts/add-tracking-bugs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- add-tracking-bugs 14 Jan 2008 16:33:12 -0000 1.3 +++ add-tracking-bugs 26 Aug 2008 11:31:14 -0000 1.4 @@ -77,5 +77,12 @@ ['alias','keywords','priority','bug_id', 'bug_severity', 'short_short_desc']); my $tracking_bugs = Libexig::Fedora::tracking_bugs ($parent_bugs, $component, @versions); -print STDERR Libexig::Fedora::file_tracking_bugs (\@bugs, $tracking_bugs, $bugzilla, $component); +# XXX temporary - as bodhi still does not handle bug aliases, make sure to +# create links with bug ids +my @bugs_ids; +foreach my $b (@{ $parent_bugs }) { + push @bugs_ids, $b->{'bug_id'}; +} + +print STDERR Libexig::Fedora::file_tracking_bugs (\@bugs_ids, $tracking_bugs, $bugzilla, $component);