]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1580371 - Audit changes to user api key changes to the audit log table (skip...
authordklawren <dklawren@users.noreply.github.com>
Wed, 11 Sep 2019 16:19:19 +0000 (12:19 -0400)
committerGitHub <noreply@github.com>
Wed, 11 Sep 2019 16:19:19 +0000 (12:19 -0400)
Bugzilla/User/APIKey.pm

index 7b3b69619a2f02e2b538d173b392886e122b8818..1fc36acce0200bd64622b31fd0ae552660ba73b0 100644 (file)
@@ -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]); }