Skip to content

Commit

Permalink
Check bucket type before filter for select bucket audit
Browse files Browse the repository at this point in the history
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 <build@couchbase.com>
Reviewed-by: James H <james.harrison@couchbase.com>
Reviewed-by: Vesko Karaganev <vesko.karaganev@couchbase.com>
  • Loading branch information
trondn committed Oct 26, 2022
1 parent 33139de commit 17cd56a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions daemon/mcaudit.cc
Expand Up @@ -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) {
Expand Down

0 comments on commit 17cd56a

Please sign in to comment.