From: dklawren Date: Wed, 11 Sep 2019 16:19:19 +0000 (-0400) Subject: Bug 1580371 - Audit changes to user api key changes to the audit log table (skip... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=591a0543671f9b719800302d6b3a296239b73fd7;p=thirdparty%2Fbugzilla.git Bug 1580371 - Audit changes to user api key changes to the audit log table (skip last_used information) --- diff --git a/Bugzilla/User/APIKey.pm b/Bugzilla/User/APIKey.pm index 7b3b69619..1fc36acce 100644 --- a/Bugzilla/User/APIKey.pm +++ b/Bugzilla/User/APIKey.pm @@ -46,13 +46,8 @@ use constant VALIDATORS => { use constant LIST_ORDER => 'id'; use constant NAME_FIELD => 'api_key'; -# turn off auditing and exclude these objects from memcached -use constant { - AUDIT_CREATES => 0, - AUDIT_UPDATES => 0, - AUDIT_REMOVES => 0, - USE_MEMCACHED => 0 -}; +# Exclude these objects from memcached +use constant USE_MEMCACHED => 0; # Accessors sub id { return $_[0]->{id} } @@ -81,6 +76,20 @@ sub update_last_used { $self->update; } +# We override Object.pm audit_log cause we need to remove the +# last_used and last_used_ip changes so they are not logged. +# Otherwise the audit_log table would fill up from people just +# normally using the api keys. +sub audit_log { + my ($self, $changes) = @_; + # Only interested in AUDIT_UPDATE + if (ref $changes eq 'HASH') { + delete $changes->{last_used}; + delete $changes->{last_used_ip}; + } + $self->SUPER::audit_log($changes); +} + # Setters sub set_description { $_[0]->set('description', $_[1]); } sub set_revoked { $_[0]->set('revoked', $_[1]); }