core: reject dashes in isolation instance names:

To avoid confusion and hard-to-debug behaviours, `-` are now rejected in isolation
instance names, only `_` is accepted.
This commit is contained in:
Goffi 2026-11-03 12:01:59 +01:00
commit 2f0c1d4818

View file

@ -57,12 +57,18 @@ class Const:
isolation_name = os.environ.get("LIBERVIA_ISOLATION") isolation_name = os.environ.get("LIBERVIA_ISOLATION")
if isolation_name: if isolation_name:
# Validate isolation name: only allow [A-Za-z0-9_-] to prevent path traversal and # Validate isolation name: only allow [A-Za-z0-9_] to prevent path traversal and
# other issues. # other issues.
if not isolation_name.replace("-", "").replace("_", "").isalnum(): if "-" in isolation_name:
raise ValueError(
f"Invalid LIBERVIA_ISOLATION name {isolation_name!r}: dashes are"
f" not allowed, please use underscores instead"
f" ({isolation_name.replace('-', '_')!r})"
)
if not isolation_name.replace("_", "").isalnum():
raise ValueError( raise ValueError(
f"Invalid LIBERVIA_ISOLATION name {isolation_name!r}, " f"Invalid LIBERVIA_ISOLATION name {isolation_name!r}, "
f"must only contain [A-Za-z0-9_-]" f"must only contain [A-Za-z0-9_]"
) )
isolation_mode = os.environ.get("LIBERVIA_ISOLATION_MODE", "normal").lower() isolation_mode = os.environ.get("LIBERVIA_ISOLATION_MODE", "normal").lower()
match isolation_mode: match isolation_mode: