IAWL ideas, group B: sizes before work, one link rule, no stand-in locale, strict switches

- Request bodies from strangers are read only up to a cap, declared length or not:
  mail-service confirm, CSP reports, page views, MCP (maxBytes, 413). readCappedBody moves
  to shared/ (the consent log keeps exporting it).
- searchContent / createSearchRoute / MCP search: queryLimit (default 200 characters,
  10 words) before the database; an unknown ?locale is the default locale throughout.
- Rich text: autolinks and links marked internal pass safeHref too; lexicalToMarkdown
  drops unsafe link targets.
- truncate() never returns more than its limit (summary / meta autofill after validation).
- resolveRoute answers null for a locale the site does not have (xx, all, *): no
  default-locale page under another code (page route past the proxy, /md/xx, MCP).
- A 404 page that is a draft is not shown (resolveNotFoundPage, getNotFoundPage).
- readPublished() access rule (exported); Site integrations readVersions: admin.
- Plugin switches, buildCsp, buildSecurityHeaders and the seed guard refuse nonsense
  values at start; an unknown role name is met by nobody, requireRole throws on one.
- Docs, AGENT.md, iapl-collection and iapl-audit skills.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 20:25:26 +01:00
co-authored by Claude Opus 5.5
parent e821d52d19
commit ecf03c8dc0
38 changed files with 914 additions and 69 deletions
+12 -2
View File
@@ -89,6 +89,11 @@ Without `draft: true`, documents with a `_status` other than `published` (page,
entry) give `null`. The page assigned as 404 in System pages also gives `null`
(a real 404 instead of a soft 404).
**A locale the site does not have gives `null` (1.17.1).** `xx`, `all` or `*` — from a URL that went past the
proxy (a dotted path, the Markdown route `/md/xx`) or a caller — used to resolve the default locale's page under that
code; now it is "not found". `isSiteLocale(payload, locale)` is the same check for your own code. A site without
localization is not affected.
Logic: the first segment is matched against the slugs of the archive pages from System
Pages. A match → we know which collection it is about. `['artykuly']` → listing of
`posts`; `['artykuly','moj-post']` → an entry in `posts`; no match → a regular
@@ -391,7 +396,8 @@ Query: `?q=` (required), `?locale=`, `?limit=`. Response:
"results": [{ "title": "O nas", "url": "https://x/pl/o-nas", "description": "…", "slug": "o-nas" }] }
```
No `q` → 400. Published only, without `noindex` (`noindex` or `meta.noindex`) and without the page assigned as the
No `q` → 400. An unknown `?locale=` is the default locale — in the search, the under-construction check and the
answer alike (1.17.1). Published only, without `noindex` (`noindex` or `meta.noindex`) and without the page assigned as the
404 page (Site settings → System pages, read through `settingsSlug`, default `site-settings`),
10 by default (`defaultLimit`), max 50 results. Under-construction mode:
pass `isPathVisible` from `createContentHelpers`, and hidden pages drop out of the results. Error/database
@@ -411,12 +417,16 @@ const results = await searchContent({ payload, query, config, locale, limit, bas
`searchContent` options: `collection` (`'pages'`), `baseUrl`, `homeSlug`, `settingsSlug` (`'site-settings'`, for the 404 page), `locale`
(default/invalid → `defaultLocale`), `limit` (10, clamped to 1–50),
`queryLimit` (1.17.1; default `{ length: 200, words: 10 }` — `SEARCH_QUERY_LIMIT`): how much of the query reaches
the database. Each word is one more `LIKE` on two columns and the text comes from a stranger, so a longer query is
cut to its first words (`limitQuery(query, queryLimit)` shows the result); `false` = the whole query, as before.
`summaryField` (e.g. `'aiSummary'` — prefers the richer description from
`buildSummaryField` over `meta.description`; see [seo.md](./seo.md)). Never throws
(error → `[]`).
`createSearchRoute` additionally takes `getCachedPayload`, `config` (required),
`defaultLimit` (10), `rateLimit`, `clientIp` (see `clientIp()` in security.md), `isPathVisible`.
`defaultLimit` (10), `rateLimit`, `clientIp` (see `clientIp()` in security.md), `isPathVisible`, `queryLimit`
(passed to `searchContent`; the MCP `search_content` tool uses the default).
`listContent({ payload, config, locale, limit, … })` — the same results without a query:
all published, indexable pages by title (`limit` 50, max 200). A list