Skip to content

test: Unit tests creating fake audit logs require create permission#5455

Merged
Emyrk merged 1 commit into
mainfrom
stevenmasley/perm_mismatch
Dec 19, 2022
Merged

test: Unit tests creating fake audit logs require create permission#5455
Emyrk merged 1 commit into
mainfrom
stevenmasley/perm_mismatch

Conversation

@Emyrk
Copy link
Copy Markdown
Member

@Emyrk Emyrk commented Dec 16, 2022

No description provided.

Comment thread coderd/audit.go
func (api *API) generateFakeAuditLog(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
if !api.Authorize(r, rbac.ActionRead, rbac.ResourceAuditLog) {
if !api.Authorize(r, rbac.ActionCreate, rbac.ResourceAuditLog) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I might have missed it, but I don't see us enforcing this authorization in production. Is it sensible here? I imagine auditing shouldn't be user-permission dependent?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If this is only used in unit tests then it probably doesn't matter. I was just fixing the auth check to match the actual action

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mafredri I see this route as a valid route being usable even in production. If it should be test scoped, that should be done in another PR. At the very least, this authz should be checked since an audit log is inserted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That makes sense!

@Emyrk Emyrk merged commit e3cf759 into main Dec 19, 2022
@Emyrk Emyrk deleted the stevenmasley/perm_mismatch branch December 19, 2022 20:02
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants