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

Validate the test name when creating new jobs #6195

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

Conversation

Martchus
Copy link
Contributor

Copy link
Contributor

@perlpunk perlpunk left a 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
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_*.+,:/#@%"'-]+$|;
Copy link
Contributor

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.

Copy link
Contributor

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 $:

Suggested change
use constant TEST_NAME_REGEX => qr|^[A-Za-z 0-9_*.+,:/#@%"'-]+$|;
use constant TEST_NAME_REGEX => qr|^[A-Za-z 0-9_*.+,:/#@%"'-]+\z|;

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Member

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

* 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
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.99%. Comparing base (2b6bb87) to head (6cbf8d9).
Report is 5 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@perlpunk perlpunk left a 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.

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.

4 participants