Repository navigation
test(docs): fail a citation pin the page stopped citing, reject :0 and ../ (#1265) - #1277
Conversation
|
PR #1277 — field Red was re-taken on the new default branch: No |
|
New tip The hole. The guard claimed to require the path to stay inside the checkout, but Red at The new test cites Green at Pushed as two new commits on top, no force, no rebase, base still |
|
Read at The two reds are the real test-first commits, not a whole-file swap.
Each check is independently load-bearing (full-tree complement probes at the tip): remove the stale-pin reporting loop → only The absolute fix rejects before any touch. The condition is
Docstring: no other sentence overstates what the guard does, and every real file citation matches Family: Not run: No UI surface: a test module only; nothing renders. No merge action from QA: this report is advisory, the merge gate is the repo's review decision on the head sha, and the merge itself is executed by the repo's merge process. |
The guard as merged in #1264 accepts a stale `_EXTERNAL` pin, a `:0` citation, and a `../` citation that resolves outside the repository. Each new test fails at that head: the stale pin is never compared with what the pages quote, line zero never exceeds a file's length, and the escape target is a real file so the existence check passes. The guard takes an optional root and pin set so the new cases can run against a temp tree; the shipped docs are not touched.
Three gaps in the guard as merged: `_EXTERNAL` pins were allowed whether or not a page still quotes them, `:0` never exceeded a line count, and a `../` path resolved outside the checkout and was checked against a file that really exists there. The walk now records the external coordinates it sees and reports `_EXTERNAL - seen`, rejects line numbers below 1 or running backwards, and rejects a path with a `..` segment before touching the filesystem.
|
Review (Birfy) Tip SHA: 95c8708
|
Fixes #1265.
What changed
Before:
tests/test_docs_citations.pyonly checked that a cited file exists and that the last cited line is inside it. A_EXTERNALpin stayed valid after the page stopped citing that path or moved the citation to another line;:0was accepted; and a../citation could read a line count outside the repository.After: the same single walk gains three checks:
_EXTERNAL - seen, naming the page and pin:docs/algo-genesis.md -> agents/nowhere.ex:7 (pinned in _EXTERNAL, no longer cited);first < 1orend < first:docs/page.md:1 -> pkg/mod.py:0 (line numbers start at 1 and run forward);..segment before touching the filesystem:docs/page.md:1 -> ../../outside.txt:1 (citation path escapes this repository)._EXTERNALstays exact coordinates and the shipped docs are untouched; every current citation still passes. Tests-only plus the guard in the test module — nodocs/or runtime change, so no changelog fragment (changelog_fragments checkpasses without one).Verification at the tip
Tip SHA: 5c0a73a
Red at
0a6e782f8fwith only the test delta (guard as merged in #1264,tests/test_docs_citations.pyfrom this branch):Ran:
python -m pytest tests/test_docs_citations.py -q→4 passed in 0.47spython -m pytest tests/test_docs_links.py tests/test_site_navigation.py tests/test_docs_examples.py -q→31 passed in 58.64spython -m tools.changelog_fragments check→45 changelog fragment(s) OKpython -m tools.gen_api_docs --check→docs/api.md is up to dateNot run:
pytest -q— the delta is one test file, the docs family above is the affected surface.mkdocs build --strict— no page, nav or mkdocs.yml change.Update at
95c87086Tip SHA: 95c8708
The tip named above stays as the record of the first read; the current tip is this one. Security found that an absolute citation path also escaped the checkout:
_CITATIONallowed a leading/, androot / pathdiscardsrootwhenpathis absolute, so/etc/ld.so.conf:1was line-counted from outside the repository (read-only, benign in outcome, but the guard did not do what its docstring said)._problems()now rejectsPath(path).is_absolute()before any filesystem touch, with the same(citation path escapes this repository)message and the same place as the..check.Red was taken red-first at
5c0a73a2dbwith only the test delta:1 failed, 4 passed in 0.95s,tests/test_docs_citations.py:168asserting the escape message againstdocs/page.md:1 -> /nonexistent/outside.txt:1 (file does not exist). The test cites a nonexistent absolute path so it fails on the message, not on the runner.Ran at this tip:
python -m pytest tests/test_docs_citations.py -q→5 passed in 0.40s31 passed in 60.44spython -m tools.changelog_fragments check→45 changelog fragment(s) OKpython -m tools.gen_api_docs --check→docs/api.md is up to date