Repository navigation
fix(cli): keep published files inside the entry directory - #1838
Merged
Lorenzobattistela merged 5 commits intoOct 23, 2026
Merged
Conversation
Contributor
Author
|
@Viana-SSJ confirmed the git-clone repro and all five cases on this head: verification. Release-note heads-up: an entry-file symlink pointing outside its directory is now refused too. Hard-link provenance is not covered by this guard; git clone does not preserve that aliasing. |
The entry's directory is now dirname(realpath(entry)), the directory the loader roots namespaces at, and every source is published at its path relative to it. Each published path and its real target must stay inside, so the old ancestor re-rooting is gone: a climb that came back inside no longer pushed the whole package under the entry's directory name. An entry linked from another directory and an entry at / are refused, the LICENSE refusal says it was the LICENSE beside a source, and the CLI help drops the publish note. gates/ping.ts covers climbs, file, directory, LICENSE and entry links out, a link inside and a climb back in. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A foreign file's published path is its import normalized as text, as an importer resolves it inside the package. Resolving it against the absolute path collapsed a climb back in (../back/ok.c from back/) to ok.c, which the published source still names as ../back/ok.c, so the package broke on import; that climb is now refused. gates/ping.ts expects the refusal and publishes a nested file whose ../ok.c stays inside. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A foreign import that climbs out of the package, even back into the entry's directory, is refused for what it is: its import climbs out (../back/ok.c), so write a path that stays inside; "it is outside" is kept for a file whose real path leaves the directory. The p === ".." guard and the non-prefix fallback could not occur: every foreign file's .bend is checked inside the directory first. gates/ping.ts expects each refusal's own reason. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Lorenzobattistela
approved these changes
Oct 23, 2026
Collaborator
There was a problem hiding this comment.
Approved at add9b8d. Publishing is confined to the loader's root: every published path and its real target must stay inside the entry's directory. bun gates/repo.ts 54/54, bun gates/ping.ts 81/81.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merged
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.
Fixes #1836.
--publishcould follow a foreign-file orLICENSEsymlink, or a../climb, and upload a file from outside the entry directory.The entry's directory is now
dirname(realpath(entry)), the directory the loader roots namespaces at. Every published file must stay inside it, both by its published path and by its real target:.bendfile is published at its namespace, and a foreign.c/.jsfile at its import's own path, normalized as text (as an importer resolves it inside the package);../climbs that leave the directory, file and directory symlinks out of it, and an automaticLICENSEthat links out are refused before mining, with no hub request;../back/ok.cfromback/) is refused too: the published source would name a file the package lacks;/, are refused;The old ancestor re-rooting of climbing imports is gone. This intentionally stops publishing shared sources above the entry directory: move them under it first. Checking and running local programs are unchanged.
Behaviour changes for the release notes: shared sources above the entry directory,
LICENSEsymlinks pointing out of it, and an entry file symlinked from another directory no longer publish.Tests:
gates/ping.tspublishes against its localhost hub: a climb, a climb back in, a file link, a directory link, aLICENSElink, a linked entry and a climbing.bendimport are each refused before mining; a link inside and a nested file's../that stays inside publish with the expected hash.bun gates/repo.ts: 54/54bun gates/ping.ts: 81/81Known limits, not addressed here: hard links to outside files (realpath does not see them; git clones never create them), and a file swapped between the check and the read.