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

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Dec 16, 2022

No description provided.

@@ -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!

@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