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

An app secret's value is never in a page's HTML: the secrets page shows its name, last change and a Replace action #13154

opened this

Merged 19d 14h ago, live in production

Each row of an app's Environment card (Settings › App) now has a Replace action: a write-only password field and a button that posts the new value to the existing POST /:owner/:name/settings/app/env, which only accepts same-origin requests.

Notes

opened this

Each row of an app's Environment card (Settings › App) now has a Replace action: a write-only password field and a button that posts the new value to the existing POST /:owner/:name/settings/app/env, which only accepts same-origin requests. The app's own secrets live in app_env and are drawn by appEnvView() in src/web/pages/settings.ts, not in app_secrets.ts, so the change is there.

Before this, the value was already never rendered: the page, GET /api/v1/repos/:owner/:name/app/env and the MCP app_env list all return names, scope and updatedAt only. Each change was already recorded as an app.env_set event holding the actor and the time, with no value. So what's new is the Replace action plus a test that proves all of it.

test/app-secrets-value.test.ts:

  • The page lists the secret's name, "set <time>", and a Replace form with a password input. This test fails without the change.
  • After the secret is set, the value appears in none of the three answers: the settings page HTML, the API list and the MCP list.
  • A cross-origin Replace is refused with 403 and records nothing.
  • A same-origin Replace returns 303 and records app.env_set with the admin's id and a time. The new value is in no event payload and in none of the three answers.

The test first also expected a POST with no Origin header to be refused. That expectation was wrong: crossOrigin() in src/http/context.ts accepts a missing Origin on purpose, treating it as a non-browser client, so I removed it.

Not done:

  • The row doesn't show who last changed a secret. The event records it, but showing it would need an event lookup per row.
  • Replace is offered on plain variables too, keeping their kind. It's the same form, and it avoids a branch.
  • No new MCP tool or action; mcp-size passes.
  • I didn't keep a plan on the issue or record an estimate, because the keep_plan and estimate tools aren't available in this session.

docs/design/areas/settings.md now lists appEnvView() among the writers of .row-fields; no new class was added.

Checks run: scripts/gate.ts, tsc --noEmit and design-lint are clean. scripts/fast.ts picked 1922 test files, too many to run here, so I ran the 8 that cover this change: the new test, app-secrets-web, mcp-size, mcp-app-env, forge-box-unit, fresh-app, app-settings-page and web-apps. All 68 tests pass.

To try it: open an app's Settings › App, find a secret under Environment, type a new value beside it and press Replace. The row's "set" time updates, and the value appears nowhere on the page.

🤖 Generated with Claude Code

Closes #13142

3 earlier comments
commented

Each row of an app's Environment card (Settings › App) now has a Replace action: a write-only password field and a button that posts the new value to the existing POST /:owner/:name/settings/app/env, which only accepts same-origin requests. The app's own secrets live in app_env and are drawn by appEnvView() in src/web/pages/settings.ts, not in app_secrets.ts, so the change is there.

Before this, the value was already never rendered: the page, GET /api/v1/repos/:owner/:name/app/env and the MCP app_env list all return names, scope and updatedAt only. Each change was already recorded as an app.env_set event holding the actor and the time, with no value. So what's new is the Replace action plus a test that proves all of it.

test/app-secrets-value.test.ts:

  • The page lists the secret's name, "set <time>", and a Replace form with a password input. This test fails without the change.
  • After the secret is set, the value appears in none of the three answers: the settings page HTML, the API list and the MCP list.
  • A cross-origin Replace is refused with 403 and records nothing.
  • A same-origin Replace returns 303 and records app.env_set with the admin's id and a time. The new value is in no event payload and in none of the three answers.

The test first also expected a POST with no Origin header to be refused. That expectation was wrong: crossOrigin() in src/http/context.ts accepts a missing Origin on purpose, treating it as a non-browser client, so I removed it.

Not done:

  • The row doesn't show who last changed a secret. The event records it, but showing it would need an event lookup per row.
  • Replace is offered on plain variables too, keeping their kind. It's the same form, and it avoids a branch.
  • No new MCP tool or action; mcp-size passes.
  • I didn't keep a plan on the issue or record an estimate, because the keep_plan and estimate tools aren't available in this session.

docs/design/areas/settings.md now lists appEnvView() among the writers of .row-fields; no new class was added.

Checks run: scripts/gate.ts, tsc --noEmit and design-lint are clean. scripts/fast.ts picked 1922 test files, too many to run here, so I ran the 8 that cover this change: the new test, app-secrets-web, mcp-size, mcp-app-env, forge-box-unit, fresh-app, app-settings-page and web-apps. All 68 tests pass.

To try it: open an app's Settings › App, find a secret under Environment, type a new value beside it and press Replace. The row's "set" time updates, and the value appears nowhere on the page.

🤖 Generated with Claude Code

commented

An app's secret value no longer appears in any page, API answer or MCP answer. Each secret's row under Settings › App › Environment now has its own Replace field: you type a new value there instead of seeing the old one.

The check failure: the forge's before/after-looks rule fails when a pull changes src/web/pages/settings.ts and no commit names a page from app.looks (the pages the forge photographs, in forge.json) or gives a reason with "No look:". None of those pages shows an app's Environment section, which needs a real app with secrets. So I added an empty commit with a No look: line saying that; no code changed. bun scripts/gate.ts now passes. I did not re-run the type check or tests, since that commit changes no files.

To try it: open an app's Settings › App, find a secret under Environment, type a new value beside it and press Replace. The secret's value should not show up in the page source or in the API's answer.

🤖 Generated with Claude Code

commented

This pull lets you replace an app secret from its own row in Settings › App › Environment. A secret's value appears in no page, no API answer and no MCP answer: you can set a new value, but nothing ever shows it back to you.

The last push failed main's comment-width rule (100 columns) in src/web/pages/settings.ts. That rule came in on main through scripts/gate.ts after this branch was cut, so this push merges main in. Running bun scripts/gate.ts --fix then rewrapped one comment, in autonomySettingsUpdate. That comment came from main through the merge, not from this pull. No behaviour changed.

Before pushing, the gate, bun x tsc --noEmit and bun scripts/design-lint.ts passed. I didn't run the files scripts/fast.ts named: the merge with main touched 1,924 test files, about 163 minutes of tests. I ran the 8 settings and secrets test files instead (app-secrets-value, app-secrets-web, app-secrets, app-settings-page, mcp-secrets, settings-secret-delete, secrets-card, settings-app-domains), and all 36 tests passed. The forge runs the full check on this push.

To try it on the preview: open an app's Settings › App, find a secret under Environment, type a new value beside it and press Replace. The page confirms the change without ever showing the value.

🤖 Generated with Claude Code

commented

An app secret is now replaced from its row under Settings › App › Environment, and its value is never in a page, an API answer or an MCP answer. The row shows the secret's name, scope and when it last changed, with a password field and Replace. Replace sends a same-origin POST to the existing settings/app/env route. The change is logged as an app.env_set event with who made it and when, never the value.

This push, after review:

  • Replace is for secrets only. The form appears only when kind === "secret" (src/web/pages/settings.ts, appEnvView). A plain variable's value is already printed in its row, so it is set again with the form under the list.
    • New test in test/app-secrets-value.test.ts: a variable's row has no Replace form. It fails on the old code.
  • The how-to now covers replacing. docs/features/app-secrets.md has a "Replacing a secret" section. It says:
    • a secret is replaced from its row;
    • its value is never shown back;
    • Replace is for secrets only.
  • The terminal docs. The terminal section now says that setting an existing name again in Variables (src/tui/screens/appenv.ts) replaces its value. It uses the same setAppEnvVar update-or-insert. The section also says the list never shows a secret's value.
  • The comment rewrap in autonomySettingsUpdate stays. The gate doesn't permit dropping it: with the comment back at 101 columns, bun scripts/gate.ts fails the 100-column rule. The overlong line came from main, but this pull changes settings.ts, so that rule covers the whole file.

Checks: the gate, bun x tsc --noEmit and bun scripts/design-lint.ts pass. The settings, secrets and app-env test files all pass: 14 files, 74 tests. I didn't run the files scripts/fast.ts names, because it names 1,924 of them since the earlier merge with main.

To try it on the preview:

  1. Open an app's Settings › App › Environment.
  2. On a secret's row, type a new value and press Replace. The page confirms the change without ever showing the value.
  3. A plain variable's row has no Replace field.

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs