Reference
Local development
Run both Workers locally, with the review sandbox in Docker, and smoke-test the scanners and agents.
Reference
Run both Workers locally, with the review sandbox in Docker, and smoke-test the scanners and agents.
You can run the whole stack on your machine: the web Worker under Vite, the engine under wrangler dev, and the review sandbox as a local Docker container. Both Workers share one local D1 database and R2 bucket, so a run created by the web Worker is visible to the engine.
wrangler dev builds the sandbox image from engine/container/Dockerfile on first start.openssl to generate keys.cloudflared so GitHub can reach your machine. You do not need either to try the scanners and agents through the /__dev routes.pnpm install
cp web/.dev.vars.example web/.dev.vars
cp engine/.dev.vars.example engine/.dev.varsBoth .dev.vars files are gitignored. Fill them in:
CREDENTIALS_KEY: generate one value with openssl rand -base64 32 and put the same value in both files.WORKOS_CLIENT_ID and WORKOS_API_KEY in web/.dev.vars: the client ID and API key of your WorkOS staging environment. Without them, the dashboard cannot sign you in.WORKOS_AUTHKIT_DOMAIN in web/.dev.vars: the staging environment's AuthKit domain, only if you want to try the MCP server.VITE_APP_URL in web/.dev.vars: keep http://localhost:3000.APP_URL in engine/.dev.vars: keep http://localhost:3000.GITHUB_* values: from your development App. Leave them empty if you only want the dashboard and the /__dev routes.Values in .dev.vars override the vars in wrangler.jsonc during local development.
In the WorkOS staging environment, add http://localhost:3000/api/auth/callback as a redirect URI and http://localhost:3000/ as the default Sign-out URI. See Configuration for the other AuthKit settings.
pnpm db:migrate:localThis applies every migration in packages/db/migrations to the local D1 database in web/.wrangler/state. The engine's dev script runs wrangler dev --persist-to ../web/.wrangler/state, so both Workers use the same local D1 and R2 state. To start from an empty database, stop both Workers, delete web/.wrangler/state and run the command again.
Start the engine in one terminal:
pnpm dev:engineIt listens on http://localhost:8787. The first start builds the container image, which takes several minutes.
Start the web Worker in another:
pnpm dev:webIt listens on http://localhost:3000. The port is pinned in web/vite.config.ts so the sign-in redirect URI, http://localhost:3000/api/auth/callback, matches the one registered in WorkOS. In development the redirect URIs use the browser's origin, so open the app at exactly that address. The web Worker's ENGINE service binding connects to the locally running engine.
The dashboard works without the engine, but starting a review needs it.
Register a separate GitHub App for development, following Register a GitHub App, with these URLs:
| Setting | Value |
|---|---|
| Callback URL | http://localhost:3000/api/github/link/callback |
| Setup URL | http://localhost:3000/api/github/setup |
| Webhook URL | https://<your-tunnel-host>/api/github/webhook |
Expose port 3000 with a tunnel:
cloudflared tunnel --url http://localhost:3000Set the App's webhook URL to the printed hostname plus /api/github/webhook. A quick tunnel gets a new hostname each time it starts, so update the App when you restart it. Keep using http://localhost:3000 in the browser: sign-in and the setup redirect stay on localhost, and only webhooks go through the tunnel.
Put the development App's ID, slug, private key, webhook secret and OAuth credentials in web/.dev.vars, and its ID and private key in engine/.dev.vars.
/__dev routesThe engine has routes for exercising the sandbox, the egress proxy, the scanners and the agents without GitHub or a D1 run. They are mounted only when DEV_ROUTES is true. Start the engine with the variable set:
pnpm --filter openvscan-engine exec wrangler dev --persist-to ../web/.wrangler/state --var DEV_ROUTES:trueYou can also add DEV_ROUTES=true to engine/.dev.vars.
curl -X POST localhost:8787/__dev/scan -d '{"repo":"OWASP/NodeGoat"}'This boots a sandbox, checks that a request to https://example.com is refused, clones the public repository through the egress proxy, checks that fetching a different repository is refused, then runs every scanner. The JSON response reports:
egressBlockedStatus: the result of the blocked request.clone: the clone's exit code and stderr.otherRepoBlocked: the result of fetching another repository.results: per scanner, the exit code, number of findings, counts by severity, a few sample findings and the time taken.repo defaults to OWASP/NodeGoat. The route clones without a token, so use a public repository.
curl -X POST localhost:8787/__dev/agent \
-d '{"kind":"anthropic_api_key","secret":"sk-ant-..."}'This starts Claude Code, Codex or Cursor in the sandbox with a one-line prompt and the real credential held by the egress proxy, then waits for it to exit. The response includes the task state, the review.json the agent wrote, a parsed failure reason if it failed, and the tail of its output.
| Field | Values |
|---|---|
kind | claude_oauth_token or anthropic_api_key (Claude Code), openai_api_key, codex_access_token or codex_chatgpt_login (Codex; secret is the whole auth.json, and it isn't refreshed), or cursor_api_key (Cursor; pass accessToken instead of secret to skip the key exchange). Defaults to anthropic_api_key. |
secret | The credential to test. |
model | Optional model name passed to the agent. |
Both routes reuse a sandbox named dev-smoke. Pass "id" in the body to use a different one. Destroy it when you are done:
curl -X POST localhost:8787/__dev/destroy| Command | What it runs |
|---|---|
pnpm typecheck | TypeScript across every package |
pnpm test | Engine unit tests with Vitest: scanner parsers, diff mapping, report and crypto |
pnpm lint | Biome on web/ |
pnpm build | The web Worker's Vite build and type check |
To apply Biome's fixes:
pnpm --filter openvscan-web exec biome check --write .After editing the Drizzle schema in packages/db/src/schema, generate a migration and apply it locally:
pnpm db:generate
pnpm db:migrate:localCommit the generated SQL file and the updated packages/db/migrations/meta files together.
After changing bindings in a wrangler.jsonc, regenerate that Worker's types:
pnpm --filter openvscan-engine run cf-typegen
pnpm --filter openvscan-web run cf-typegen