Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased — security remediation pass

- Stage the hosted origin on codexbot.appsolves.workers.dev with Workers.dev enabled and previews disabled; preserve the existing custom domain for controlled cutover. Default CLI/generated callers and the onboarding page/manifest to the new URL. Reject all privileged requests on noncanonical aliases, keep exact OIDC audiences and require fresh origin-bound ChatGPT connection. No deployment, zone-security change or credential migration is automatic; see docs/origin-migration.md.

- Correct Environment secret forwarding: generate named references after a required environment-free caller guard rejects repository/organization credentials. Empty literals did not enable Environment lookup; named references alone would allow fallback. Existing callers must update through a PR; reusable/Worker pins and credentials remain unchanged. See docs/review-rollout.md.

- Explicitly forward only named Environment credential grants; add a credential-only availability diagnostic, safe runner/broker/OIDC failure codes and failed-job publication safeguards.
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

An Apache-2.0 GitHub App for Codex pull request reviews on repository-owned GitHub Actions runners. The Cloudflare Worker authenticates requests and publishes native reviews; it never runs Codex.

Hosted backend: **[https://codexbot.appsolves.workers.dev](https://codexbot.appsolves.workers.dev/)**. This is the CLI and generated-workflow default. The hostname migration is staged; production availability and credential acceptance must be verified during the [operator cutover](docs/origin-migration.md). Independent installations pass their own HTTPS origin with `--backend`.

```text
@CBReview review --effort xhigh --merge

Expand All @@ -14,7 +16,7 @@ Set `bot.trigger: "@CBReview"` to use the example above. The legacy default `@co

## Status

**Pre-release implementation; no public hosted App has been deployed by this repository setup.** Unit/integration tests exercise signed webhooks, official OAuth contracts, OIDC, actual SQLite persistence, setup PR creation and GitHub publishing against mocked external APIs. The pinned official Codex binary is tested without credentials. A separate Docker check uses synthetic inference; it does not claim to have performed a real AI review. See [validation and live acceptance](docs/validation.md).
**Pre-release; full production review acceptance remains pending.** Unit/integration tests exercise signed webhooks, official OAuth contracts, OIDC, actual SQLite persistence, setup PR creation and GitHub publishing against mocked external APIs. The pinned official Codex binary is tested without credentials. A separate Docker check uses synthetic inference; it does not claim to have performed a real AI review. See [validation and live acceptance](docs/validation.md).

Live GitHub installation, real OpenAI inference/allowance, OAuth eligibility and Cloudflare production resource usage require operator credentials and acceptance testing. Do not market this as battle-tested or deploy with automatic merge before completing those checks.

Expand Down Expand Up @@ -43,8 +45,8 @@ npm run check
3. Create the setup PR (replace the uppercase values):

```sh
npm run cli -- setup --repository OWNER/REPO --backend https://YOUR-WORKER \
--source YOUR-ORG/codexbot --ref FULL_40_CHARACTER_COMMIT_SHA
npm run cli -- setup --repository OWNER/REPO --backend https://codexbot.appsolves.workers.dev \
--source AppSolves/codexbot --ref 4ed668864cac0682e09ec49a2515a6e1893a2780
```

The source must match the Worker's trusted reusable workflow. If you prefer a temporary personal setup token to granting the App Workflows write, add `--setup-as-user`; the user credential needs Contents/Pull requests/Workflows write. No files are overwritten. See [manual setup](docs/installation.md).
Expand All @@ -53,10 +55,10 @@ The source must match the Worker's trusted reusable workflow. If you prefer a te

```sh
# Preferred, when your deployment is eligible for OpenAI's OSS/hosted policy:
npm run cli -- connect --repository OWNER/REPO --backend https://YOUR-WORKER
npm run cli -- connect --repository OWNER/REPO --backend https://codexbot.appsolves.workers.dev

# Alternative: set CODEXBOT_API_KEY securely in your local process environment first.
npm run cli -- connect-api-key --repository OWNER/REPO --backend https://YOUR-WORKER
npm run cli -- connect-api-key --repository OWNER/REPO --backend https://codexbot.appsolves.workers.dev
```

The ChatGPT flow displays **Continue with ChatGPT** and opens an official authorization URL using a loopback callback. Manual `auth.json` export is unnecessary. API-key mode requires `credentials.mode: api-key` in trusted configuration. Do not keep both mode secrets in the Environment.
Expand Down
8 changes: 4 additions & 4 deletions app-manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "CodexBot",
"url": "https://YOUR-WORKER.example",
"hook_attributes": { "url": "https://YOUR-WORKER.example/webhook", "active": true },
"redirect_url": "https://YOUR-WORKER.example/",
"setup_url": "https://YOUR-WORKER.example/",
"url": "https://codexbot.appsolves.workers.dev",
"hook_attributes": { "url": "https://codexbot.appsolves.workers.dev/webhook", "active": true },
"redirect_url": "https://codexbot.appsolves.workers.dev/",
"setup_url": "https://codexbot.appsolves.workers.dev/",
"public": true,
"default_permissions": { "metadata": "read", "contents": "write", "pull_requests": "write", "actions": "write" },
"default_events": ["issue_comment", "pull_request"]
Expand Down
2 changes: 2 additions & 0 deletions docs/authentication.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Authentication and credential ownership

The hosted canonical origin is `https://codexbot.appsolves.workers.dev`; independent operators explicitly select their own origin. OAuth AAD includes this exact origin, installation, repository and actor, and local profile files are separated by backend host. Existing ChatGPT connections require [safe revocation and fresh sign-in](origin-migration.md#chatgpt-reconnection) when the origin changes. Do not copy profiles, rebind ciphertext or accept both OIDC audiences during a cutover. API-key mode keeps its existing owning Environment; it does not have OAuth ciphertext to migrate.

Reusable callers must use explicit named secret references after the environment-free `credential-scope` guard rejects nonempty repository/organization credentials under either name. The called installation/actor Environment supplies the actual credential. Literal empty grants do not enable Environment secret resolution. Named references alone would permit a global-secret fallback if an Environment secret were missing; keep the guard and its required dependency. [Credential diagnostics and rollout](review-rollout.md) explain the GitHub contract and no-inference check. No reusable-workflow/Worker pin or session format changes are needed for this caller-only correction.

## Official ChatGPT OAuth
Expand Down
8 changes: 5 additions & 3 deletions docs/deployment.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Deployment checklist

Hosted canonical origin: **https://codexbot.appsolves.workers.dev**. Use the [staged origin migration](origin-migration.md) for the existing App/Worker; it preserves the current D1, secrets, immutable review pin and zone Bot Fight Mode. This repository prepares the change; merging or a dry-run does not deploy it.

For Worker/reusable-workflow upgrades, follow [the coordinated immutable-pin upgrade](review-rollout.md), apply required migrations and set the caller pin and Worker TRUSTED_WORKFLOW to the same actual merged commit. The caller-only Environment-secret correction uses named references plus a scope guard; it keeps the existing `4ed668864cac0682e09ec49a2515a6e1893a2780` pin and needs no Worker deployment or migration. Keep merge disabled. Report validation before any production change; a temporary pin mismatch fails closed.

The shared setup generator is bundled into `/v1/setup`. Publishing its corrected templates for future hosted installations requires a separately authorized Worker bundle deployment, with the existing trusted review pin preserved. The existing caller can be repaired independently; no backend deployment is performed by the fix PR.
Expand All @@ -8,12 +10,12 @@ This document is operator instructions, not evidence of an existing hosted deplo

## GitHub App

Register a public GitHub App with installation access for any account, selecting repositories narrowly. [app-manifest.json](../app-manifest.json) is a settings reference; replace example URLs. Manifest-code conversion is not implemented: use GitHub's App settings or your own approved registration tooling.
Register a public GitHub App with installation access for any account, selecting repositories narrowly. [app-manifest.json](../app-manifest.json) contains the hosted URL defaults; independent operators replace all four origin-bearing fields with their own backend. Manifest-code conversion is not implemented: use GitHub's App settings or your own approved registration tooling.

| Setting | Required value |
|---|---|
| Homepage/setup URL | https://YOUR-WORKER/ |
| Webhook | https://YOUR-WORKER/webhook |
| Homepage/setup URL | https://codexbot.appsolves.workers.dev/ (or the independent backend) |
| Webhook | https://codexbot.appsolves.workers.dev/webhook (or the independent backend) |
| Secret | Cryptographically random, at least 32 bytes |
| Default permissions | Metadata read; Actions write; Contents write; Pull requests write |
| Optional automated setup | Workflows write, explicit installer consent; otherwise manual/temporary-user setup |
Expand Down
10 changes: 6 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Install the operator's public App and select repositories. Its Worker landing page is an operational checklist, not a hosted OAuth wizard. All credential sign-in runs in the local CLI. Each installation can instead use its own App, Worker and immutable source fork.

The hosted backend and CLI default is `https://codexbot.appsolves.workers.dev`. Self-hosted operators supply their own `--backend` and source pin. Existing ChatGPT connections must follow the [origin cutover and reconnect procedure](origin-migration.md) before using this new origin; they are not transferable ciphertext.

## Setup permissions and supported plans

The default manifest deliberately omits Workflows write. App-authored setup requires an explicit operator permission upgrade and installer consent. Otherwise use the first-class manual workflow below, or add `--setup-as-user` with a temporary single-repository administrator credential granting Contents/Pull requests/Workflows write. It creates the same reviewed setup PR under your own identity; no automatic elevation or retained user token is used.
Expand All @@ -10,7 +12,7 @@ Before creating a setup PR or connecting credentials, the CLI probes Environment

```sh
npm ci --ignore-scripts
npm run cli -- setup --repository OWNER/REPO --backend https://YOUR-WORKER \
npm run cli -- setup --repository OWNER/REPO --backend https://codexbot.appsolves.workers.dev \
--source YOUR-ORG/codexbot --ref FULL_COMMIT_SHA --setup-as-user
```

Expand Down Expand Up @@ -65,7 +67,7 @@ jobs:
request_id: ${{ inputs.request_id }}
credential_owner: ${{ inputs.credential_owner }}
installation_id: ${{ inputs.installation_id }}
backend: https://YOUR-WORKER
backend: https://codexbot.appsolves.workers.dev
credential_check_only: ${{ inputs.credential_check_only }}
```

Expand All @@ -78,9 +80,9 @@ Use the two named secret references, not literal empty grants. The `credential-s
Protect the default branch **before** connecting. New codexbot-INSTALLATION_ID-NUMERIC_USER_ID and codexbot-publish-INSTALLATION_ID Environments use a default-branch-only custom deployment policy. The installation namespace isolates both API keys and OAuth vault keys across independent Apps/reinstalls. Existing reviewers/timers are preserved. Unrestricted Environments and custom policies allowing other branches/tags are rejected. Existing protected-branch policies require an actually protected default branch: GitHub otherwise permits every branch when no protected branches exist. Private Free repositories are unsupported.

```sh
npm run cli -- connect --repository OWNER/REPO --backend https://YOUR-WORKER
npm run cli -- connect --repository OWNER/REPO --backend https://codexbot.appsolves.workers.dev
# Or, after securely setting CODEXBOT_API_KEY in the local process:
npm run cli -- connect-api-key --repository OWNER/REPO --backend https://YOUR-WORKER
npm run cli -- connect-api-key --repository OWNER/REPO --backend https://codexbot.appsolves.workers.dev
```

ChatGPT connection checks the backend deployment gate before sign-in. Use your own eligible account/workspace; manual auth.json export is unnecessary and not supported. API keys go to GitHub through gh stdin; never the Worker. Set credentials.mode appropriately and remove the other mode's secret. API billing and ChatGPT allowance never fall back into one another.
Expand Down
Loading