Skip to content

Commit 73f51aa

Browse files
craig[bot]yuzefovich
andcommitted
107282: sql: do not audit internal executors r=yuzefovich a=yuzefovich Previously, we were using `planner.isInternalPlanner` to check whether audit logging should be applied, but that field is not set for internal executors, and I believe IE should be excluded from audit too. Epic: None Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
2 parents be21b3b + a3a6dc5 commit 73f51aa

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pkg/sql/audit_logging.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ func (p *planner) maybeAuditSensitiveTableAccessEvent(
3939
)
4040
}
4141

42-
func (p *planner) maybeAuditRoleBasedAuditEvent(ctx context.Context) {
42+
func (p *planner) maybeAuditRoleBasedAuditEvent(ctx context.Context, execType executorType) {
4343
// Avoid doing audit work if not necessary.
44-
if p.shouldNotRoleBasedAudit() {
44+
if p.shouldNotRoleBasedAudit(execType) {
4545
return
4646
}
4747

@@ -114,10 +114,16 @@ func (p *planner) initializeReducedAuditConfig(ctx context.Context) {
114114
p.reducedAuditConfig.AuditSetting = p.AuditConfig().GetMatchingAuditSetting(userRoles, user)
115115
}
116116

117-
// shouldNotRoleBasedAudit checks if we should do any auditing work for RoleBasedAuditEvents.
118-
func (p *planner) shouldNotRoleBasedAudit() bool {
117+
// shouldNotRoleBasedAudit checks if we should do any auditing work for
118+
// RoleBasedAuditEvents.
119+
func (p *planner) shouldNotRoleBasedAudit(execType executorType) bool {
119120
// Do not do audit work if role-based auditing is not enabled.
120-
// Do not emit audit events for reserved users/roles. This does not omit the root user.
121+
// Do not emit audit events for reserved users/roles. This does not omit the
122+
// root user.
121123
// Do not emit audit events for internal planners.
122-
return !auditlogging.UserAuditEnabled(p.execCfg.Settings, p.EvalContext().ClusterID) || p.User().IsReserved() || p.isInternalPlanner
124+
// Do not emit audit events for internal executors.
125+
return !auditlogging.UserAuditEnabled(p.execCfg.Settings, p.EvalContext().ClusterID) ||
126+
p.User().IsReserved() ||
127+
p.isInternalPlanner ||
128+
execType == executorTypeInternal
123129
}

pkg/sql/exec_log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (p *planner) maybeLogStatement(
131131
queryStats *topLevelQueryStats,
132132
statsCollector sqlstats.StatsCollector,
133133
) {
134-
p.maybeAuditRoleBasedAuditEvent(ctx)
134+
p.maybeAuditRoleBasedAuditEvent(ctx, execType)
135135
p.maybeLogStatementInternal(ctx, execType, isCopy, numRetries, txnCounter,
136136
rows, bulkJobId, err, queryReceived, hasAdminRoleCache,
137137
telemetryLoggingMetrics, stmtFingerprintID, queryStats, statsCollector,

0 commit comments

Comments
 (0)