8000 fix: refuse unsafe state key and state dir path components by minimal-backporter[bot] · Pull Request #3563 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix: refuse unsafe state key and state dir path components - #3563

Merged
norrietaylor merged 4 commits into
release/0.7.xfrom
backport/3342-to-release/0.7.x
Nov 19, 2026
Merged

norrietaylor merged 4 commits into
release/0.7.xfrom
backport/3342-to-release/0.7.x

Conversation

@minimal-backporter
@minimal-backporter minimal-backporter Bot commented Nov 18, 2026 •
Copy link
Copy Markdown

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.rs
  • crates/mfile/src/lib.rs
  • crates/minimal/src/main.rs

@minimal-backporter
Copy link
Copy Markdown
Author

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

@coderabbitai
coderabbitai Bot commented Nov 18, 2026 •
Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dfa8ff20-faa4-4a1c-bdf8-8f69adb1765b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@minimal-backporter minimal-backporter Bot added the backport-conflict Backport PR with committed conflicts; resolve before marking ready label Nov 18, 2026
@norrietaylor
Copy link
Copy Markdown
Member

/revise and resolve conflicts

@minimal-foundry
minimal-foundry Bot commented Nov 18, 2026 •
Copy link
Copy Markdown
Contributor

Round 1 of 10 is on this pull request.

branch backport/3342-to-release/0.7.x

round outcome job
1 pushed b6e91560

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.
@minimal-foundry
Copy link
Copy Markdown
Contributor

Round 1 of 10 on a /revise note, pushed as 3a476f0a0938.

No test: line was run.

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.

@norrietaylor
norrietaylor enabled auto-merge (squash) November 19, 2026 06:28
@minimal-foundry
minimal-foundry Bot commented Nov 19, 2026 •
Copy link
Copy Markdown
Contributor

Reviewed: no findings; approval withheld, 1 thread unresolved at 1f7cf4725348.

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.

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

Comment thread crates/mctx/src/lib.rs
Comment on lines +1104 to +1109
.map_err(|reason| {
Error::Other(anyhow!(
"refusing to use state key {name:?}: {reason}. Choose a state key \
that is a single directory name"
))
})?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@norrietaylor
Copy link
Copy Markdown
Member

Pushed 1f7cf47: crates/graph/src/env_setup.rs had two tests named a_state_dir_prefix_that_is_not_a_single_component_fails_the_whole_setup once #3614 landed on the line (E0428 in clippy, tests and native-daemon-e2e). Kept this PR's broader version, as main does, and dropped the older one. cargo test -p graph --lib env_setup passes locally (8 tests).

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approval withheld

Verdict COMMENT — APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/mctx/src/lib.rs:1109. No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@norrietaylor
norrietaylor merged commit 7e054d4 into release/0.7.x Nov 19, 2026
36 of 38 checks passed
@norrietaylor
norrietaylor deleted the backport/3342-to-release/0.7.x branch November 19, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-conflict Backport PR with committed conflicts; resolve before marking ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0