Skip to content
Draft
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
6 changes: 4 additions & 2 deletions .github/scripts/pr-guard.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node
// pr-guard: the security gate for pull requests into main (.github/workflows/pr-guard.yml).
//
Expand Down Expand Up @@ -37,7 +37,7 @@
export const RULES = {
"contract-locked": { tier: "block", title: "Deployed contract files changed", help: "These files are pinned in contracts/deployed.lock, or stand guard over it (the lock itself, the scripts that check it, .gitmodules, everything under contracts/lib/), and stay byte-identical to what is live. A change for another chain goes in a new copied file (see contracts/src/LaunchFactoryArc.sol)." },
"ci-config": { tier: "block", title: "CI, the guard or code owners changed", help: "Workflow and guard changes come from the maintainers, in a pull request of their own." },
"release-tooling": { tier: "block", title: "Release and deploy tooling", help: "The deploy and smoke scripts run on a maintainer's machine with the deploy credentials; the migration and its helpers run against the production database on every deploy; the Dockerfile, .dockerignore and fly.toml decide what is built and what runs at release; release-please-config.json decides how releases are cut. They change only in a pull request of their own, which a maintainer merges with the guard bypassed." },
"release-tooling": { tier: "block", title: "Release and deploy tooling", help: "These paths include scripts that use deployment credentials or broadcast contract deployments, SQL that is applied during releases or production repairs, and configuration that controls builds and releases. They change only in a dedicated maintainer pull request." },
"dev-machine": { tier: "block", title: "Editor, agent or git hook configuration", help: "These files can run commands or steer an AI agent on a maintainer's machine the moment the branch is checked out. The repository tracks none of them." },
"registry-config": { tier: "block", title: "Package manager configuration", help: "A registry, proxy or script setting here redirects every install." },
"secret-file": { tier: "block", title: "A file that holds keys or wallet material", help: "Environment files, key files and wallet files are never committed. If this was real, rotate it now: the branch is public." },
Expand Down Expand Up @@ -78,7 +78,9 @@

const BLOCK_PATHS = [
["ci-config", /^\.github\/|^(docs\/)?CODEOWNERS$/i],
["release-tooling", /^app\/scripts\/(deploy\.sh|smoke\.sh|migrate\.mjs)$|^app\/scripts\/lib\/|^app\/(Dockerfile|\.dockerignore|fly\.toml)$|^release-please-config\.json$/i],
["release-tooling", /^app\/scripts\/(deploy\.sh|smoke\.sh|fly-secrets\.sh|migrate\.mjs|usd-backfill\.ts|rebuild-[^/]+\.sql)$|^app\/scripts\/lib\//i],
["release-tooling", /^app\/db\/.+\.sql$|^contracts\/script\/DeployLaunchFactory\.s\.sol$/i],
["release-tooling", /^app\/(Dockerfile|\.dockerignore|fly\.toml)$|^release-please-config\.json$/i],
["dev-machine", /(^|\/)\.(claude|cursor|codex|gemini|qwen|windsurf|continue|aider[^/]*|clinerules|roo|kiro|zed|fleet|junie|amazonq|augment|trae|opencode|goose|vscode|idea|devcontainer|husky|githooks)(\/|$)|(^|\/)(CLAUDE|AGENTS|GEMINI|QWEN)(\.[^/]*)?\.md$|(^|\/)(\.cursorrules|\.clinerules|\.windsurfrules|\.goosehints|\.mcp\.json|opencode\.jsonc?|\.devcontainer\.json|[^/]*\.code-workspace|\.envrc|\.huskyrc(\.[^/]*)?|\.lintstagedrc(\.[^/]*)?|\.pre-commit-config\.ya?ml|\.?lefthook\.ya?ml|\.?mise(\.[^/]*)?\.toml)$/i],
["registry-config", /(^|\/)(\.npmrc|\.yarnrc(\.yml)?|\.pnpmfile\.cjs|pnpm-workspace\.yaml|bunfig\.toml)$/i],
];
Expand Down
25 changes: 21 additions & 4 deletions .github/scripts/pr-guard.test.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Tests for pr-guard.mjs. Each case builds a small git repository shaped like this one, makes the change a pull request
// would make, and asks the guard what it sees. node --test .github/scripts/pr-guard.test.mjs
//
Expand Down Expand Up @@ -293,9 +293,26 @@
}
});

test("other scripts and the schema stay owner-reviewed, not blocked", () => {
test("production SQL and credentialed deployment paths stay blocked on owner-authored pushes", () => {
const paths = [
"app/db/schema.sql",
"app/db/concurrent-indexes.sql",
"app/db/migrations/add-index.sql",
"app/scripts/fly-secrets.sh",
"app/scripts/rebuild-holders.sql",
"app/scripts/rebuild-launch-totals.sql",
"app/scripts/usd-backfill.ts",
"contracts/script/DeployLaunchFactory.s.sol",
];
const found = check(Object.fromEntries(paths.map((path) => [path, "\n"])));
assert.deepEqual(of(found, "release-tooling").map((finding) => finding.path).sort(), paths.sort());
assert.equal(verdict(found, { author: OWNERS[0], pusher: OWNERS[0] }).outcome, "block");
assert.equal(details(check({ "app/db/schema.sql": null }), "release-tooling"), "deleted");
});

test("other scripts and routine release metadata are outside the release-tooling block", () => {
// the manifest and the changelog change in every release pull request: blocking them would block every release
for (const path of ["app/scripts/fix.mjs", "app/scripts/usd-backfill.ts", "app/db/schema.sql", "app/db/concurrent-indexes.sql", "app/fly.staging.toml", "app/scripts/deploy.sh.bak", ".release-please-manifest.json", "app/CHANGELOG.md", "app/scripts/release-notes.mjs"]) {
for (const path of ["app/scripts/fix.mjs", "app/scripts/e2e-edit-fix.mjs", "app/db/README.md", "app/fly.staging.toml", "app/scripts/deploy.sh.bak", ".release-please-manifest.json", "app/CHANGELOG.md", "app/scripts/release-notes.mjs"]) {
assert.ok(!rules(check({ [path]: "x\n" })).includes("release-tooling"), path);
}
});
Expand Down Expand Up @@ -972,11 +989,11 @@
assert.deepEqual(rules(check({ "app/src/lib/obf.js": "var _0x4f2a=['log'];\n" })), ["opaque"]);
});

test("security headers, deploy files, migrations and policy files need an owner", () => {
test("security headers, release tooling and policy files use their respective tiers", () => {
assert.deepEqual(rules(check({ "app/src/lib/security-headers.ts": "export const csp = \"default-src *\";\n" })), ["security-config"]);
// the Dockerfile is release tooling: blocked, which takes the place of the review finding
assert.deepEqual(rules(check({ "app/Dockerfile": "FROM node:22-slim\nRUN true\n" })), ["release-tooling"]);
assert.deepEqual(rules(check({ "app/db/schema.sql": "drop table launches;\n" })), ["build-deploy"]);
assert.deepEqual(rules(check({ "app/db/schema.sql": "-- migration\n" })), ["release-tooling"]);
assert.deepEqual(rules(check({ "app/scripts/fix.mjs": "console.log(1);\n" })), ["build-deploy"]);
assert.deepEqual(rules(check({ "SECURITY.md": "Report to help@elsewhere.example.com\n" })), ["policy"]);
assert.deepEqual(rules(check({ ".gitattributes": "*.sol linguist-vendored\n" })), ["git-config"]);
Expand Down
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ your code. It has two answers besides "passed":
(`contracts/script/check-deployed-sources.sh`, `contracts/script/check-arc-factory.sh`), to `.gitmodules`, or
anything added under `contracts/lib/`.
- `ci-config`: anything under `.github/`, or a `CODEOWNERS` file.
- `release-tooling`: the release and deploy tooling: `app/scripts/deploy.sh`, `smoke.sh`, `migrate.mjs` and anything
under `app/scripts/lib/`, `app/Dockerfile`, `app/.dockerignore`, `app/fly.toml`, and `release-please-config.json`.
These run with the deploy credentials or against the production database, or decide how releases are cut, so a
maintainer changes them in a pull request of their own.
- `release-tooling`: `app/scripts/deploy.sh`, `smoke.sh`, `fly-secrets.sh`, `migrate.mjs`, `usd-backfill.ts`,
`rebuild-*.sql`, and files under `app/scripts/lib/`; SQL under `app/db/`;
`contracts/script/DeployLaunchFactory.s.sol`; and `app/Dockerfile`, `app/.dockerignore`, `app/fly.toml`, and
`release-please-config.json`. These paths control releases, use deployment credentials, or supply SQL for
production migrations and repairs. Changes require a dedicated maintainer pull request.
- `dev-machine`: editor, agent or git hook configuration (`.vscode/`, `.claude/`, `AGENTS.md`, `.envrc` and the like).
- `registry-config`: package manager configuration (`.npmrc` and the like).
- `secret-file`, `secret`: a key, wallet or `.env` file, or a credential anywhere in the diff.
Expand Down
Loading