From d5eeb71311d474b6c7cca0ddab12fbbd90192c31 Mon Sep 17 00:00:00 2001 From: Clarence Lee Date: Wed, 2 Dec 2026 10:05:25 +0800 Subject: [PATCH 1/5] fix(scaffold): close holes in the seeded gate ratchet config checks Co-Authored-By: Claude Sonnet 5.5 --- changelog.d/ratchet-config-holes.fixed.md | 1 + scripts/gate-ratchet.test.sh | 80 +++++++++++++++++++ .../shared/template/scripts/gate-ratchet.sh | 29 +++++-- tests/golden/fastapi-azure.sha256 | 2 +- tests/golden/fastapi-github.sha256 | 2 +- tests/golden/nestjs-azure.sha256 | 2 +- tests/golden/nestjs-github.sha256 | 2 +- tests/golden/nextjs-azure.sha256 | 2 +- tests/golden/nextjs-github.sha256 | 2 +- tests/golden/vite-react-azure.sha256 | 2 +- tests/golden/vite-react-github.sha256 | 2 +- 11 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 changelog.d/ratchet-config-holes.fixed.md diff --git a/changelog.d/ratchet-config-holes.fixed.md b/changelog.d/ratchet-config-holes.fixed.md new file mode 100644 index 00000000..cce15825 --- /dev/null +++ b/changelog.d/ratchet-config-holes.fixed.md @@ -0,0 +1 @@ +- Gate ratchet: now reports as WEAKENED `blockExoticSubdeps: false` in `pnpm-workspace.yaml`, an empty `files` list in `tsconfig*.json`, `allowEmptyCatch` on the ESLint `no-empty` rule, and a second `vitest*.config.*` file that competes with the ratcheted one. A `pyrightconfig.json` or `tsconfig*.json` with an unquoted key or an unclosed object is now UNREADABLE (exit 2) instead of silently accepted. A run that compared zero config files no longer reports ok. diff --git a/scripts/gate-ratchet.test.sh b/scripts/gate-ratchet.test.sh index 58678202..dbb500de 100644 --- a/scripts/gate-ratchet.test.sh +++ b/scripts/gate-ratchet.test.sh @@ -169,6 +169,84 @@ expect() { for frag in "$@"; do has "$frag" "$OUT" "$label: reports $frag"; done } +# Config holes: each probe has a clean control that must pass. GR_ONLY=holes runs only this section; it prints one line per case. +holes_cases() { + local sel + hc() { echo "gate-ratchet.test: holes: $1"; } + hbase() { edit "$@"; git_ checkout -q -B main work; } + + hc "ts controls" + seed ts + git_ checkout -q -B work main + expect 0 "holes: unchanged TS config passes" + passes pnpm-workspace.yaml "minimumReleaseAge: 10080" "minimumReleaseAge: 20160" "holes: tightened pnpm workspace" + passes tsconfig.json '"noImplicitOverride": true,' '"noImplicitOverride": true, + "noImplicitReturns": true,' "holes: tightened tsconfig" + passes eslint.config.mjs "['error', 15]" "['error', 10]" "holes: tightened eslint limit" + + hc "blockExoticSubdeps" + weakens pnpm-workspace.yaml "blockExoticSubdeps: true" "blockExoticSubdeps: false" "holes: blockExoticSubdeps false" "blockExoticSubdeps" + + hc "tsconfig files" + weakens tsconfig.json '"include": [' '"files": [], "include": [' "holes: tsconfig empty files list" "files" + passes tsconfig.json '"include": [' '"files": ["src/main.ts"], "include": [' "holes: tsconfig files with an entry" + + hc "second vitest config" + add_file vitest.unit.config.ts "export default { test: { coverage: { thresholds: { lines: 1 } } } };" + expect 1 "holes: new second vitest config" "vitest.unit.config.ts" + add_file vitest.config.e2e.mts "export default {};" + expect 0 "holes: new e2e vitest config keeps its old route" + seed ts + git_ checkout -q -B work main + printf 'export default { test: { coverage: { thresholds: { lines: 80 } } } };\n' > "$R/vitest.unit.config.ts" + git_ add -A; git_ commit -q -m "second config"; git_ checkout -q -B main work + weakens vitest.unit.config.ts "lines: 80" "lines: 1" "holes: threshold lowered in a second vitest config" "was 80" "now 1" + passes vitest.unit.config.ts "lines: 80" "lines: 90" "holes: threshold raised in a second vitest config" + + hc "allowEmptyCatch" + seed ts + weakens eslint.config.mjs "// @ts-check" "// @ts-check +const noEmpty = { rules: { 'no-empty': ['error', { allowEmptyCatch: true }] } };" "holes: no-empty allowEmptyCatch true" "allow-empty-catch" + passes eslint.config.mjs "// @ts-check" "// @ts-check +const noEmpty = { rules: { 'no-empty': ['error', { allowEmptyCatch: false }] } };" "holes: no-empty allowEmptyCatch false" + + hc "unreadable effective eslint config" + seed ts + cp "$SH/template-ts/scripts/eslint-effective.mjs" "$R/scripts/eslint-effective.mjs" + git_ add -A; git_ commit -q -m helper + edit eslint.config.mjs "['error', 15]" "['error', 10]" + expect 2 "holes: no installed eslint is unreadable, never a pass" "UNREADABLE eslint.config.mjs" "fail closed" + + hc "python controls" + seed py + git_ checkout -q -B work main + expect 0 "holes: unchanged Python config passes" + passes pyproject.toml '"TID251", "TID252",' '"TID251", "TID252", "ANN",' "holes: ruff select gains a family" + sel='"E4", "E7", "E9", "F", "I",' + weakens pyproject.toml "$sel" '"E4", "E7", "E9", "F",' "holes: ruff select loses a family" "select 'I'" + weakens pyproject.toml "$sel" '"E4",' "holes: ruff select narrowed" "select 'E7'" + hc "pyright" + edit pyrightconfig.json '"venvPath": ".",' '"venvPath": ".", oops: 1, "reportMissingImports": "none",' + expect 2 "holes: malformed pyrightconfig fails closed" "UNREADABLE pyrightconfig.json" + git_ checkout -q -B work main + printf '{ "typeCheckingMode": "strict"\n' > "$R/pyrightconfig.json" + git_ commit -q -am truncated + expect 2 "holes: truncated pyrightconfig fails closed" "UNREADABLE pyrightconfig.json" + passes pyrightconfig.json '"typeCheckingMode": "strict"' '"typeCheckingMode": "strict", "reportMissingImports": "error"' "holes: pyright gains a report setting" + + hc "malformed tsconfig" + seed ts + edit tsconfig.json '"compilerOptions": {' 'oops: 1, "compilerOptions": {' + expect 2 "holes: malformed tsconfig fails closed" "UNREADABLE tsconfig.json" +} + +if [[ "${GR_ONLY:-}" == holes ]]; then + holes_cases + echo "gate-ratchet.test: $PASS passed, $FAIL failed" + [[ "$FAIL" -eq 0 ]] + exit +fi + TAB=$(printf '\t') NEWSHA=$(printf 'a%.0s' {1..40}) seed ts @@ -2152,5 +2230,7 @@ check 0 "$EC" "first manifest revert proof: without the 1b branch the self-hashe RATCHET=$RATCHET_REAL seed ts +holes_cases + echo "gate-ratchet.test: $PASS passed, $FAIL failed" [[ "$FAIL" -eq 0 ]] diff --git a/skills/scaffold/shared/template/scripts/gate-ratchet.sh b/skills/scaffold/shared/template/scripts/gate-ratchet.sh index cff8ac45..7d3e743b 100755 --- a/skills/scaffold/shared/template/scripts/gate-ratchet.sh +++ b/skills/scaffold/shared/template/scripts/gate-ratchet.sh @@ -7,6 +7,7 @@ # pytest: any change to a [tool.pytest.ini_options] key or a new key is a finding, except raising --cov-fail-under and the markers, pythonpath and asyncio_default_fixture_loop_scope keys. # import-linter: every key of [tool.importlinter] and its contracts must stay as it was (layers, root_packages, ignore_imports); a new .importlinter or setup.cfg competes with it. # Type checkers: tsconfig and pyright strictness may tighten, never loosen; a new tsconfig or pyright config may not switch strictness off. +# Closed list of config keys the ratchet reads beyond the above: pnpm-workspace.yaml blockExoticSubdeps (false is a fact), tsconfig files (an empty list is a fact), eslint no-empty with allowEmptyCatch: true (a fact), and every vitest*.config.* file (an existing one is compared by its facts; a new one beside a vite or vitest config is WEAKENED). A value the readers cannot parse fails closed; nothing they read is skipped. # Gate-time budget: .claude/gate-budget.conf may not be deleted, and its three limits may not rise; a conf with no merge-base copy is held to the seeded defaults (600, 180, 25) and may not set a higher limit or leave one out. The kind is not enforced, so a human applying the allow-gate-change label can waive a raise or a deletion, by design. # Allow-lists: dep-audit-allow.txt may only lose lines; comment-hygiene-patterns.txt may only gain lines at the end. # Seeded-file exemptions: when the merge base has .claude/harness.json, a new entry, a changed origin_hash or a path added to .claude/seeded-paths.txt is WEAKENED, a dropped manifest is WEAKENED, an entry or list line removed is fine, and an unreadable or duplicated manifest is UNREADABLE. The seedmf kind is not enforced, so the human-applied allow-gate-change label waives WEAKENED (the bless, upgrade and refresh routes change hashes and entries and need it); UNREADABLE is never waived. When the merge base has .claude/gates.txt but no manifest, a manifest added in this change is WEAKENED (human waiver only). Without any harness at the merge base (adoption) one NOTE counts the exempt files. @@ -80,7 +81,7 @@ kind_of() { case "$1" in .jscpd.json | */.jscpd.json) KIND=jscpd ;; eslint.config.* | */eslint.config.* | layers.config.mjs | */layers.config.mjs) KIND=eslint ;; - vitest.config.* | vite.config.* | vitest.workspace.* | */vitest.config.* | */vite.config.* | */vitest.workspace.*) KIND=vitest ;; + vitest*.config.* | vite.config.* | vitest.workspace.* | */vitest*.config.* | */vite.config.* | */vitest.workspace.*) KIND=vitest ;; sonar-project.properties | */sonar-project.properties) KIND=sonar ;; package.json | */package.json) KIND=pkgjson ;; pyproject.toml | */pyproject.toml) KIND=pyproject ;; @@ -255,6 +256,15 @@ shadow_reason() { fi done ;; + vitest?*.config.*) + case "${name#*.config.}" in js | mjs | cjs | ts | mts | cts | json) ;; *) return 1 ;; esac + for f in vite vitest; do + if gs_test awk -v pre="${dir}${f}.config." 'index($0, pre) == 1 && substr($0, length(pre) + 1) ~ /^([cm]?[jt]s|json)$/ { hit = 1 } END { exit !hit }' "$wd/base.paths"; then + echo "a second vitest config can carry its own coverage thresholds, and a run reads only the config it is pointed at" + return 0 + fi + done + ;; eslint.config.* | vitest.config.* | vite.config.* | jest.config.*) case "${name#*.config.}" in js | mjs | cjs | ts | mts | cts | json) ;; *) return 1 ;; esac fam=${name%%.config.*} @@ -669,6 +679,7 @@ function do_eslint( from, m, name, rest, sev, seen, p, opt, sc, key, lim) { emit("sev", key, sev); seen = 1 if (sev < 2 && in_rules(MS)) emit("set", "rule-below-error", key) p = substr(T, from) + if (name == "no-empty" && match(p, /^[ \t\n]*,[ \t\n]*[{][^}]*allowEmptyCatch[ \t\n]*:[ \t\n]*true/)) emit("set", "allow-empty-catch", key) if (match(p, /^[ \t\n]*,[ \t\n]*[0-9]+[ \t\n]*[],]/)) emit("max", lim, num_in(substr(p, 1, RLENGTH))) else if (match(p, /^[ \t\n]*,[ \t\n]*[{][^}]*(max|maximum|threshold|complexity)[ \t\n]*:[ \t\n]*[0-9]+/)) { opt = substr(p, 1, RLENGTH); sub(/.*:[ \t\n]*/, "", opt); emit("max", lim, opt) } } @@ -1111,15 +1122,19 @@ function do_tsconfig( p, n, j, key, v) { if (p <= 1) fail("tsconfig is not a JSON object") while (p > 1 && p <= n) { while (p <= n && substr(T, p, 1) ~ /[ \t\n,]/) p++ - if (substr(T, p, 1) != "\"") break + if (substr(T, p, 1) != "\"") { if (substr(T, p, 1) != "}") fail("a key is not a quoted name, so the rest of the file is unread: " substr(T, p, 20)); break } j = jstr_end(p); key = substr(T, p + 1, j - p - 1); p = j + 1 while (p <= n && substr(T, p, 1) ~ /[ \t\n:]/) p++ if (key == "compilerOptions") ts_options(p) else if (key == "extends") emit("cfg", "extends", vtext(p)) else if (key == "exclude") strict_array(p, "set", "exclude") - else if (key == "include" || key == "files") strict_array(p, "req", key) + else if (key == "include" || key == "files") { + strict_array(p, "req", key) + if (key == "files" && vtext(p) ~ /^\[[ \t\n]*\]$/) emit("set", "files", "empty") + } v = vtext(p); p = VEND } + if (p > n) fail("the top-level object is not closed") } function sev_of(v) { @@ -1135,7 +1150,7 @@ function do_pyright( p, n, j, key, v, m, sv, mode) { if (p <= 1) fail("pyrightconfig is not a JSON object") while (p > 1 && p <= n) { while (p <= n && substr(T, p, 1) ~ /[ \t\n,]/) p++ - if (substr(T, p, 1) != "\"") break + if (substr(T, p, 1) != "\"") { if (substr(T, p, 1) != "}") fail("a key is not a quoted name, so the rest of the file is unread: " substr(T, p, 20)); break } j = jstr_end(p); key = substr(T, p + 1, j - p - 1); p = j + 1 while (p <= n && substr(T, p, 1) ~ /[ \t\n:]/) p++ v = vtext(p) @@ -1153,6 +1168,7 @@ function do_pyright( p, n, j, key, v, m, sv, mode) { else if (key !~ /^(venvPath|venv|pythonVersion|pythonPlatform|extraPaths|stubPath|typeshedPath|verboseOutput)$/) emit("cfg", key, v) p = VEND } + if (p > n) fail("the top-level object is not closed") emit("min", "pyright-mode", mode) emit("flag", "typeCheckingMode", (mode >= 2) ? 1 : 0) } @@ -1333,7 +1349,7 @@ function do_pnpmws( i, n, L, line, v, inbuilds, inlist) { if (line ~ /^minimumReleaseAge:/) { v = line; sub(/^[^:]*:[ \t]*/, "", v); gsub(/^["']|["']$/, "", v); if (!plain_num(v)) fail("minimumReleaseAge is not a plain number"); emit("min", "minimumReleaseAge", v) } else if (line ~ /^minimumReleaseAgeExclude:/) emit("set", "minimumReleaseAgeExclude", "present") else if (line ~ /^dangerouslyAllowAllBuilds:/) { v = line; sub(/^[^:]*:[ \t]*/, "", v); gsub(/^["']|["']$/, "", v); if (yes(v)) emit("set", "dangerouslyAllowAllBuilds", "true") } - else if (line ~ /^(strictDepBuilds|ignoreScripts):/) { v = line; sub(/^[^:]*:[ \t]*/, "", v); gsub(/^["']|["']$/, "", v); if (no(v)) { sub(/:.*$/, "", line); emit("set", line, "false") } } + else if (line ~ /^(strictDepBuilds|ignoreScripts|blockExoticSubdeps):/) { v = line; sub(/^[^:]*:[ \t]*/, "", v); gsub(/^["']|["']$/, "", v); if (no(v)) { sub(/:.*$/, "", line); emit("set", line, "false") } } else if (inbuilds && line ~ /^[ \t]+[^ \t].*:[ \t]*["']?[Tt][Rr][Uu][Ee]["']?[ \t]*$/) { v = line; sub(/:[ \t]*["']?[Tt][Rr][Uu][Ee]["']?[ \t]*$/, "", v); gsub(/^[ \t'"'"'"]+|[ \t'"'"'"]+$/, "", v); emit("set", "allowBuilds", v) } } } @@ -2406,7 +2422,7 @@ fp_cfg() { awk -v p="$pre" ' index($0, p) == 1 { n = split($0, a, "/"); name = a[n]; dir = substr($0, 1, length($0) - length(name)) - if (name ~ /^(vite|vitest)[.]config[.]([cm]?[jt]s|json)$/) v[dir]++ + if (name ~ /^(vite[.]config|vitest[^\/]*[.]config)[.]([cm]?[jt]s|json)$/) v[dir]++ if (name ~ /^eslint[.]config[.]([cm]?[jt]s|json)$/) e[dir]++ if (name ~ /^vitest[.]workspace[.]/) printf "WEAKENED %s: a vitest workspace file replaces the test projects of the seeded vitest config, so its coverage floor may not apply\n", $0 if (name ~ /^sonar-project[.]properties$/ || name ~ /^[.]sonarcloud[.]properties$/) s[dir]++ @@ -2707,4 +2723,5 @@ if [ "$unreadable" -eq 1 ]; then echo "Fix: make the file parseable again (restore it from the merge base), then rerun." exit 2 fi +[ "$checked" -gt 0 ] || die "no config file was compared, so nothing was checked; a run that checked nothing is never a pass" echo "gate-ratchet: ok, no gate weaker than at the merge base ($checked config files compared)" diff --git a/tests/golden/fastapi-azure.sha256 b/tests/golden/fastapi-azure.sha256 index 85821eaa..87f00dee 100644 --- a/tests/golden/fastapi-azure.sha256 +++ b/tests/golden/fastapi-azure.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -f67147507c9772d6ee52c82200bfd1cdf8e5d7875824d0363a52ee42f2e2ad2b scripts/gate-ratchet.sh +09814890df7717a04accf3b74513bd7bff28e9bef534c48457e12271a914afe2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/fastapi-github.sha256 b/tests/golden/fastapi-github.sha256 index f004eaba..1eedae85 100644 --- a/tests/golden/fastapi-github.sha256 +++ b/tests/golden/fastapi-github.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -f67147507c9772d6ee52c82200bfd1cdf8e5d7875824d0363a52ee42f2e2ad2b scripts/gate-ratchet.sh +09814890df7717a04accf3b74513bd7bff28e9bef534c48457e12271a914afe2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/nestjs-azure.sha256 b/tests/golden/nestjs-azure.sha256 index a3928b48..42e1c8c7 100644 --- a/tests/golden/nestjs-azure.sha256 +++ b/tests/golden/nestjs-azure.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -f67147507c9772d6ee52c82200bfd1cdf8e5d7875824d0363a52ee42f2e2ad2b scripts/gate-ratchet.sh +09814890df7717a04accf3b74513bd7bff28e9bef534c48457e12271a914afe2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nestjs-github.sha256 b/tests/golden/nestjs-github.sha256 index 4507cb4d..41a30a5d 100644 --- a/tests/golden/nestjs-github.sha256 +++ b/tests/golden/nestjs-github.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -f67147507c9772d6ee52c82200bfd1cdf8e5d7875824d0363a52ee42f2e2ad2b scripts/gate-ratchet.sh +09814890df7717a04accf3b74513bd7bff28e9bef534c48457e12271a914afe2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-azure.sha256 b/tests/golden/nextjs-azure.sha256 index ab57b568..6441f56b 100644 --- a/tests/golden/nextjs-azure.sha256 +++ b/tests/golden/nextjs-azure.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -f67147507c9772d6ee52c82200bfd1cdf8e5d7875824d0363a52ee42f2e2ad2b scripts/gate-ratchet.sh +09814890df7717a04accf3b74513bd7bff28e9bef534c48457e12271a914afe2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-github.sha256 b/tests/golden/nextjs-github.sha256 index 6b654318..438cd199 100644 --- a/tests/golden/nextjs-github.sha256 +++ b/tests/golden/nextjs-github.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -f67147507c9772d6ee52c82200bfd1cdf8e5d7875824d0363a52ee42f2e2ad2b scripts/gate-ratchet.sh +09814890df7717a04accf3b74513bd7bff28e9bef534c48457e12271a914afe2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-azure.sha256 b/tests/golden/vite-react-azure.sha256 index 2e4b8018..0d84b88d 100644 --- a/tests/golden/vite-react-azure.sha256 +++ b/tests/golden/vite-react-azure.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -f67147507c9772d6ee52c82200bfd1cdf8e5d7875824d0363a52ee42f2e2ad2b scripts/gate-ratchet.sh +09814890df7717a04accf3b74513bd7bff28e9bef534c48457e12271a914afe2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-github.sha256 b/tests/golden/vite-react-github.sha256 index b6c9da52..664053bb 100644 --- a/tests/golden/vite-react-github.sha256 +++ b/tests/golden/vite-react-github.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -f67147507c9772d6ee52c82200bfd1cdf8e5d7875824d0363a52ee42f2e2ad2b scripts/gate-ratchet.sh +09814890df7717a04accf3b74513bd7bff28e9bef534c48457e12271a914afe2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh From 20a78567d0b51d039d9d7cb0c232b7b4b0b838b2 Mon Sep 17 00:00:00 2001 From: Clarence Lee Date: Wed, 2 Dec 2026 12:21:27 +0800 Subject: [PATCH 2/5] fix(scaffold): ratchet allow-list for pnpm switches, key forms, no-empty options, files strings Co-Authored-By: Claude Sonnet 5.5 --- changelog.d/ratchet-config-holes.fixed.md | 2 +- scripts/gate-ratchet.test.sh | 66 +++++++++++++++---- .../shared/template/scripts/gate-ratchet.sh | 46 +++++++++++-- tests/golden/fastapi-azure.sha256 | 2 +- tests/golden/fastapi-github.sha256 | 2 +- tests/golden/nestjs-azure.sha256 | 2 +- tests/golden/nestjs-github.sha256 | 2 +- tests/golden/nextjs-azure.sha256 | 2 +- tests/golden/nextjs-github.sha256 | 2 +- tests/golden/vite-react-azure.sha256 | 2 +- tests/golden/vite-react-github.sha256 | 2 +- 11 files changed, 102 insertions(+), 28 deletions(-) diff --git a/changelog.d/ratchet-config-holes.fixed.md b/changelog.d/ratchet-config-holes.fixed.md index cce15825..0377ab01 100644 --- a/changelog.d/ratchet-config-holes.fixed.md +++ b/changelog.d/ratchet-config-holes.fixed.md @@ -1 +1 @@ -- Gate ratchet: now reports as WEAKENED `blockExoticSubdeps: false` in `pnpm-workspace.yaml`, an empty `files` list in `tsconfig*.json`, `allowEmptyCatch` on the ESLint `no-empty` rule, and a second `vitest*.config.*` file that competes with the ratcheted one. A `pyrightconfig.json` or `tsconfig*.json` with an unquoted key or an unclosed object is now UNREADABLE (exit 2) instead of silently accepted. A run that compared zero config files no longer reports ok. +- Gate ratchet: now reports as WEAKENED `blockExoticSubdeps: false` and `ignoreScripts: false` in `pnpm-workspace.yaml`, an empty `files` list in `tsconfig*.json` (also one holding only a comment or empty strings), `allowEmptyCatch` on the ESLint `no-empty` rule, and a second `vitest*.config.*` file that competes with the ratcheted one. The three pnpm switches follow an allow-list: only `true` passes, and any other value (`no`, `off`, `0`, `null`, `~`, a tag) or a key form it cannot judge (flow style, nested, quoted) is UNREADABLE. Non-literal `no-empty` options are UNREADABLE. A `pyrightconfig.json` or `tsconfig*.json` with an unquoted key or an unclosed object is UNREADABLE (exit 2) instead of silently accepted. A run that compared zero config files no longer reports ok. diff --git a/scripts/gate-ratchet.test.sh b/scripts/gate-ratchet.test.sh index dbb500de..e239f0fa 100644 --- a/scripts/gate-ratchet.test.sh +++ b/scripts/gate-ratchet.test.sh @@ -171,12 +171,13 @@ expect() { # Config holes: each probe has a clean control that must pass. GR_ONLY=holes runs only this section; it prints one line per case. holes_cases() { - local sel + local sel hts hc() { echo "gate-ratchet.test: holes: $1"; } - hbase() { edit "$@"; git_ checkout -q -B main work; } hc "ts controls" seed ts + hts=$(git_ rev-parse HEAD) + reseed() { git_ checkout -q -f -B main "$1" && git_ clean -fdq; } git_ checkout -q -B work main expect 0 "holes: unchanged TS config passes" passes pnpm-workspace.yaml "minimumReleaseAge: 10080" "minimumReleaseAge: 20160" "holes: tightened pnpm workspace" @@ -186,37 +187,83 @@ holes_cases() { hc "blockExoticSubdeps" weakens pnpm-workspace.yaml "blockExoticSubdeps: true" "blockExoticSubdeps: false" "holes: blockExoticSubdeps false" "blockExoticSubdeps" + weakens pnpm-workspace.yaml "blockExoticSubdeps: true" '"blockExoticSubdeps": false' "holes: blockExoticSubdeps quoted key false" "blockExoticSubdeps" + weakens pnpm-workspace.yaml "blockExoticSubdeps: true" "blockExoticSubdeps: true +ignoreScripts: false" "holes: ignoreScripts false" "ignoreScripts" + passes pnpm-workspace.yaml "blockExoticSubdeps: true" "blockExoticSubdeps: true +ignoreScripts: true" "holes: ignoreScripts true" + passes pnpm-workspace.yaml "blockExoticSubdeps: true" "'blockExoticSubdeps': true" "holes: blockExoticSubdeps quoted key true" + for v in no off 0 '~' '!!bool false' null; do + edit pnpm-workspace.yaml "blockExoticSubdeps: true" "blockExoticSubdeps: $v" + expect 2 "holes: blockExoticSubdeps $v is unreadable" "UNREADABLE pnpm-workspace.yaml" "fail closed" + done + edit pnpm-workspace.yaml "blockExoticSubdeps: true" "strictDepBuilds: no +blockExoticSubdeps: true" + expect 2 "holes: strictDepBuilds no is unreadable" "UNREADABLE pnpm-workspace.yaml" "fail closed" + edit pnpm-workspace.yaml "blockExoticSubdeps: true" "blockExoticSubdeps: true +nested: + blockExoticSubdeps: false" + expect 2 "holes: nested blockExoticSubdeps is unreadable" "UNREADABLE pnpm-workspace.yaml" "fail closed" + edit pnpm-workspace.yaml "blockExoticSubdeps: true" "{blockExoticSubdeps: false}" + expect 2 "holes: flow-style blockExoticSubdeps is unreadable" "UNREADABLE pnpm-workspace.yaml" "fail closed" + passes pnpm-workspace.yaml "blockExoticSubdeps: true" "# blockExoticSubdeps: false +blockExoticSubdeps: true" "holes: blockExoticSubdeps false only in a comment" hc "tsconfig files" weakens tsconfig.json '"include": [' '"files": [], "include": [' "holes: tsconfig empty files list" "files" passes tsconfig.json '"include": [' '"files": ["src/main.ts"], "include": [' "holes: tsconfig files with an entry" + weakens tsconfig.json '"include": [' '"files": [ /* none */ ], "include": [' "holes: tsconfig files list holding only a comment" "files" + weakens tsconfig.json '"include": [' '"files": [""], "include": [' "holes: tsconfig files list holding only an empty string" "files" hc "second vitest config" add_file vitest.unit.config.ts "export default { test: { coverage: { thresholds: { lines: 1 } } } };" expect 1 "holes: new second vitest config" "vitest.unit.config.ts" add_file vitest.config.e2e.mts "export default {};" expect 0 "holes: new e2e vitest config keeps its old route" - seed ts + reseed "$hts" git_ checkout -q -B work main printf 'export default { test: { coverage: { thresholds: { lines: 80 } } } };\n' > "$R/vitest.unit.config.ts" git_ add -A; git_ commit -q -m "second config"; git_ checkout -q -B main work weakens vitest.unit.config.ts "lines: 80" "lines: 1" "holes: threshold lowered in a second vitest config" "was 80" "now 1" passes vitest.unit.config.ts "lines: 80" "lines: 90" "holes: threshold raised in a second vitest config" + hc "vitest config renamed" + reseed "$hts" + git_ checkout -q -B work main + git_ mv vitest.config.ts vitest.main.config.ts + git_ commit -q -m rename + expect 1 "holes: renamed vitest config is a removal" "vitest.config.ts" "now removed" + hc "allowEmptyCatch" - seed ts + reseed "$hts" weakens eslint.config.mjs "// @ts-check" "// @ts-check const noEmpty = { rules: { 'no-empty': ['error', { allowEmptyCatch: true }] } };" "holes: no-empty allowEmptyCatch true" "allow-empty-catch" passes eslint.config.mjs "// @ts-check" "// @ts-check const noEmpty = { rules: { 'no-empty': ['error', { allowEmptyCatch: false }] } };" "holes: no-empty allowEmptyCatch false" + ne() { printf '// @ts-check\nconst opts = { allowEmptyCatch: true };\nconst base = {};\nconst noEmpty = { rules: { %s } };' "$1"; } + weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { 'allowEmptyCatch': true }]")" "holes: no-empty quoted allowEmptyCatch" "allow-empty-catch" + weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { allowEmptyCatch: !0 }]")" "holes: no-empty allowEmptyCatch !0" "allow-empty-catch" + weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { allowEmptyCatch: /* x */ true }]")" "holes: no-empty allowEmptyCatch after a comment" "allow-empty-catch" + weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { x: { y: 1 }, allowEmptyCatch: true }]")" "holes: no-empty allowEmptyCatch after a nested object" "allow-empty-catch" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', opts]")" + expect 2 "holes: no-empty options by variable are unreadable" "UNREADABLE eslint.config.mjs" "fail closed" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { ...base }]")" + expect 2 "holes: no-empty options with a spread are unreadable" "UNREADABLE eslint.config.mjs" "fail closed" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error']")" + expect 0 "holes: no-empty with severity only passes" hc "unreadable effective eslint config" - seed ts + reseed "$hts" cp "$SH/template-ts/scripts/eslint-effective.mjs" "$R/scripts/eslint-effective.mjs" git_ add -A; git_ commit -q -m helper edit eslint.config.mjs "['error', 15]" "['error', 10]" expect 2 "holes: no installed eslint is unreadable, never a pass" "UNREADABLE eslint.config.mjs" "fail closed" + hc "malformed tsconfig" + reseed "$hts" + edit tsconfig.json '"compilerOptions": {' 'oops: 1, "compilerOptions": {' + expect 2 "holes: malformed tsconfig fails closed" "UNREADABLE tsconfig.json" + hc "python controls" seed py git_ checkout -q -B work main @@ -233,15 +280,10 @@ const noEmpty = { rules: { 'no-empty': ['error', { allowEmptyCatch: false }] } } git_ commit -q -am truncated expect 2 "holes: truncated pyrightconfig fails closed" "UNREADABLE pyrightconfig.json" passes pyrightconfig.json '"typeCheckingMode": "strict"' '"typeCheckingMode": "strict", "reportMissingImports": "error"' "holes: pyright gains a report setting" - - hc "malformed tsconfig" - seed ts - edit tsconfig.json '"compilerOptions": {' 'oops: 1, "compilerOptions": {' - expect 2 "holes: malformed tsconfig fails closed" "UNREADABLE tsconfig.json" } +holes_cases if [[ "${GR_ONLY:-}" == holes ]]; then - holes_cases echo "gate-ratchet.test: $PASS passed, $FAIL failed" [[ "$FAIL" -eq 0 ]] exit @@ -2230,7 +2272,5 @@ check 0 "$EC" "first manifest revert proof: without the 1b branch the self-hashe RATCHET=$RATCHET_REAL seed ts -holes_cases - echo "gate-ratchet.test: $PASS passed, $FAIL failed" [[ "$FAIL" -eq 0 ]] diff --git a/skills/scaffold/shared/template/scripts/gate-ratchet.sh b/skills/scaffold/shared/template/scripts/gate-ratchet.sh index f9160be3..eaef09bc 100755 --- a/skills/scaffold/shared/template/scripts/gate-ratchet.sh +++ b/skills/scaffold/shared/template/scripts/gate-ratchet.sh @@ -7,7 +7,7 @@ # pytest: any change to a [tool.pytest.ini_options] key or a new key is a finding, except raising --cov-fail-under and the markers, pythonpath and asyncio_default_fixture_loop_scope keys. # import-linter: every key of [tool.importlinter] and its contracts must stay as it was (layers, root_packages, ignore_imports); a new .importlinter or setup.cfg competes with it. # Type checkers: tsconfig and pyright strictness may tighten, never loosen; a new tsconfig or pyright config may not switch strictness off. -# Closed list of config keys the ratchet reads beyond the above: pnpm-workspace.yaml blockExoticSubdeps (false is a fact), tsconfig files (an empty list is a fact), eslint no-empty with allowEmptyCatch: true (a fact), and every vitest*.config.* file (an existing one is compared by its facts; a new one beside a vite or vitest config is WEAKENED). A value the readers cannot parse fails closed; nothing they read is skipped. +# Closed list of config keys the ratchet reads beyond the above: pnpm-workspace.yaml strictDepBuilds, ignoreScripts and blockExoticSubdeps (allow-list: only the literal safe value true passes, false is a fact, any other value or key form the reader cannot judge is UNREADABLE), tsconfig files (an empty list, or one holding only empty strings, is a fact), eslint no-empty (any allowEmptyCatch other than literal false is a fact; options the reader cannot read are UNREADABLE), and every vitest*.config.* file (an existing one is compared by its facts; a new one beside a vite or vitest config is WEAKENED). A value the readers cannot parse fails closed; nothing they read is skipped. # Gate-time budget: .claude/gate-budget.conf may not be deleted, and its three limits may not rise; a conf with no merge-base copy is held to the seeded defaults (600, 180, 25) and may not set a higher limit or leave one out. The kind is not enforced, so a human applying the allow-gate-change label can waive a raise or a deletion, by design. # Allow-lists: dep-audit-allow.txt may only lose lines; comment-hygiene-patterns.txt may only gain lines at the end. # Seeded-file exemptions: when the merge base has .claude/harness.json, a new entry, a changed origin_hash or a path added to .claude/seeded-paths.txt is WEAKENED, a dropped manifest is WEAKENED, an entry or list line removed is fine, and an unreadable or duplicated manifest is UNREADABLE. The seedmf kind is not enforced, so the human-applied allow-gate-change label waives WEAKENED (the bless, upgrade and refresh routes change hashes and entries and need it); UNREADABLE is never waived. When the merge base has .claude/gates.txt but no manifest, a manifest added in this change is WEAKENED (human waiver only). Without any harness at the merge base (adoption) one NOTE counts the exempt files. @@ -683,9 +683,30 @@ function do_eslint_import( from, m) { } } -function do_eslint( from, m, name, rest, sev, seen, p, opt, sc, key, lim) { +# no-empty options (index i is just after the severity): none, or one object literal whose allowEmptyCatch is only ever the literal false. Any other allowEmptyCatch (true, !0, 1, a variable, a shorthand, nested) is a fact; an options argument that is not an object literal, or one with a spread or a computed key, cannot be read and fails closed. +function no_empty(i, arr, key, q, n, body, r, after, flagged) { + if (!arr) return + n = length(T); q = i + while (q <= n && substr(T, q, 1) ~ /[ \t\n]/) q++ + if (substr(T, q, 1) == "]") return + if (substr(T, q, 1) != ",") fail("no-empty is set in a form the reader cannot judge: " oneline(substr(T, q, 30))) + q++ + while (q <= n && substr(T, q, 1) ~ /[ \t\n]/) q++ + if (substr(T, q, 1) != "{") fail("no-empty options are not an object literal, so allowEmptyCatch cannot be read: " oneline(substr(T, q, 30))) + body = substr(T, q, CL[q] - q + 1) + if (body ~ /[.][.][.]/ || body ~ /[[]/) fail("no-empty options use a spread or a computed key, so allowEmptyCatch cannot be read") + flagged = 0; r = body + while (match(r, /allowEmptyCatch/)) { + after = substr(r, RSTART + RLENGTH) + if (after !~ /^["']?[ \t\n]*:[ \t\n]*false[ \t\n]*([,}]|$)/) flagged = 1 + r = after + } + if (flagged) emit("set", "allow-empty-catch", key) +} + +function do_eslint( from, m, name, rest, sev, seen, p, opt, sc, key, lim, ne_seen, ne_all) { code_scan() - seen = 0; from = 1 + seen = 0; from = 1; ne_seen = 0 brace_map() while (find("['\"]?[@A-Za-z0-9/_.-]+['\"]?[ \t\n]*:[ \t\n]*([[][ \t\n]*)?(['\"](off|warn|error)['\"]|[012][],} \t\n])", from)) { sc = scope_of(MS) @@ -698,10 +719,13 @@ function do_eslint( from, m, name, rest, sev, seen, p, opt, sc, key, lim) { emit("sev", key, sev); seen = 1 if (sev < 2 && in_rules(MS)) emit("set", "rule-below-error", key) p = substr(T, from) - if (name == "no-empty" && match(p, /^[ \t\n]*,[ \t\n]*[{][^}]*allowEmptyCatch[ \t\n]*:[ \t\n]*true/)) emit("set", "allow-empty-catch", key) + if (name == "no-empty") { ne_seen++; no_empty(from, rest ~ /^[ \t\n]*[[]/, key) } if (match(p, /^[ \t\n]*,[ \t\n]*[0-9]+[ \t\n]*[],]/)) emit("max", lim, num_in(substr(p, 1, RLENGTH))) else if (match(p, /^[ \t\n]*,[ \t\n]*[{][^}]*(max|maximum|threshold|complexity)[ \t\n]*:[ \t\n]*[0-9]+/)) { opt = substr(p, 1, RLENGTH); sub(/.*:[ \t\n]*/, "", opt); emit("max", lim, opt) } } + from = 1; ne_all = 0 + while (find("(^|[^A-Za-z0-9_$./@-])[\"']?no-empty[\"']?[ \t\n]*:", from)) { ne_all++; from = MS + ML } + if (ne_all > ne_seen) fail("no-empty is set in a form the reader cannot judge (its value is not a severity or a [severity, options] array)") from = 1 while (find("[A-Za-z0-9_]+[.]configs[.][A-Za-z0-9_.]+|[A-Za-z0-9_]+[.]recommended", from)) { emit("req", "preset", substr(T, MS, ML)); from = MS + ML; seen = 1 } from = 1 @@ -1149,7 +1173,7 @@ function do_tsconfig( p, n, j, key, v) { else if (key == "exclude") strict_array(p, "set", "exclude") else if (key == "include" || key == "files") { strict_array(p, "req", key) - if (key == "files" && vtext(p) ~ /^\[[ \t\n]*\]$/) emit("set", "files", "empty") + if (key == "files") { v = vtext(p); gsub(/""|''|``/, "", v); if (v ~ /^\[[ \t\n,]*\]$/) emit("set", "files", "empty") } } v = vtext(p); p = VEND } @@ -1359,16 +1383,26 @@ function norm_yaml(line) { if (line ~ /^["'][A-Za-z]+["'][ \t]*:/) { sub(/^["']/, "", line); sub(/["'][ \t]*:/, ":", line) } return line } +# strictDepBuilds, ignoreScripts and blockExoticSubdeps are safe only as the plain literal true at column 0. The weak literal false is a fact; any other value, and any other spelling or place of the key (nested, flow style, spaced colon), cannot be judged and fails closed. +function pnpm_switch(line, k, v) { + match(line, /(strictDepBuilds|ignoreScripts|blockExoticSubdeps)/); k = substr(line, RSTART, RLENGTH) + if (line !~ ("^" k ":[ \t]*[^ \t]")) fail("pnpm-workspace.yaml has " k " in a form the reader cannot judge (nested, flow style, quoted with a space, or with no value): " substr(line, 1, 60)) + v = line; sub(/^[^:]*:[ \t]*/, "", v); gsub(/^["']|["']$/, "", v) + if (yes(v)) return + if (no(v)) { emit("set", k, "false"); return } + fail("pnpm-workspace.yaml " k " is not the plain literal true or false: " v) +} function do_pnpmws( i, n, L, line, v, inbuilds, inlist) { n = split(T, L, "\n"); inbuilds = 0; inlist = "" for (i = 1; i <= n; i++) { + if (L[i] ~ /^[ \t]*#/) continue line = norm_yaml(L[i]) + if (line ~ /(strictDepBuilds|ignoreScripts|blockExoticSubdeps)/) { pnpm_switch(line); continue } if (line ~ /^[^ \t#-]/) { inbuilds = (line ~ /^allowBuilds:/); inlist = ""; if (line ~ /^(onlyBuiltDependencies|minimumReleaseAgeExclude|neverBuiltDependencies):/) { inlist = line; sub(/:.*$/, "", inlist) } } if (inlist != "" && line ~ /^[ \t]*-[ \t]/) { v = line; sub(/^[ \t]*-[ \t]+/, "", v); gsub(/^[ \t'"'"'"]+|[ \t'"'"'"]+$/, "", v); if (inlist != "neverBuiltDependencies") emit("set", inlist, v); continue } if (line ~ /^minimumReleaseAge:/) { v = line; sub(/^[^:]*:[ \t]*/, "", v); gsub(/^["']|["']$/, "", v); if (!plain_num(v)) fail("minimumReleaseAge is not a plain number"); emit("min", "minimumReleaseAge", v) } else if (line ~ /^minimumReleaseAgeExclude:/) emit("set", "minimumReleaseAgeExclude", "present") else if (line ~ /^dangerouslyAllowAllBuilds:/) { v = line; sub(/^[^:]*:[ \t]*/, "", v); gsub(/^["']|["']$/, "", v); if (yes(v)) emit("set", "dangerouslyAllowAllBuilds", "true") } - else if (line ~ /^(strictDepBuilds|ignoreScripts|blockExoticSubdeps):/) { v = line; sub(/^[^:]*:[ \t]*/, "", v); gsub(/^["']|["']$/, "", v); if (no(v)) { sub(/:.*$/, "", line); emit("set", line, "false") } } else if (inbuilds && line ~ /^[ \t]+[^ \t].*:[ \t]*["']?[Tt][Rr][Uu][Ee]["']?[ \t]*$/) { v = line; sub(/:[ \t]*["']?[Tt][Rr][Uu][Ee]["']?[ \t]*$/, "", v); gsub(/^[ \t'"'"'"]+|[ \t'"'"'"]+$/, "", v); emit("set", "allowBuilds", v) } } } diff --git a/tests/golden/fastapi-azure.sha256 b/tests/golden/fastapi-azure.sha256 index df739fe9..c5b2196f 100644 --- a/tests/golden/fastapi-azure.sha256 +++ b/tests/golden/fastapi-azure.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -0339d55586602f3a40724c4510a300a147aaccc8735314d74b5558c27c3702b9 scripts/gate-ratchet.sh +8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/fastapi-github.sha256 b/tests/golden/fastapi-github.sha256 index 0b617791..c5d96397 100644 --- a/tests/golden/fastapi-github.sha256 +++ b/tests/golden/fastapi-github.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -0339d55586602f3a40724c4510a300a147aaccc8735314d74b5558c27c3702b9 scripts/gate-ratchet.sh +8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/nestjs-azure.sha256 b/tests/golden/nestjs-azure.sha256 index c1b41df1..1f174013 100644 --- a/tests/golden/nestjs-azure.sha256 +++ b/tests/golden/nestjs-azure.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -0339d55586602f3a40724c4510a300a147aaccc8735314d74b5558c27c3702b9 scripts/gate-ratchet.sh +8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nestjs-github.sha256 b/tests/golden/nestjs-github.sha256 index ecefff43..6f742ead 100644 --- a/tests/golden/nestjs-github.sha256 +++ b/tests/golden/nestjs-github.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -0339d55586602f3a40724c4510a300a147aaccc8735314d74b5558c27c3702b9 scripts/gate-ratchet.sh +8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-azure.sha256 b/tests/golden/nextjs-azure.sha256 index 41aefd8c..c516ac12 100644 --- a/tests/golden/nextjs-azure.sha256 +++ b/tests/golden/nextjs-azure.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -0339d55586602f3a40724c4510a300a147aaccc8735314d74b5558c27c3702b9 scripts/gate-ratchet.sh +8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-github.sha256 b/tests/golden/nextjs-github.sha256 index 724a41ab..58e0220f 100644 --- a/tests/golden/nextjs-github.sha256 +++ b/tests/golden/nextjs-github.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -0339d55586602f3a40724c4510a300a147aaccc8735314d74b5558c27c3702b9 scripts/gate-ratchet.sh +8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-azure.sha256 b/tests/golden/vite-react-azure.sha256 index 0e7f851e..cbd04b40 100644 --- a/tests/golden/vite-react-azure.sha256 +++ b/tests/golden/vite-react-azure.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -0339d55586602f3a40724c4510a300a147aaccc8735314d74b5558c27c3702b9 scripts/gate-ratchet.sh +8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-github.sha256 b/tests/golden/vite-react-github.sha256 index 792d9c9b..dbaff064 100644 --- a/tests/golden/vite-react-github.sha256 +++ b/tests/golden/vite-react-github.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -0339d55586602f3a40724c4510a300a147aaccc8735314d74b5558c27c3702b9 scripts/gate-ratchet.sh +8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh From 24f73ad4c9112e7d340e1fe8edd33e0dd205e2e5 Mon Sep 17 00:00:00 2001 From: Clarence Lee Date: Wed, 2 Dec 2026 15:29:32 +0800 Subject: [PATCH 3/5] fix(scaffold): keep original KIND=vitest case arm, add separate vitest*.config arm Co-Authored-By: Claude Sonnet 5.5 --- skills/scaffold/shared/template/scripts/gate-ratchet.sh | 3 ++- tests/golden/fastapi-azure.sha256 | 2 +- tests/golden/fastapi-github.sha256 | 2 +- tests/golden/nestjs-azure.sha256 | 2 +- tests/golden/nestjs-github.sha256 | 2 +- tests/golden/nextjs-azure.sha256 | 2 +- tests/golden/nextjs-github.sha256 | 2 +- tests/golden/vite-react-azure.sha256 | 2 +- tests/golden/vite-react-github.sha256 | 2 +- 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/skills/scaffold/shared/template/scripts/gate-ratchet.sh b/skills/scaffold/shared/template/scripts/gate-ratchet.sh index eaef09bc..4328ac59 100755 --- a/skills/scaffold/shared/template/scripts/gate-ratchet.sh +++ b/skills/scaffold/shared/template/scripts/gate-ratchet.sh @@ -100,7 +100,8 @@ kind_of() { case "$1" in .jscpd.json | */.jscpd.json) KIND=jscpd ;; eslint.config.* | */eslint.config.* | layers.config.mjs | */layers.config.mjs) KIND=eslint ;; - vitest*.config.* | vite.config.* | vitest.workspace.* | */vitest*.config.* | */vite.config.* | */vitest.workspace.*) KIND=vitest ;; + vitest.config.* | vite.config.* | vitest.workspace.* | */vitest.config.* | */vite.config.* | */vitest.workspace.*) KIND=vitest ;; + vitest*.config.* | */vitest*.config.*) KIND=vitest ;; sonar-project.properties | */sonar-project.properties) KIND=sonar ;; package.json | */package.json) KIND=pkgjson ;; pyproject.toml | */pyproject.toml) KIND=pyproject ;; diff --git a/tests/golden/fastapi-azure.sha256 b/tests/golden/fastapi-azure.sha256 index c5b2196f..73ff3281 100644 --- a/tests/golden/fastapi-azure.sha256 +++ b/tests/golden/fastapi-azure.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh +1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/fastapi-github.sha256 b/tests/golden/fastapi-github.sha256 index c5d96397..11763c41 100644 --- a/tests/golden/fastapi-github.sha256 +++ b/tests/golden/fastapi-github.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh +1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/nestjs-azure.sha256 b/tests/golden/nestjs-azure.sha256 index 1f174013..c674ba26 100644 --- a/tests/golden/nestjs-azure.sha256 +++ b/tests/golden/nestjs-azure.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh +1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nestjs-github.sha256 b/tests/golden/nestjs-github.sha256 index 6f742ead..8174812d 100644 --- a/tests/golden/nestjs-github.sha256 +++ b/tests/golden/nestjs-github.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh +1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-azure.sha256 b/tests/golden/nextjs-azure.sha256 index c516ac12..c7fbc96a 100644 --- a/tests/golden/nextjs-azure.sha256 +++ b/tests/golden/nextjs-azure.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh +1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-github.sha256 b/tests/golden/nextjs-github.sha256 index 58e0220f..920aa4bf 100644 --- a/tests/golden/nextjs-github.sha256 +++ b/tests/golden/nextjs-github.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh +1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-azure.sha256 b/tests/golden/vite-react-azure.sha256 index cbd04b40..e2f942a1 100644 --- a/tests/golden/vite-react-azure.sha256 +++ b/tests/golden/vite-react-azure.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh +1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-github.sha256 b/tests/golden/vite-react-github.sha256 index dbaff064..efb3e82c 100644 --- a/tests/golden/vite-react-github.sha256 +++ b/tests/golden/vite-react-github.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -8973cfd23b8acada39c00d61b70e9887be3fae2dafb7435a92bf8806bcb12160 scripts/gate-ratchet.sh +1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh From 6e4dda4f8b04e2dd8bf2223ce0925428dbd8aa46 Mon Sep 17 00:00:00 2001 From: Clarence Lee Date: Wed, 2 Dec 2026 16:06:46 +0800 Subject: [PATCH 4/5] fix(scaffold): ratchet npmrc allow-list, escaped keys, numeric no-empty severity Co-Authored-By: Claude Sonnet 5.5 --- changelog.d/ratchet-config-holes.fixed.md | 2 +- scripts/gate-ratchet.test.sh | 33 +++++++++++++++++++ .../shared/template/scripts/gate-ratchet.sh | 25 +++++++++++--- tests/golden/fastapi-azure.sha256 | 2 +- tests/golden/fastapi-github.sha256 | 2 +- tests/golden/nestjs-azure.sha256 | 2 +- tests/golden/nestjs-github.sha256 | 2 +- tests/golden/nextjs-azure.sha256 | 2 +- tests/golden/nextjs-github.sha256 | 2 +- tests/golden/vite-react-azure.sha256 | 2 +- tests/golden/vite-react-github.sha256 | 2 +- 11 files changed, 62 insertions(+), 14 deletions(-) diff --git a/changelog.d/ratchet-config-holes.fixed.md b/changelog.d/ratchet-config-holes.fixed.md index 0377ab01..c443277e 100644 --- a/changelog.d/ratchet-config-holes.fixed.md +++ b/changelog.d/ratchet-config-holes.fixed.md @@ -1 +1 @@ -- Gate ratchet: now reports as WEAKENED `blockExoticSubdeps: false` and `ignoreScripts: false` in `pnpm-workspace.yaml`, an empty `files` list in `tsconfig*.json` (also one holding only a comment or empty strings), `allowEmptyCatch` on the ESLint `no-empty` rule, and a second `vitest*.config.*` file that competes with the ratcheted one. The three pnpm switches follow an allow-list: only `true` passes, and any other value (`no`, `off`, `0`, `null`, `~`, a tag) or a key form it cannot judge (flow style, nested, quoted) is UNREADABLE. Non-literal `no-empty` options are UNREADABLE. A `pyrightconfig.json` or `tsconfig*.json` with an unquoted key or an unclosed object is UNREADABLE (exit 2) instead of silently accepted. A run that compared zero config files no longer reports ok. +- Gate ratchet: now reports as WEAKENED `blockExoticSubdeps: false` and `ignoreScripts: false` in `pnpm-workspace.yaml`, an empty `files` list in `tsconfig*.json` (also one holding only a comment or empty strings), `allowEmptyCatch` on the ESLint `no-empty` rule, and a second `vitest*.config.*` file that competes with the ratcheted one. The three pnpm switches follow an allow-list: only `true` passes, and any other value (`no`, `off`, `0`, `null`, `~`, a tag) or a key form it cannot judge (flow style, nested, quoted) is UNREADABLE. Non-literal `no-empty` options are UNREADABLE. A `pyrightconfig.json` or `tsconfig*.json` with an unquoted key or an unclosed object is UNREADABLE (exit 2) instead of silently accepted. A run that compared zero config files no longer reports ok. `.npmrc` `ignore-scripts` and `dangerously-allow-all-builds` follow the same allow-list (quotes and blanks stripped; `ignore-scripts=0`, `=no`, `=off`, an empty value and `dangerously-allow-all-builds=1` or `=yes` are UNREADABLE). An escaped key in `pnpm-workspace.yaml` or in the `no-empty` options is UNREADABLE. diff --git a/scripts/gate-ratchet.test.sh b/scripts/gate-ratchet.test.sh index e239f0fa..d031899b 100644 --- a/scripts/gate-ratchet.test.sh +++ b/scripts/gate-ratchet.test.sh @@ -215,6 +215,32 @@ blockExoticSubdeps: true" "holes: blockExoticSubdeps false only in a comment" weakens tsconfig.json '"include": [' '"files": [ /* none */ ], "include": [' "holes: tsconfig files list holding only a comment" "files" weakens tsconfig.json '"include": [' '"files": [""], "include": [' "holes: tsconfig files list holding only an empty string" "files" + hc "npmrc switches" + for v in 'ignore-scripts="false"' "ignore-scripts='false'" " Ignore-Scripts = false"; do + weakens .npmrc "# note" "# note +$v" "holes: npmrc $v" "ignore-scripts=false" + done + for v in 'ignore-scripts=0' 'ignore-scripts=no' 'ignore-scripts=off' 'ignore-scripts=' 'ignore-scripts' 'dangerously-allow-all-builds=1' 'dangerously-allow-all-builds=yes' 'dangerously-allow-all-builds='; do + edit .npmrc "# note" "# note +$v" + expect 2 "holes: npmrc $v is unreadable" "UNREADABLE .npmrc" "fail closed" + done + weakens .npmrc "# note" '# note +dangerously-allow-all-builds="true"' "holes: npmrc dangerously-allow-all-builds quoted true" "dangerously-allow-all-builds=true" + weakens .npmrc "# note" "# note +dangerously-allow-all-builds=true" "holes: npmrc dangerously-allow-all-builds true" "dangerously-allow-all-builds=true" + for v in 'ignore-scripts=true' 'ignore-scripts="true"' 'dangerously-allow-all-builds=false' '# ignore-scripts=false' '; ignore-scripts=0'; do + passes .npmrc "# note" "# note +$v" "holes: npmrc $v" + done + + hc "pnpm escaped key" + edit pnpm-workspace.yaml "blockExoticSubdeps: true" '"blockExoticSubdeps": true +"ignore\x53cripts": false' + expect 2 "holes: pnpm escaped switch key is unreadable" "UNREADABLE pnpm-workspace.yaml" "fail closed" + passes pnpm-workspace.yaml "blockExoticSubdeps: true" '"blockExoticSubdeps": true +"ignoreScripts": true' "holes: pnpm double-quoted switch keys without an escape" + hc "second vitest config" add_file vitest.unit.config.ts "export default { test: { coverage: { thresholds: { lines: 1 } } } };" expect 1 "holes: new second vitest config" "vitest.unit.config.ts" @@ -245,6 +271,13 @@ const noEmpty = { rules: { 'no-empty': ['error', { allowEmptyCatch: false }] } } weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { allowEmptyCatch: !0 }]")" "holes: no-empty allowEmptyCatch !0" "allow-empty-catch" weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { allowEmptyCatch: /* x */ true }]")" "holes: no-empty allowEmptyCatch after a comment" "allow-empty-catch" weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { x: { y: 1 }, allowEmptyCatch: true }]")" "holes: no-empty allowEmptyCatch after a nested object" "allow-empty-catch" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { \\u0061llowEmptyCatch: true }]")" + expect 2 "holes: no-empty unicode-escaped key is unreadable" "UNREADABLE eslint.config.mjs" "fail closed" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { 'allow\\x45mptyCatch': true }]")" + expect 2 "holes: no-empty hex-escaped quoted key is unreadable" "UNREADABLE eslint.config.mjs" "fail closed" + weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': [2, { allowEmptyCatch: true }]")" "holes: no-empty numeric severity allowEmptyCatch true" "allow-empty-catch" + passes eslint.config.mjs "// @ts-check" "$(ne "'no-empty': [2, { allowEmptyCatch: false }]")" "holes: no-empty numeric severity allowEmptyCatch false" + passes eslint.config.mjs "// @ts-check" "$(ne "'no-empty': [2]")" "holes: no-empty numeric severity only" edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', opts]")" expect 2 "holes: no-empty options by variable are unreadable" "UNREADABLE eslint.config.mjs" "fail closed" edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { ...base }]")" diff --git a/skills/scaffold/shared/template/scripts/gate-ratchet.sh b/skills/scaffold/shared/template/scripts/gate-ratchet.sh index 4328ac59..c6330130 100755 --- a/skills/scaffold/shared/template/scripts/gate-ratchet.sh +++ b/skills/scaffold/shared/template/scripts/gate-ratchet.sh @@ -7,7 +7,7 @@ # pytest: any change to a [tool.pytest.ini_options] key or a new key is a finding, except raising --cov-fail-under and the markers, pythonpath and asyncio_default_fixture_loop_scope keys. # import-linter: every key of [tool.importlinter] and its contracts must stay as it was (layers, root_packages, ignore_imports); a new .importlinter or setup.cfg competes with it. # Type checkers: tsconfig and pyright strictness may tighten, never loosen; a new tsconfig or pyright config may not switch strictness off. -# Closed list of config keys the ratchet reads beyond the above: pnpm-workspace.yaml strictDepBuilds, ignoreScripts and blockExoticSubdeps (allow-list: only the literal safe value true passes, false is a fact, any other value or key form the reader cannot judge is UNREADABLE), tsconfig files (an empty list, or one holding only empty strings, is a fact), eslint no-empty (any allowEmptyCatch other than literal false is a fact; options the reader cannot read are UNREADABLE), and every vitest*.config.* file (an existing one is compared by its facts; a new one beside a vite or vitest config is WEAKENED). A value the readers cannot parse fails closed; nothing they read is skipped. +# Closed list of config keys the ratchet reads beyond the above: pnpm-workspace.yaml strictDepBuilds, ignoreScripts and blockExoticSubdeps (allow-list: only the literal safe value true passes, false is a fact, any other value or key form the reader cannot judge is UNREADABLE), tsconfig files (an empty list, or one holding only empty strings, is a fact), eslint no-empty (any allowEmptyCatch other than literal false is a fact; options or an escaped key the reader cannot read are UNREADABLE), .npmrc ignore-scripts (true safe, false a fact) and dangerously-allow-all-builds (false safe, true a fact; quotes and blanks stripped, any other value UNREADABLE), and every vitest*.config.* file (an existing one is compared by its facts; a new one beside a vite or vitest config is WEAKENED). A value the readers cannot parse fails closed; nothing they read is skipped. # Gate-time budget: .claude/gate-budget.conf may not be deleted, and its three limits may not rise; a conf with no merge-base copy is held to the seeded defaults (600, 180, 25) and may not set a higher limit or leave one out. The kind is not enforced, so a human applying the allow-gate-change label can waive a raise or a deletion, by design. # Allow-lists: dep-audit-allow.txt may only lose lines; comment-hygiene-patterns.txt may only gain lines at the end. # Seeded-file exemptions: when the merge base has .claude/harness.json, a new entry, a changed origin_hash or a path added to .claude/seeded-paths.txt is WEAKENED, a dropped manifest is WEAKENED, an entry or list line removed is fine, and an unreadable or duplicated manifest is UNREADABLE. The seedmf kind is not enforced, so the human-applied allow-gate-change label waives WEAKENED (the bless, upgrade and refresh routes change hashes and entries and need it); UNREADABLE is never waived. When the merge base has .claude/gates.txt but no manifest, a manifest added in this change is WEAKENED (human waiver only). Without any harness at the merge base (adoption) one NOTE counts the exempt files. @@ -684,10 +684,12 @@ function do_eslint_import( from, m) { } } -# no-empty options (index i is just after the severity): none, or one object literal whose allowEmptyCatch is only ever the literal false. Any other allowEmptyCatch (true, !0, 1, a variable, a shorthand, nested) is a fact; an options argument that is not an object literal, or one with a spread or a computed key, cannot be read and fails closed. +# no-empty options (index i is just after the severity): none, or one object literal whose allowEmptyCatch is only ever the literal false. Any other allowEmptyCatch (true, !0, 1, a variable, a shorthand, nested) is a fact; an options argument that is not an object literal, or one with a spread, a computed key or an escape sequence, cannot be read and fails closed. function no_empty(i, arr, key, q, n, body, r, after, flagged) { if (!arr) return n = length(T); q = i + if (substr(T, i - 1, 1) == "]") return + if (substr(T, i - 1, 1) == ",") q = i - 1 while (q <= n && substr(T, q, 1) ~ /[ \t\n]/) q++ if (substr(T, q, 1) == "]") return if (substr(T, q, 1) != ",") fail("no-empty is set in a form the reader cannot judge: " oneline(substr(T, q, 30))) @@ -696,6 +698,7 @@ function no_empty(i, arr, key, q, n, body, r, after, flagged) { if (substr(T, q, 1) != "{") fail("no-empty options are not an object literal, so allowEmptyCatch cannot be read: " oneline(substr(T, q, 30))) body = substr(T, q, CL[q] - q + 1) if (body ~ /[.][.][.]/ || body ~ /[[]/) fail("no-empty options use a spread or a computed key, so allowEmptyCatch cannot be read") + if (body ~ /[\\][ux]/) fail("no-empty options hold an escape sequence, so a key could hide allowEmptyCatch and cannot be read") flagged = 0; r = body while (match(r, /allowEmptyCatch/)) { after = substr(r, RSTART + RLENGTH) @@ -1397,6 +1400,7 @@ function do_pnpmws( i, n, L, line, v, inbuilds, inlist) { n = split(T, L, "\n"); inbuilds = 0; inlist = "" for (i = 1; i <= n; i++) { if (L[i] ~ /^[ \t]*#/) continue + if (L[i] ~ /^["][^"]*[\\][^"]*["][ \t]*:/) fail("pnpm-workspace.yaml has a double-quoted key with an escape sequence, which can hide a switch key and cannot be read: " substr(L[i], 1, 60)) line = norm_yaml(L[i]) if (line ~ /(strictDepBuilds|ignoreScripts|blockExoticSubdeps)/) { pnpm_switch(line); continue } if (line ~ /^[^ \t#-]/) { inbuilds = (line ~ /^allowBuilds:/); inlist = ""; if (line ~ /^(onlyBuiltDependencies|minimumReleaseAgeExclude|neverBuiltDependencies):/) { inlist = line; sub(/:.*$/, "", inlist) } } @@ -1419,12 +1423,23 @@ function do_dependabot( i, n, L, line, v) { } } -function do_npmrc( i, n, L, line) { +# ignore-scripts is safe only as true; false is a fact. dangerously-allow-all-builds is safe only as false or absent; true is a fact. Quotes and blanks are stripped from key and value first; any other value, or the key with no value, cannot be judged and fails closed. +function npmrc_switch(k, line, safe, weak, v) { + if (line !~ /=/) fail(".npmrc has " k " with no value: " substr(line, 1, 60)) + v = line; sub(/^[^=]*=/, "", v) + if (v == safe) return + if (v == weak) { emit("set", "npmrc", k "=" weak); return } + fail(".npmrc " k " is not the plain literal true or false: " v) +} +function do_npmrc( i, n, L, line, k, q) { n = split(T, L, "\n") for (i = 1; i <= n; i++) { line = L[i]; sub(/\r$/, "", line); line = tolower(line); gsub(/[ \t]+/, "", line) - if (line ~ /^ignore-scripts=false/) emit("set", "npmrc", "ignore-scripts=false") - else if (line ~ /^dangerously-allow-all-builds=true/) emit("set", "npmrc", "dangerously-allow-all-builds=true") + if (line ~ /^[#;]/) continue + q = line; gsub(/["']/, "", q) + k = q; sub(/=.*$/, "", k) + if (k == "ignore-scripts") npmrc_switch(k, q, "true", "false") + else if (k == "dangerously-allow-all-builds") npmrc_switch(k, q, "false", "true") else if (line ~ /^(@[^:]+:)?registry=/) emit("set", "npmrc-registry", line) } } diff --git a/tests/golden/fastapi-azure.sha256 b/tests/golden/fastapi-azure.sha256 index 73ff3281..8e813e71 100644 --- a/tests/golden/fastapi-azure.sha256 +++ b/tests/golden/fastapi-azure.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh +1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/fastapi-github.sha256 b/tests/golden/fastapi-github.sha256 index 11763c41..2d5f83b9 100644 --- a/tests/golden/fastapi-github.sha256 +++ b/tests/golden/fastapi-github.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh +1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/nestjs-azure.sha256 b/tests/golden/nestjs-azure.sha256 index c674ba26..d55c6277 100644 --- a/tests/golden/nestjs-azure.sha256 +++ b/tests/golden/nestjs-azure.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh +1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nestjs-github.sha256 b/tests/golden/nestjs-github.sha256 index 8174812d..44bfe091 100644 --- a/tests/golden/nestjs-github.sha256 +++ b/tests/golden/nestjs-github.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh +1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-azure.sha256 b/tests/golden/nextjs-azure.sha256 index c7fbc96a..f86c4152 100644 --- a/tests/golden/nextjs-azure.sha256 +++ b/tests/golden/nextjs-azure.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh +1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-github.sha256 b/tests/golden/nextjs-github.sha256 index 920aa4bf..8ef6e488 100644 --- a/tests/golden/nextjs-github.sha256 +++ b/tests/golden/nextjs-github.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh +1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-azure.sha256 b/tests/golden/vite-react-azure.sha256 index e2f942a1..f933fe4a 100644 --- a/tests/golden/vite-react-azure.sha256 +++ b/tests/golden/vite-react-azure.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh +1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-github.sha256 b/tests/golden/vite-react-github.sha256 index efb3e82c..0f82e040 100644 --- a/tests/golden/vite-react-github.sha256 +++ b/tests/golden/vite-react-github.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1c4131b7b3da4311f65ff3824f43950885832f7a2e369ccf96e584e237d377a3 scripts/gate-ratchet.sh +1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh From 0d4d936dbd958088b4fd5f931795a1f80708c32d Mon Sep 17 00:00:00 2001 From: Clarence Lee Date: Wed, 2 Dec 2026 17:58:52 +0800 Subject: [PATCH 5/5] fix(scaffold): ratchet refuses every backslash key, indented pnpm keys, strict npmrc quotes Co-Authored-By: Claude Sonnet 5.5 --- changelog.d/ratchet-config-holes.fixed.md | 2 +- scripts/gate-ratchet.test.sh | 32 +++++++++++++++++ .../shared/template/scripts/gate-ratchet.sh | 35 ++++++++++++------- tests/golden/fastapi-azure.sha256 | 2 +- tests/golden/fastapi-github.sha256 | 2 +- tests/golden/nestjs-azure.sha256 | 2 +- tests/golden/nestjs-github.sha256 | 2 +- tests/golden/nextjs-azure.sha256 | 2 +- tests/golden/nextjs-github.sha256 | 2 +- tests/golden/vite-react-azure.sha256 | 2 +- tests/golden/vite-react-github.sha256 | 2 +- 11 files changed, 63 insertions(+), 22 deletions(-) diff --git a/changelog.d/ratchet-config-holes.fixed.md b/changelog.d/ratchet-config-holes.fixed.md index c443277e..a8ac2412 100644 --- a/changelog.d/ratchet-config-holes.fixed.md +++ b/changelog.d/ratchet-config-holes.fixed.md @@ -1 +1 @@ -- Gate ratchet: now reports as WEAKENED `blockExoticSubdeps: false` and `ignoreScripts: false` in `pnpm-workspace.yaml`, an empty `files` list in `tsconfig*.json` (also one holding only a comment or empty strings), `allowEmptyCatch` on the ESLint `no-empty` rule, and a second `vitest*.config.*` file that competes with the ratcheted one. The three pnpm switches follow an allow-list: only `true` passes, and any other value (`no`, `off`, `0`, `null`, `~`, a tag) or a key form it cannot judge (flow style, nested, quoted) is UNREADABLE. Non-literal `no-empty` options are UNREADABLE. A `pyrightconfig.json` or `tsconfig*.json` with an unquoted key or an unclosed object is UNREADABLE (exit 2) instead of silently accepted. A run that compared zero config files no longer reports ok. `.npmrc` `ignore-scripts` and `dangerously-allow-all-builds` follow the same allow-list (quotes and blanks stripped; `ignore-scripts=0`, `=no`, `=off`, an empty value and `dangerously-allow-all-builds=1` or `=yes` are UNREADABLE). An escaped key in `pnpm-workspace.yaml` or in the `no-empty` options is UNREADABLE. +- Gate ratchet: now reports as WEAKENED `blockExoticSubdeps: false` and `ignoreScripts: false` in `pnpm-workspace.yaml`, an empty `files` list in `tsconfig*.json` (also one holding only a comment or empty strings), `allowEmptyCatch` on the ESLint `no-empty` rule, and a second `vitest*.config.*` file that competes with the ratcheted one. The three pnpm switches follow an allow-list: only `true` passes, and any other value (`no`, `off`, `0`, `null`, `~`, a tag) or a key form it cannot judge (flow style, nested, quoted) is UNREADABLE. Non-literal `no-empty` options are UNREADABLE. A `pyrightconfig.json` or `tsconfig*.json` with an unquoted key or an unclosed object is UNREADABLE (exit 2) instead of silently accepted. A run that compared zero config files no longer reports ok. `.npmrc` `ignore-scripts` and `dangerously-allow-all-builds` follow the same allow-list (quotes and blanks stripped; `ignore-scripts=0`, `=no`, `=off`, an empty value and `dangerously-allow-all-builds=1` or `=yes` are UNREADABLE). A key written with a backslash (`no-empty` options, a quoted `pnpm-workspace.yaml` key, a `tsconfig*.json` or `pyrightconfig.json` key, an ESLint rule name) is UNREADABLE, and a stray quote inside an `.npmrc` value is UNREADABLE. diff --git a/scripts/gate-ratchet.test.sh b/scripts/gate-ratchet.test.sh index d031899b..5bcad431 100644 --- a/scripts/gate-ratchet.test.sh +++ b/scripts/gate-ratchet.test.sh @@ -222,10 +222,17 @@ $v" "holes: npmrc $v" "ignore-scripts=false" done for v in 'ignore-scripts=0' 'ignore-scripts=no' 'ignore-scripts=off' 'ignore-scripts=' 'ignore-scripts' 'dangerously-allow-all-builds=1' 'dangerously-allow-all-builds=yes' 'dangerously-allow-all-builds='; do edit .npmrc "# note" "# note +$v" + expect 2 "holes: npmrc $v is unreadable" "UNREADABLE .npmrc" "fail closed" + done + for v in 'ignore-scripts="tr"ue' "ignore-scripts=\"true'" 'ignore-scripts=tr"ue"'; do + edit .npmrc "# note" "# note $v" expect 2 "holes: npmrc $v is unreadable" "UNREADABLE .npmrc" "fail closed" done weakens .npmrc "# note" '# note +"ignore-scripts"="false"' "holes: npmrc quoted key and value false" "ignore-scripts=false" + weakens .npmrc "# note" '# note dangerously-allow-all-builds="true"' "holes: npmrc dangerously-allow-all-builds quoted true" "dangerously-allow-all-builds=true" weakens .npmrc "# note" "# note dangerously-allow-all-builds=true" "holes: npmrc dangerously-allow-all-builds true" "dangerously-allow-all-builds=true" @@ -240,6 +247,19 @@ $v" "holes: npmrc $v" expect 2 "holes: pnpm escaped switch key is unreadable" "UNREADABLE pnpm-workspace.yaml" "fail closed" passes pnpm-workspace.yaml "blockExoticSubdeps: true" '"blockExoticSubdeps": true "ignoreScripts": true' "holes: pnpm double-quoted switch keys without an escape" + edit pnpm-workspace.yaml "blockExoticSubdeps: true" 'blockExoticSubdeps: true +nested: + "ignore\x53cripts": false' + expect 2 "holes: pnpm indented escaped switch key is unreadable" "UNREADABLE pnpm-workspace.yaml" "fail closed" + edit pnpm-workspace.yaml "blockExoticSubdeps: true" "blockExoticSubdeps: true +'ignore\\x53cripts': false" + expect 2 "holes: pnpm single-quoted key with a backslash is unreadable" "UNREADABLE pnpm-workspace.yaml" "fail closed" + passes pnpm-workspace.yaml "blockExoticSubdeps: true" 'blockExoticSubdeps: true +# "ignore\x53cripts": false' "holes: pnpm escaped key only in a comment" + + weakens tsconfig.json '"include": [' '"files": [], "include": [' "holes: tsconfig plain files key control" "files" + edit tsconfig.json '"include": [' '"fil\u0065s": [], "include": [' + expect 2 "holes: tsconfig escaped top-level key is unreadable" "UNREADABLE tsconfig.json" "fail closed" hc "second vitest config" add_file vitest.unit.config.ts "export default { test: { coverage: { thresholds: { lines: 1 } } } };" @@ -271,6 +291,16 @@ const noEmpty = { rules: { 'no-empty': ['error', { allowEmptyCatch: false }] } } weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { allowEmptyCatch: !0 }]")" "holes: no-empty allowEmptyCatch !0" "allow-empty-catch" weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { allowEmptyCatch: /* x */ true }]")" "holes: no-empty allowEmptyCatch after a comment" "allow-empty-catch" weakens eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { x: { y: 1 }, allowEmptyCatch: true }]")" "holes: no-empty allowEmptyCatch after a nested object" "allow-empty-catch" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { 'allowEmptyC\\atch': true }]")" + expect 2 "holes: no-empty identity-escaped key is unreadable" "UNREADABLE eslint.config.mjs" "fail closed" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { \"allowEmpty\\Catch\": true }]")" + expect 2 "holes: no-empty double-quoted identity-escaped key is unreadable" "UNREADABLE eslint.config.mjs" "fail closed" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { 'allowEmpty\\ +Catch': true }]")" + expect 2 "holes: no-empty key with a line continuation is unreadable" "UNREADABLE eslint.config.mjs" "fail closed" + edit eslint.config.mjs "// @ts-check" "$(ne "'no-em\\u0070ty': ['error', { allowEmptyCatch: true }]")" + expect 2 "holes: escaped no-empty rule name is unreadable" "UNREADABLE eslint.config.mjs" "fail closed" + passes eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { 'allowEmptyCatch': false }]")" "holes: no-empty quoted key false passes" edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { \\u0061llowEmptyCatch: true }]")" expect 2 "holes: no-empty unicode-escaped key is unreadable" "UNREADABLE eslint.config.mjs" "fail closed" edit eslint.config.mjs "// @ts-check" "$(ne "'no-empty': ['error', { 'allow\\x45mptyCatch': true }]")" @@ -313,6 +343,8 @@ const noEmpty = { rules: { 'no-empty': ['error', { allowEmptyCatch: false }] } } git_ commit -q -am truncated expect 2 "holes: truncated pyrightconfig fails closed" "UNREADABLE pyrightconfig.json" passes pyrightconfig.json '"typeCheckingMode": "strict"' '"typeCheckingMode": "strict", "reportMissingImports": "error"' "holes: pyright gains a report setting" + edit pyrightconfig.json '"typeCheckingMode": "strict"' '"typeCheckingMode": "strict", "reportMissingImp\u006frts": "none"' + expect 2 "holes: pyright escaped key is unreadable" "UNREADABLE pyrightconfig.json" "fail closed" } holes_cases diff --git a/skills/scaffold/shared/template/scripts/gate-ratchet.sh b/skills/scaffold/shared/template/scripts/gate-ratchet.sh index c6330130..ff599309 100755 --- a/skills/scaffold/shared/template/scripts/gate-ratchet.sh +++ b/skills/scaffold/shared/template/scripts/gate-ratchet.sh @@ -7,7 +7,7 @@ # pytest: any change to a [tool.pytest.ini_options] key or a new key is a finding, except raising --cov-fail-under and the markers, pythonpath and asyncio_default_fixture_loop_scope keys. # import-linter: every key of [tool.importlinter] and its contracts must stay as it was (layers, root_packages, ignore_imports); a new .importlinter or setup.cfg competes with it. # Type checkers: tsconfig and pyright strictness may tighten, never loosen; a new tsconfig or pyright config may not switch strictness off. -# Closed list of config keys the ratchet reads beyond the above: pnpm-workspace.yaml strictDepBuilds, ignoreScripts and blockExoticSubdeps (allow-list: only the literal safe value true passes, false is a fact, any other value or key form the reader cannot judge is UNREADABLE), tsconfig files (an empty list, or one holding only empty strings, is a fact), eslint no-empty (any allowEmptyCatch other than literal false is a fact; options or an escaped key the reader cannot read are UNREADABLE), .npmrc ignore-scripts (true safe, false a fact) and dangerously-allow-all-builds (false safe, true a fact; quotes and blanks stripped, any other value UNREADABLE), and every vitest*.config.* file (an existing one is compared by its facts; a new one beside a vite or vitest config is WEAKENED). A value the readers cannot parse fails closed; nothing they read is skipped. +# Closed list of config keys the ratchet reads beyond the above: pnpm-workspace.yaml strictDepBuilds, ignoreScripts and blockExoticSubdeps (allow-list: only the literal safe value true passes, false is a fact, any other value or key form the reader cannot judge is UNREADABLE), tsconfig files (an empty list, or one holding only empty strings, is a fact), eslint no-empty (any allowEmptyCatch other than literal false is a fact; options, or any key written with a backslash (no-empty options, a quoted pnpm-workspace.yaml key, a tsconfig or pyright key, an eslint rule name), cannot be read and are UNREADABLE), .npmrc ignore-scripts (true safe, false a fact) and dangerously-allow-all-builds (false safe, true a fact; blanks stripped and one matching quote pair removed, any other value UNREADABLE), and every vitest*.config.* file (an existing one is compared by its facts; a new one beside a vite or vitest config is WEAKENED). A value the readers cannot parse fails closed; nothing they read is skipped. # Gate-time budget: .claude/gate-budget.conf may not be deleted, and its three limits may not rise; a conf with no merge-base copy is held to the seeded defaults (600, 180, 25) and may not set a higher limit or leave one out. The kind is not enforced, so a human applying the allow-gate-change label can waive a raise or a deletion, by design. # Allow-lists: dep-audit-allow.txt may only lose lines; comment-hygiene-patterns.txt may only gain lines at the end. # Seeded-file exemptions: when the merge base has .claude/harness.json, a new entry, a changed origin_hash or a path added to .claude/seeded-paths.txt is WEAKENED, a dropped manifest is WEAKENED, an entry or list line removed is fine, and an unreadable or duplicated manifest is UNREADABLE. The seedmf kind is not enforced, so the human-applied allow-gate-change label waives WEAKENED (the bless, upgrade and refresh routes change hashes and entries and need it); UNREADABLE is never waived. When the merge base has .claude/gates.txt but no manifest, a manifest added in this change is WEAKENED (human waiver only). Without any harness at the merge base (adoption) one NOTE counts the exempt files. @@ -684,7 +684,7 @@ function do_eslint_import( from, m) { } } -# no-empty options (index i is just after the severity): none, or one object literal whose allowEmptyCatch is only ever the literal false. Any other allowEmptyCatch (true, !0, 1, a variable, a shorthand, nested) is a fact; an options argument that is not an object literal, or one with a spread, a computed key or an escape sequence, cannot be read and fails closed. +# no-empty options (index i is just after the severity): none, or one object literal whose allowEmptyCatch is only ever the literal false. Any other allowEmptyCatch (true, !0, 1, a variable, a shorthand, nested) is a fact; an options argument that is not an object literal, or one with a spread, a computed key or any backslash, cannot be read and fails closed. function no_empty(i, arr, key, q, n, body, r, after, flagged) { if (!arr) return n = length(T); q = i @@ -698,7 +698,7 @@ function no_empty(i, arr, key, q, n, body, r, after, flagged) { if (substr(T, q, 1) != "{") fail("no-empty options are not an object literal, so allowEmptyCatch cannot be read: " oneline(substr(T, q, 30))) body = substr(T, q, CL[q] - q + 1) if (body ~ /[.][.][.]/ || body ~ /[[]/) fail("no-empty options use a spread or a computed key, so allowEmptyCatch cannot be read") - if (body ~ /[\\][ux]/) fail("no-empty options hold an escape sequence, so a key could hide allowEmptyCatch and cannot be read") + if (body ~ /[\\]/) fail("no-empty options hold a backslash, so a key could hide allowEmptyCatch behind an escape and cannot be read") flagged = 0; r = body while (match(r, /allowEmptyCatch/)) { after = substr(r, RSTART + RLENGTH) @@ -731,6 +731,8 @@ function do_eslint( from, m, name, rest, sev, seen, p, opt, sc, key, lim, ne_s while (find("(^|[^A-Za-z0-9_$./@-])[\"']?no-empty[\"']?[ \t\n]*:", from)) { ne_all++; from = MS + ML } if (ne_all > ne_seen) fail("no-empty is set in a form the reader cannot judge (its value is not a severity or a [severity, options] array)") from = 1 + if (find("['\"][^'\"\n]*[\\\\][^'\"\n]*['\"][ \t\n]*:[ \t\n]*([[][ \t\n]*)?(['\"](off|warn|error)['\"]|[012][],} \t\n])", from)) fail("a rule name with a backslash is set to a severity, so the rule behind the escape cannot be read: " oneline(substr(T, MS, 40))) + from = 1 while (find("[A-Za-z0-9_]+[.]configs[.][A-Za-z0-9_.]+|[A-Za-z0-9_]+[.]recommended", from)) { emit("req", "preset", substr(T, MS, ML)); from = MS + ML; seen = 1 } from = 1 while (find("(from|import|require)[ \t\n]*[(]?[ \t\n]*['\"][.][.]?/[^'\"]*['\"]", from)) { @@ -1171,6 +1173,7 @@ function do_tsconfig( p, n, j, key, v) { while (p <= n && substr(T, p, 1) ~ /[ \t\n,]/) p++ if (substr(T, p, 1) != "\"") { if (substr(T, p, 1) != "}") fail("a key is not a quoted name, so the rest of the file is unread: " substr(T, p, 20)); break } j = jstr_end(p); key = substr(T, p + 1, j - p - 1); p = j + 1 + if (key ~ /\\/) fail("tsconfig key with an escape sequence: " key) while (p <= n && substr(T, p, 1) ~ /[ \t\n:]/) p++ if (key == "compilerOptions") ts_options(p) else if (key == "extends") emit("cfg", "extends", vtext(p)) @@ -1199,6 +1202,7 @@ function do_pyright( p, n, j, key, v, m, sv, mode) { while (p <= n && substr(T, p, 1) ~ /[ \t\n,]/) p++ if (substr(T, p, 1) != "\"") { if (substr(T, p, 1) != "}") fail("a key is not a quoted name, so the rest of the file is unread: " substr(T, p, 20)); break } j = jstr_end(p); key = substr(T, p + 1, j - p - 1); p = j + 1 + if (key ~ /\\/) fail("pyrightconfig key with an escape sequence: " key) while (p <= n && substr(T, p, 1) ~ /[ \t\n:]/) p++ v = vtext(p) if (key == "typeCheckingMode") { @@ -1400,7 +1404,7 @@ function do_pnpmws( i, n, L, line, v, inbuilds, inlist) { n = split(T, L, "\n"); inbuilds = 0; inlist = "" for (i = 1; i <= n; i++) { if (L[i] ~ /^[ \t]*#/) continue - if (L[i] ~ /^["][^"]*[\\][^"]*["][ \t]*:/) fail("pnpm-workspace.yaml has a double-quoted key with an escape sequence, which can hide a switch key and cannot be read: " substr(L[i], 1, 60)) + if (L[i] ~ /^[ \t]*([-][ \t]+)?["'][^"']*[\\][^"']*["'][ \t]*:/) fail("pnpm-workspace.yaml has a quoted key with a backslash, which can hide a switch key behind an escape and cannot be read: " substr(L[i], 1, 60)) line = norm_yaml(L[i]) if (line ~ /(strictDepBuilds|ignoreScripts|blockExoticSubdeps)/) { pnpm_switch(line); continue } if (line ~ /^[^ \t#-]/) { inbuilds = (line ~ /^allowBuilds:/); inlist = ""; if (line ~ /^(onlyBuiltDependencies|minimumReleaseAgeExclude|neverBuiltDependencies):/) { inlist = line; sub(/:.*$/, "", inlist) } } @@ -1423,23 +1427,28 @@ function do_dependabot( i, n, L, line, v) { } } -# ignore-scripts is safe only as true; false is a fact. dangerously-allow-all-builds is safe only as false or absent; true is a fact. Quotes and blanks are stripped from key and value first; any other value, or the key with no value, cannot be judged and fails closed. -function npmrc_switch(k, line, safe, weak, v) { - if (line !~ /=/) fail(".npmrc has " k " with no value: " substr(line, 1, 60)) - v = line; sub(/^[^=]*=/, "", v) +# ignore-scripts is safe only as true; false is a fact. dangerously-allow-all-builds is safe only as false or absent; true is a fact. Blanks are stripped and one matching quote pair around the key or around the value is removed; any other value (a quote anywhere else included), or the key with no value, cannot be judged and fails closed. +function unquote(x) { + if (length(x) >= 2 && (x ~ /^".*"$/ || x ~ /^'.*'$/)) return substr(x, 2, length(x) - 2) + return x +} +function npmrc_switch(k, v, safe, weak) { if (v == safe) return if (v == weak) { emit("set", "npmrc", k "=" weak); return } fail(".npmrc " k " is not the plain literal true or false: " v) } -function do_npmrc( i, n, L, line, k, q) { +function do_npmrc( i, n, L, line, k, v) { n = split(T, L, "\n") for (i = 1; i <= n; i++) { line = L[i]; sub(/\r$/, "", line); line = tolower(line); gsub(/[ \t]+/, "", line) if (line ~ /^[#;]/) continue - q = line; gsub(/["']/, "", q) - k = q; sub(/=.*$/, "", k) - if (k == "ignore-scripts") npmrc_switch(k, q, "true", "false") - else if (k == "dangerously-allow-all-builds") npmrc_switch(k, q, "false", "true") + k = line; sub(/=.*$/, "", k); k = unquote(k) + if (k == "ignore-scripts" || k == "dangerously-allow-all-builds") { + if (line !~ /=/) fail(".npmrc has " k " with no value: " substr(line, 1, 60)) + v = line; sub(/^[^=]*=/, "", v); v = unquote(v) + if (k == "ignore-scripts") npmrc_switch(k, v, "true", "false") + else npmrc_switch(k, v, "false", "true") + } else if (line ~ /^(@[^:]+:)?registry=/) emit("set", "npmrc-registry", line) } } diff --git a/tests/golden/fastapi-azure.sha256 b/tests/golden/fastapi-azure.sha256 index 8e813e71..377e759e 100644 --- a/tests/golden/fastapi-azure.sha256 +++ b/tests/golden/fastapi-azure.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh +a92bbd963ffd56f67dfb384e59417b53ec56fde1b55b9f4aea5cf8697b9b8db2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/fastapi-github.sha256 b/tests/golden/fastapi-github.sha256 index 2d5f83b9..59a2d040 100644 --- a/tests/golden/fastapi-github.sha256 +++ b/tests/golden/fastapi-github.sha256 @@ -85,7 +85,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 84d10ea43df30579ca62c7d212bff597b7a5d14fd2b2be631b636ee038ff3476 scripts/export-openapi.py 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh +a92bbd963ffd56f67dfb384e59417b53ec56fde1b55b9f4aea5cf8697b9b8db2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 55604fae082ab98f07e6b263221a614e5399f46c1dbbf89aad5351eb68531748 scripts/hook-shim.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py diff --git a/tests/golden/nestjs-azure.sha256 b/tests/golden/nestjs-azure.sha256 index d55c6277..65c0ee5d 100644 --- a/tests/golden/nestjs-azure.sha256 +++ b/tests/golden/nestjs-azure.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh +a92bbd963ffd56f67dfb384e59417b53ec56fde1b55b9f4aea5cf8697b9b8db2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nestjs-github.sha256 b/tests/golden/nestjs-github.sha256 index 44bfe091..936b67b8 100644 --- a/tests/golden/nestjs-github.sha256 +++ b/tests/golden/nestjs-github.sha256 @@ -91,7 +91,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 5cf243f9c1e927b4b5fa4bdbffc2cb7331643405b2cb15c2cebf4d44f2c42530 scripts/export-openapi.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh +a92bbd963ffd56f67dfb384e59417b53ec56fde1b55b9f4aea5cf8697b9b8db2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-azure.sha256 b/tests/golden/nextjs-azure.sha256 index f86c4152..4753aa02 100644 --- a/tests/golden/nextjs-azure.sha256 +++ b/tests/golden/nextjs-azure.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh +a92bbd963ffd56f67dfb384e59417b53ec56fde1b55b9f4aea5cf8697b9b8db2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/nextjs-github.sha256 b/tests/golden/nextjs-github.sha256 index 8ef6e488..77831597 100644 --- a/tests/golden/nextjs-github.sha256 +++ b/tests/golden/nextjs-github.sha256 @@ -96,7 +96,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh +a92bbd963ffd56f67dfb384e59417b53ec56fde1b55b9f4aea5cf8697b9b8db2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-azure.sha256 b/tests/golden/vite-react-azure.sha256 index f933fe4a..71f48aba 100644 --- a/tests/golden/vite-react-azure.sha256 +++ b/tests/golden/vite-react-azure.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh +a92bbd963ffd56f67dfb384e59417b53ec56fde1b55b9f4aea5cf8697b9b8db2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh diff --git a/tests/golden/vite-react-github.sha256 b/tests/golden/vite-react-github.sha256 index 0f82e040..e3e95674 100644 --- a/tests/golden/vite-react-github.sha256 +++ b/tests/golden/vite-react-github.sha256 @@ -94,7 +94,7 @@ ab80c3ab9f8ac2eeab4c5a0f0004f1e26fd6adacbc75469fd4bfe00e791070e7 scripts/check- 32a4c641ed3fa587143c2638c02c8ee86dc7a57119ef87f7dfd435487c531144 scripts/eslint-effective.mjs 4faf3621d621960140445689dbea50be175340b1a31a6475ef063d8da9e3bb59 scripts/gate-baseline.sh e9b3932a76e18705aaaeedb5ef3adc14d2160f78b84f995b0a74ce86f6d556ae scripts/gate-baselined.sh -1b3e0afd6c9129dad2d5621d085bfedd8e523fc4c7d82cac2aac01a819f83aa8 scripts/gate-ratchet.sh +a92bbd963ffd56f67dfb384e59417b53ec56fde1b55b9f4aea5cf8697b9b8db2 scripts/gate-ratchet.sh f105c09063c535f5aed591915e34621227d0ea3f98f337794d78cb1dfaff3b9a scripts/generate-sbom.sh 70edb543475618e2dddc2954a0b9f24309a312cb114cfe3596ff9ebe91db6d7e scripts/py-env.py ff24e2d2b39700e7434a461746fadfcd285814185f1ac297e3f6f0517f4479ac scripts/record-review.sh