Security audit fixes: docs (security.md, content.md, i18n.md, AGENT.md, skills), changelog, static-rule judgments for the merged doctor and 2FA code, hook mark for the account-rule tests
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e9f9947eb7
commit
e5964d4e05
+24
-5
@@ -344,8 +344,11 @@ blocksToMarkdown(page.layout, {
|
||||
(default true — a YAML block with `locale`, `title`, `description`, `url`, `updated`), `baseUrl`
|
||||
(gives `url:` — the canonical HTML address), `config` (i18n — with one language `url:` has no `/pl`).
|
||||
|
||||
`markdownResponse(md, { canonical? })` — `null` → 404 `text/plain`; otherwise `text/markdown`,
|
||||
`x-robots-tag: noindex`, `s-maxage=3600`, optional `Link: <…>; rel="canonical"` header.
|
||||
`markdownResponse(md, { canonical?, negotiated? })` — `null` → 404 `text/plain`; otherwise `text/markdown`,
|
||||
`x-robots-tag: noindex`, `s-maxage=3600`, optional `Link: <…>; rel="canonical"` header. `negotiated: true` (the
|
||||
answer goes out at the page's own URL, see "content negotiation" below) sends `cache-control: private, no-store` and
|
||||
`Vary: Accept` instead of the public lifetime; `createMarkdownRoute` sets it by itself when the proxy marked the
|
||||
request (`MARKDOWN_NEGOTIATED_HEADER`).
|
||||
|
||||
Shorter — the whole route in one line:
|
||||
|
||||
@@ -385,14 +388,30 @@ Without it, on a multi-language site the proxy redirects `/md/pl/o-nas` to
|
||||
`/pl/md/pl/o-nas` (it treats `md` as a path without a language), so the Markdown route does not
|
||||
work. The option lets `/md/…` paths through and does the `Accept` negotiation below.
|
||||
|
||||
**The negotiated answer is never cached as the page (1.18.0, security audit F3).** It shares the page's URL, so a
|
||||
CDN that caches HTML ("Cache Everything" on Cloudflare, Varnish) would otherwise store the Markdown and serve it to
|
||||
every visitor of that page. The proxy marks the rewritten request, the route answers `private, no-store` with
|
||||
`Vary: Accept`, the rewrite carries the same headers, and the pages under the proxy matcher get `Vary: Accept`.
|
||||
`/md/…` keeps its public caching. Cloudflare ignores `Vary` for HTML — `no-store` is what keeps it out of the cache
|
||||
there. Options: `markdown: { prefix: '/ai', negotiate: false }` — `negotiate: false` serves Markdown only at `/md/…`
|
||||
(no rewrite, no `Vary: Accept` on pages). Verify:
|
||||
`curl -sD- -o/dev/null -H 'Accept: text/markdown' https://<domain>/pl | grep -iE 'content-type|cache-control|vary'`
|
||||
→ `text/markdown`, `private, no-store`, `Vary` with `Accept`; or `pnpm exec iapl-doctor --url https://<domain> --only live-probes`
|
||||
(probe `markdown-vary`).
|
||||
|
||||
Manually (when you have your own proxy): the same URL serves Markdown on negotiation with the `Accept` header
|
||||
(a rewrite in the proxy):
|
||||
|
||||
```ts
|
||||
// proxy.ts
|
||||
import { prefersMarkdown, markdownHref } from '@intecion/ipal-kit'
|
||||
// proxy.ts — keep the answer out of shared caches: mark the request for createMarkdownRoute and say Vary: Accept
|
||||
import { appendVary, MARKDOWN_NEGOTIATED_HEADER, markdownHref, NEGOTIATED_CACHE_CONTROL, prefersMarkdown } from '@intecion/ipal-kit'
|
||||
if (prefersMarkdown(request)) {
|
||||
return NextResponse.rewrite(new URL(markdownHref(request.nextUrl.pathname), request.url))
|
||||
const headers = new Headers(request.headers)
|
||||
headers.set(MARKDOWN_NEGOTIATED_HEADER, '1')
|
||||
const res = NextResponse.rewrite(new URL(markdownHref(request.nextUrl.pathname), request.url), { request: { headers } })
|
||||
res.headers.set('cache-control', NEGOTIATED_CACHE_CONTROL)
|
||||
appendVary(res.headers, 'Accept')
|
||||
return res
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user