From 6f1f455bf09f719b7ad465adbd78a39e57c3895b Mon Sep 17 00:00:00 2001 From: Jonathan Gangi Date: Mon, 9 Dec 2024 16:13:52 -0300 Subject: [PATCH] fix(marketplacesvm): path regex This commit updates the regex patter for validating the staged directory path string. Signed-off-by: Jonathan Gangi --- pubtools-marketplacesvm-wrapper/marketplacesvm_push_wrapper.py | 2 +- .../test_marketplacesvm_push_wrapper.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pubtools-marketplacesvm-wrapper/marketplacesvm_push_wrapper.py b/pubtools-marketplacesvm-wrapper/marketplacesvm_push_wrapper.py index 72a305d..a5efa4e 100755 --- a/pubtools-marketplacesvm-wrapper/marketplacesvm_push_wrapper.py +++ b/pubtools-marketplacesvm-wrapper/marketplacesvm_push_wrapper.py @@ -70,7 +70,7 @@ def parse_args(): def get_source_url(stagedirs): - regex = re.compile(r"^/[\w++/*]+$") + regex = re.compile(r"^/([^/\0]+(/)?)+$") for item in stagedirs: if not regex.match(item): raise ValueError("Not a valid staging directory: %s" % item) diff --git a/pubtools-marketplacesvm-wrapper/test_marketplacesvm_push_wrapper.py b/pubtools-marketplacesvm-wrapper/test_marketplacesvm_push_wrapper.py index 2628c9b..c6bfa4f 100644 --- a/pubtools-marketplacesvm-wrapper/test_marketplacesvm_push_wrapper.py +++ b/pubtools-marketplacesvm-wrapper/test_marketplacesvm_push_wrapper.py @@ -126,6 +126,7 @@ def test_basic_command_nochannel(mock_run, caplog, mock_mkt_env_vars): ["/foo/bar/"], ["/a", "/tmp/foo/"], ["/a/b/c/d/e/f/g/h/i", "/a1/a2/a3/", "/f"], + ["/tmp/afASFu.fas", "/tmp/A.fs_.", "/tmp/fas12414fas"], ], ) def test_get_source_url(stageddirs): @@ -136,7 +137,7 @@ def test_get_source_url(stageddirs): @pytest.mark.parametrize( "stageddirs", - [["foo"], ["foo/bar"], [r"/\/\/\/\/\/\/"]], + [["foo"], ["foo/bar"], [r"/////////////"]], ) def test_get_source_url_invalid(stageddirs): err = "Not a valid staging directory:"