Skip to content

test(docs): refuse a citation through a symlink that leaves the checkout (#1282) - #1285

Merged
Birfy merged 2 commits into
mainfrom
agent/1282-docs-citation-symlink
Nov 25, 2026
Merged

Birfy merged 2 commits into
mainfrom
agent/1282-docs-citation-symlink

Conversation

@Birfy

@Birfy Birfy commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #1282.

What changed

Before: tests/test_docs_citations.py decided containment lexically (.. in the path, or an absolute path) and then called is_file() / _line_count() on root / path. A committed symlink at that leaf is neither .. nor absolute, so the guard followed it and line-counted a file this repository does not contain. An in-range citation reported nothing (the page read as verified); a past-the-end one reported the outside file's length.

After: after the lexical checks, the guard resolves the cited path and requires it to stay under root.resolve() before any is_file() or line count. An escaping link is reported as (citation path escapes this repository), the same message as #988 / the .. and absolute cases.

The shipped docs are untouched. Tests-only plus the guard in the test module — no docs/ or runtime change, so no changelog fragment (changelog_fragments check passes without one).

Verification at the tip

Tip SHA: 4208b59

Red at 48fdc67889 with only the test delta (6629fddb97):

2 failed, 5 passed in 0.12s
tests/test_docs_citations.py:184: AssertionError: []  (assert 0 == 1)  — in-range citation through the link reported nothing
tests/test_docs_citations.py:200: AssertionError: ['docs/page.md:1 -> link.txt:9 (file has 3 lines)']  — past-the-end reported the outside file's length

Ran:

  • python -m pytest tests/test_docs_citations.py -q → 7 passed in 0.10s
  • python -m pytest tests/test_docs_citations.py tests/test_docs_links.py tests/test_site_navigation.py tests/test_docs_examples.py -q → 38 passed in 7.92s
  • python -m tools.changelog_fragments check → 47 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date

Not run:

  • full 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.

Red first: a committed symlink to a file outside the checkout is still
followed, so an in-range citation reports nothing and a past-the-end
one reports the outside file's length.
Resolve the cited path and require it to stay under the checkout root
before is_file() or a line count, so a committed symlink to an outside
file is reported as an escape rather than verified against a file this
repository does not contain.
@Birfy

Birfy commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Review (Birfy)

Tip SHA: 4208b59
Ran:

  • .github/scripts/risk_gate.py --repo ThinkFlowLab/agentdescent --pr 1285 → T1
  • pytest -q -o addopts='' tests/test_docs_citations.py at this tip → 7 passed
  • docs family (test_docs_citations, test_docs_links, test_site_navigation, test_docs_examples) → 38 passed
  • python -m tools.changelog_fragments check → 47 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
    Not run:
  • Full offline suite locally — the delta is one test file; required CI will cover test 3.9–3.13, build, otel-wire
    Findings:
  • No actionable defects. After the lexical .. / absolute checks, the guard now resolves the cited path and requires it to stay under the checkout root before is_file() or a line count. A committed symlink to an outside file is reported as (citation path escapes this repository) instead of being verified against a file this repository does not contain. Red was taken first at 6629fddb97 (in-range link reported nothing; past-the-end reported the outside file's length).
    Verdict: PASS

@Birfy
Birfy enabled auto-merge (squash) November 25, 2026 16:30
@github-actions github-actions Bot added risk:T1 Risk tier T1 (tests, examples, changelog.d), set by the controller from the diff agent-pr Pull request opened by an agent labels Nov 25, 2026
@Birfy
Birfy merged commit a0d70e4 into main Nov 25, 2026
12 checks passed
@Birfy
Birfy deleted the agent/1282-docs-citation-symlink branch November 25, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr Pull request opened by an agent risk:T1 Risk tier T1 (tests, examples, changelog.d), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(docs): a committed symlink to an outside file is followed, so a citation can be verified against nothing

1 participant