fix(scripts): refuse a dependency URL with a port in the allow-sync gate

How apm 0.39 writes a port into a package identity is unverified, so a
key derived from a git: URL with a port could be wrong while looking
right. The gate now fails clearly on one, naming `apm approve --list` as
the way to read the real identity. The script and gates.md record that
only an https URL on a lowercase host was checked against apm.

The test drops its GNU-only `sed -i` for a python3 rewrite, and covers
ssh:// and https URLs with a port under both readers.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-12-02 09:47:38 +00:00
1 parent 615d3dd881
commit dca0b5823b
3 files changed
+81 -14

No files matched your search

+4 -1
View File
@@ -1273,7 +1273,10 @@ matched no longer matches: the first 0.39 install parks the hooks, rewrites `.cl
without them, and root `apm audit --ci` still passes (spike #269, on #268). So the gate now derives
each expected key from root `apm.yml`'s own `git:` + `path:` dependency entry for the plugin (URL
without scheme, user or `.git`, then the path), appends `#<version>`, and fails a bare key with a
message saying why. A shipping plugin with no such entry fails, since no key can be derived. The
message saying why. A shipping plugin with no such entry fails, since no key can be derived, and so
does one whose `git:` URL names a port, because how apm writes a port into the identity is
unverified. Only an https URL on a lowercase host was checked against `apm approve --list`; the
scp-like and `ssh://` forms follow the same rule unchecked, and the host's case is kept as written. The
`#<version>` suffix is still stripped before apm matches, so the grant stays version-blind and the
version half stays a repo-level record. The grants are type-level (`hooks: true`), not
content-pinned: `apm approve` would pin content, strip the block's comments, and park the hook on