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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ A clean review can retain settled `disputed` findings in its ledger so later
rounds remember the rebuttals. Profile receipt validation rejects open findings;
retained settled findings do not block proof or authorize unresolved GitHub threads.

The final CI race check blocks matching active reviews and reviews completing at
or after proof starts. Older completed branch-workflow audits do not invalidate
a newer trusted-main proof; the review used for authorization must still pass
all current caller, pin, receipt, and proof checks.

### Baseline panels

| Profile | Standard (auto) | Deep (maintainer dispatch) |
Expand Down
13 changes: 7 additions & 6 deletions scripts/profile_consumer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ async function reviewRaceBlocksAuthorization(
context,
{ pullNumber, headSha, createdAt, proofStartedAt, currentReviewRun },
) {
const { owner, repo, repository, defaultBranch, reviewPin, trustedCallerSha } = context;
const { owner, repo } = context;
if (currentReviewRun.status !== 'completed') {
throw new Error('current review run is not completed');
}
Expand All @@ -594,11 +594,12 @@ async function reviewRaceBlocksAuthorization(
if (!runMatchesPull(run, pullNumber, headSha)) {
continue;
}
try {
await verifyReviewRunProvenance(github, context, run);
} catch {
throw new Error('matching review run has untrusted provenance');
}
// This scan only invalidates proof; it never authorizes a review. The
// authoritative review and completed proof have already passed provenance.
// Older branch-caller audits are expected during a workflow-pin migration;
// they are not races once they finish before that trusted proof starts.
// Any matching active or later-completing run still blocks authorization,
// including runs that would fail provenance themselves.
if (run.status !== 'completed') {
throw new Error('a newer matching review run is still active');
}
Expand Down
37 changes: 37 additions & 0 deletions tests/profile-consumer.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,43 @@ describe('authorizeProfileReceipt', () => {
assert.equal(result.authorized, true);
});

it('allows an older branch-caller audit before a newer trusted profile proof', async () => {
const { github, store } = buildStore({
reviewRuns: [
reviewRun(),
reviewRun({ id: 101, referenced_workflows: [], updated_at: '2024-01-02T09:55:00Z' }),
],
});
const result = await authorizeProfileReceipt(github, authorizeContext(store));
assert.equal(result.authorized, true);
});

for (const status of ['queued', 'in_progress', 'waiting', 'pending', 'requested']) {
it(`blocks a matching untrusted ${status} run even when it predates the proof`, async () => {
const { github, store } = buildStore({
reviewRuns: [reviewRun(), reviewRun({
id: 101, status, conclusion: null, referenced_workflows: [],
updated_at: '2024-01-02T09:55:00Z',
})],
});
const result = await authorizeProfileReceipt(github, authorizeContext(store));
assert.equal(result.authorized, false);
assert.match(result.reason, /still active/i);
});
}

for (const updatedAt of [PROOF_STARTED, '2024-01-02T10:01:00Z', 'invalid']) {
it(`blocks a matching untrusted completion at ${updatedAt}`, async () => {
const { github, store } = buildStore({
reviewRuns: [reviewRun(), reviewRun({
id: 101, referenced_workflows: [], updated_at: updatedAt,
})],
});
const result = await authorizeProfileReceipt(github, authorizeContext(store));
assert.equal(result.authorized, false);
});
}

it('does not attribute a workflow_dispatch on main via empty pull_requests', async () => {
const { github, store } = buildStore({
reviewRuns: [
Expand Down