Skip to content

Commit

Permalink
fix(marketplacesvm) path regex
Browse files Browse the repository at this point in the history
This commit updates the regex patter for validating the staged directory
path string.

Signed-off-by: Jonathan Gangi <[email protected]>
  • Loading branch information
JAVGan committed Dec 9, 2024
1 parent cd12f6a commit ad94ba0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:"
Expand Down

0 comments on commit ad94ba0

Please sign in to comment.