fix(apm): key executables.allow on the full 0.39 package identity
apm 0.39.3 matches executable grants on the package identity <host>/<owner>/<repo>/<path>. The bare kyberforge#<version> and delivery#<version> keys that 0.28.0 matched no longer match, so the first 0.39 install parks both hooks and rewrites .claude/settings.json without them, while root apm audit --ci stays green (spike #269, on #268). Rename both keys to git.rkdr.net/Mortis/Holocron/plugins/<name>#<version> with type-level grants, as `apm approve --list` names them on 0.39.3. Keep the version suffix convention; apm strips it before matching. Do not use `apm approve`, which would content-pin, strip the block's comments and park the hook on every script edit. check-executables-allow-sync now derives each expected key from root apm.yml's git + path dependency entry for the plugin, fails a bare key with a message saying why, and fails a shipping plugin with no such entry. Both readers carry the change, and the test covers URL and path spellings. Refs: #271 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
feef6d8307
commit
e1a99a7291
4 files changed
+249
-50
No files matched your search
@@ -46,12 +46,18 @@ make_fixture() {
|
||||
echo "description: fixture"
|
||||
} > "$dir/plugins/kyberforge/apm.yml"
|
||||
|
||||
# Both plugins are declared the way the real root apm.yml declares them, as
|
||||
# git + path entries: the gate derives each key's identity from these.
|
||||
{
|
||||
echo "name: ai-development"
|
||||
echo "version: 0.0.1"
|
||||
echo "dependencies:"
|
||||
echo " apm:"
|
||||
echo " - name: kyberforge"
|
||||
echo " - git: https://git.example.invalid/Owner/Repo.git"
|
||||
echo " path: plugins/kyberforge"
|
||||
echo " - git: https://git.example.invalid/Owner/Repo.git"
|
||||
echo " path: plugins/delivery"
|
||||
echo " mcp: []"
|
||||
[[ -n "$executables_block" ]] && printf '%s\n' "$executables_block"
|
||||
# A top-level key after the block: the fallback reader must stop collecting
|
||||
# allow keys here rather than reading on into the next section.
|
||||
@@ -74,40 +80,50 @@ add_plugin() {
|
||||
} > "$dir/apm.yml"
|
||||
}
|
||||
|
||||
# The identity apm 0.39 matches on: <host>/<owner>/<repo>/<path>.
|
||||
ID=git.example.invalid/Owner/Repo/plugins
|
||||
|
||||
MATCHING_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.5.0:
|
||||
git.example.invalid/Owner/Repo/plugins/kyberforge#1.5.0:
|
||||
hooks: true
|
||||
bin: true'
|
||||
|
||||
STALE_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.4.0:
|
||||
git.example.invalid/Owner/Repo/plugins/kyberforge#1.4.0:
|
||||
hooks: true
|
||||
bin: true'
|
||||
|
||||
TWO_MATCHING_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.5.0:
|
||||
git.example.invalid/Owner/Repo/plugins/kyberforge#1.5.0:
|
||||
hooks: true
|
||||
bin: true
|
||||
# delivery ships a guard hook; an indented comment must not read as a key.
|
||||
delivery#0.1.0:
|
||||
git.example.invalid/Owner/Repo/plugins/delivery#0.1.0:
|
||||
hooks: true'
|
||||
|
||||
TWO_STALE_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.4.0:
|
||||
git.example.invalid/Owner/Repo/plugins/kyberforge#1.4.0:
|
||||
hooks: true
|
||||
bin: true
|
||||
delivery#0.0.9:
|
||||
git.example.invalid/Owner/Repo/plugins/delivery#0.0.9:
|
||||
hooks: true'
|
||||
|
||||
OTHER_PACKAGE_BLOCK='executables:
|
||||
allow:
|
||||
git#1.0.0:
|
||||
git.example.invalid/Owner/Repo/plugins/git#1.0.0:
|
||||
hooks: true'
|
||||
|
||||
# The bare '<name>#<version>' form apm 0.28 matched and 0.39 does not.
|
||||
BARE_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.5.0:
|
||||
hooks: true
|
||||
bin: true'
|
||||
|
||||
# run_gate <fixture> — echoes combined output, sets GATE_RC.
|
||||
GATE_RC=0
|
||||
run_gate() {
|
||||
@@ -281,6 +297,33 @@ run_gate "$F"
|
||||
[[ $GATE_RC -ne 0 ]] && pass "refuses an unquoted 2-component version" \
|
||||
|| fail "a float version must fail rather than be compared in reader-invented form"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- the key is the full package identity apm 0.39 matches on ---"
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# The 0.28-era bare key: apm 0.39.3 parks the hooks under it while root
|
||||
# `apm audit --ci` stays green (spike #269), so this gate is what catches it.
|
||||
F="$(make_fixture "version: 1.5.0" "$BARE_BLOCK")"
|
||||
run_gate "$F"
|
||||
[[ $GATE_RC -ne 0 ]] && pass "fails on a bare '<name>#<version>' key" \
|
||||
|| fail "a bare key no longer matches under apm 0.39 and must fail"
|
||||
OUT="$(bash "$SCRIPT" "$F" 2>&1 || true)"
|
||||
grep -qF "$ID/kyberforge#1.5.0" <<< "$OUT" && pass "names the full-identity key to use" \
|
||||
|| fail "the failure must state the full-identity key, got: $OUT"
|
||||
grep -qF "full package identity" <<< "$OUT" && pass "says why a bare key no longer matches" \
|
||||
|| fail "the failure must explain the bare key, got: $OUT"
|
||||
|
||||
# No git+path dependency entry for the plugin means no identity to derive.
|
||||
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||
sed -i '/path: plugins\/kyberforge/d' "$F/apm.yml"
|
||||
run_gate "$F"
|
||||
[[ $GATE_RC -ne 0 ]] && pass "fails when root apm.yml has no git+path entry for the plugin" \
|
||||
|| fail "with no dependency entry the identity cannot be derived; must fail"
|
||||
OUT="$(bash "$SCRIPT" "$F" 2>&1 || true)"
|
||||
grep -qF "cannot be derived" <<< "$OUT" && pass "says the identity cannot be derived" \
|
||||
|| fail "the failure must say why, got: $OUT"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- the fallback reader agrees with the PyYAML reader ---"
|
||||
@@ -338,6 +381,41 @@ run_fallback "$F"
|
||||
run_fallback "$REPO_ROOT"
|
||||
[[ $GATE_RC -eq 0 ]] && pass "fallback passes the real repo" || fail "fallback disagrees with PyYAML on the real repo"
|
||||
|
||||
# Dependency entry shapes that name the same identity: no .git suffix, path
|
||||
# first, quoted values, ./ prefix and trailing slash, and an scp-like URL. Each
|
||||
# must pass under both readers.
|
||||
identity_variant() {
|
||||
local label="$1" entry="$2" f
|
||||
f="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||
python3 - "$f/apm.yml" "$entry" << 'PY2'
|
||||
import sys
|
||||
path, entry = sys.argv[1], sys.argv[2]
|
||||
text = open(path).read()
|
||||
old = " - git: https://git.example.invalid/Owner/Repo.git\n path: plugins/kyberforge\n"
|
||||
assert old in text
|
||||
open(path, "w").write(text.replace(old, entry + "\n"))
|
||||
PY2
|
||||
run_gate "$f"
|
||||
[[ $GATE_RC -eq 0 ]] && pass "PyYAML reader derives the identity: $label" \
|
||||
|| fail "PyYAML reader: $label should pass, got: $(bash "$SCRIPT" "$f" 2>&1 | head -2 || true)"
|
||||
run_fallback "$f"
|
||||
[[ $GATE_RC -eq 0 ]] && pass "fallback reader derives the identity: $label" \
|
||||
|| fail "fallback reader: $label should pass"
|
||||
}
|
||||
|
||||
identity_variant "no .git suffix" " - git: https://git.example.invalid/Owner/Repo
|
||||
path: plugins/kyberforge"
|
||||
identity_variant "path before git" " - path: plugins/kyberforge
|
||||
git: https://git.example.invalid/Owner/Repo.git"
|
||||
identity_variant "quoted values, ./ and trailing /" " - git: \"https://git.example.invalid/Owner/Repo.git\"
|
||||
path: './plugins/kyberforge/'"
|
||||
identity_variant "scp-like URL" " - git: [email protected]:Owner/Repo.git
|
||||
path: plugins/kyberforge"
|
||||
|
||||
F="$(make_fixture "version: 1.5.0" "$BARE_BLOCK")"
|
||||
run_fallback "$F"
|
||||
[[ $GATE_RC -ne 0 ]] && pass "fallback fails a bare key" || fail "fallback missed a bare key"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- wired into the pre-push gate ---"
|
||||
|
||||
Reference in new issue
Block a user