mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
fix: TOCTOU race in personal file delete + IndexError on whitespace cmd (#2228)
1. routes/personal_routes.py: os.path.exists() then os.remove() is a classic TOCTOU race — another request or cleanup can delete the file between the check and the remove, raising FileNotFoundError. Replace with try/except FileNotFoundError. 2. src/tool_implementations.py: cmd.split()[0] crashes with IndexError when cmd is a non-empty whitespace-only string (split() returns []). Guard with (cmd.split() or [''])[0]. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -286,9 +286,12 @@ def setup_personal_routes(personal_docs_manager, rag_manager, rag_available):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
# commonpath raises on mixed drives / non-comparable paths
|
# commonpath raises on mixed drives / non-comparable paths
|
||||||
in_uploads = False
|
in_uploads = False
|
||||||
if in_uploads and abs_target != base_abs and os.path.exists(abs_target):
|
if in_uploads and abs_target != base_abs:
|
||||||
os.remove(abs_target)
|
try:
|
||||||
deleted_from_disk = True
|
os.remove(abs_target)
|
||||||
|
deleted_from_disk = True
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass # already gone — race with another request or cleanup
|
||||||
|
|
||||||
# Exclude the file from the listing (persists across restarts)
|
# Exclude the file from the listing (persists across restarts)
|
||||||
personal_docs_manager.exclude_file(filepath)
|
personal_docs_manager.exclude_file(filepath)
|
||||||
|
|||||||
@@ -2662,7 +2662,7 @@ async def _cookbook_register_task(session_id: str, model: str, host: str,
|
|||||||
placeholder = (
|
placeholder = (
|
||||||
f"Launched via agent — waiting for tmux output…\n"
|
f"Launched via agent — waiting for tmux output…\n"
|
||||||
f" session: {session_id}\n"
|
f" session: {session_id}\n"
|
||||||
f" target: {target}{cmd.split()[0] if cmd else ''}\n"
|
f" target: {target}{(cmd.split() or [''])[0] if cmd else ''}\n"
|
||||||
f" cmd: {cmd[:200]}{'…' if len(cmd) > 200 else ''}"
|
f" cmd: {cmd[:200]}{'…' if len(cmd) > 200 else ''}"
|
||||||
)
|
)
|
||||||
tasks.append({
|
tasks.append({
|
||||||
|
|||||||
Reference in New Issue
Block a user