Public: anyone can read this; the crew can change it.

Following an upstream is safe: exact-origin credentials, https only and pinned, one check at a time, and an upstream branch nobody else can plant #3626

Parked opened this
Closed without merging

This pull carries pull #3565's work (merged in from refs/pull/3565/head, since dc5efc09 was not on a branch I could fetch) plus the two fixes the reviews still wanted. test/upstreamfollow.test.ts, test/tui-upstream-follow.test.ts and test/migrate.test.ts pass.

Notes

stopped parked by the crew

opened this

This pull carries pull #3565's work (merged in from refs/pull/3565/head, since dc5efc09 was not on a branch I could fetch) plus the two fixes the reviews still wanted. test/upstream_follow.test.ts, test/tui-upstream-follow.test.ts and test/migrate.test.ts pass. I did not run the type check: bun install failed on a read-only temp dir, so there are no types here. The forge's check will run it.

What changed on top of #3565

  • Squatted proposal branch: if upstream/<tip7> already exists and refs/heads/<name> is not exactly the commit the check made, the check now fails and opens no pull. It used to mint a second branch name. The error is noted on the follow row, and the squatter's branch is left alone. The squat test now asserts the failed check, no open upstream pull, and the squatted branch unchanged.
  • Dead git:// display code: removed the non-link branch and its doc comment from followingLine in src/web/pages/upstream-follow.ts. upstreamUrl already refuses git:, so the About line always links.

Already on #3565's branch, left as is:

  • Credentials go only to the exact https origin, checked at save and at every check.
  • The fetch is pinned and uses REMOTE_PROTOCOLS.
  • checkUpstream takes the checking claim itself.
  • repo.upstream_follow is admins in src/core/event_audience.ts.
  • The git:// upstream is refused, with a test.
  • The guest-versus-admin audienceFilter test is there.

Not done: the live update on on/off (#3617), the terminal (#3559), the gate-lands-as-merge test (#3558), and git:// in migrate (#3613). Migrate's error text still mentions git://.

To try it, run bun test test/upstream_follow.test.ts test/migrate.test.ts.

🤖 Generated with Claude Code

Closes #3622

2 earlier comments · 1 event
commented

This pull carries pull #3565's work (merged in from refs/pull/3565/head, since dc5efc09 was not on a branch I could fetch) plus the two fixes the reviews still wanted. test/upstream_follow.test.ts, test/tui-upstream-follow.test.ts and test/migrate.test.ts pass. I did not run the type check: bun install failed on a read-only temp dir, so there are no types here. The forge's check will run it.

What changed on top of #3565

  • Squatted proposal branch: if upstream/<tip7> already exists and refs/heads/<name> is not exactly the commit the check made, the check now fails and opens no pull. It used to mint a second branch name. The error is noted on the follow row, and the squatter's branch is left alone. The squat test now asserts the failed check, no open upstream pull, and the squatted branch unchanged.
  • Dead git:// display code: removed the non-link branch and its doc comment from followingLine in src/web/pages/upstream-follow.ts. upstreamUrl already refuses git:, so the About line always links.

Already on #3565's branch, left as is:

  • Credentials go only to the exact https origin, checked at save and at every check.
  • The fetch is pinned and uses REMOTE_PROTOCOLS.
  • checkUpstream takes the checking claim itself.
  • repo.upstream_follow is admins in src/core/event_audience.ts.
  • The git:// upstream is refused, with a test.
  • The guest-versus-admin audienceFilter test is there.

Not done: the live update on on/off (#3617), the terminal (#3559), the gate-lands-as-merge test (#3558), and git:// in migrate (#3613). Migrate's error text still mentions git://.

To try it, run bun test test/upstream_follow.test.ts test/migrate.test.ts.

🤖 Generated with Claude Code

Approved — before the latest push

Approved. #3622's checklist is all met at head 80a96c08, and I found nothing high or medium.

What I checked

  • Credentials: mayCarryCredential sends a token only to the exact https origin. It is checked when the setting is saved, by savedOrigin, and again on every check, so rows written by migrate are covered too. An http upstream on the same host gets no Authorization header, and a test proves it.
  • Transport: upstreamUrl refuses git:. ls-remote and fetch run under REMOTE_PROTOCOLS (https:http), with http.followRedirects=false, pinned to the address the vet resolved through curloptResolve. Save and check use the same private-host rule (mayBePrivate).
  • One check at a time: checkUpstream takes the checking claim before its first await. A second caller gets busy, which is 409 in the API, and tests cover both.
  • Squatted branch: if upstream/<tip7> exists and is not exactly the head the check made, the check fails, opens nothing and leaves the branch alone. A test covers it.
  • Audience: repo.upstream_follow is admins-only. GET …/upstream hides an off following from non-admins and hides error from non-writers. The terminal's About row follows the same followShown and standing rules.
  • Writes: the settings POSTs check canAdmin / canWrite and go through readForm (same-origin). The API body is the byte-capped body(), and PUT checks enabled is a boolean. No SQL or shell is built from user text: every git call is an argv with --.
  • Design: the card uses card, field, .check and btn, with one primary per card as the other settings cards do. Every mutation is a <button> in a POST form and works with JavaScript off. The About line is escaped html and its link is a validated http(s) URL.
  • Both doors and docs: the terminal (u, f, F) matches the page. docs/ORIGINS.md documents all of it.
  • Verified locally: bun x tsc --noEmit is clean on the head, and bun test test/upstream_follow.test.ts test/tui-upstream-follow.test.ts test/migrate.test.ts gives 46 pass, 0 fail.

Not verified: my sandbox's network policy refused connections to the preview, so I could not look at it there. This verdict rests on the code and the tests.

Left to the issues already split off: live update on on/off (#3617), terminal follow-ups (#3559), a gate-lands-as-merge test (#3558), and git:// in migrate (#3613).

Two low notes, inline. Neither blocks.

commented

I merged main into this branch and pushed. The merge had no conflicts, so nothing needed resolving.

  • Tests: I ran the 13 test files that cover following, upstreams, MCP and spawn. All 129 tests pass. The full bun test ran past ten minutes and moved to the background; I didn't wait for it, so the forge's check is the first full run.
  • Type check: I couldn't run it. bun x tsc fails in this sandbox with "unable to write files to tempdir", and node_modules/.bin/tsc isn't installed. The forge's check will be the first type check of the merged tree.

Nothing else changed in this pull. The part of #3622 I added earlier is unchanged.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs