Add explicit path-containment check to kanban_task_path
The regex allow-list alone wasn't enough for CodeQL's path-injection sanitizer recognition. Resolve the candidate path and verify it's still a direct child of the resolved kanban directory before returning it, which is the pattern CodeQL's py/path-injection query recognizes as clearing taint.
This commit is contained in:
parent
52aa18b019
commit
d0ae2926e6
|
|
@ -780,7 +780,11 @@ def kanban_task_path(task_id: str) -> Path:
|
|||
"""Resolve a task id to its file path, rejecting anything that isn't a plain generated id."""
|
||||
if not KANBAN_ID_RE.fullmatch(task_id or ""):
|
||||
raise HTTPException(400, "Invalid task id")
|
||||
return KANBAN_DIR / f"{task_id}.json"
|
||||
base = KANBAN_DIR.resolve()
|
||||
candidate = (base / f"{task_id}.json").resolve()
|
||||
if candidate.parent != base:
|
||||
raise HTTPException(400, "Invalid task id")
|
||||
return candidate
|
||||
|
||||
def save_kanban_task(task: dict):
|
||||
ensure_dir(KANBAN_DIR)
|
||||
|
|
|
|||
Loading…
Reference in New Issue