From 17cd56a62bd9012ae6fa3dc24ec2acbb65b31f00 Mon Sep 17 00:00:00 2001 From: Trond Norbye Date: Thu, 20 Oct 2022 10:37:55 +0200 Subject: [PATCH] Check bucket type before filter for select bucket audit We don't audit no-bucket, and comparing the bucket type is simpler than checking the filter. Change-Id: I9213fd68526227a3e5da5329330b5ffaf9d0e3e9 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/181584 Tested-by: Build Bot Reviewed-by: James H Reviewed-by: Vesko Karaganev --- daemon/mcaudit.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/daemon/mcaudit.cc b/daemon/mcaudit.cc index 57b3ec6cb0..10ec8195ef 100644 --- a/daemon/mcaudit.cc +++ b/daemon/mcaudit.cc @@ -178,19 +178,18 @@ void audit_auth_success(const Connection& c, Cookie* cookie) { } void audit_bucket_selection(const Connection& c, Cookie* cookie) { - if (!isEnabled(MEMCACHED_AUDIT_SELECT_BUCKET, c)) { - return; - } const auto& bucket = c.getBucket(); // Don't audit that we're jumping into the "no bucket" - if (bucket.type != BucketType::NoBucket) { - auto root = create_memcached_audit_object(c, c.getUser(), {}); - root["bucket"] = c.getBucket().name; - do_audit(cookie, - MEMCACHED_AUDIT_SELECT_BUCKET, - root, - "Failed to send SELECT BUCKET audit event"); + if (bucket.type == BucketType::NoBucket || + !isEnabled(MEMCACHED_AUDIT_SELECT_BUCKET, c)) { + return; } + auto root = create_memcached_audit_object(c, c.getUser(), {}); + root["bucket"] = c.getBucket().name; + do_audit(cookie, + MEMCACHED_AUDIT_SELECT_BUCKET, + root, + "Failed to send SELECT BUCKET audit event"); } void audit_bucket_flush(Cookie& cookie, const std::string_view bucket) {