Skip to content

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

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coderd/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (api *API) auditLogs(rw http.ResponseWriter, r *http.Request) {

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
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
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
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
Member

Choose a reason for hiding this comment

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

That makes sense!

httpapi.Forbidden(rw)
return
}
Expand Down