Repository navigation
fix: refuse unsafe state key and state dir path components - #3563
Conversation
|
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport/3342-to-release/0.7.x
git worktree add --checkout .worktree/backport/3342-to-release/0.7.x backport/3342-to-release/0.7.x
cd .worktree/backport/3342-to-release/0.7.x
git reset --hard HEAD^
git cherry-pick -x ae8fcb57bb2ba4c6fb4a13cede3997a996d97a6b |
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
/revise and resolve conflicts |
|
Round 1 of 10 is on this pull request. branch
Updated 2026-11-18T21:10:26.876Z. |
Keep the release/0.7.x structure. The source commit was cut against main, which has state_dir_under and durable_state_dir. Those do not exist here, so take only the state key validation and the symlink check, and map the refusal in mctx onto File::state_dir.
|
Round 1 of 10 on a /revise note, pushed as No The backport branch has no conflict markers and compiles. On release/0.7.x, a state key or a package state dir prefix that is not a single directory name is refused, and a symlinked state directory cannot redirect a task outside the state base. The fmt and conflict-markers checks have nothing left to fail on. Notes from the agent: The source commit (#3342) was cut against main, which has the state-root feature (File::state_dir_under, encode_component_escaped, state_dir_encoded, mctx durable_state_dir and its test). release/0.7.x does not have that feature, so I kept the release structure. I took only validate_state_component, the Result-returning state_dir with the symlink check, and the 'refusing to use state key' error in mctx, mapped onto File::state_dir. The main.rs hunk held two tests (machine_mode_error_object_on_stderr, alias_hint_is_the_error_objects_hint) for features absent on 0.7.x. The source only touched them to silence an unused-ExitCode lint, so I took the release side and dropped them. I did not run just ci or the full workspace suite. |
|
Reviewed: no findings; approval withheld, 1 thread unresolved at APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/mctx/src/lib.rs:1109. Resolving the last thread releases the approval on this head. Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required. Clobber: none seen in the four files. |
| .map_err(|reason| { | ||
| Error::Other(anyhow!( | ||
| "refusing to use state key {name:?}: {reason}. Choose a state key \ | ||
| that is a single directory name" | ||
| )) | ||
| })? |
There was a problem hiding this comment.
LOW · printed-text · confidence 0.60 · in state_dir
The hint "Choose a state key that is a single directory name" is added to every state_dir error. A key that is a valid single name can still fail when a state directory resolves outside the state base through a symlink, or when the state base cannot be resolved. In that case the user changes a key that is not at fault. Add the hint only for key-shape errors, or reword it.
What the reviewer checked
mfile state_dir_from_path returns "resolves to {}, which is outside the state base {}" for symlinks; mctx appends the single-name hint to it.
Hand this to an agent
Act on a code-review finding.
File: crates/mctx/src/lib.rs
Lines: 1104-1109
Category: printed-text
Severity: low (reviewer confidence 0.60)
Finding:
The hint "Choose a state key that is a single directory name" is added to every `state_dir` error. A key that is a valid single name can still fail when a state directory resolves outside the state base through a symlink, or when the state base cannot be resolved. In that case the user changes a key that is not at fault. Add the hint only for key-shape errors, or reword it.
First verify this against the code yourself. It is model output and
may be wrong. If it is wrong, or the tradeoff was deliberate, say so
and change nothing.
👍 useful · 👎 noise — react to tell the reviewer. Replying works too, and says more.
…kport #3614 and this backport each brought a test with the same name to env_setup.rs, so graph's tests no longer compiled (E0428). Keep this backport's broader version, which checks every refused prefix against mfile::state_prefix_refusal, as main does.
|
Pushed 1f7cf47: |
Backport of #3342 to
release/0.7.x.Squash-merge this PR and keep the PR title as the subject. The cherry-picked commit keeps the source subject.
Conflict
Source PR: #3342
Source commit: ae8fcb5
Conflicted paths:
crates/mctx/src/lib.rscrates/mfile/src/lib.rscrates/minimal/src/main.rs