fix(disk-hygiene): gate PowerShell move/rename/overwrite spellings - #2470
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Claude finished @kyle-sexton's task in 2m 59s —— View job Security review of PR #2470 (
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 403b64dbfb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
52c152d to
62fbaa9
Compare
|
Claude finished @kyle-sexton's task in 2m 22s —— View job Security review of PR #2470 (
|
Fixes #387 Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
62fbaa9 to
d3de451
Compare
|
Claude finished @kyle-sexton's task in 1m 57s —— View job Security review of PR #2470 (
|
|
Claude finished @kyle-sexton's task in 3m 23s —— View job Code review of PR #2470 (
|
| "Move-Item C:/tmp/old C:/tmp/new", | ||
| "Rename-Item C:/tmp/old C:/tmp/new", | ||
| "Set-Content C:/tmp/file.txt 'overwrite'", | ||
| "Out-File C:/tmp/file.txt -Force", | ||
| "New-Item C:/tmp/file.txt -ItemType File -Force", | ||
| "'data' > C:/tmp/file.txt", |
There was a problem hiding this comment.
🔴 Important — several of the newly added regex alternatives have no test coverage at all
_POWERSHELL_MUTATION_WORDS (destructive_guard.py#L937-L939) adds mv|move|ren|rename (aliases for Move-Item/Rename-Item), add-content, and format-volume|clear-disk|initialize-disk — but this test only exercises Move-Item, Rename-Item, Set-Content, Out-File, New-Item -Force, and bare >. A grep of the whole test file turns up zero hits for Add-Content, Format-Volume, Clear-Disk, or Initialize-Disk in any PowerShell test, and no test exercises the mv/move/ren/rename aliases on the PowerShell lane (the one mv hit at line 2918 is an unrelated Bash-lane test). Since this is a blocklist-by-design lane, an untested alternative that's subtly wrong (typo, wrong precedence, word-boundary miss) would silently defer instead of prompting, and nothing in the suite would catch it.
Suggest adding one case per newly-added alternative (mv, move, ren, rename, Add-Content, Format-Volume, Clear-Disk, Initialize-Disk) to this loop.
| "Move-Item C:/tmp/old C:/tmp/new", | ||
| "Rename-Item C:/tmp/old C:/tmp/new", | ||
| "Set-Content C:/tmp/file.txt 'overwrite'", | ||
| "Out-File C:/tmp/file.txt -Force", | ||
| "New-Item C:/tmp/file.txt -ItemType File -Force", | ||
| "'data' > C:/tmp/file.txt", |
There was a problem hiding this comment.
🔴 Important — audit-only (kill-switch) deny path isn't re-verified for any of the new spellings
test_powershell_deletion_spellings_denied_in_audit_only_mode (test_hygiene.py#L4457-L4472) is the counterpart to this test — it asserts enabled=False turns the same spellings into deny instead of ask (kill-switch B2 behavior called out in this module's own docstring at destructive_guard.py:970-972). This PR extends the ask-path list here but leaves that deny-path list untouched, so none of Move-Item, Rename-Item, Set-Content, Out-File, New-Item -Force, or output redirection are verified to actually deny in audit-only mode — only that they prompt when the kill switch is on. _powershell_mutation_verdict routes both branches through shared code today, but that symmetry is exactly the kind of thing a future refactor could break unnoticed without a test on both sides.
|
Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count. |
…elt's documented posture Re-lands the report-ordering fix from #2635 (reverted by #2639's stale base) and the session-lifetime honesty from #2639 (reverted by #2641's stale base), then corrects three further documentation defects in the clean skill's two operator- facing markdown surfaces. F1 (#2590) — reports are ordered by tier and evidence strength, never by byte size: provenance/what-it-is/why-removable/risk lead, bytes come last; empty directories are first-class findings distinguished from not-walked coverage gaps; `provenance` and `risk` return to the plan schema; §5's preview table and §6's apply summary lead with tidiness rather than bytes. F5(a) (#2618) — the frontmatter PreToolUse belt is session-lifetime, not skill-scoped. Both markdown sites now say so, sourced from the skills reference ("registers when the skill is invoked and keeps running for the rest of the session"), and name the allowed-tools/hooks asymmetry that made the narrower claim plausible. The third site (destructive_guard.py's resolve_mode docstring) is covered by a sibling PR. F6 (#2618) — SKILL.md claimed the belt "still launches in exec form via python3", contradicting its own frontmatter and safety-model.md: it has been shell form since 0.17.9 (#2568). The false statement and the conclusions drawn from it (a silently-inert belt, defense-in-depth "lost, not preserved", #2568 unconverted) are removed rather than reworded; safety-model.md's accurate account, including the real residual fail-open, is the single copy. F4 (#2618) — step 6.2 listed three ways reversible removal silently becomes permanent but omitted path length, which fails differently: beyond MAX_PATH (260) a path cannot reach the Recycle Bin at all, so the only fallback is a permanent delete through a long-path API. That fallback now requires its own explicit irreversible-action approval instead of inheriting the tier approval given for reversible removals. F3 (#2618) — §3 now states that relocation is out of scope: the skill offers keep-or-delete only, and a move is the operator's own action outside the workflow. F7 (#2618) — the Gotchas section carried ~56 lines of harness mechanics already documented in full by reference/safety-model.md; hand-maintained duplication is how F6's stale bullet survived a fix to the reference. Those bullets are replaced with load-when pointers, leaving the engine-behavior and operator- actionable gotchas in place. Gotchas 77 -> 35 lines; SKILL.md 490 -> 495 net, the other findings having added required content, and back under the 500-line skill-quality cap it had 10 lines of headroom against. Also corrects safety-model.md's claim that Move-Item/Rename-Item "reach the tool with no guard verdict at all" — stale in the unsafe-sounding direction since #2470 gated move/rename/overwrite/volume spellings and closed #387. The lane is still enumerated rather than fail-closed, so the residuals are named concretely. Closes #2590 Refs #2618 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fixes #387
Extends the PowerShell lane mutation-spelling set with move, rename, overwrite, and truncation spellings.
Test plan
python3 -m pytest plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py -k powershell_deletion_spellings_forceRelated
N/A