Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita77a9ab

Browse files
authored
chore: skip audit log filter for owner/admin users (#14132)
* chore: audit log filter to be skipped if user is owner/adminOptimize for speed in the case the user can read all audit_logs* fixup! chore: audit log filter to be skipped if user is owner/admin
1 parent203f48a commita77a9ab

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,13 @@ func (q *querier) GetApplicationName(ctx context.Context) (string, error) {
12481248
}
12491249

12501250
func (q*querier)GetAuditLogsOffset(ctx context.Context,arg database.GetAuditLogsOffsetParams) ([]database.GetAuditLogsOffsetRow,error) {
1251+
// Shortcut if the user is an owner. The SQL filter is noticeable,
1252+
// and this is an easy win for owners. Which is the common case.
1253+
err:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceAuditLog)
1254+
iferr==nil {
1255+
returnq.db.GetAuditLogsOffset(ctx,arg)
1256+
}
1257+
12511258
prep,err:=prepareSQLFilter(ctx,q.auth,policy.ActionRead,rbac.ResourceAuditLog.Type)
12521259
iferr!=nil {
12531260
returnnil,xerrors.Errorf("(dev error) prepare sql filter: %w",err)

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,14 @@ func (s *MethodTestSuite) TestAuditLogs() {
267267
_=dbgen.AuditLog(s.T(),db, database.AuditLog{})
268268
check.Args(database.GetAuditLogsOffsetParams{
269269
LimitOpt:10,
270-
}).Asserts()
270+
}).Asserts(rbac.ResourceAuditLog,policy.ActionRead)
271271
}))
272272
s.Run("GetAuthorizedAuditLogsOffset",s.Subtest(func(db database.Store,check*expects) {
273273
_=dbgen.AuditLog(s.T(),db, database.AuditLog{})
274274
_=dbgen.AuditLog(s.T(),db, database.AuditLog{})
275275
check.Args(database.GetAuditLogsOffsetParams{
276276
LimitOpt:10,
277-
},emptyPreparedAuthorized{}).Asserts()
277+
},emptyPreparedAuthorized{}).Asserts(rbac.ResourceAuditLog,policy.ActionRead)
278278
}))
279279
}
280280

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp