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

Prevent No-Folder or root S3 model access #1512

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

manaswinidas
Copy link
Contributor

@manaswinidas manaswinidas commented Jul 13, 2023

Fixes #1423

Description

  1. Renamed "Folder Path" to "Path"
  2. Make "Path" a required field
  3. Add helper text to "Path" field
  4. Add validation for "Path" field(don't allow / or /////// -> enable "Deploy" button only if "Path" is valid )
Screenshot 2023-07-20 at 2 37 04 AM

GIF(outdated):

Please refer to this comment for the latest GIF

Screen.Recording.2023-07-20.at.1.43.22.AM.mov

How Has This Been Tested?

  1. Create a Model Server
  2. Click on Deploy Modal
  3. Fill out the data(Path field in both Existing and New data connection)

Test Impact

Added tests for the required "Path" field

Request review criteria:

Self checklist (all need to be checked):

  • The developer has manually tested the changes and verified that the changes work
  • Commits have been squashed into descriptive, self-contained units of work (e.g. 'WIP' and 'Implements feedback' style messages have been removed)
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit tests & storybook for related changes)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change.

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Jul 13, 2023
@manaswinidas manaswinidas changed the title [WIP]Prevent No-Folder or root S3 model access Prevent No-Folder or root S3 model access Jul 17, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Jul 17, 2023
@manaswinidas
Copy link
Contributor Author

@vconzola @kywalker-rh @kaedward Is the text "Can either be a folder path or the path to a single model" alright?

Also, as discussed, I haven't added any inline alerts. Just enabling and disabling the "Deploy" button if the "Path" is a valid path as shown in the GIF.

Here are the other alternatives:

With inline alert and validating tick in case of wrong input:

Screen.Recording.2023-07-18.at.4.43.13.PM.mov

With a validating tick(without inline alert):

Screen.Recording.2023-07-18.at.4.45.51.PM.mov

Let me know if any of these are a better option in place of the above GIF.

@DaoDaoNoCode
Copy link
Member

BTW, when editing, I can still see the / path.

Screenshot 2023-07-18 at 11 24 35 AM

@vconzola
Copy link

@manaswinidas There are three allowable inputs, correct: (1) a model name in the root folder, (2) a folder path with no model name, or (3) a folder path + model name? If that's true, I prefer more specific helper text without the validation tick and only showing the error helper text when Deploy is selected. I find the helper text and tick changes while typing to be confusing.

I'd like @kaedward to share her opinion, but I think helper text that says something like, "This must be a model name, a folder path, or a folder path and model name." would work. If the input is invalid when the user selects deploy we would show error helper text that says something like, "Not a valid model name or folder path." in red with the error icon displayed in the field as shown here: https://www.patternfly.org/v4/components/helper-text/design-guidelines#when-to-use-helper-text.

@andrewballantyne
Copy link
Member

There are three allowable inputs, correct: (1) a model name in the root folder, (2) a folder path with no model name, or (3) a folder path + model name? If that's true...

@vconzola yes that is correct

@manaswinidas
Copy link
Contributor Author

BTW, when editing, I can still see the / path.

Screenshot 2023-07-18 at 11 24 35 AM

@DaoDaoNoCode Edit seems to work for me, let me know if I'm missing something

Screen.Recording.2023-07-18.at.11.05.15.PM.mov

@DaoDaoNoCode
Copy link
Member

@manaswinidas What if you had a model mounted with the empty path before? Try to edit that one.

@manaswinidas
Copy link
Contributor Author

manaswinidas commented Jul 18, 2023

@DaoDaoNoCode My change is to ensure it's not empty anymore. The "Deploy" button won't be enabled if it's empty or just has / while Deploying a model in the first place.

@DaoDaoNoCode
Copy link
Member

Hmm, sounds fair. @andrewballantyne WDYT, do we need to consider the previously created models which could possibly mount on the root dir?

@andrewballantyne
Copy link
Member

Hmm, sounds fair. @andrewballantyne WDYT, do we need to consider the previously created models which could possibly mount on the root dir?

I made a thread in slack -- What is important to note is we need to consider how the flow impacts existing models.

What is the downside from having an "invalid" model deployed against the root /? If it locks up the mode from accepting any other inputs, we should address that with UX.

@kaedward
Copy link

@andrewballantyne For the helper text, how about "Enter the path to a folder or single model."?

@andrewballantyne
Copy link
Member

@andrewballantyne For the helper text, how about "Enter the path to a folder or single model."?

@kaedward Yeah, I guess we can go with that -- my only concern is technically I'd view / as a folder path heh... Could you sneak an extra couple words in there?

Enter the path to a non-root folder or single model.

Feels weird still... but it's more technically accurate

@kaedward
Copy link

@andrewballantyne does this sound any better?
"Enter a path to a model or folder. This path cannot point to a root folder."

@andrewballantyne
Copy link
Member

Thanks @kaedward fits my mental model better... @manaswinidas please implement the last text noted by Katie.

"Enter a path to a model or folder. This path cannot point to a root folder."

@manaswinidas
Copy link
Contributor Author

manaswinidas commented Jul 19, 2023

@andrewballantyne any other changes regarding the error helperText? I can see some comments above: #1512 (comment) or we stick to enabling the Deploy button when the input is valid?

Also, a suggestion: it will be great if we can check whether the folderPath exists from the backend side(if it's not too far-fetched).

@andrewballantyne
Copy link
Member

Also, a suggestion: it will be great if we can check whether the folderPath exists from the backend side(if it's not too far-fetched).

@andrewballantyne any other changes regarding the error helperText? I can see some comments above: #1512 (comment) or we stick to enabling the Deploy button when the input is valid?

@manaswinidas I don't follow what you're asking here -- if you're asking for more wording, pitch the scenario to @kaedward -- if you're asking for what we should do, I think Vince answered that 🤔 Let me know how I can help!

@manaswinidas
Copy link
Contributor Author

If the input is invalid when the user selects deploy we would show error helper text that says something like, "Not a valid >model name or folder path." in red with the error icon displayed in the field as shown here: >https://www.patternfly.org/v4/components/helper-text/design-guidelines#when-to-use-helper-text.

@andrewballantyne I was just confirming whether there is a need for an error helperText as shown in the comment here. I think I confused Vince with the GIFs 😅

@manaswinidas manaswinidas force-pushed the odh-1423 branch 2 times, most recently from b85c244 to d0fd60d Compare July 19, 2023 21:00
@kaedward
Copy link

@manaswinidas I think error help text would be useful. Can we detect when an invalid path is entered, or only if the user enters a root folder?

@manaswinidas
Copy link
Contributor Author

We are preventing inputs like / or ///// It needs to be some text that can contain / but not only /. As of now, I'm enabling the Deploy button if the Path is valid. Here's a GIF for your reference. Does this look good or it still needs an error helperText?

Screen.Recording.2023-07-20.at.1.43.22.AM.mov

@vconzola
Copy link

@kaedward I don't understand where/when you're suggesting that error be displayed?

@manaswinidas
Copy link
Contributor Author

manaswinidas commented Jul 21, 2023

We have 2(or 3) options:

  1. Show the error message while the user is typing the input. Do we still disable the "Deploy" button when the error helperText is getting displayed? Or enable the "Deploy" button anyways(even if the user is typing the wrong input) and make the user try to send the form with the wrong input, and after they click on "Deploy"- show them the error.
    (My concerns in the first case: Changing the helperText to the error helperText while typing might confuse the user coz it draws attention

My concerns for the second case(disputed opinion): I've found it annoying as a user when I get an error after clicking on the "Submit" button when the form/field could have shown the error while doing it, thus saving me time.)

  1. Disable the "Deploy" button when the user types / or ///// and enable it when the user types the correct input(the latest changes of this PR has this - refer to first comment of this PR to have a glimpse of how it looks like now)

Would you like me to send GIFs for some or all of these scenarios?

@andrewballantyne
Copy link
Member

andrewballantyne commented Jul 21, 2023

@kaedward I don't understand where/when you're suggesting that error be displayed?

@vconzola @manaswinidas @kaedward okay, let me step in here and cap this off. (hopefully)

My suggested state of this modal is this, let me know if you agree.

For the folder field...

  1. Empty initial state => show the empty field, deploy button is disabled (invalid input)
    • the red asterisk will help the user know the field is needed
    • the help text of "Enter a path to a model or folder. This path cannot point to the root folder."
  2. If the user types / we show them the error under the field "The path must not point to a root folder."
    • The error goes away (and the button enables -- if the rest of the modal is good) when they continue /<any character> -- eg /a
    • We stay in error if they type more than 1 / -- /////// scenario; even if they type ////<any character>
    • We show the error using PF field validation (link)
  3. If the user straight up types a non slash character, we don't show anything in the field but we enable the button (if the rest of the modal is good)
    • I think it's important we don't use success validation here because we are not validating the validity of the path

Does that make sense to everyone? If not, let us take this to slack (or a meeting), as it'll likely need more back and forth.

@vconzola
Copy link

@andrewballantyne @manaswinidas @kaedward I'm OK with everything @andrewballantyne suggested with one exception. i think it's going to look weird if we immediately show the error as soon as the user types"/". It could cause the error message to flash briefly if they don't type the next, non-/ character quickly enough. Can we add a short (500 ms to 1 s - will probably need to play around with it to see what feels right) delay before displaying the error below the field?

@manaswinidas
Copy link
Contributor Author

@kaedward @vconzola Do we have a success helperText too or just the default helperText "Enter a path to a model or folder. This path cannot point to the root folder." will do?

@vconzola
Copy link

@manaswinidas We don't need any success helperText - only if there's an error.

@manaswinidas
Copy link
Contributor Author

@vconzola @kaedward Final GIF:

Screen.Recording.2023-07-25.at.8.49.07.PM.mov

@vconzola
Copy link

lgtm

@andrewballantyne
Copy link
Member

@andrewballantyne @manaswinidas @kaedward I'm OK with everything @andrewballantyne suggested with one exception. i think it's going to look weird if we immediately show the error as soon as the user types"/". It could cause the error message to flash briefly if they don't type the next, non-/ character quickly enough. Can we add a short (500 ms to 1 s - will probably need to play around with it to see what feels right) delay before displaying the error below the field?

For starters, they shouldn't type the slash... the slash is in the UI -- if they do, they can see the error imo; I'm okay with the delay too. Also I imagine most people will probably not type out the value and copy paste it from the path they have in their storage.

If we expect the avg user to type the / @vconzola -- I recommend we decide that we should remove the left-of-the-field / as the original design point was for "root" and a blank field -- which naturally because of this PR is no longer the case. (we can handle that as another issue though and not hold this one up)

@andrewballantyne
Copy link
Member

@kaedward @vconzola Do we have a success helperText too or just the default helperText "Enter a path to a model or folder. This path cannot point to the root folder." will do?

For what it is worth -- don't put success intentionally. We are not validating the value, we are just helping them avoid known failure points. Success would mislead the user to think we know if their folder path is accurate -- which we do not.

@manaswinidas
Copy link
Contributor Author

For what it is worth -- don't put success intentionally. We are not validating the value, we are just helping them avoid known failure points. Success would mislead the user to think we know if their folder path is accurate -- which we do not.

I was reiterating the same yesterday, we don't have a success helperText and the check mark in the textbox for the same reason. Also, I've added a 1s delay, let me know if that needs to be changed. This comment has the latest GIF.

</FormGroup>
);
}) => {
type validate = 'success' | 'warning' | 'error' | 'default';
Copy link
Member

Choose a reason for hiding this comment

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

Types are always PascalCase

Also, why do you need this? Infer the data from PF.

React.ComponentProps<typeof FormGroup>['validated']

That should get you the value behind the prop of FormGroup's prop validated.

const timer = setTimeout(() => {
if (folderPath === '') {
setValidated('default');
} else if (folderPath === '/' || folderPath.includes('//')) {
Copy link
Member

Choose a reason for hiding this comment

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

If you get into an error -- I think you're going to not get out of it on paste... can you switch your logic around if this, else set back to default?

@vconzola
Copy link

vconzola commented Jul 26, 2023

For starters, they shouldn't type the slash... the slash is in the UI -- if they do, they can see the error imo; I'm okay with the delay too. Also I imagine most people will probably not type out the value and copy paste it from the path they have in their storage.

If we expect the avg user to type the / @vconzola -- I recommend we decide that we should remove the left-of-the-field / as the original design point was for "root" and a blank field -- which naturally because of this PR is no longer the case. (we can handle that as another issue though and not hold this one up)

@andrewballantyne Iirc, we had an earlier issue where we "ignore" any leading slash. And we should keep that. The idea behind adding the delay is so that the only time the user will see the error is if they enter only one or more / in the input field - which is unlikely to happen. Tl;dr - I think we're good.

@manaswinidas One other question... The example text in the input field says, "e.g., data". For this to be a valid input means the model is stored in a folder named "data". Is this confusing? Would it be more clear if we changed this to "data_folder" or removed the example altogether? Thoughts @kaedward ?

@andrewballantyne
Copy link
Member

I think the design is fine the way it is... we should log another issue to handle the field if we are changing -- the placeholder and prefix / may no longer be needed in a no root design.

There are code issues and thus I cannot approve at this time. Please fix those when you get a chance @manaswinidas

Copy link
Member

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes -- you really should use PascalCase for your Type variables... but this solves the real problem I saw.

/approve

Give me a moment to spin up my UI to test it, but should work fine. - tested and lgtm but Lucas got to it first

Copy link
Contributor

@lucferbux lucferbux left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne, lucferbux

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit ae1533a into opendatahub-io:main Jul 27, 2023
7 checks passed
@manaswinidas
Copy link
Contributor Author

Issue logged for changes discussed in #1512 (comment) : #1601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Prevent No-Folder (or "root") S3 Model Access
7 participants