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

Commit4c9902a

Browse files
committed
fix sql query matcher
1 parentc99cc31 commit4c9902a

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,22 +1248,28 @@ 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-
// To optimize the authz checks for audit logs, do not run an authorize
1252-
// check on each individual audit log row. In practice, audit logs are either
1253-
// fetched from a global or an organization scope.
1254-
// Applying a SQL filter would slow down the query for no benefit on how this query is
1255-
// actually used.
1256-
1257-
object:=rbac.ResourceAuditLog
1258-
ifarg.OrganizationID!=uuid.Nil {
1259-
object=object.InOrg(arg.OrganizationID)
1251+
//// To optimize the authz checks for audit logs, do not run an authorize
1252+
//// check on each individual audit log row. In practice, audit logs are either
1253+
//// fetched from a global or an organization scope.
1254+
//// Applying a SQL filter would slow down the query for no benefit on how this query is
1255+
//// actually used.
1256+
//
1257+
//object := rbac.ResourceAuditLog
1258+
//if arg.OrganizationID != uuid.Nil {
1259+
//object = object.InOrg(arg.OrganizationID)
1260+
//}
1261+
//
1262+
//if err := q.authorizeContext(ctx, policy.ActionRead, object); err != nil {
1263+
//return nil, err
1264+
//}
1265+
1266+
prep,err:=prepareSQLFilter(ctx,q.auth,policy.ActionRead,rbac.ResourceAuditLog.Type)
1267+
iferr!=nil {
1268+
returnnil,xerrors.Errorf("(dev error) prepare sql filter: %w",err)
12601269
}
12611270

1262-
iferr:=q.authorizeContext(ctx,policy.ActionRead,object);err!=nil {
1263-
returnnil,err
1264-
}
12651271

1266-
returnq.db.GetAuditLogsOffset(ctx,arg)
1272+
returnq.db.GetAuthorizedAuditLogsOffset(ctx,arg,prep)
12671273
}
12681274

12691275
func (q*querier)GetAuthorizationUserRoles(ctx context.Context,userID uuid.UUID) (database.GetAuthorizationUserRolesRow,error) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp