-
Notifications
You must be signed in to change notification settings - Fork 213
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
Validate the test name when creating new jobs #6195
base: master
Are you sure you want to change the base?
Conversation
Martchus
commented
Feb 20, 2025
- Use the same regex we already use when validating the YAML schema for job templates
- See https://progress.opensuse.org/issues/177267
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you restrict the TEST variable to that, then many jobs will be rejected.
I added a comment in the ticket and removed AC2 for that reason
* Use the same regex we already use when validating the YAML schema for job templates * See https://progress.opensuse.org/issues/177267
98d3a34
to
00264e5
Compare
lib/OpenQA/Jobs/Constants.pm
Outdated
use constant TEST_NAME_REGEX => qr/^[A-Za-z 0-9_*.+-]+$/; | ||
# note: In contrast to the YAML schema a few more characters are allowed here as they are useful for manually | ||
# triggered jobs, e.g. via `openqa-clone-custom-git-refspec`. | ||
use constant TEST_NAME_REGEX => qr|^[A-Za-z 0-9_*.+,:/#@%"'-]+$|; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not allow %'"
. Are they actually used?
I only saw "
being used on osd, but only a handful cases, and I think it can be rather confusing, and it creates hard to read command lines if you have to quote something that can contain quotes itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you can disallow a trailing newline by using \z
instead of $
:
use constant TEST_NAME_REGEX => qr|^[A-Za-z 0-9_*.+,:/#@%"'-]+$|; | |
use constant TEST_NAME_REGEX => qr|^[A-Za-z 0-9_*.+,:/#@%"'-]+\z|; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, %
is used, e.g. Chubykalo_welcome_to_wsl_poo%23176676
. However, I guess people would probably be able to live without it.
I added '
because "
was used and I think if we allow double-quotes we should also allow single-quotes for consistency. However, maybe you're right and we should not allow quotes at all. The only occurrence with quote that comes to mind is sles4sap_gnome_saptune_delete_rename"rbmarliere"
and maybe people can also here live without it. Maybe this was actually even a mistake again.
@okurz What is your take on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me it looks like poo%23176676
could be a typo and was meant to be poo#23176676
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apparently missed a lot of the conversation. You asked me for my take on that but I now see that the test name regex only allows A-Za-z so really only ASCII alphabet characters? I see the main problem within https://progress.opensuse.org/journals/910146/diff?detail_id=853467 which adds as AC1 the opposite of what the ticket subject says. If I am not mistaken Martchus and me suggested a blocklist, not a passlist. I suggest that we either go back to the decision step what we want to achieve or you better clarify in the git commit and PR what the reasoning is behind this
As mentioned on https://progress.opensuse.org/issues/177267, the use of `\s` was probably a mistake.
* Allow more special characters including the colon (the `openqa-clone-job` script will have to cope with it by only splitting the key/testname on the first colon) * Keep `=` and tabs disallowed; the production jobs using those characters are most likely created by accident * See https://progress.opensuse.org/issues/177267
00264e5
to
6cbf8d9
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6195 +/- ##
=======================================
Coverage 98.99% 98.99%
=======================================
Files 396 396
Lines 39785 39795 +10
=======================================
+ Hits 39386 39396 +10
Misses 399 399 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Allow only simple white space characters in test names/Allow only simple space characters in test names/
White space is the term for multilple occurrences of spaces, tabs, line breaks etc.