Repository navigation
fix(config): make the merge shape check agree with the reader - #1278
Merged
Merged
Conversation
The shape check and the TOML reader in merge-command.sh named table headers differently and judged keys outside the merge table by their own text. Valid TOML such as [dev] + merge.command, a quoted header, or dev = { merge = ... } passed the check and read as unset, so the kit merged plain and skipped the project merge guard. The check now finds headers exactly as the reader does and judges keys by full path; each such form refuses (exit 2). Proof: docs/verification/merge-shape-differential.md.
An independent review found more valid TOML that passed the shape check and read as unset: nested-array lines, multi-line strings, escaped keys and headers, a two-line dev inline table, form-feed blanks. The check now accepts a line opening with [ only as a plain header, refuses multi-line strings, odd blanks and a backslash in a key, and refuses any value on a parent of the merge table.
A second review found a nested array element alone on its line still read as a header, and that refusing every triple quote or nested array blocked plain configs. The check now tracks multi-line arrays and strings and refuses a stray [ line only where the reader would leave or enter the merge table. Check and reader run under LC_ALL=C so a locale cannot change what counts as a blank.
A third review showed quote counting cannot follow TOML strings: a triple quote inside a one-line string, mixed delimiters, a backslash ending a literal string or a double quote inside one still hid a key or a header from the check. One left-to-right scan per line now tracks basic, literal and both multi-line string kinds, comments, and array depth.
A fresh fuzzing review found no fail-open in about 69,000 generated files. It found one low-impact case ([[dev]] before [dev.merge]) and a new over-refusal: array element lines with = or a backslash were judged as keys. Both fixed, with test rows.
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.
What
A push security review flagged a parser differential in
lib/config/merge-command.sh: the shape check (_kit_mc_shape) and the reader (_kit_toml_get) did not agree on which lines form the merge table. It is real. Valid TOML that names the merge command, such as[dev]+merge.command = "...",dev = { merge = { ... } }or["dev".merge], passed the check while the reader returned empty. Empty means unset, sowrap merge,wrap land,mega-mergeandstack-mergefell back to the plain squash and skipped the project's own merge guard. Thedev.mergeforms came in with #1277. The quoted legacy["merge"]header and the header-comment forms predate it.The check now scans each line left to right the way TOML does (strings, escapes, multi-line strings, comments, array depth). It accepts a
[line only as a plain header, judges keys by full path, refuses an array of tables on a parent, and runs with the reader underLC_ALL=C. Every form the reader would misplace now refuses (exit 2), as the contract already said.Risk scope: the key is read from the default branch, so a PR cannot use this on its own merge. It is a fail-open on a config edit that looks like a no-op to anyone reading TOML: every later merge would silently skip the guard.
Demo
Proof
docs/verification/merge-shape-differential.md: the differential table, the red run, the green runs, the negative controls, four rounds of independent review, the guard-settings check and the rollback.
tomllib. The final corpus shows zero disagreements in both sections under macOS awk, gawk and mawk. The same harness flags failures onorigin/master, so the zero means something.kit.toml/.kit.tomlfiles from the local workspace (plus the operator file) give the same check result before and after. Plain[dev.merge], unrelated dev keys, regex lists, multi-line strings and nested arrays outside the merge table, and Vietnamese comments all still read.[dev.gate]has one reader and no separate check, so the check and the reader cannot disagree. An unreadable form falls back to the operator or default value, so it cannot switch a gate off.Bookkeeping
no-board-row: security fix from a push review, scoped to one function and its tests