Repository navigation
fix: refuse a save-script destination another local user can steer #4584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
thymikee
wants to merge
28
commits into
main
Choose a base branch
from
fix/save-script-ancestor-redirect
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,990
−248
Draft
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
ca8aec9
fix(host-kit): refuse a script destination another local user can steer
thymikee b4340d0
fix(daemon): apply the destination rule to a local script save
thymikee a0b1332
fix(remote): refuse an unsafe script destination before it is downloaded
thymikee e26b698
docs: say which directories a script save accepts
thymikee cc0b597
test: carry the script publish through the wire and ownership gates
thymikee d93ac5d
fix(host-kit): judge a script destination by ownership and its real path
thymikee 5816981
fix(host-kit): keep foreign ground out of a script destination chain
thymikee 35fb969
test(daemon): refuse a recording under a directory another user owns
thymikee 1540984
fix(host-kit): judge every directory a script destination walks through
thymikee 5901614
fix(host-kit): walk a script destination the way the kernel resolves it
thymikee 352adcc
fix(host-kit): resolve a link target relative to the directory that h…
thymikee 239ad68
fix(host-kit): name a published temp file by the directory it stands in
thymikee 43d436c
fix(host-kit): judge a relative destination from the root down
thymikee 8440213
fix(host-kit): judge a script destination before creating its parent
thymikee 2af90f4
fix(remote): create a published script in the directory the rule veri…
thymikee c5b41a0
fix(host-kit): refuse a script destination the walk cannot resolve
thymikee 927b042
refactor(host-kit): own script destination creation in one call
thymikee 925158d
fix(host-kit): judge every script-path step from its own lstat
thymikee eaa9747
fix(daemon-contracts): judge a state repair before forcing its mode
thymikee ed5c7b9
fix(host-kit): confirm a script destination with one call, and cut th…
thymikee b9f17ce
fix(daemon-contracts): never let a state-mode repair decide daemon st…
thymikee 632cc84
test(daemon-contracts): pin a state repair that skips levels it may n…
thymikee 4b630c1
docs(adr): say what the state repair judges, in the tense the code has
thymikee e38764b
fix(daemon): judge the state repair down from the state base
thymikee 8cd5b8a
fix(daemon): judge what a state level is before its mode
thymikee fa64dfe
fix(daemon): refuse a script the state repair could not claim
thymikee 687822a
fix(daemon): carry the close refusal's reason and say who owns the state
thymikee 208b380
fix(daemon): judge the ancestry above the state base before repairing it
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
491 changes: 491 additions & 0 deletions
491
packages/daemon-contracts/src/daemon-registration-owner-state-dir.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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
27 changes: 27 additions & 0 deletions
27
packages/daemon/src/__tests__/support/script-staging-failure.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import fs from 'node:fs'; | ||
| import { vi } from 'vitest'; | ||
| import { isAtomicPublishTemporaryPath } from '@agent-device/host-kit/file'; | ||
|
|
||
| /** | ||
| * Makes the staging write of a script publication fail, and only that write. | ||
| * | ||
| * A publication stages the recording in a private temp sibling of the destination and moves it into place, | ||
| * so the seam where the filesystem can refuse a script is that one write. `host-kit`'s temp-path predicate | ||
| * says which write it is, so the fixture does not have to know how the name is built. | ||
| * | ||
| * This replaces a fixture that made the destination's directory `0500`. That one asked the HOST whether a | ||
| * write into it is allowed, and a caller the mode bits do not bind — root — writes straight through it, so | ||
| * the write succeeded and the test that expected a failure failed with it. The failure injected here is the | ||
| * fixture's own, which makes the outcome the same for every caller. | ||
| */ | ||
| export function failScriptStagingWrite(destination: string): void { | ||
| const failure: NodeJS.ErrnoException = Object.assign( | ||
| new Error(`EACCES: permission denied, open '${destination}'`), | ||
| { code: 'EACCES', errno: -13, syscall: 'open', path: destination }, | ||
| ); | ||
| const realWriteFileSync = fs.writeFileSync; | ||
| vi.spyOn(fs, 'writeFileSync').mockImplementation(((file: fs.PathLike | number, ...rest) => { | ||
| if (isAtomicPublishTemporaryPath(file, destination)) throw failure; | ||
| return (realWriteFileSync as (...args: unknown[]) => unknown)(file, ...rest); | ||
| }) as typeof fs.writeFileSync); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.