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

Fix URL regex marking as invalid legal URL #3789

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

MDeLuise
Copy link
Contributor

@MDeLuise MDeLuise commented Jun 8, 2023

Brief description of the PR.
Some valid URLs was considered illegal, for example the following: http://172.16.0.2:1234/static/com.eurotech.opcua.driver_1.1.1.dp.
This PR is to fix this issue.

Related Issue
This PR fixes #3788.

Description of the solution adopted
Change the regex in order to include more URLs.

Any side note on the changes made
Added also the validation check on the backend side, in order to avoid console parameter validation bypass.

- Some valid URL was considered illegal in the device packages tab.
- Add the URL validation check even on the backend side
@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #3789 (d82b830) into develop (805094a) will decrease coverage by 27.40%.
The diff coverage is 0.00%.

❗ Current head d82b830 differs from pull request most recent head 0c6c3af. Consider uploading reports for the commit 0c6c3af to get more accurate results

Impacted file tree graph

@@              Coverage Diff               @@
##             develop    #3789       +/-   ##
==============================================
- Coverage      50.55%   23.16%   -27.40%     
  Complexity        26       26               
==============================================
  Files           1866     1866               
  Lines          35284    35288        +4     
  Branches        2782     2782               
==============================================
- Hits           17839     8173     -9666     
- Misses         16527    26804    +10277     
+ Partials         918      311      -607     
Impacted Files Coverage Δ
...s/internal/DevicePackageManagementServiceImpl.java 0.00% <0.00%> (-9.47%) ⬇️

... and 625 files with indirect coverage changes

@@ -70,7 +69,7 @@ public enum FieldType {
ALPHANUMERIC("alphanumeric", "^[a-zA-Z0-9_]+$"),
NUMERIC("numeric", "^[+0-9.]+$"),
PACKAGE_VERSION("package_version", "^[a-zA-Z0-9.\\-\\_]*$"),
URL("url", "(http(s)?:\\/\\/.)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)");
URL("url", "^(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=//]{1,256}\\.[a-zA-Z0-9()//]{2,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$");
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this making use of https mandatory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's ok to have a URL without the https with this regex, in fact the first part of it have the trailing ? character (^(https?:\\/\\/)?).

Screenshot 2023-06-09 at 16 44 45

@Coduz Coduz added Bug This is a bug or an unexpected behaviour. Fix it! Console GWT This issue/PR is related to Admin Web Console labels Jun 12, 2023
@Coduz Coduz merged commit e7225d1 into eclipse-kapua:develop Jun 12, 2023
@MDeLuise MDeLuise deleted the fix/package-url branch June 27, 2023 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug or an unexpected behaviour. Fix it! Console GWT This issue/PR is related to Admin Web Console
Projects
None yet
Development

Successfully merging this pull request may close these issues.

URL regex does not accept valid URL
2 participants