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

Commit36bb86f

Browse files
fix: dbauthz
1 parent90ed0f2 commit36bb86f

File tree

3 files changed

+43
-38
lines changed

3 files changed

+43
-38
lines changed

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,9 @@ func As(ctx context.Context, actor rbac.Subject) context.Context {
483483
// running the insertFunc. The insertFunc is expected to return the object that
484484
// was inserted.
485485
funcinsert[
486-
ObjectTypeany,
487-
ArgumentTypeany,
488-
Insertfunc(ctx context.Context,argArgumentType) (ObjectType,error),
486+
ObjectTypeany,
487+
ArgumentTypeany,
488+
Insertfunc(ctx context.Context,argArgumentType) (ObjectType,error),
489489
](
490490
logger slog.Logger,
491491
authorizer rbac.Authorizer,
@@ -496,9 +496,9 @@ func insert[
496496
}
497497

498498
funcinsertWithAction[
499-
ObjectTypeany,
500-
ArgumentTypeany,
501-
Insertfunc(ctx context.Context,argArgumentType) (ObjectType,error),
499+
ObjectTypeany,
500+
ArgumentTypeany,
501+
Insertfunc(ctx context.Context,argArgumentType) (ObjectType,error),
502502
](
503503
logger slog.Logger,
504504
authorizer rbac.Authorizer,
@@ -525,10 +525,10 @@ func insertWithAction[
525525
}
526526

527527
funcdeleteQ[
528-
ObjectType rbac.Objecter,
529-
ArgumentTypeany,
530-
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
531-
Deletefunc(ctx context.Context,argArgumentType)error,
528+
ObjectType rbac.Objecter,
529+
ArgumentTypeany,
530+
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
531+
Deletefunc(ctx context.Context,argArgumentType)error,
532532
](
533533
logger slog.Logger,
534534
authorizer rbac.Authorizer,
@@ -540,10 +540,10 @@ func deleteQ[
540540
}
541541

542542
funcupdateWithReturn[
543-
ObjectType rbac.Objecter,
544-
ArgumentTypeany,
545-
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
546-
UpdateQueryfunc(ctx context.Context,argArgumentType) (ObjectType,error),
543+
ObjectType rbac.Objecter,
544+
ArgumentTypeany,
545+
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
546+
UpdateQueryfunc(ctx context.Context,argArgumentType) (ObjectType,error),
547547
](
548548
logger slog.Logger,
549549
authorizer rbac.Authorizer,
@@ -554,10 +554,10 @@ func updateWithReturn[
554554
}
555555

556556
funcupdate[
557-
ObjectType rbac.Objecter,
558-
ArgumentTypeany,
559-
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
560-
Execfunc(ctx context.Context,argArgumentType)error,
557+
ObjectType rbac.Objecter,
558+
ArgumentTypeany,
559+
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
560+
Execfunc(ctx context.Context,argArgumentType)error,
561561
](
562562
logger slog.Logger,
563563
authorizer rbac.Authorizer,
@@ -575,9 +575,9 @@ func update[
575575
// user cannot read the resource. This is because the resource details are
576576
// required to run a proper authorization check.
577577
funcfetchWithAction[
578-
ArgumentTypeany,
579-
ObjectType rbac.Objecter,
580-
DatabaseFuncfunc(ctx context.Context,argArgumentType) (ObjectType,error),
578+
ArgumentTypeany,
579+
ObjectType rbac.Objecter,
580+
DatabaseFuncfunc(ctx context.Context,argArgumentType) (ObjectType,error),
581581
](
582582
logger slog.Logger,
583583
authorizer rbac.Authorizer,
@@ -608,9 +608,9 @@ func fetchWithAction[
608608
}
609609

610610
funcfetch[
611-
ArgumentTypeany,
612-
ObjectType rbac.Objecter,
613-
DatabaseFuncfunc(ctx context.Context,argArgumentType) (ObjectType,error),
611+
ArgumentTypeany,
612+
ObjectType rbac.Objecter,
613+
DatabaseFuncfunc(ctx context.Context,argArgumentType) (ObjectType,error),
614614
](
615615
logger slog.Logger,
616616
authorizer rbac.Authorizer,
@@ -623,10 +623,10 @@ func fetch[
623623
// from SQL 'exec' functions which only return an error.
624624
// See fetchAndQuery for more information.
625625
funcfetchAndExec[
626-
ObjectType rbac.Objecter,
627-
ArgumentTypeany,
628-
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
629-
Execfunc(ctx context.Context,argArgumentType)error,
626+
ObjectType rbac.Objecter,
627+
ArgumentTypeany,
628+
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
629+
Execfunc(ctx context.Context,argArgumentType)error,
630630
](
631631
logger slog.Logger,
632632
authorizer rbac.Authorizer,
@@ -649,10 +649,10 @@ func fetchAndExec[
649649
// **before** the query runs. The returns from the fetch are only used to
650650
// assert rbac. The final return of this function comes from the Query function.
651651
funcfetchAndQuery[
652-
ObjectType rbac.Objecter,
653-
ArgumentTypeany,
654-
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
655-
Queryfunc(ctx context.Context,argArgumentType) (ObjectType,error),
652+
ObjectType rbac.Objecter,
653+
ArgumentTypeany,
654+
Fetchfunc(ctx context.Context,argArgumentType) (ObjectType,error),
655+
Queryfunc(ctx context.Context,argArgumentType) (ObjectType,error),
656656
](
657657
logger slog.Logger,
658658
authorizer rbac.Authorizer,
@@ -686,9 +686,9 @@ func fetchAndQuery[
686686
// fetchWithPostFilter is like fetch, but works with lists of objects.
687687
// SQL filters are much more optimal.
688688
funcfetchWithPostFilter[
689-
ArgumentTypeany,
690-
ObjectType rbac.Objecter,
691-
DatabaseFuncfunc(ctx context.Context,argArgumentType) ([]ObjectType,error),
689+
ArgumentTypeany,
690+
ObjectType rbac.Objecter,
691+
DatabaseFuncfunc(ctx context.Context,argArgumentType) ([]ObjectType,error),
692692
](
693693
authorizer rbac.Authorizer,
694694
action policy.Action,
@@ -2235,7 +2235,12 @@ func (q *querier) GetPresetParametersByTemplateVersionID(ctx context.Context, ar
22352235
}
22362236

22372237
func (q*querier)GetPresetsAtFailureLimit(ctx context.Context,hardLimitint64) ([]database.GetPresetsAtFailureLimitRow,error) {
2238-
panic("not implemented")
2238+
// GetPresetsAtFailureLimit returns a list of template version presets that have reached the hard failure limit.
2239+
// Request the same authorization permissions as GetPresetsBackoff, since the methods are similar.
2240+
iferr:=q.authorizeContext(ctx,policy.ActionViewInsights,rbac.ResourceTemplate.All());err!=nil {
2241+
returnnil,err
2242+
}
2243+
returnq.db.GetPresetsAtFailureLimit(ctx,hardLimit)
22392244
}
22402245

22412246
func (q*querier)GetPresetsBackoff(ctx context.Context,lookback time.Time) ([]database.GetPresetsBackoffRow,error) {

‎coderd/database/dbmem/dbmem.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4363,7 +4363,7 @@ func (q *FakeQuerier) GetPresetParametersByTemplateVersionID(_ context.Context,
43634363
}
43644364

43654365
func (q*FakeQuerier)GetPresetsAtFailureLimit(ctx context.Context,hardLimitint64) ([]database.GetPresetsAtFailureLimitRow,error) {
4366-
panic("not implemented")
4366+
returnnil,ErrUnimplemented
43674367
}
43684368

43694369
func (*FakeQuerier)GetPresetsBackoff(_ context.Context,_ time.Time) ([]database.GetPresetsBackoffRow,error) {

‎codersdk/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ func (c *DeploymentValues) Options() serpent.OptionSet {
15141514
Value:&c.DERP.Config.BlockDirect,
15151515
Group:&deploymentGroupNetworkingDERP,
15161516
YAML:"blockDirect",Annotations: serpent.Annotations{}.
1517-
Mark(annotationExternalProxies,"true"),
1517+
Mark(annotationExternalProxies,"true"),
15181518
},
15191519
{
15201520
Name:"DERP Force WebSockets",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp