Conversation
feat: action menu replacement with Action Menu component
… feat/deployment-metrics-charts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Abhishek <abhishek@devtron.ai>
Co-authored-by: Abhishek <abhishek@devtron.ai>
…abs/dashboard into feat/deployment-metrics-charts
…icsEnabled and toggleAppMetrics for better state management
…lusterForm for enhanced state management
…arts feat: replace recharts with Chart component in deployment metrics
fix: multiple issues
… feat/backup-n-schedule
…updating related components
fix: cluster form error
chore: cost config
…EditClusterDrawerMetadata
chore: remove switch
…n-labs/dashboard into feat/overview-oss
…s for better readability and maintainability
…, and add gap class to EnvironmentStatusComponent
feat: add app, infra and security overview from fe-lib
…feat/page-header-doclink
feat: Dynamic doc link added in help button
… chore/sync-main-rc-44
chore: sync main rc 44
|
Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n |
|
| required: RemoteConnectionRadio && remoteConnectionMethod === RemoteConnectionType.Proxy, | ||
| validator: { | ||
| error: 'Please provide a valid URL. URL must start with http:// or https://', | ||
| regex: /^(http(s)?:\/\/)[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 2 months ago
General fix:
To resolve the ambiguity and prevent catastrophic backtracking, the ambiguous sub-patterns must be rewritten. This is typically done by ensuring that within a repeated group, no part can match the same string in multiple ways. In this case, [\w.-]+ should be rewritten to make . and - unambiguous, typically by not allowing them to be adjacent to each other in a way that would create ambiguity, or by splitting host/domain validation into stricter components.
Best detailed fix:
Rewrite the pattern to avoid [.-] inside a repetition over the group. In the context of validating a URL, it's better to switch to a stricter hostname/domain matching pattern. For common domain validation, one can use:
- Each label:
[a-zA-Z0-9-]+(cannot start/end with-) - Separated by
., at least one.
But for quick practical repairs (avoiding extensive rewriting), replace[\w.-]+with[\w-]+(?:\.[\w-]+)*which means "one or more word/dash, optionally repeated, separated by"."". This approach avoids the ambiguity.
The overall regex could become:
/^(http(s)?:\/\/)[\w-]+(?:\.[\w-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/
Alternatively, if strict URL validation is needed, consider using a trusted library (e.g. validator.js) instead of custom regex, but as per the prompt, only touch what we've been shown.
Where to change:
In file src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/utils.tsx, at line 62, change the regular expression to use [\w-]+(?:\.[\w-]+)+.
What's needed:
- Only code edit — no new imports or methods necessary.
| @@ -59,7 +59,7 @@ | ||
| required: RemoteConnectionRadio && remoteConnectionMethod === RemoteConnectionType.Proxy, | ||
| validator: { | ||
| error: 'Please provide a valid URL. URL must start with http:// or https://', | ||
| regex: /^(http(s)?:\/\/)[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, | ||
| regex: /^(http(s)?:\/\/)[\w-]+(?:\.[\w-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, | ||
| }, | ||
| }, | ||
| sshUsername: { |
| remoteConnectionMethod === RemoteConnectionType.SSHTunnel | ||
| ? { | ||
| error: 'Please provide a valid URL. URL must start with http:// or https://', | ||
| regex: /^(http(s)?:\/\/)[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 2 months ago
To fix this problem, we need to remove ambiguity from the repeated subexpression by ensuring that each repetition can't match the same string via different paths. Specifically, [\w.-]+ can be ambiguous since . and - can be matched by more than one iteration. Instead, for validating domain names, a safer approach is to split alternation so that periods are treated as separators, not as possible characters within the repeated part, or to use a more specific character class such as [\w-] (excluding period) for matching domain labels, and use (?:\.[\w-]+)+ for subsequent parts.
The best way to fix this, focusing only on the snippet shown, is to change [\w.-]+(?:\.[\w.-]+)+ to [\w-]+(?:\.[\w-]+)+. This ensures:
- Each domain label is
[\w-]+ - Labels are separated by a literal dot
- No ambiguity between dot and other characters inside the repeated group.
Apply this change on line 94 and also on line 62, since both use the same pattern. No external dependencies or additional imports are required as this is a pure regex fix.
| @@ -59,7 +59,7 @@ | ||
| required: RemoteConnectionRadio && remoteConnectionMethod === RemoteConnectionType.Proxy, | ||
| validator: { | ||
| error: 'Please provide a valid URL. URL must start with http:// or https://', | ||
| regex: /^(http(s)?:\/\/)[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, | ||
| regex: /^(http(s)?:\/\/)[\w-]+(?:\.[\w-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, | ||
| }, | ||
| }, | ||
| sshUsername: { | ||
| @@ -91,7 +91,7 @@ | ||
| remoteConnectionMethod === RemoteConnectionType.SSHTunnel | ||
| ? { | ||
| error: 'Please provide a valid URL. URL must start with http:// or https://', | ||
| regex: /^(http(s)?:\/\/)[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, | ||
| regex: /^(http(s)?:\/\/)[\w-]+(?:\.[\w-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, | ||
| } | ||
| : { error: '', regex: /^(?!\s*$).+/ }, | ||
| }, |



Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes https://github.com/devtron-labs/sprint-tasks/issues/2743
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: