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
22 changes: 21 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
#
# Workflow actions and the Python tooling in scripts/requirements.txt are the ecosystems tracked here.
# Workflow actions, the Python tooling in scripts/requirements.txt, and the Caddy image the unit suite adapts the Caddyfile with are the ecosystems tracked here.
# The theme is vendored rather than pulled by a manager.
# Both branches are targeted so each stays current independently of the release cadence.
version: 2
Expand Down Expand Up @@ -45,3 +45,23 @@ updates:
pip-deps:
patterns:
- "*"

- package-ecosystem: "docker"
target-branch: "main"
directory: "/checks/caddy"
schedule:
interval: "daily"
groups:
docker-deps:
patterns:
- "*"

- package-ecosystem: "docker"
target-branch: "develop"
directory: "/checks/caddy"
schedule:
interval: "daily"
groups:
docker-deps:
patterns:
- "*"
13 changes: 3 additions & 10 deletions OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Sourcing the environment file first puts the deploy root and the base URL in the

It refuses to install a release that fails the build gate. `check-live-urls.sh` does take a base URL, which is where the sourced `$SITE_BASE_URL` goes. It follows every URL in the contract against the running mirror, checking each redirect's destination rather than trusting its status code.

Expect a `PASS` naming the number of URLs honored. That is the three lists' combined length, plus the family pages where `SITE_EXTRA_BASE_URL` is set. Anything less is a finding, and the output names each URL that failed and what it answered.
Expect a `PASS` naming the number of URLs honored. That is the three lists' combined length plus one missing file that must answer `404`. Where `SITE_EXTRA_BASE_URL` is set, the family pages and a family missing file add to it. Every response must also carry the security headers in [`checks/security-headers.txt`](./checks/security-headers.txt) with their exact values. Anything less is a finding, and the output names each URL that failed and what it answered.

A documentation-only or workflow-only change does not need this. A change to the four paths above does, because for those CI's green is not evidence.

Expand Down Expand Up @@ -129,16 +129,9 @@ The deploy root and the base URL are the only host-specific values. A local run

**A VPS release is named by its deploy run, never by a commit.** The hub's deploy task names each release `<UTC yyyymmdd-HHMMSS>-<run id>-<run attempt>` and verifies the site against that id itself. To check a VPS site by hand afterwards, pass that id as `EXPECT_RELEASE`. Read it from the **Deploy site job**'s log, where `make-release.sh` prints `==> installing release <id>` with the id ending in the run's own id and attempt. The Validate sources job prints the same line earlier in the run, for a scratch bundle stamped with a bare timestamp, so the first match of a log search is the wrong id. Never copy it from the site's `X-Blog-Release` header, since a stale config still serves the previous id and the check would then pass against it. A short SHA never matches, so the check waits out its timeout and fails.

**Production's deploy checks a sample of the contract, and every other run checks all of it.** The production edge bans a client that requests more than 40 distinct pages in a burst. It also bans one when more than 10 distinct pages answer `404`, `403` or `400`. A full run from the GitHub runner therefore gets it banned. The deploy hook sets `SAMPLE_CONTRACT=1` for `production` alone, and the check then requests one URL from each class. That covers each redirect class, each shape of page that must render, each media tree, and the family pages. It also covers `/all/`, `/feed.xml`, and `/sitemap.xml`, the fixed redirect destinations no list names. The script holds that to 30 distinct pages at most, and none is expected to answer an error. Staging and the local mirrors keep the whole contract, which is where it is proven. **A hand run against the VPS production site sets `SAMPLE_CONTRACT=1` too**, for the same reason the hook does. The local production mirror sits behind no such edge and keeps the whole contract. `checks/check-live-urls.sh --print-sample` lists what a sampled run requests without requesting anything. [`deploy/README.md`](./deploy/README.md#environment-variables) carries the budget.
**Production's deploy checks a sample of the contract, and every other run checks all of it.** The production edge bans a client that requests more than 40 distinct pages in a burst. It also bans one when more than 10 distinct pages answer `404`, `403` or `400`. A full run from the GitHub runner therefore gets it banned. The deploy hook sets `SAMPLE_CONTRACT=1` for `production` alone, and the check then requests one URL from each class. That covers each redirect class, each shape of page that must render, each media tree, and the family pages. It also covers `/all/`, `/feed.xml`, and `/sitemap.xml`, the fixed redirect destinations no list names. The script holds that to 30 distinct pages at most, and none is expected to answer an error. Its `404`s are a missing `.png` on each site, which the edge counts as a static request rather than a page. Staging and the local mirrors keep the whole contract, which is where it is proven. **A hand run against the VPS production site sets `SAMPLE_CONTRACT=1` too**, for the same reason the hook does. The local production mirror sits behind no such edge and keeps the whole contract. `checks/check-live-urls.sh --print-sample` lists what a sampled run requests without requesting anything. [`deploy/README.md`](./deploy/README.md#environment-variables) carries the budget.

**A hand run counts as measured through Cloudflare only once the target answers `server: cloudflare` with a `cf-ray` header.** Right after a hostname flips to proxied, the resolver on the machine running the check can keep answering with the origin for minutes. Another resolver can already answer with Cloudflare by then. A run in that window measures the origin directly. Before the run, check every host it reaches from the same machine, the family host included, and go ahead only when each prints `proxied`:

```sh
for host in <blog-host> <family-host>; do
h=$(curl -q -sSI "https://$host/")
if printf '%s\n' "$h" | grep -qi '^server: cloudflare' && printf '%s\n' "$h" | grep -qi '^cf-ray:'; then echo "$host proxied"; else echo "$host UNCONFIRMED"; fi
done
```
**A hand run counts as measured through Cloudflare only once every host it reaches prints `<host> proxied`.** The check prints a verdict for the base host after its preflight and for the family host after its pages. It prints `proxied` only when the response carries `server: cloudflare` with a `cf-ray` header. Right after a hostname flips to proxied, the resolver on the machine running the check can keep answering with the origin for minutes. Another resolver can already answer with Cloudflare by then. A run in that window prints `<host> UNCONFIRMED`, since it reached the origin directly, so run it again once the resolver catches up.

**Always set `SITE_BASE_URL` for anything that is not production.** The base URL is baked into the canonical tag, the feed links, and every absolute permalink, so a mirror built without it serves pages that all point back at the production address. Nothing downstream catches this, because the pages render at the right paths and the build gate passes. `make-release.sh` bridges it to Hugo's own `HUGO_BASEURL` internally, and the effective value is printed on every build for that reason.

Expand Down
12 changes: 12 additions & 0 deletions checks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ wc -l checks/golden-urls.txt checks/redirect-urls.txt checks/golden-media-legacy

**The mode case is why this is not theoretical.** A hard-linked file carries its inode's mode, so a media file that acquires a bad one rides the chain into every later release, present and correctly named and unreadable to the server. A build-time `is_file()` on the runner cannot see it, and neither can a check that never requests an image.

## `security-headers.txt`, and why every response's headers are read

`security-headers.txt` holds, per site, each security header `deploy/Caddyfile` sends and its exact value. `check-live-urls.sh` reads it and asserts those headers on every response it requests. That covers the preflight, each page, redirect, followed destination, and media file, the `404` probes, and each family page. A header that goes missing or loses strength fails the run, where a presence check would pass a shortened HSTS lifetime or a loosened policy.

**One request per site is added, a missing `.png` under `/media/`.** Each site answers its `404` from its own `handle_errors` block rather than from the route other requests take, so each is checked. The probes are static files, so they stay out of the sampled run's page budget.

**The values live once here, and a unit case holds them to the Caddyfile.** `checks/tests/test_check_live_urls_sample.py` reads the Caddyfile through `caddy adapt`, so Caddy's own parser decides what each directive covers. It compares every header a site sets on all its responses with this file, in both directions. The cache headers and the site's own markers are left out. It also fails on a security header that reaches fewer responses than all of them. A matcher, a status requirement, an error route, a deletion, or a handler answering first each narrows one.

**That case needs Docker.** It builds the image [`caddy/Dockerfile`][caddy-dockerfile] pins and runs it with networking off. That works the same on a GitHub runner and on a workstation with no Caddy installed. Dependabot moves the pin. See [`deploy/README.md`][deploy-readme-security-headers] for why each value is what it is.

## Directionality

The parity check fails on a **missing** URL and only notes an **extra** one. New posts, new tags, and deeper pagination legitimately add URLs, and nothing legitimately removes a URL the site has served. That asymmetry is what makes the lists append-only, which in turn is what makes the length-floor assertion in `check-live-urls.sh` sound: without it a truncated list would make every assertion below it pass vacuously.
Expand Down Expand Up @@ -175,6 +185,7 @@ Three traps in that adjudication, each of which produced a wrong answer first an
<!-- Repo -->

[capture-build-redirects]: ../capture/build-redirects.py
[caddy-dockerfile]: ./caddy/Dockerfile
[capture-readme]: ../capture/README.md
[check-env-docs]: ./check-env-docs.py
[check-github-env]: ./check-github-env.py
Expand All @@ -184,4 +195,5 @@ Three traps in that adjudication, each of which produced a wrong answer first an
[check-text-pii]: ./check-text-pii.py
[check-url-parity]: ./check-url-parity.py
[deploy-readme-redirects]: ../deploy/README.md#how-the-redirects-are-expressed
[deploy-readme-security-headers]: ../deploy/README.md#security-headers
[fuzz-media-parsers]: ./fuzz-media-parsers.py
1 change: 1 addition & 0 deletions checks/caddy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM caddy:2.11.7@sha256:504a44d7d74bd2bc28a66afc4774912fc21223ca8a67734af1c54ab2f999b489
Loading
Loading