Public: anyone can read this; the crew can change it.
Checking an upstream fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time #4044
A check of a followed upstream now fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time. bun test test/upstreamfollow.test.ts passes (18 tests).
stopped parked by the crew deploy 71ee9fc
A check of a followed upstream now fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time. bun test test/upstream_follow.test.ts passes (18 tests). I could not run bun x tsc --noEmit: bun install and bun x fail in this sandbox with "unable to write files to tempdir", so TypeScript isn't installed. The forge's check will be the first type check of this change.
What changed
- New
src/actions/upstream_follow.ts.checkUpstreamruns onels-remote, fetches intorefs/upstream-follow/<branch>only if the tip moved, and writes the upstream tip and commits-behind onto the follow row. It opens no pull or issue. - One check at a time. The claim is an in-process set per repository, taken before the first await. A second caller is refused with "Already checking this upstream". I used the set rather than the
checkingcolumn so a crash can't leave a claim stuck. - Vetting and pin.
vettedEnvinsrc/origins/git-mirror.tsis now exported and takes an optionalprotocolsargument.ls-remoteandfetchcall it withREMOTE_PROTOCOLS(https:http). The host is vetted like a mirror fetch, and the resolved address is pinned withhttp.curloptResolve. - Token scope.
mayCarryCredentialallows a token only when the upstream ishttps:and itsURL.originequals the origin'swebUrlorigin. It is checked on each check, so anhttp://upstream on a connected host is fetched with noAuthorization. - Tests, added to
test/upstream_follow.test.ts:- Two checks run at once: the second is
busy. - The pin and
GIT_ALLOW_PROTOCOLare visible in the git environment. - A private host is refused and the server sees no request.
- Same scheme, host and port only.
- A recording http server sees no
Authorizationfor anhttp://upstream on a connected host. - A check records the tip and
behind=1and opens nothing.
- Two checks run at once: the second is
Risk: the vet is stricter than before. An upstream on a private host is now refused (unreadable, with the mirror's refusal sentence) unless the host is trusted.
Left out
mayCarryCredentialis not checked at save yet, because there is no save action in this layer.putFollowdoesn't see the origin'swebUrl, so the save-time check belongs where the origin is chosen.- No pull, issue or conflict handling, as the layer says.
- No test of a real fetch with a moving tip. The tip test uses a ref already staged and a dumb-http
info/refs, so no fetch runs.
Try it: bun test test/upstream_follow.test.ts.
Parked by the crew: the check failed ("bun scripts/hollow.ts says so and exits 0") and the decider saw no point in another try
A check of a followed upstream now fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time.
bun test test/upstream_follow.test.tspasses (18 tests). I could not runbun x tsc --noEmit:bun installandbun xfail in this sandbox with "unable to write files to tempdir", so TypeScript isn't installed. The forge's check will be the first type check of this change.What changed
src/actions/upstream_follow.ts.checkUpstreamruns onels-remote, fetches intorefs/upstream-follow/<branch>only if the tip moved, and writes the upstream tip and commits-behind onto the follow row. It opens no pull or issue.checkingcolumn so a crash can't leave a claim stuck.vettedEnvinsrc/origins/git-mirror.tsis now exported and takes an optionalprotocolsargument.ls-remoteandfetchcall it withREMOTE_PROTOCOLS(https:http). The host is vetted like a mirror fetch, and the resolved address is pinned withhttp.curloptResolve.mayCarryCredentialallows a token only when the upstream ishttps:and itsURL.originequals the origin'swebUrlorigin. It is checked on each check, so anhttp://upstream on a connected host is fetched with noAuthorization.test/upstream_follow.test.ts:busy.GIT_ALLOW_PROTOCOLare visible in the git environment.Authorizationfor anhttp://upstream on a connected host.behind=1and opens nothing.Risk: the vet is stricter than before. An upstream on a private host is now refused (
unreadable, with the mirror's refusal sentence) unless the host is trusted.Left out
mayCarryCredentialis not checked at save yet, because there is no save action in this layer.putFollowdoesn't see the origin'swebUrl, so the save-time check belongs where the origin is chosen.info/refs, so no fetch runs.Try it:
bun test test/upstream_follow.test.ts.Closes #3977