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;
security-commits@lists.fedoraproject.org