fix: validate clean option types (#111)

Co-authored-by: Guillaume Meyer (The Opinionated Man) <1385518+guillaumemeyer@users.noreply.github.com>
This commit is contained in:
初心Yearth
2026-08-17 16:08:31 -07:00
committed by GitHub
co-authored by Guillaume Meyer
parent 07be21e54a
commit 5e43d53fc3
2 changed files with 24 additions and 1 deletions
+5 -1
View File
@@ -462,9 +462,13 @@ class Handler(BaseHTTPRequestHandler):
options = {}
if not isinstance(options, dict):
raise ValueError("'options' must be an object")
for key in options:
for key, value in options.items():
if key not in ALLOWED_CLEAN_OPTIONS:
raise ValueError(f"unknown option: {key}")
expected_type = ALLOWED_CLEAN_OPTIONS[key]
if not isinstance(value, expected_type):
type_name = "boolean" if expected_type is bool else "string"
raise ValueError(f"option {key!r} must be a {type_name}")
with tempfile.TemporaryDirectory(prefix="wm-clean-") as tmp:
tmpdir = Path(tmp)