-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
104383: auditloggingccl: migrate role-based audit logging as a CCL feature r=THardy98 a=THardy98 Part of: #100467 This change moves the existing role-based audit logging logic to be consumed as a CCL (enterprise) feature. The notable changes here are: - moving the audit logging cluster settings (i.e. `sql.log.user_audit` and `sql.log.user_audit.reduced_config.enabled`) to the `ccl` package. Consequently, these cluster settings will only exist when the use has a CCL license (free or paid) - gating the `sql.log.user_audit` cluster setting behind the enterprise CCL license. This was done by adding an enterprise CCL license check in the `sql.log.user_audit` validation function. Users will be unable to change this cluster setting (and thereby will not be able to enable/configure role-based audit logging) unless they have an enterprise CCL license - the addition of function hooks to be used at CCL initialization, namely: - `ConfigureRoleBasedAuditClusterSettings`: used to add a `SetOnChange` hook to `sql.log.user_audit` - `UserAuditLogConfigEmpty`: used to check whether the audit logging cluster setting is empty - `UserAuditReducedConfigEnabled`: used to check whether the reduced audit configuration is enabled (note: regular users are still able to enable/disable this cluster setting, but it will take no effect as they will have no way to enable role-based audit logging) - `UserAuditEnterpriseParamsHook`: used to retrieve parameters necessary for enterprise license checks within the the `sql.log.user_audit` cluster setting validation function Release note (sql change): Role-based audit logging is now a CCL (enterprise) feature. Only enterprise CCL users will be able to configure role-based audit logging using the `sql.log.user_audit` cluster setting. Co-authored-by: Thomas Hardy <[email protected]>
- Loading branch information
Showing
16 changed files
with
214 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "auditloggingccl", | ||
srcs = ["audit_log_config.go"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/ccl/auditloggingccl", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/ccl/utilccl", | ||
"//pkg/settings", | ||
"//pkg/settings/cluster", | ||
"//pkg/sql/auditlogging", | ||
"//pkg/sql/pgwire/pgcode", | ||
"//pkg/sql/pgwire/pgerror", | ||
"//pkg/util/log", | ||
"@com_github_cockroachdb_errors//:errors", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "auditloggingccl_test", | ||
srcs = [ | ||
"audit_logging_test.go", | ||
"main_test.go", | ||
], | ||
args = ["-test.timeout=295s"], | ||
embed = [":auditloggingccl"], | ||
tags = ["ccl_test"], | ||
deps = [ | ||
"//pkg/base", | ||
"//pkg/ccl", | ||
"//pkg/ccl/utilccl", | ||
"//pkg/security/securityassets", | ||
"//pkg/security/securitytest", | ||
"//pkg/security/username", | ||
"//pkg/server", | ||
"//pkg/testutils", | ||
"//pkg/testutils/serverutils", | ||
"//pkg/testutils/sqlutils", | ||
"//pkg/testutils/testcluster", | ||
"//pkg/util/leaktest", | ||
"//pkg/util/log", | ||
"//pkg/util/log/logpb", | ||
"//pkg/util/log/logtestutils", | ||
"//pkg/util/randutil", | ||
"@com_github_cockroachdb_errors//:errors", | ||
"@com_github_stretchr_testify//require", | ||
], | ||
) | ||
|
||
get_x_data(name = "get_x_data") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package auditloggingccl_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/ccl" | ||
"github.com/cockroachdb/cockroach/pkg/security/securityassets" | ||
"github.com/cockroachdb/cockroach/pkg/security/securitytest" | ||
"github.com/cockroachdb/cockroach/pkg/server" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster" | ||
"github.com/cockroachdb/cockroach/pkg/util/randutil" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
defer ccl.TestingEnableEnterprise()() | ||
securityassets.SetLoader(securitytest.EmbeddedAssets) | ||
randutil.SeedForTests() | ||
serverutils.InitTestServerFactory(server.TestServerFactory) | ||
serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) | ||
os.Exit(m.Run()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.