Repository navigation
Destructive-command check closes the command-parsing gaps found after the last release (GST-3190) - #4521
Closed
garrytan wants to merge 3 commits into
Closed
Destructive-command check closes the command-parsing gaps found after the last release (GST-3190)#4521garrytan wants to merge 3 commits into
garrytan wants to merge 3 commits into
Conversation
… the last release (GST-3190) Force-pushes to main written with --repo=, after a cd or with --all are blocked again; pipeline cds, $ reset revisions, quiet git clean, alternate git trees, find -L, trailing rm flags, reassigned mktemp variables, .. paths and same-line dry runs ask again; dry-run pushes, wipefs on files and SQL text in greps no longer trip it; GSTACK_SESSION_KIND=interactive outranks CI=1. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
…atement, and six review fixes (GST-3190) A dry run on the line before no longer excuses a real aws delete. SQL text that is printed into a pipe or file still asks, push-option values are not read as flags, wipefs stays blocked unless every target is a disk image, cd counts only as a command, and || is not a pipe. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… and wipefs reads /dev and option values correctly (GST-3190) Puts back the earlier cd handling, so a discard after if cd, while cd or time cd asks again. wipefs stays blocked for any /dev/ target, and the values of -t, -o and -O are not read as targets. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Contributor
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.
The destructive-command check now blocks force-pushes to main written with
--repo=, after acd, or with--all, and asks again for the other shapes that slipped past it after #4513.It also stops over-blocking dry runs,
wipefson image files, and greps for SQL text, andGSTACK_SESSION_KIND=interactivekeeps the ask underCI=1.Nothing to do: the check runs in every session already.
What changed, by shape
Steps back from main, fixed first:
git push --repo=origin +refs/heads/mainandgit push --repo=origin --force mainare denied. With--repo, every operand is read as a possible refspec (git itself reads the first one as the repository, so this is the cautious reading).cdinside a pipeline (cd /tmp | true && rm -rf dir) no longer counts as moving into scratch: bash runs each pipeline part in a subshell. A subshell now gives back the exact outer state, socd /tmp && (pwd) && rm -rf dirno longer asks.git reset --hard "$REV"asks again.printf x >> f && git reset --hardon a clean tree stays allowed: the only work it can lose is what the same command wrote.git stash popearlier in the same command does make a later discard ask, because pop drops the stash, the same lossstash dropalways asks about.Gaps in the catches #4513 added:
git clean -q/--quietno longer hides the dry-run listing.--work-tree,--git-dir,GIT_DIR=andGIT_WORK_TREE=forms ofcheckout -f,switch -fandclean -fask.find -L <dir> -delete(leading find options) is read correctly.rm dir -rfwith flags at the end asks whenrmis the command;docker rm web -fandaws s3 rmstay those tools' subcommands.mktempvariable assigned again in the same command is no longer scratch...beats the/procand/devexemptions, acdthrough..is never scratch, andrm -rf ../buildno longer rides the build-output allow.;with no space) never excuses it, andplancounts only as a whole word.GSTACK_SESSION_KIND=interactiveoutranksCI=1in the every-session guard hook (claude -pstays headless).Over-catches removed:
git push -nfis a dry run (letters afteroin a short-option group are a push-option value, not flags).wipefs -astays blocked unless every target has a disk-image suffix (.img,.iso,.raw,.qcow2,.vhd,.vhdx,.vmdk,.dmg) outside/dev/; the values of-t,-oand-Oare not targets.TRUNCATE x;) is ignored inside grep, rg, ag, ack andgit grep, and inecho/printftext when nothing after it pipes or redirects (||is not a pipe);./psql/in a path is a folder, not a client.Force-pushes that only asked:
cd . && git push -f originon main is denied: git now reads the folder acdchain leads to for the force-push lookups (discard checks still ask after anycd).git push --force --all,--branchesand--mirrorare denied when main, master or the default branch exists locally.Speed: the statement loop no longer indexes a bash array, which is linear per read on bash 3.2. A 200 KB command takes 1.3 s instead of 4.3 s on bash 3.2.57 and 0.9 s instead of 1.1 s on bash 5.2. Everyday commands are unchanged: p50 73.4 ms vs 73.2 ms at 55aaa6c on bash 5.2 (n=400 each, same machine, interleaved), with 9 ms of drift between repeat passes.
Tests
test/careful-replay.test.tsgains 48 rows (PARSER_CASES), one or more per shape above; 26 fail at 55aaa6c, 10 more (from review) fail at e20997b, 5 fail at e74219a, and the rest are controls or the pinnedprintfdecision. Non-main test trees now also hold a localmainbranch, as a feature checkout does.test/destructive-guard-hook.test.tsgains theCI=1case, which fails at 55aaa6c. The 102-row GEVA-560 replay stays green on bash 5.2.21 and 3.2.57.Not in this PR (outside its scope, none a step back from main): a quoted scratch path with a space, denying a literal home path, a failure while reading input before the safety trap, and a backtick revision in
reset --hard.Open notes found in review, left for a follow-up: the SQL-text exemption still allows
grep 'truncate users;' a.sql | shandecho "$(dbtool exec 'TRUNCATE TABLE users')"; quoted parentheses can restore an earliercdinto scratch;echo cd /tmpstill counts as acd;LC_ALL=C cd /tmp && rm -rf dirand printed SQL text followed by a pipe in a later statement ask; andgrep 'a; truncate demo;'still asks.Agent notes