Skip to content
Snippets Groups Projects
Commit b974ab06d0c1 authored by Arnaud Vergnet's avatar Arnaud Vergnet :sun_with_face:
Browse files

fix: improve config path checks

parent 52aa18a21e84
No related branches found
No related tags found
1 merge request!17fix: improve config path checks
Pipeline #135213 passed
......@@ -39,9 +39,9 @@
path_prefix: str = (
repo.get_option_value("api-path-prefix") or API_PATH_DEFAULT_PREFIX
)
match = re.match("^[a-zA-Z0-9-_@.&+!*(),/]{1,30}$", path_prefix)
match = re.match("^/[a-zA-Z0-9-_@.&+!*(),/]{1,29}$", path_prefix)
if match:
return path_prefix.rstrip("/")
else:
if len(path_prefix) > 30:
raise ConfigurationError(
......@@ -43,9 +43,16 @@
if match:
return path_prefix.rstrip("/")
else:
if len(path_prefix) > 30:
raise ConfigurationError(
"api-path-prefix is too long. Max size allowed is 30 characters."
f"api-path-prefix '{path_prefix}' is too long. "
f"Max size allowed is 30 characters. "
f"Current size is {len(path_prefix)}."
)
if not path_prefix.startswith("/"):
raise ConfigurationError(
f"api-path-prefix '{path_prefix}' does not start with '/'. "
"Prefix should start with '/' to be validated by openapi"
)
raise ConfigurationError(
......@@ -49,6 +56,6 @@
)
raise ConfigurationError(
"api-path-prefix contains invalid characters."
f"api-path-prefix '{path_prefix}' contains invalid characters. "
"Allowed characters are: a-zA-Z0-9-_@.&+!*(),/"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment