Repository navigation
fix: read_file rejects non-regular files (FIFO hang in the jail) - #122
Merged
Merged
Conversation
A named pipe inside the workspace passed the directory check, reported len() == 0 (so the size cap never fired), and open() BLOCKED until a writer appeared — a hang inside a ReadOnly tool that freezes the whole turn loop. execute() now requires meta.is_file() and refuses anything else with a clean error. Regression test creates a real FIFO (mkfifo, skipped when unavailable) and asserts the refusal — if the guard ever regresses, the test itself hangs, which is the point.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
ajianaz
added a commit
that referenced
this pull request
Oct 28, 2026
…lines (#439) Cora (alerts #122/#123): a corrupt index line whose file is not <id>.jsonl made resume recurse without bound, and the first non-UTF-8 line ended the index read. find() now only returns an entry whose file is <dir>/<id>.jsonl and resume only looks up a valid id, so the recursive call always resolves locally; the index is read as raw byte lines and an unparsable one is skipped.
ajianaz
added a commit
that referenced
this pull request
Oct 28, 2026
… dir (#454) ## What A global session index so sessions can be found and resumed across projects: `tole sessions --all [--grep <text>]`, and `tole resume <id>` naming the project a session belongs to. Closes #439. ## Why Sessions live per cwd (`.tole/sessions/`); on a multi-project machine there was no way to find which project a session was in, and resuming required remembering the cwd. ## Changes - `tole-cli/src/session_index.rs` (new): `$CODECORA_HOME/tole/sessions-index.jsonl` (next to the trust store, rather than XDG, so all tole state shares one root). One line per session START — id, absolute session file, cwd, face, start time — written in one append-mode `write`, owner-only (0600); the last line per id wins, malformed/torn lines are skipped. **No prompt text in the index:** preview, status and turn count are read from the session file when listing. Recording is best effort (never fails a session); `TOLE_NO_SESSION_INDEX=1` disables it. - Recorded by `run`, `chat` (new sessions), `mission` and the session host (serve / ACP / MCP). - `tole sessions --all` — newest first, id, name, pc, turns, start time, cwd and a sanitized one-line preview; sessions whose file is gone are hidden. `--grep` (requires `--all`) filters case-insensitively on first prompt, name or cwd. - `tole resume <id>`: when the id is not in the current sessions dir but the index knows it, resume REFUSES and prints the command to run in the owning project (`cd <project> && tole resume <id>`, with `--sessions-dir` when non-default). Deliberate deviation from the issue's "cwd-independent resume" (Cora alert #124): resuming from here would apply this directory's workspace jail, project config and trust to another project's session. A missing local sessions dir is now "no local match" instead of an error. The index fallback only accepts a valid id whose indexed file is `<dir>/<id>.jsonl`, and the index is read as raw byte lines (a non-UTF-8 line is skipped) — Cora alerts #122/#123. - Docs: README, CHANGELOG, `docs/epics.md`, `docs/threat-model.md`. - Not in this PR: `chat --resume` does not consult the index yet. ## Testing - Unit: last-line-wins, newest-first, torn/foreign lines skipped, owner-only mode; rows read from the session file, gone sessions hidden, preview bounded and one-line, grep on prompt/cwd, `find` ignores gone files. - E2E (real binary, isolated `CODECORA_HOME`, mock provider): a session started in project A is invisible to B's `sessions`, listed by `sessions --all` with A's cwd and preview, matched by `--grep`, `resume <id>` from B refused with the exact `cd <A> && tole resume <id>` command and nothing written, then resumed from A; the index holds no prompt text; `TOLE_NO_SESSION_INDEX=1` records nothing; `--grep` without `--all` is refused. - `cargo fmt`, clippy (workspace all-targets, bare, shell-tools, mcp), `cargo test --workspace`: green (one run hit the known load-sensitive `web::fetch_and_search_round_trip_against_local_mock` flake, untouched here; green on rerun). Cora agent review (prepare + finalize): 0 findings, `should_block: false`. Note: e2e tests elsewhere that do not isolate `CODECORA_HOME` add their temp sessions to a developer's real index; `--all` hides them once their files are deleted. --------- Co-authored-by: ajianaz <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What (description of the change)
read_filenow requiresmeta.is_file()before reading: FIFOs, sockets, and device nodes inside the workspace jail are refused with a cleannot a regular fileerror instead of being opened.Why (the problem you're solving)
Closes #117 (cora full-scan MAJOR #21). A named pipe passed the directory check and reported
len() == 0, so the 1 MiB size cap never fired — andopen()on a FIFO BLOCKS until a writer appears. That is an indefinite hang inside a ReadOnly tool (no approval gate in front of it), freezing the entire turn loop with no durable record.Testing (how you verified this works)
rejects_non_regular_files_instead_of_hanging: creates a real FIFO viamkfifo(skips on platforms without it), asserts execute() returns the regular-file refusal. If the guard ever regresses, the test itself hangs → the suite times out, which is the intended failure mode.-D warningsclean.