✨ NEW: enforce mounted-directive path confinement (path_check)#7
Open
ubmarco wants to merge 11 commits into
Open
✨ NEW: enforce mounted-directive path confinement (path_check)#7ubmarco wants to merge 11 commits into
ubmarco wants to merge 11 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds path confinement for mounted bundles: a directive inside a mounted bundle that references a file outside the bundle root now fails the build by default, keeping bundles self-contained and portable.
Directives resolve file paths relative to the document's own location, which for a mounted doc is the bundle on disk — so relative references resolve inside the bundle. Two shapes escape: a leading-slash path (
/foo, "absolute from the source root" = the hostsrcdir) and a..climb above the bundle root. Either drags an outside file into the host build (and, for asset directives, copies it into the host's_images/_downloadsoutput, risking collisions with host files). The check is directive-agnostic — it inspectsenv.dependenciesfor each mounted doc — so it coversliteralinclude,include,csv-table/raw(:file:),image,figure,graphviz,uml,mermaid, and any other directive that records a file dependency.Config
New per-mount
path_checkinubproject.toml:"error"(default — fail the build),"warn"(log a warning; escalates under-W), or"off"(disable for that mount).Behavior change: a bundle that today references a file via a leading slash or
..will now fail by default; setpath_check = "warn"/"off"to opt out.Tests
tests/test_path_directives.py(new): happy-path resolution for all nine file-referencing directives (host-side decoy proves bundle-relative-not-host resolution; renderer-independent — mermaidraw, plantuml/graphviz asserted via the recorded dependency), the two leak boundaries, and enforcement (error/warn/off, directive-agnostic, file-list mode, per-mount).tests/test_config.py:path_checkvalidation + parse round-trip.tests/test_example.py: the Bazel example'sapi-foobundle now exercises all nine directives end-to-end under-nW.Docs / changelog
docs/source/configuration.rst: newpath_checkoption row + a "Path confinement" section.docs/source/changelog.rst: Unreleased entry.Code quality
uv run prek run --all-filespasses;uv run --group ty ty checkclean; non-bazel suite green (132); Bazel e2e green (withdot/java/plantumlavailable).