Skip to content
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

Exp checklist permission mismatch bug. #2545

Merged
merged 5 commits into from
May 20, 2024

Conversation

mknowlton89
Copy link
Collaborator

Features and Changes

Our sentry logs indicated a user received an error when attempting to edit an experiment's checklist.

When digging in, it appeared that this error was thrown for an analyst user trying to update a manual checklist item on an experiment's checklist. After some digging, I found that on the frontend, when determining whether the user should have edit access, we were checking canViewExperimentModal which checks the createAnalyses permission, but on the backend, we were checking canRunExperiment which checks the runExperiments permission.

Looking at the roles and policies, an analyst is described as being able to create, edit, and delete experiments, so my understanding is the backend check we were doing was checking too high of a permission level.

This PR updates the backend to check the same permission that we're checking on the frontend so no users will get UI that says they can update, but the backend says otherwise.

Testing

  • Ensure that analysts, experiments, and admins can edit manual checklist items, but no other roles.

@mknowlton89 mknowlton89 self-assigned this May 17, 2024
@mknowlton89 mknowlton89 marked this pull request as ready for review May 17, 2024 12:54
@mknowlton89 mknowlton89 requested review from jdorn and msamper May 17, 2024 12:54
Copy link

github-actions bot commented May 17, 2024

Your preview environment pr-2545-bttf has been deployed.

Preview environment endpoints are available at:

const envs = experiment ? getAffectedEnvsForExperiment({ experiment }) : [];

if (!context.permissions.canRunExperiment(experiment, envs)) {
if (!context.permissions.canViewExperimentModal(experiment.project)) {
Copy link
Member

Choose a reason for hiding this comment

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

This seems like it should be canUpdateExperiment instead, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DOH. Yes. I've updated the both places to use the canUpdateExperiment.


if (!context.permissions.canRunExperiment(experiment, envs)) {
const updatedExperiment = { ...experiment, manualLaunchChecklist: checklist };
if (!context.permissions.canUpdateExperiment(experiment, updatedExperiment)) {
Copy link
Member

Choose a reason for hiding this comment

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

The 2nd argument should just be the fields that are changing, not the entire updated experiment.

Copy link
Member

@jdorn jdorn left a comment

Choose a reason for hiding this comment

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

Added a comment, but it's minor so approving

@mknowlton89 mknowlton89 changed the base branch from main to mk/deactive-role-flow May 20, 2024 11:10
@mknowlton89 mknowlton89 changed the base branch from mk/deactive-role-flow to main May 20, 2024 11:11
@mknowlton89 mknowlton89 merged commit 1135872 into main May 20, 2024
3 checks passed
@mknowlton89 mknowlton89 deleted the mk/experiment-checklist-permission-bug branch May 20, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants