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

[23.1] Fix regex validation for global inline flags #16683

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/galaxy/dependencies/pinned-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ pyyaml==6.0 ; python_version >= "3.7" and python_version < "3.12"
pyzmq==25.1.0 ; python_version >= "3.7" and python_version < "3.12"
rdflib==6.2.0 ; python_version >= "3.7" and python_version < "3.12"
refgenconf==0.12.2 ; python_version >= "3.7" and python_version < "3.12"
regex==2023.8.8 ; python_version >= "3.7" and python_version < "3.12"
repoze-lru==0.7 ; python_version >= "3.7" and python_version < "3.12"
requests-oauthlib==1.3.1 ; python_version >= "3.7" and python_version < "3.12"
requests-toolbelt==1.0.0 ; python_version >= "3.7" and python_version < "3.12"
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/tools/parameters/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import abc
import logging
import os.path
import re

import regex

from galaxy import (
model,
Expand Down Expand Up @@ -143,7 +144,7 @@ def validate(self, value, trans=None):
if not isinstance(value, list):
value = [value]
for val in value:
match = re.match(self.expression, val or "")
match = regex.match(self.expression, val or "")
super().validate(match is not None, value_to_show=val)


Expand Down
1 change: 1 addition & 0 deletions packages/app/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ install_requires =
PyJWT
PyYAML
refgenconf>=0.12.0
regex
requests
SQLAlchemy>=1.4.25,<2
sqlitedict
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ python-magic = "*"
python-multipart = "*" # required to support form parsing in FastAPI/Starlette
PyYAML = "*"
refgenconf = ">=0.12.0"
regex = "*"
requests = "*"
rocrate = "*"
Routes = "*"
Expand Down
12 changes: 12 additions & 0 deletions test/unit/app/tools/test_parameter_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ def test_ExpressionValidator_message(self):
ValueError, r"Validator 'value.lower\(\) == \"foo\"' could not be evaluated on '1'"
):
p.validate(1)

def test_RegexValidator_global_flag_inline(self):
# tests that global inline flags continue to work past python 3.10
p = self._parameter_for(
xml=r"""
<param name="blah" type="text" value="">
<validator type="regex">^(?ims)\s*select\s+.*\s+from\s+.*$</validator>
</param>"""
)
p.validate("select id from job where id = 1;")
with self.assertRaises(ValueError):
p.validate("not sql")