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

chore: ensure proper rbac permissions on 'Acquire' file in the cache#18348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Emyrk wants to merge14 commits intomain
base:main
Choose a base branch
Loading
fromstevenmasley/file_cache_perms

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedJun 12, 2025
edited
Loading

The file cache was caching theUnauthorized errors if a user without the right perms opened the file first. So all future opens would fail.

Now the cache always opens with a subject that can read files. And authz is checked on the Acquire per user.

@EmyrkEmyrk changed the titlechore: check proper rbac perms onAcquire file in cachechore: ensure proper rbac permissions on 'Acquire' file in the cacheJun 12, 2025
@EmyrkEmyrk requested a review fromaslilacJune 12, 2025 19:28
Comment on lines 236 to +238
func (r *RecordingAuthorizer) AssertActor(t *testing.T, actor rbac.Subject, did ...ActionObjectPair) {
r.AssertActorID(t, actor.ID, did...)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

what if we just got rid of this function rather than have the indirection? how many instances would we need to fix?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Eh, it is all in a test package. It is kinda convient to callAssertActor with the subject if you have it:

b:=coderdtest.RandomRBACSubject()bPairs:=fuzzAuthz(t,b,rec,10)rec.AssertActor(t,b,bPairs...)

I would have to dob.ID. Which is not bad, but sinceID is just a string, it is not type safe. I don't mind having the extra handle 🤷

"github.com/coder/coder/v2/coderd/util/lazy"
)

type AuthorizeFile func(ctx context.Context, subject rbac.Subject, action policy.Action, object rbac.Object) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nothing about this is "file" specific. it takes anrbac.Object. is this not a type def somewhere already? could we move this to a move general place with a more general name?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

True. Actually, I can just pass in anrbac.Authorizer. Not just the function.

c9cf780

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ahh I did it because it's an import loop

imports github.com/coder/coder/v2/coderd/coderdtest from cache_internal_test.goimports github.com/coder/coder/v2/coderd from authorize.go

I fixed it because it was in ainternal test, but I had to export thecacheEntryValue.

If we do our solution discussed in slack, this will be cleaned up.

@@ -101,6 +111,7 @@ type Cache struct {
lock sync.Mutex
data map[uuid.UUID]*cacheEntry
fetcher
authz AuthorizeFile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
authzAuthorizeFile
authorizeAuthorizeFile

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It is now

authz rbac.Authorizer

return nil, dbauthz.ErrNoActor
}
// Always check the caller can actually read the file.
if err := c.authz(ctx, subject, policy.ActionRead, it.object); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
iferr:=c.authz(ctx,subject,policy.ActionRead,it.object);err!=nil {
iferr:=c.authorize(ctx,subject,policy.ActionRead,it.object);err!=nil {

@EmyrkEmyrk requested a review fromaslilacJune 13, 2025 17:36
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@aslilacaslilacAwaiting requested review from aslilac

At least 1 approving review is required to merge this pull request.

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Emyrk@aslilac

[8]ページ先頭

©2009-2025 Movatter.jp