- Notifications
You must be signed in to change notification settings - Fork906
chore(coderd/database/dbauthz): update RBAC for InsertWorkspaceApp#18223
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3851,9 +3851,19 @@ func (q *querier) InsertWorkspaceAgentStats(ctx context.Context, arg database.In | ||
} | ||
func (q *querier) InsertWorkspaceApp(ctx context.Context, arg database.InsertWorkspaceAppParams) (database.WorkspaceApp, error) { | ||
// NOTE(DanielleMaywood): | ||
// It is possible for there to exist an agent without a workspace. | ||
// This means that we want to allow execution to continue if | ||
// there isn't a workspace found to allow this behavior to continue. | ||
workspace, err := q.db.GetWorkspaceByAgentID(ctx, arg.AgentID) | ||
if err != nil && !errors.Is(err, sql.ErrNoRows) { | ||
return database.WorkspaceApp{}, err | ||
} | ||
Comment on lines +3858 to +3861 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Doesn't this mean you can insert a workspace app for a non-existent agent ID? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. If you used a non-existent Agent ID, you would get past this check, correct. However, the If you think we should tweak the logic slightly to ensure there is a valid agent then I'm happy to make that change 👍. https://github.com/coder/coder/blob/9995a098d5f0816128d00f5ec01767bba0b76164/coderd/database/dump.sql#L2035 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That's fair 👍 We could add an extra check for an agent with the given ID, but it does introduce an extra DB lookup. I'm not sure the extra round-trip gives us anything here. | ||
if err := q.authorizeContext(ctx, policy.ActionUpdate, workspace); err != nil { | ||
return database.WorkspaceApp{}, err | ||
} | ||
return q.db.InsertWorkspaceApp(ctx, arg) | ||
} | ||
Uh oh!
There was an error while loading.Please reload this page.