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

Traces 5b: a trace has a share link, off by default, revocable, served with secrets redacted #18162

opened this

Closed 10h 21m ago

Trace owners can now make a share link for a crew run, and take it back; /t/ serves the trace read-only with secrets masked. I ran the new tests, the dead-code, module-state, doorless and migration suites, tsc and design-lint.

Notes

opened this

Trace owners can now make a share link for a crew run, and take it back; /t/<token> serves the trace read-only with secrets masked. I ran the new tests, the dead-code, module-state, doorless and migration suites, tsc and design-lint. One earlier run of the combined set showed a single failure I could not reproduce; two reruns were clean. The full suite was not run.

What changed

  • Storage: a new migration (pinned) adds trace_share: run id, SHA-256 of the token, who made it, when it was revoked. Only the hash is kept; the raw tr_… token is shown once, on the answer to making it.
  • Who may make or revoke: only someone who may read the run's log and sees its owner facts (canSeeOwnerFacts: the repository's owner or writers). There is no new grant table or admin shortcut. A non-owner gets 404, and 403 if they can read the log but are not an owner.
  • Same-origin: both POST /traces/:id/share and /unshare go through readForm, which refuses a cross-origin request.
  • GET /t/:token: shows the steps and their raw lines. Every line goes through redactHeld again, so a log written before a value was masked is still masked now. It shows no repository, cost or links. It is no-store, no-referrer and noindex. A revoked, unknown or malformed token is 404.
  • Page: /traces/:id has a Share section for the owner, with Make a link and Revoke every link.
  • Terminal: on the trace screen, s makes a link (shown once) and x revokes.
  • Docs: docs/features/traces.md has a new section.
  • Test: test/trace-share.test.ts plants a ghp_… token in the log and checks that:
    • the response shows it as [redacted];
    • after revoke the same link is 404;
    • a non-owner cannot create or revoke a link;
    • a cross-origin make or revoke is refused;
    • the table holds no raw token.

Left out

  • Expiry, naming a link, and revoking one of several (revoke takes back all of a run's links). Also no JSON twin.
  • Refreshing the POST answer makes another link.
  • The terminal s and x act without asking first. The tui-asks-first test passes.

Gate notes

  • The gate warns that ownerOf in share.ts is similar to gate in origin_read_grant.ts. They check different things, so I left them separate.
  • The gate also says the /traces/:id route is not an app.looks page in forge.json, so the reviewer decides on the look.

Try Open /traces/<run id> as the repository owner and press Make a link. Open the /t/<token> shown in a private window, then press Revoke every link and reload it for a 404.

[
  {"go":"/traces/<run id> as the repo owner","look":"Share section: 'Sharing is off.' and Make a link","expect":"after Make a link, the page shows 'Link, shown once' with /t/tr_… and a Revoke button"},
  {"go":"/t/<token> in a private window","look":"steps with raw lines, no repo, cost or links","expect":"any credential-shaped text reads [redacted]"},
  {"go":"Revoke every link, then reload /t/<token>","look":"the shared page","expect":"404"}
]

Closes #18084

commented

Trace owners can now make a share link for a crew run, and take it back; /t/<token> serves the trace read-only with secrets masked. I ran the new tests, the dead-code, module-state, doorless and migration suites, tsc and design-lint. One earlier run of the combined set showed a single failure I could not reproduce; two reruns were clean. The full suite was not run.

What changed

  • Storage: a new migration (pinned) adds trace_share: run id, SHA-256 of the token, who made it, when it was revoked. Only the hash is kept; the raw tr_… token is shown once, on the answer to making it.
  • Who may make or revoke: only someone who may read the run's log and sees its owner facts (canSeeOwnerFacts: the repository's owner or writers). There is no new grant table or admin shortcut. A non-owner gets 404, and 403 if they can read the log but are not an owner.
  • Same-origin: both POST /traces/:id/share and /unshare go through readForm, which refuses a cross-origin request.
  • GET /t/:token: shows the steps and their raw lines. Every line goes through redactHeld again, so a log written before a value was masked is still masked now. It shows no repository, cost or links. It is no-store, no-referrer and noindex. A revoked, unknown or malformed token is 404.
  • Page: /traces/:id has a Share section for the owner, with Make a link and Revoke every link.
  • Terminal: on the trace screen, s makes a link (shown once) and x revokes.
  • Docs: docs/features/traces.md has a new section.
  • Test: test/trace-share.test.ts plants a ghp_… token in the log and checks that:
    • the response shows it as [redacted];
    • after revoke the same link is 404;
    • a non-owner cannot create or revoke a link;
    • a cross-origin make or revoke is refused;
    • the table holds no raw token.

Left out

  • Expiry, naming a link, and revoking one of several (revoke takes back all of a run's links). Also no JSON twin.
  • Refreshing the POST answer makes another link.
  • The terminal s and x act without asking first. The tui-asks-first test passes.

Gate notes

  • The gate warns that ownerOf in share.ts is similar to gate in origin_read_grant.ts. They check different things, so I left them separate.
  • The gate also says the /traces/:id route is not an app.looks page in forge.json, so the reviewer decides on the look.

Try Open /traces/<run id> as the repository owner and press Make a link. Open the /t/<token> shown in a private window, then press Revoke every link and reload it for a 404.

[
  {"go":"/traces/<run id> as the repo owner","look":"Share section: 'Sharing is off.' and Make a link","expect":"after Make a link, the page shows 'Link, shown once' with /t/tr_… and a Revoke button"},
  {"go":"/t/<token> in a private window","look":"steps with raw lines, no repo, cost or links","expect":"any credential-shaped text reads [redacted]"},
  {"go":"Revoke every link, then reload /t/<token>","look":"the shared page","expect":"404"}
]
commented

Declined: already done on main in 7a173148f. That commit, "Traces 5: compare two traces, and share one with secrets redacted (#18017)", is the work the issue asks for, and it replaces this branch's version of the share feature. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m909wnmhxbd9wr3ky9c9jmq1

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs