Merge claude/security-c-files-jobs-tests-cfba70: resolved paths in the bins and starter, proxy matcher ends at /, closed doors on the built site, every public route judged

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 20:57:50 +01:00
co-authored by Claude Opus 5.5
47 changed files with 1675 additions and 34 deletions
+48
View File
@@ -1106,6 +1106,54 @@ loosens it. **`'all'` checks nothing** — no role and no second factor: whoever
the full text, as before. The components take the same as props
(`details`, `audience`).
## Closed doors from outside (`closed-doors.spec`)
Access rules are tested from OUTSIDE, on a **production build** (`pnpm build && pnpm start`): some doors behave
differently outside production (Payload's GraphQL playground and introspection), and a bundler renames every
function (a rule told apart by its name was skipped there in 1.16.7). The test asks every door that must stay closed
as three callers and fails when one opens:
- **anonymous** — no session;
- **customer** — an account of a visitor login collection (a shop, a member zone), if the site has one;
- **editor** — a staff account with the role `editor`, signed in with the second factor.
**In a project:** copy `.agents/skills/iapl-audit/resources/closed-doors.spec.template.ts` to
`tests/closed-doors.spec.ts`, set the test accounts' variables (the file's header: `E2E_CUSTOMER_*`, `E2E_EDITOR_*`,
local or staging database only) and add the project's own doors to `DOORS`: each names who it is closed for and,
where 401 / 403 / 404 is not the whole story, what a closed answer looks like. A write door is asked with a body
that changes nothing when it is open (a document id that does not exist, `{}`): an open door then answers 404 or
400 instead of 403. Run it before every release and after every Payload / IAPL upgrade. Verify: the run lists one
test per door and caller; temporarily set a collection's `read: () => true` where a door says closed and the test
fails.
**In the plugin repository** it is `reference/e2e/closed-doors.ts` (the doors) and `closed-doors.spec.ts`, run by
`pnpm e2e:built` after a webpack and a Turbopack build; the customer is the late-staff fixture's self-signing-up
`e2e-visitors` collection, the editor `e2e/create-test-admin.ts`'s `…-editor@` account. A door that is still open
for a caller while the owner decides is listed under `openFor` and asserted OPEN (`test.fail`): the day somebody
closes it, the run says "passed unexpectedly" and the entry moves to `closedFor`.
## Routes nobody has judged (`routes:check`)
A Payload, plugin or project change can add a public route without anybody noticing (IAWL idea 34). `routes:check`
lists every door a built config opens — each REST route of every collection, global and root endpoint (Payload's
own and the plugin's), each GraphQL query and mutation, each Next route file with its methods — and compares the list
with a committed snapshot in which **every entry carries one line saying who may use it and why**. It fails on a
route that is not in the snapshot and on an entry without a reason (or one that still says `TODO`); routes that went
away are listed, not failed. The list comes from the config only, never from the database, so it is the same on
MongoDB, Postgres and SQLite.
**In a project:** copy `.agents/skills/iapl-audit/resources/routes.template.ts` to `tests/routes.ts`; `pnpm payload
run tests/routes.ts update` writes `tests/routes.snapshot.json` with an empty reason per route; write the reasons
(the reference site's `e2e/routes.snapshot.json` in the plugin repository shows the style), commit, and run
`pnpm payload run tests/routes.ts` in CI. After an upgrade: `update` again, judge the new entries, review the diff.
(`payload run` drops `--flags`, so the word is `update`.) Building blocks, for a test of your own:
`listPublicRoutes(config, { graphqlSchema, routeFiles })`, `listNextRouteFiles`, `compareRouteSnapshot`,
`updateRouteSnapshot` (`@intecion/ipal-kit`) and `runRouteCheck` (`@intecion/ipal-kit/doctor`, Node only). Verify: add
a root endpoint to the config and the check names it as "not judged".
**In the plugin repository:** `pnpm routes:check` (`--update` after a Payload upgrade) on the reference site, also
the first step of `pnpm e2e:built`; the test fixtures are switched off for it.
## Turn off, override, extend
- **Stored secrets:** `secrets: { writeOnly: false }`, `secrets: { reenterOnChange: false }`; `writeOnlySecret` /