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

Parked opened this
Closed without merging

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).

Notes

stopped parked by the crew deploy 71ee9fc

opened this

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. checkUpstream runs one ls-remote, fetches into refs/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 checking column so a crash can't leave a claim stuck.
  • Vetting and pin. vettedEnv in src/origins/git-mirror.ts is now exported and takes an optional protocols argument. ls-remote and fetch call it with REMOTE_PROTOCOLS (https:http). The host is vetted like a mirror fetch, and the resolved address is pinned with http.curloptResolve.
  • Token scope. mayCarryCredential allows a token only when the upstream is https: and its URL.origin equals the origin's webUrl origin. It is checked on each check, so an http:// upstream on a connected host is fetched with no Authorization.
  • Tests, added to test/upstream_follow.test.ts:
    • Two checks run at once: the second is busy.
    • The pin and GIT_ALLOW_PROTOCOL are 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 Authorization for an http:// upstream on a connected host.
    • A check records the tip and behind=1 and 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

  • mayCarryCredential is not checked at save yet, because there is no save action in this layer. putFollow doesn't see the origin's webUrl, 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.

Closes #3977

commented

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. checkUpstream runs one ls-remote, fetches into refs/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 checking column so a crash can't leave a claim stuck.
  • Vetting and pin. vettedEnv in src/origins/git-mirror.ts is now exported and takes an optional protocols argument. ls-remote and fetch call it with REMOTE_PROTOCOLS (https:http). The host is vetted like a mirror fetch, and the resolved address is pinned with http.curloptResolve.
  • Token scope. mayCarryCredential allows a token only when the upstream is https: and its URL.origin equals the origin's webUrl origin. It is checked on each check, so an http:// upstream on a connected host is fetched with no Authorization.
  • Tests, added to test/upstream_follow.test.ts:
    • Two checks run at once: the second is busy.
    • The pin and GIT_ALLOW_PROTOCOL are 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 Authorization for an http:// upstream on a connected host.
    • A check records the tip and behind=1 and 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

  • mayCarryCredential is not checked at save yet, because there is no save action in this layer. putFollow doesn't see the origin's webUrl, 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.

commented

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

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs