fix(core): authorize symlinks by lexical path (#38180)
Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
This commit is contained in:
parent
128e2550ef
commit
e6607fb58d
4 changed files with 78 additions and 15 deletions
|
|
@ -220,6 +220,39 @@ describe("WriteTool", () => {
|
|||
),
|
||||
)
|
||||
|
||||
it.live("writes an external symlink target with only its in-location permission", () =>
|
||||
Effect.acquireUseRelease(
|
||||
Effect.promise(() => Promise.all([tmpdir(), tmpdir()])),
|
||||
([active, outside]) => {
|
||||
reset()
|
||||
if (process.platform === "win32") return Effect.void
|
||||
const target = path.join(outside.path, "external.txt")
|
||||
const link = path.join(active.path, "link.txt")
|
||||
return Effect.promise(async () => {
|
||||
await fs.writeFile(target, "before")
|
||||
await fs.symlink(target, link)
|
||||
}).pipe(
|
||||
Effect.andThen(
|
||||
withTool(active.path, (registry) => executeTool(registry, call({ path: "link.txt", content: "after" }))),
|
||||
),
|
||||
Effect.andThen((result) =>
|
||||
Effect.sync(() => {
|
||||
expect(result.type).toBe("text")
|
||||
expect(assertions.map((input) => input.action)).toEqual(["edit"])
|
||||
expect(assertions[0]?.resources).toEqual(["link.txt"])
|
||||
}),
|
||||
),
|
||||
Effect.andThen(Effect.promise(() => fs.readFile(target, "utf8"))),
|
||||
Effect.tap((content) => Effect.sync(() => expect(content).toBe("after"))),
|
||||
)
|
||||
},
|
||||
([active, outside]) =>
|
||||
Effect.promise(() =>
|
||||
Promise.all([active[Symbol.asyncDispose](), outside[Symbol.asyncDispose]()]).then(() => undefined),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
it.live("approves an explicit external absolute path before edit", () =>
|
||||
Effect.acquireUseRelease(
|
||||
Effect.promise(() => Promise.all([tmpdir(), tmpdir()])),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue