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 regex for validating "remotehost" parameter #771

Conversation

Bischoff
Copy link
Contributor

@Bischoff Bischoff commented Nov 20, 2023

The regular expression used to validate "remotehost" parameter has two problems:

  • the dots (.) should be escaped with \, otherwise they mean "any character" ;
  • the second and further domain names are made of more than one character, and therefore need a +.

This small python program permits to reproduce the problem in isolation:

import re

rbad = '^[a-zA-Z0-9\-]+\@([0-9]{1,3}(.[0-9]{1,3}){3}$|[a-zA-Z0-9\-]+(.[a-zA-Z0-9\-]){1,}$)'
rok  = '^[a-zA-Z0-9\-]+\@([0-9]{1,3}(\.[0-9]{1,3}){3}$|[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+){1,}$)'
if re.compile(rbad).match("[email protected]") == None:
  print("failed")
else:
  print("matched")

Matching fails for [email protected], while this is a legitimate user@domain syntax. With the correct regular exception, it works.

Reference: https://cloudlib4zvm.readthedocs.io/en/latest/restapi.html#deploy-guest

the format is username@ip, for example, [email protected] or username@hostname eg.``[email protected]``

@Bischoff Bischoff force-pushed the fix-remotehost-validation-regex branch from e45fa73 to 94cf471 Compare November 20, 2023 08:28
Change-Id: I35311e790ec19d95059a0b8eed0e5ac885c12ca6
Signed-off-by: Eric Bischoff <[email protected]>
@Bischoff Bischoff force-pushed the fix-remotehost-validation-regex branch from 94cf471 to 25e7480 Compare December 2, 2023 17:12
@bjhuangr bjhuangr merged commit bab565b into openmainframeproject:master Dec 4, 2023
2 checks passed
@Bischoff
Copy link
Contributor Author

Bischoff commented Dec 4, 2023

Thank you @bjhuangr .

@Bischoff Bischoff deleted the fix-remotehost-validation-regex branch December 14, 2023 14:37
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.

2 participants