Repository navigation
#673 [tests][mutants] 変異試験が防御を外したまま kill(-1) などを実行し、利用者の全プロセスを止める - #678
Merged
Merged
Conversation
Add `.cargo/mutants.toml` excluding `signalable_process_group` and `group_is_signalable`, add last, non-mutatable `assert!` defenses in the functions that call `kill`, guard the product `remove_dir_all` targets with an independent real-path strict-descendant check, add the dangerous-command inventory test and doc, and document the mutants rules in the dev harness. 判断: 子の session を変える変異の回収の仕組みは入れず、leader の隔離環境での確認に委ねた 読み替え: `is_strict_descendant` は最終成分が symlink の場合も拒否する(内側を指す symlink を含む) 本文に無い指摘: pager 試験の `git` は利用者の HOME を継承していた。bounded child の HOME を隔離 HOME に上書きした Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Make the recursive-delete guard return the checked real path (`strict_descendant_real_path -> Option<PathBuf>`) and have each caller delete only that returned value, so the checked value is the value removed. Widen the dangerous-command inventory to read tracked `scripts/**/*.sh`, `scripts/**/*.py`, and `tests/**/*.py` for external `kill`/`pkill`/`killall`, `rm -rf`/`rm -r `, `os.kill(`/`os.killpg(`, and `shutil.rmtree(`. 判断: F2(install_for_test の run_tmp_root)は変更していない。独立の root にすると src/lib.rs の sigint_finalizer 試験が失敗し、その修正も呼び出し側の署名変更も契約外のファイルを要するため Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
State in the recursive-delete section that the independent-root guarantee covers the production `install` path, and that the test-only `install_for_test` seam derives its root from the delete target, so making it independent needs files outside this Issue's scope. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Add `dangerous_value_terminate_process_group_by_pid_refuses_init_and_caller_group` (bounded_process) and `dangerous_value_send_group_signal_refuses_init_caller_and_negative_groups` (trial_process). Both skip the selector and pass 0/1/-1 to the `kill` wrappers, so a mutated selector reaches the non-mutatable `assert!` in front of `kill` instead of failing on the selector's own assertion (Issue #673 対処の方向 4). Document the two tests and their Docker commands. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
… Err Harness §3a: isolate signal/delete/child-session mutations unconditionally, spell out the Docker conditions (non-root uid 1000, --network none, no mounts, no privileged/pid=host/socket), and require a disposable container because cargo-mutants' --timeout does not reap a TERM-ignoring child. dangerous-commands §5: correct the scope (no host run only under mutation; unmutated CI/verify runs them and returns before the syscall; a new dangerous_value_ test is confirmed once in the container first) and add the new preflight test. preflight.rs: SystemPortControl::kill returns Err via bail! for pid 0/1 and the caller's own pid before the last-defense asserts (which stay). Add the container-only dangerous_value_system_port_control_kill_refuses_init_zero_and_own_pid.
The comment said the test runs only in the isolated container; it now matches docs/dev/dangerous-commands.md §5: under a mutation it runs only in the isolated container, and on an unmutated tree it also runs in host CI and verify.
10 tasks
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.
Refs #673
概要
2026-10-14 に、macOS で
cargo mutantsが process group の防御(signalable_process_group -> Some(1))を変異させ、変異した試験の binary がkill(-1, SIGTERM)を実行しました。その結果、利用者のプロセスがすべて止まりました。この PR は、その再発を防ぎます。変更の要約
.cargo/mutants.toml(新規):通常の設定で、signalable_process_groupとgroup_is_signalableをexclude_reで除外します。killの直前に、変異の対象にならないassert!を直接書きました。helper には包んでいません。src/bounded_process.rs、src/bin/gui_server/trial_process.rs、src/planner/runner/acceptance.rs、src/preflight.rs。preflightは、assert!の前でpid <= 1と自分の pid をbail!で断ります。dir_fd::strict_descendant_real_path(root, target) -> Option<PathBuf>を足しました。削除先が root の真の子孫かを確かめ、確かめた実パスだけをremove_dir_allに渡します。session_paths、model_probe、pack::supply、os_sandbox。docs/dev/dangerous-commands.md(新規)を足しました。tests/issue673_dangerous_command_inventory.rs(新規)は、src・tests・build.rs・scripts の signal と再帰削除を grep で拾います。一覧と食い違えば失敗します。docs/dev/parallel-dev-harness.mdに §3a(mutants の規則)を追加しました。--network none、mount・--privileged・--pid=host・Docker socket なし、木は build の context かdocker cpで渡す。--timeoutは残ったプロセスを回収しないので、run の後はコンテナごと捨てます(docker rm -f)。cargo mutants --listを全件照合します。tests/issue502_os_sandbox_write.rs:pager の試験の HOME と Git の設定を、利用者のものから隔離しました。利用者に見える挙動の変化
preflight:lsof がポートの持ち主として pid 0・1・自分の pid を返した場合、利用者が kill を選んでも signal は送りません。refusing to signal …のErrで返ります。以前はkillを呼んでいました(pid 1 ではEPERMなどのErr)。assert!に届く前にErr・bail!・falseで返ります。panic はしません。docs/dev/parallel-dev-harness.mdに §3a を追加しています(開発の手順の変更です)。検証
commandmate verifypassed 15/15。HEAD1f082adaで、最後の commit の後、clean です。cargo-zigbuild clippy --all-targets --target x86_64-unknown-linux-gnuexit 0。--network none、mount なし):dangerous_value_*)、番兵の試験、gui の試験はすべて pass しました。gui/outの build なし)でだけ失敗する 8 本は skip しました。base の739c441cでも同じ 8 本が失敗します。host の verify では pass しています。dangerous_value_の試験は、修正前のコードで FAILED(assert!で panic、signal の送信は 0 件)、修正後で pass です。kill(-1|0|1, …)は 0 件、canary は生存しました。signalable_process_group(除外なしの確認用の設定)group_is_signalable(除外なしの確認用の設定)configure_child_sessionpreflightの変えた行Some(0)・Some(1)・Some(-1))は、killの手前のassert!で panic しました。delete -)は、setsid() == 1が真にならないので等価です。レビュー
preflightのErrから panic への変化(F6)も直しました。後続の論点(この PR では直していません)
os_sandbox::install_for_testの root が、削除先と独立に決まっていません(試験だけで使う経路)。tests/**/*.shの読み込み。session_paths::rollback_unstartedの NotFound の判定の missed 3 本:試験を強化します。🤖 Generated with Claude Code