Skip to content

14144 s3 endpoint field in cluster configuration missing input validation #14557

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

marytlf
Copy link

@marytlf marytlf commented Jun 23, 2025

Summary

The core requirement was to prevent users from entering "http://" or "https://" at the beginning of the S3 endpoint URL in a form, and consequently, disable the main "Save" button of the cluster creation/edit form. Additionally, a tooltip should appear next to the endpoint field to inform the user about this specific error.

Fixes #14144

Occurred changes and/or fixed issues

Check if value typed on endpoint form is http:// or https://, in case of positive, return an error and disable the save button.
The save button was kept enable in view mode, the fix was to disable it in case the mode is view.

Technical notes summary

Areas or cases that should be tested

Rancher new cluster`s provisioning with etcd/s3 endpoint information
Browser: Opera 119.0.5497.88
Steps to reproduce:
Scenario 1)

Scenario 2)

  • Create new cluster (custom)
  • Tab etcd > Save Backup to s3 (enable) > set values on endpoint field (localhost:9000)
  • Save

Screenshot/Video

Screencast.From.2025-06-23.14-06-54.webm

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • [] The PR has been reviewed in terms of Accessibility

@richard-cox richard-cox added this to the v2.13.0 milestone Jun 23, 2025
@marytlf marytlf requested a review from rak-phillip June 23, 2025 20:13
@richard-cox richard-cox self-requested a review June 24, 2025 07:49
@richard-cox
Copy link
Member

Note that the issue is currently targeting 2.13, and 2.12 priorities need to come first

@marytlf marytlf modified the milestones: v2.13.0, v2.12.0 Jun 25, 2025
};
},

computed: {
...mapGetters({ features: 'features/get' }),

s3ConfigComponent() {
Copy link
Member

Choose a reason for hiding this comment

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

this logic should be encapsulated inside the S3Config component and it's valid state can be emited out

  • logic specific to inside a component stays inside the component
  • the interface between parent and child components is clear, rather than parent reaching into child and using internal properties

@@ -12,6 +16,7 @@ export default {
Checkbox,
SelectOrCreateAuthSecret,
},
mixins: [CreateEditView, FormValidation],
Copy link
Member

Choose a reason for hiding this comment

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

the CreateEditView mixin is intended for root resources create/edit/view components rather than a sub component

};
</script>

<template>
<div>
<SelectOrCreateAuthSecret
v-model:value="config.cloudCredentialName"
:mode="mode"
:disable="isView"
Copy link
Member

Choose a reason for hiding this comment

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

:disable="isView" on this and below shouldn't be needed with :mode="mode"

return false; // Or throw new Error('Input is not a string');
}

return value.toLowerCase().startsWith('https://') || value.toLowerCase().startsWith('http://');
Copy link
Member

Choose a reason for hiding this comment

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

generally it's better to reduce duplication

  const lowerCaseValue = value.toLowerCase();
  
  return lowerCaseValue.startsWith('https://') || lowerCaseValue.startsWith('http://');

@marytlf marytlf requested a review from richard-cox July 3, 2025 19:44
@marytlf
Copy link
Author

marytlf commented Jul 4, 2025

Hi @richard-cox
I made the changes you asked, when you have time can you take a look, please?
thank you

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.

S3 endpoint field in cluster configuration missing input validation
2 participants