Skip to content

v1.2.0

Latest

Choose a tag to compare

@github-actions github-actions released this 05 Nov 12:50

Closes the known gaps listed in 1.1.0's README, following the review by
@_shift_MIND (Claude + Codex, round after round). Every gap= row in tests/cases.py
is now a real expectation.

Added

  • One parser for the whole text. Quotes and heredocs span lines; \-newline joins lines; << counts only as an
    unquoted operator (not inside quotes, $((…)) or <<<); <<\EOF, <<-, several heredocs on one line;
    redirections are dropped with their target (2>/dev/null rm -rf $D); $'…' is decoded; zsh $=D is dynamic;
    ~+ is the working directory, and a quoted "~" is a plain name.

  • Command heads behind any wrapper. The command is the first rm/find/shell/… word behind a wrapper, so
    wrapper options need no table: env -u X, sudo -u U, timeout -s KILL 60, exec -a, caffeinate -i,
    stdbuf, coproc, watch, busybox, grm, function f {, and GNU prefixes of --recursive (--rec).

  • Quoted expansions are judged by their values. An unknown variable is empty, so rm -rf "$D"/* is rm -rf /*.
    $HOME, $PWD, $(pwd), $(git rev-parse --show-toplevel), ${D:-.}, ${D%/*}, ${D?} and literal
    assignments earlier in the command (D=/; rm -rf "$D") are resolved. Only "${D:?}" guarantees a value.

  • Globs and braces are expanded against the filesystem and every match is judged: .git/*, repo/*, .[!.]*,
    */.git, **/.git, {..,x}. Anything inside a .git directory is protected.

  • Strings the shell parses again are checked: bash -c, sh -c, zsh -lc, eval, trap, env -S, su -c,
    watch, a here-string or a heredoc fed to a shell, echo … | sh, and the $(…) / backticks of an unquoted heredoc.

  • find is judged like rm -r unless a name test narrows it (a literal character, not negated, not able to match
    .git): find ., the implicit ., -mindepth, -type f, -name '*', -regex '.*', an -o branch. -H -L -P
    are skipped; -exec /bin/rm, -execdir, -ok and -exec sh -c count as deletes.

  • xargs rm -r is blocked unless the input is NUL- or newline-separated (-0, -d '\n').

  • cd is followed: cd .. && rm -rf repo, pushd, env -C, sudo -D; ( … ) restores the directory; after ;
    both the old and the new directory count (the cd may have failed); cd x || exit and if cd x; then are certain.
    cd build && rm -rf * is no longer blocked.

  • Scripts: bash FILE / source FILE are read whatever the extension; a quoted script variable ("$S"); 8 levels
    deep; a heredoc written to a file (>, tee, a variable target) and run later in the same command.

  • Edit / MultiEdit are judged on the file they produce, and only the issues an edit adds are reported (an unrelated
    edit to a legacy script passes). Write is judged the same way against the file it replaces.

  • ~/.claude and ~/.ssh are protected; rsync --delete* is judged on its destination ("$DST/" with an empty DST
    is /).

  • The Monitor tool is checked like Bash. --install upgrades an existing entry (its matcher gains the missing
    tools, its command is updated) instead of reporting "already registered"; it warns on Windows.

  • Review panel (four reviewers: shell parser, values and globs, find/xargs/cd, scripts and edits; their rows are
    P1-* in tests/cases.py). Fixed on their findings:

    • $(…) is read like the shell reads it: an apostrophe in a "$(cat <<'EOF' … EOF)" commit message no longer
      hides the rest of the command; comments and case patterns inside $(…) too.
    • Wrappers are read with their option arities (sudo -u "$U", timeout "$T", env FOO=$X, flock FILE -c,
      /usr/bin/time -v, noglob), so timeout 30 git rm -r --cached . is no longer taken for rm.
    • bash -euo pipefail FILE, bash -s ARGS, positional arguments (bash -c '…' _ ~, ./x.sh ., f ~ for a
      function defined in the same command), trap --, su -lc, eval that changes directory, and bash -c "$CMD"
      with CMD assigned in the same command.
    • Unquoted heredocs are judged as the text the shell receives (\$D is $D; $OUT is its known value).
    • Scripts written with echo/printf and run, >> appends, a script rewritten and run again, more than 8 levels
      of scripts (blocks), NUL bytes in scripts (no crash), and a bare command name no longer looked up in the cwd.
    • find primaries are evaluated in order and per -o branch inside parentheses; a name pattern built from a
      variable, or one that matches names inside .git (-name objects), does not narrow unless .git is pruned;
      a narrowed find that matches the working directory by name blocks; -type l narrows; find … -print0 | xargs -0 rm and ls | xargs -d '\n' rm -r are judged by what they print.
    • cd x && + newline, cd x || { …; exit; }, set -e, if ! cd x, cd --, env -C.., $(cd .. && pwd),
      $(dirname …), $(mktemp -d), ~- and $OLDPWD after a cd.
    • Conditional and += assignments, ${V:=w}, ${V%…}/${V#…} of known values, globs, ~ and braces in for
      lists, {~,x}, a directory holding a repository one level down, ~/.claude/hooks and ~/.claude/projects,
      rsync option arguments and sources without a trailing slash, *.*.
    • Limits: the glob budget is per glob, a huge brace range is cheap, too many values block, and checking stops
      after 5 s (and blocks) instead of running into the hook timeout.
    • Edit diffs count repeated issues; Write/Edit of ~/.bashrc, .envrc, .husky/* and .git/hooks/* is checked.
    • --install leaves a * or empty matcher alone, adds a separate entry instead of widening one shared with
      another hook, recognises our hook by its file name, refuses malformed settings, and backs up only on change.
  • Review panel, round 2 (an adversary and a regression reviewer on the round-1 fixes; rows P2-*):

    • $(…): the word case as an argument ("$(echo edge case)") and a heredoc closed by EOF) no longer hide
      the rest of the command.
    • "$@" and "${A[@]}" are judged element by element when the arguments are known (bash -c 'rm -rf "$@"' _ ~,
      f ~, ./x.sh ~); arrays (DIRS=(. build)); exported and NAME=value prefix variables reach scripts and
      bash -c; source runs in the caller's shell (its variables, functions and cd stay); $0/BASH_SOURCE are set
      for scripts; RM=rm; $RM -rf; source <(echo …); echo … | tee x.sh && bash x.sh; printf '%s\n' ….
    • Variables after if/case/loops and && chains: an assignment used in its own branch is certain; after the
      block every path's value counts (if/else and case with a *) arm cover every path). esac closes the case.
    • Functions are checked where they are called, with the call's arguments; a call is followed once per distinct
      arguments and a function calling itself is not followed (sourcing nvm took 5 s and blocked; it takes ~0.5 s now).
      A function that is never called is checked once with unknown arguments.
    • find: an unknown name pattern (-name "$PAT") does not narrow; real branch names inside .git are tested;
      -path ./.git -prune -o … -print0 | xargs -0 rm passes; nested-repetition regexes are not run (they could hang).
    • cd - follows OLDPWD, popd the pushd stack; eval "cd x" && …; set +o errexit, set -- -e; a function that
      always exits after ||; sudo -Hu root; env "NAME=$V"; xargs -I{} (whole lines) is accepted.
    • >> reports only what it adds; caches of clones (~/.cache/pre-commit, build/_deps, .terraform, cargo, Go)
      are not protected as "a directory holding a repository"; a submodule or linked worktree (.git is a file) does
      not protect its parent directory, since its history lives elsewhere (the directory itself is still protected).
    • --install no longer adds a second entry on every run for a shared entry, and raises a timeout below 10 s.

Changed

  • Block messages say why: would delete the filesystem root contents (when D is empty or unset).
  • Git's temporary state inside .git (rebase-merge, rebase-apply, sequencer, worktrees/<name>) may be
    deleted; everything else inside .git is protected.