Repository navigation
#645 [security][tools] Bash の作業ディレクトリを変えるオプションの省略形・まとまり・git の全体オプションの後の形を検査する - #654
Merged
Merged
Conversation
A table program's long option now matches a non-empty prefix (tar --dir), a `-`-prefixed option value is recorded and scanned again so a hidden `-C` is found (tar -cfC -C sub), git's value-taking global options skip their value word so a later `-C` is scanned (git -c k=v -C sub), and `npm -C` joins the table (Issue #645). The changed shapes become R=1; every other value is unchanged and the change only adds candidates. 判断: git の値をとる全体のオプションは本文の一覧どおり完全一致で扱い、接頭辞一致は加えていない(本文が名前を列挙しているため)。 判断: 値をとる全体オプションは Entry に欄を足して表し、git 以外は空にした(表を作業ディレクトリの解析の中だけに閉じるため)。 Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Add a `git -pc k=v -C sub log lf2` read case (Issue #645) to the variant integration test and the leaf unit test, so a cluster where the value-taking `-c` is not at position 0 pins that its value word is skipped and the later `-C` is still read. Product code is unchanged. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
git -C always takes exactly one literal path word. Rescanning its value made a value spelled like a value-taking global option (`--git-dir`, `-pc`, `-c`) swallow the following `-C sub`, so `sub/lf2` escaped (R=1 -> R=0). Now git's value is never rescanned (value_step returns 2 for stop_at_subcommand), while other table programs keep rescanning `-`-prefixed values (Issue #645). Tests: four new read rejections in git_c_value_named_like_a_global_option_still_reads_the_next_c, plus leaf unit assertions. The pre-fix code was observed to fail these. 判断: リーダーの差し戻しどおり、git の -C の値は値オプションとして読まず常に 2 語進め、git 以外の走査は変えない。 Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
…issue-645-security-tools-bash-git-637
Add a leaf unit case (`values(["tar", "-C", "--", "-C", "sub"])`) and a read rejection (`tar -C -- -C sub -tf lf2` with `sub/lf2` an outward symlink) for a non-git table program whose `-C` value is literally `--` (Issue #645). The value is one path word, so the walk advances two words and still reads the following `-C sub`. Product code is unchanged; the two cases fail under the `&&` -> `||` mutation of value_step. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
6 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.
概要
Bash の書き込みガードには、作業ディレクトリを変えるオプション(#637)を検査する処理があります。この処理は、次の 4 つの書き方を見落としていました。
tar --dir=sub・env --ch sub)-C(tar -cfC -C sub)-C(git -c k=v -C sub)npm -C(--prefixの短い形)見落とすと、その後ろの
/を含まない相対の読み取りが、ワークスペースの root だけを基準に判定されます。オプションで指定した directory の中に外を指す symlink があると、外を読めてしまいました(R=0)。この PR は、4 つの形を作業ディレクトリの候補に加えます。候補を足すだけで、減らす経路はありません。変更
src/tools/bash_write_guard/option_directory.rsmatches_long)。あいまいな省略形も候補を足す向き、つまり厳しい側になります。-で始まる値は値として記録し、その語をオプションとしても続けて走査します。こうして、隠れた-Cを見つけます。--は対象外です。-c・--git-dir・--work-tree・--namespace・--super-prefix・--config-env・--attr-source)は、値の語を読み飛ばしてから走査を続けます。走査は subcommand で止まります。npm -Cを表に加えました。17443e4a):value_step(entry, value)は、git(stop_at_subcommand)のとき常に 2 を返します。git の-Cの値の語を、もう一度オプションとして読むことはしません。git 以外のプログラムの式は変えていません。tests/issue645_bash_option_directory_variants.rs(新規、8 本)path_confinement_rejectionを、tempdir の fixture に対して呼びます。git -C --git-dir -C subなど)、tar -C -- -C sub。meson -C・unzip -d・git --git-dir=x)と、もともと拒否されていた git の形。runner.rs・loop_run.rs・baseline も変えていません。検証
commandmate verifyの 15 ゲートを、HEAD1ba87389で実行し、15/15 pass でした。fmt、clippy(-D warnings)、cargo testの全体を含みます。この HEAD には developd708619aを取り込んであります。c98bdc7c:表 1 の 3 本が FAIL しました(6 本中)。2a98c9fe:8 本中 1 本が FAIL しました(git_c_value_named_like_a_global_option_still_reads_the_next_c)。--jobs 1、--timeoutを明示):git -pcの形)。テストを足して、caught に直しました。value_stepの 244:61&&→||)は、テストを足して直しました(1ba87389、製品コードは変えていません)。merge 前レビュー
2a98c9fe):blocker 1。-Cの値が、値をとる全体オプションの名前のとき(git -C --git-dir -C sub log lf2など)、続く-Cを見落としていました。base では R=1 だった 3 形が R=0 になり、base より緩んでいました。17443e4aで、git では-Cの値の語を続けて走査しないようにしました。テストに 4 形を足しました。30c370d8):merge 可、blocker 0。1ba87389は、テストだけの commit です(製品コードは変えていません)。確かめてほしい点
-pc)の中のcにも、git の値の読み飛ばしが当たります。git 自身はまとめた全体オプションを受け付けないので、緩む向きの実害はありません(H-20 の後続の候補)。Refs #645
🤖 Generated with Claude Code