Merge remote-tracking branch 'origin/master' into fix/runner-paid-matrix-integrity

* origin/master:
  ci(runner): prepare target lockfile once for paid validation (#12774)
  chore(deps): bump paperclipai/paperclip/.github/workflows/pr-trusted.yml from 39b8ee2960 to f038633bf5 (#12562)
  chore(deps): bump sharp from 0.35.3 to 0.35.4 (#12563)
  chore(deps): bump @mdxeditor/editor from 4.2.1 to 4.2.3 (#12564)
  fix(server): stop paging Sentry for supervised boot races in managed cloud (#12772)
  Secure Cloud canonical runtime identity (#12766)

# Conflicts:
#	.github/workflows/runner-full-stack-e2e.yml
#	tests/runner-e2e/README.md
#	tests/runner-e2e/SECURITY.md
#	tests/runner-e2e/workflow-security.test.ts
This commit is contained in:
Dotta committed 2026-09-03 12:42:04 -05:00
commit 9e5f0e60fa
25 files changed
+1594 -211

No files matched your search

+15 -6
View File
@@ -274,12 +274,21 @@ auto-stop/archive/delete values remain as cancellation backstops.
never runs for a pull request or ordinary push. Start the trusted workflow from
the default branch. A CODEOWNER can set the optional `target_branch` input to
any branch in `paperclipai/paperclip`. The authorization job resolves that
branch to one immutable commit before any checkout. Catalog, image, and paid
test jobs check out that exact commit. Report sanitization and AWS history
publication explicitly check out the trusted workflow commit. The workflow
definition, runner-group permission, and protected-environment deployment still
come from the default branch. Do not select the target branch in GitHub's **Use
workflow from** control.
branch to one immutable commit before any checkout. A separate credential-free
job checks out the resolved commit and regenerates `pnpm-lock.yaml` once with
`--ignore-scripts --no-frozen-lockfile --lockfile-only`. It uploads that exact
lockfile under a run-attempt-scoped artifact ID and records its SHA-256.
Catalog, image, shared-build, provider-pack, and paid test jobs download the
artifact by ID, verify its digest, and restore it before setup or a frozen
install. The paid test job disables dependency lifecycle scripts, and provider
secrets are introduced only in the final test step. This permits an authorized
target branch to exercise an intentionally uncommitted workspace patch while
keeping every target job on one identical dependency resolution. Report
sanitization and AWS history publication do not consume the target lockfile;
they explicitly check out and install from the trusted workflow commit. The
workflow definition, runner-group permission, and protected-environment
deployment still come from the default branch. Do not select the target branch
in GitHub's **Use workflow from** control.
Because this repository is public, manual campaigns fail before checkout unless
the trusted workflow runs from the default branch and both the original actor
+15 -6
View File
@@ -20,10 +20,19 @@ gh api users/LOGIN --jq '{login,id}'
The paid workflows reject manual dispatches when the workflow definition does
not come from the default branch. A trusted dispatcher may name any branch in
`paperclipai/paperclip` as the code under test. The authorization job resolves
that branch through the GitHub API and passes only its immutable commit SHA to
the catalog, image, and paid test checkouts. Report sanitization and AWS history
publication explicitly use the trusted workflow commit. Never run the workflow
definition from the target branch.
that branch through the GitHub API and passes only its immutable commit SHA to a
credential-free target-lock job. That job checks out the commit, regenerates
`pnpm-lock.yaml` once with lifecycle scripts disabled and lockfile-only mode,
then uploads the file under a run-attempt-scoped artifact ID. Catalog, image,
shared-build, provider-pack, and paid test jobs download that exact artifact by
ID, verify its recorded SHA-256, and restore it before setup or a frozen
dependency install. The lock resolver receives no provider credentials and
must never run repository lifecycle scripts. The paid test job also installs
with lifecycle scripts disabled, and provider secrets are scoped only to its
final test step rather than dependency setup. Report sanitization and AWS
history publication explicitly use the trusted workflow commit and do not
consume the target lockfile. Never run the workflow definition from the target
branch.
The workflows verify both the original actor and triggering actor for every
scheduled or manual attempt, including human reruns. Every
@@ -56,8 +65,8 @@ only `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `OPENROUTER_API_KEY`, and
organization-level Actions secrets: environment scoping is the boundary that
prevents branch or pull-request jobs from requesting them. Require approval
from an account in `RUNNER_E2E_ALLOWED_ACTOR_IDS` for this environment and
disable administrator bypass. The authorize,
catalog, image, report, history, and Pages jobs receive none of these secrets.
disable administrator bypass. The authorize, target-lock, catalog, image,
report, history, and Pages jobs receive none of these secrets.
Each full-stack matrix cell receives only its selected profile credential, plus
Daytona only for Daytona cells. Secret-bearing and OIDC jobs use frozen installs
without a shared dependency cache.
+98 -8
View File
@@ -4,7 +4,11 @@ import { describe, expect, it } from "vitest";
const repositoryRoot = path.resolve(import.meta.dirname, "../..");
const fullStackTestNeeds =
/needs:\s*\[\s*authorize,\s*catalog,\s*daytona_image,\s*build_runner_artifacts,\s*build_remote_provider_pack,?\s*\]/u;
/needs:\s*\[\s*authorize,\s*target_lock,\s*catalog,\s*daytona_image,\s*build_runner_artifacts,\s*build_remote_provider_pack,?\s*\]/u;
const buildRunnerNeeds =
/needs:\s*\[\s*authorize,\s*target_lock,\s*catalog,?\s*\]/u;
const buildRemoteProviderPackNeeds =
/needs:\s*\[\s*authorize,\s*target_lock,\s*catalog,\s*daytona_image,\s*build_runner_artifacts,?\s*\]/u;
describe("public repository paid workflow security", () => {
it("gates every provider-secret job with stable actor IDs", async () => {
@@ -68,6 +72,10 @@ describe("public repository paid workflow security", () => {
);
const authorizeJob = fullStack.slice(
fullStack.indexOf(" authorize:"),
fullStack.indexOf(" target_lock:"),
);
const targetLockJob = fullStack.slice(
fullStack.indexOf(" target_lock:"),
fullStack.indexOf(" catalog:"),
);
expect(authorizeJob).toContain(
@@ -84,13 +92,44 @@ describe("public repository paid workflow security", () => {
"repos/$REPOSITORY/branches/$encoded_branch",
);
expect(authorizeJob).toContain('echo "sha=$target_sha"');
expect(authorizeJob).not.toContain("actions/checkout@");
expect(authorizeJob).not.toContain("pnpm install");
expect(targetLockJob).toContain("name: Resolve target pnpm lockfile");
expect(targetLockJob).toContain("needs: authorize");
expect(targetLockJob).toContain(
"ref: ${{ needs.authorize.outputs.target_sha }}",
);
expect(targetLockJob).toContain("persist-credentials: false");
expect(targetLockJob).toContain(
"pnpm install --ignore-scripts --no-frozen-lockfile --lockfile-only",
);
expect(targetLockJob).toContain(
"artifact_id: ${{ steps.upload.outputs.artifact-id }}",
);
expect(targetLockJob).toContain("lock_sha256:");
expect(targetLockJob).toContain(
"runner-e2e-target-pnpm-lock-${{ github.run_id }}-${{ github.run_attempt }}",
);
expect(targetLockJob).not.toContain("name: runner-e2e-paid");
expect(targetLockJob).not.toMatch(
/(?:OPENAI|ANTHROPIC|OPENROUTER|DAYTONA)_API_KEY/,
);
expect(paidJob).toContain(
"runs-on: ${{ needs.authorize.outputs.test_runner }}",
);
expect(paidJob).toMatch(fullStackTestNeeds);
expect(paidJob).toContain("name: runner-e2e-paid");
expect(paidJob).toMatch(
/Reauthorize paid execution before provider access[\s\S]*actions\/checkout@[0-9a-f]{40}[\s\S]*persist-credentials: false/,
/Reauthorize paid execution before provider access[\s\S]*actions\/checkout@[0-9a-f]{40}[\s\S]*persist-credentials: false[\s\S]*Download resolved target lockfile/,
);
const paidInstall = paidJob.indexOf(
"pnpm install --frozen-lockfile --ignore-scripts",
);
const paidExecution = paidJob.indexOf("- name: Run paid cell");
expect(paidInstall).toBeGreaterThan(0);
expect(paidExecution).toBeGreaterThan(paidInstall);
expect(paidJob.slice(0, paidExecution)).not.toMatch(
/secrets\.(?:OPENAI|ANTHROPIC|OPENROUTER|DAYTONA)_API_KEY/,
);
expect(authorizeJob).toContain('echo "max_parallel_limit=100"');
expect(fullStack).toContain('[ "$MAX_PARALLEL_LIMIT" -gt 100 ]');
@@ -103,13 +142,64 @@ describe("public repository paid workflow security", () => {
expect(fullStack).toContain(
"cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' && inputs.target_branch != '' && inputs.target_branch != github.event.repository.default_branch }}",
);
const targetCodeJobs = [
fullStack.slice(
fullStack.indexOf(" catalog:"),
fullStack.indexOf(" daytona_image:"),
),
fullStack.slice(
fullStack.indexOf(" daytona_image:"),
fullStack.indexOf(" build_runner_artifacts:"),
),
fullStack.slice(
fullStack.indexOf(" build_runner_artifacts:"),
fullStack.indexOf(" build_remote_provider_pack:"),
),
fullStack.slice(
fullStack.indexOf(" build_remote_provider_pack:"),
fullStack.indexOf(" test:"),
),
paidJob,
];
for (const targetCodeJob of targetCodeJobs) {
const checkout = targetCodeJob.indexOf("actions/checkout@");
const downloadLock = targetCodeJob.indexOf(
"Download resolved target lockfile",
);
const restoreLock = targetCodeJob.indexOf(
"Restore resolved target lockfile",
);
const setupNode = targetCodeJob.indexOf("actions/setup-node@");
const install = targetCodeJob.indexOf("pnpm install --frozen-lockfile");
expect(checkout).toBeGreaterThan(0);
expect(downloadLock).toBeGreaterThan(checkout);
expect(restoreLock).toBeGreaterThan(downloadLock);
if (setupNode >= 0) {
expect(setupNode).toBeGreaterThan(restoreLock);
}
if (install >= 0) {
expect(install).toBeGreaterThan(restoreLock);
}
expect(targetCodeJob).toContain(
"artifact-ids: ${{ needs.target_lock.outputs.artifact_id }}",
);
expect(targetCodeJob).toContain(
"EXPECTED_LOCK_SHA256: ${{ needs.target_lock.outputs.lock_sha256 }}",
);
}
expect(fullStack.match(/Download resolved target lockfile/g)).toHaveLength(
5,
);
expect(fullStack.match(/Restore resolved target lockfile/g)).toHaveLength(
5,
);
expect(
fullStack.match(
/ref: \$\{\{ needs\.authorize\.outputs\.target_sha \}\}/g,
),
).toHaveLength(5);
).toHaveLength(6);
expect(fullStack.match(/ref: \$\{\{ github\.sha \}\}/g)).toHaveLength(2);
expect(fullStack.match(/persist-credentials: false/g)).toHaveLength(7);
expect(fullStack.match(/persist-credentials: false/g)).toHaveLength(8);
expect(fullStack).not.toContain("ref: ${{ inputs.target_branch }}");
expect(fullStack).toContain(
"PAPERCLIP_RUNNER_SOURCE_REVISION=${TARGET_SHA}",
@@ -123,10 +213,12 @@ describe("public repository paid workflow security", () => {
expect(reportJob).not.toContain(
"ref: ${{ needs.authorize.outputs.target_sha }}",
);
expect(reportJob).not.toContain("Download resolved target lockfile");
expect(historyJob).toContain("ref: ${{ github.sha }}");
expect(historyJob).not.toContain(
"ref: ${{ needs.authorize.outputs.target_sha }}",
);
expect(historyJob).not.toContain("Download resolved target lockfile");
expect(fullStack).toContain(
"if: always() && !cancelled() && needs.catalog.result == 'success'",
);
@@ -201,10 +293,8 @@ describe("public repository paid workflow security", () => {
expect(buildJobStart).toBeGreaterThan(0);
expect(testJobStart).toBeGreaterThan(buildJobStart);
expect(buildJob).toContain("needs: [authorize, catalog]");
expect(buildJob).toContain(
"needs: [authorize, catalog, daytona_image, build_runner_artifacts]",
);
expect(buildJob).toMatch(buildRunnerNeeds);
expect(buildJob).toMatch(buildRemoteProviderPackNeeds);
expect(buildJob).not.toContain("environment:");
expect(buildJob).not.toContain("secrets.");
expect(buildJob).toContain(