|
|
@@ -387,57 +387,63 @@ describe("ShellTool", () => {
|
|
|
),
|
|
|
)
|
|
|
|
|
|
- it.live("approves an explicit external workdir before shell execution", () =>
|
|
|
- Effect.acquireUseRelease(
|
|
|
- Effect.promise(() => Promise.all([tmpdir(), tmpdir()])),
|
|
|
- ([active, outside]) => {
|
|
|
- reset()
|
|
|
- return withSession(active.path, (registry) =>
|
|
|
- executeTool(registry, call({ command: cwdCommand, workdir: outside.path })),
|
|
|
- ).pipe(
|
|
|
- Effect.andThen(
|
|
|
- Effect.sync(() => {
|
|
|
- expect(assertions.map((item) => item.action)).toEqual(["external_directory", "shell"])
|
|
|
- expect(assertions[0]).toMatchObject({
|
|
|
- resources: [path.join(realpathSync(outside.path), "*").replaceAll("\\", "/")],
|
|
|
- })
|
|
|
- }),
|
|
|
+ it.live(
|
|
|
+ "approves an explicit external workdir before shell execution",
|
|
|
+ () =>
|
|
|
+ Effect.acquireUseRelease(
|
|
|
+ Effect.promise(() => Promise.all([tmpdir(), tmpdir()])),
|
|
|
+ ([active, outside]) => {
|
|
|
+ reset()
|
|
|
+ return withSession(active.path, (registry) =>
|
|
|
+ executeTool(registry, call({ command: cwdCommand, workdir: outside.path })),
|
|
|
+ ).pipe(
|
|
|
+ Effect.andThen(
|
|
|
+ Effect.sync(() => {
|
|
|
+ expect(assertions.map((item) => item.action)).toEqual(["external_directory", "shell"])
|
|
|
+ expect(assertions[0]).toMatchObject({
|
|
|
+ resources: [path.join(realpathSync(outside.path), "*").replaceAll("\\", "/")],
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ },
|
|
|
+ ([active, outside]) =>
|
|
|
+ Effect.promise(() =>
|
|
|
+ Promise.all([active[Symbol.asyncDispose](), outside[Symbol.asyncDispose]()]).then(() => undefined),
|
|
|
),
|
|
|
- )
|
|
|
- },
|
|
|
- ([active, outside]) =>
|
|
|
- Effect.promise(() =>
|
|
|
- Promise.all([active[Symbol.asyncDispose](), outside[Symbol.asyncDispose]()]).then(() => undefined),
|
|
|
- ),
|
|
|
- ),
|
|
|
+ ),
|
|
|
+ { timeout: 15_000 },
|
|
|
)
|
|
|
|
|
|
- it.live("approves an external directory used by a directory-change command", () =>
|
|
|
- Effect.acquireUseRelease(
|
|
|
- Effect.promise(() => Promise.all([tmpdir(), tmpdir()])),
|
|
|
- ([active, outside]) => {
|
|
|
- reset()
|
|
|
- const command = isWindows
|
|
|
- ? `Set-Location -LiteralPath '${outside.path}'; (Get-Location).Path`
|
|
|
- : `cd '${outside.path}' && pwd`
|
|
|
- return withSession(active.path, (registry) =>
|
|
|
- executeTool(registry, call({ command }, "call-external-cd")),
|
|
|
- ).pipe(
|
|
|
- Effect.andThen(
|
|
|
- Effect.sync(() => {
|
|
|
- expect(assertions.map((item) => item.action)).toEqual(["external_directory", "shell"])
|
|
|
- expect(assertions[0]).toMatchObject({
|
|
|
- resources: [path.join(realpathSync(outside.path), "*").replaceAll("\\", "/")],
|
|
|
- })
|
|
|
- }),
|
|
|
+ it.live(
|
|
|
+ "approves an external directory used by a directory-change command",
|
|
|
+ () =>
|
|
|
+ Effect.acquireUseRelease(
|
|
|
+ Effect.promise(() => Promise.all([tmpdir(), tmpdir()])),
|
|
|
+ ([active, outside]) => {
|
|
|
+ reset()
|
|
|
+ const command = isWindows
|
|
|
+ ? `Set-Location -LiteralPath '${outside.path}'; (Get-Location).Path`
|
|
|
+ : `cd '${outside.path}' && pwd`
|
|
|
+ return withSession(active.path, (registry) =>
|
|
|
+ executeTool(registry, call({ command }, "call-external-cd")),
|
|
|
+ ).pipe(
|
|
|
+ Effect.andThen(
|
|
|
+ Effect.sync(() => {
|
|
|
+ expect(assertions.map((item) => item.action)).toEqual(["external_directory", "shell"])
|
|
|
+ expect(assertions[0]).toMatchObject({
|
|
|
+ resources: [path.join(realpathSync(outside.path), "*").replaceAll("\\", "/")],
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ },
|
|
|
+ ([active, outside]) =>
|
|
|
+ Effect.promise(() =>
|
|
|
+ Promise.all([active[Symbol.asyncDispose](), outside[Symbol.asyncDispose]()]).then(() => undefined),
|
|
|
),
|
|
|
- )
|
|
|
- },
|
|
|
- ([active, outside]) =>
|
|
|
- Effect.promise(() =>
|
|
|
- Promise.all([active[Symbol.asyncDispose](), outside[Symbol.asyncDispose]()]).then(() => undefined),
|
|
|
- ),
|
|
|
- ),
|
|
|
+ ),
|
|
|
+ { timeout: 15_000 },
|
|
|
)
|
|
|
|
|
|
it.live("approves an expanded external home directory", () =>
|
|
|
@@ -459,28 +465,31 @@ describe("ShellTool", () => {
|
|
|
),
|
|
|
)
|
|
|
|
|
|
- it.live("does not execute after external-directory or shell denial", () =>
|
|
|
- Effect.acquireUseRelease(
|
|
|
- Effect.promise(() => Promise.all([tmpdir(), tmpdir()])),
|
|
|
- ([active, outside]) =>
|
|
|
- Effect.gen(function* () {
|
|
|
- reset()
|
|
|
- denyAction = "external_directory"
|
|
|
- yield* withSession(active.path, (registry) =>
|
|
|
- executeTool(registry, call({ command: cwdCommand, workdir: outside.path })),
|
|
|
- )
|
|
|
- expect(assertions.map((item) => item.action)).toEqual(["external_directory"])
|
|
|
+ it.live(
|
|
|
+ "does not execute after external-directory or shell denial",
|
|
|
+ () =>
|
|
|
+ Effect.acquireUseRelease(
|
|
|
+ Effect.promise(() => Promise.all([tmpdir(), tmpdir()])),
|
|
|
+ ([active, outside]) =>
|
|
|
+ Effect.gen(function* () {
|
|
|
+ reset()
|
|
|
+ denyAction = "external_directory"
|
|
|
+ yield* withSession(active.path, (registry) =>
|
|
|
+ executeTool(registry, call({ command: cwdCommand, workdir: outside.path })),
|
|
|
+ )
|
|
|
+ expect(assertions.map((item) => item.action)).toEqual(["external_directory"])
|
|
|
|
|
|
- reset()
|
|
|
- denyAction = "shell"
|
|
|
- yield* withSession(active.path, (registry) => executeTool(registry, call({ command: cwdCommand })))
|
|
|
- expect(assertions.map((item) => item.action)).toEqual(["shell"])
|
|
|
- }),
|
|
|
- ([active, outside]) =>
|
|
|
- Effect.promise(() =>
|
|
|
- Promise.all([active[Symbol.asyncDispose](), outside[Symbol.asyncDispose]()]).then(() => undefined),
|
|
|
- ),
|
|
|
- ),
|
|
|
+ reset()
|
|
|
+ denyAction = "shell"
|
|
|
+ yield* withSession(active.path, (registry) => executeTool(registry, call({ command: cwdCommand })))
|
|
|
+ expect(assertions.map((item) => item.action)).toEqual(["shell"])
|
|
|
+ }),
|
|
|
+ ([active, outside]) =>
|
|
|
+ Effect.promise(() =>
|
|
|
+ Promise.all([active[Symbol.asyncDispose](), outside[Symbol.asyncDispose]()]).then(() => undefined),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ { timeout: 15_000 },
|
|
|
)
|
|
|
|
|
|
it.live("keeps non-zero exits useful", () =>
|
|
|
@@ -619,7 +628,7 @@ describe("ShellTool", () => {
|
|
|
},
|
|
|
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]().then(() => undefined)),
|
|
|
),
|
|
|
- { timeout: 10_000 },
|
|
|
+ { timeout: 15_000 },
|
|
|
)
|
|
|
|
|
|
it.live(
|
|
|
@@ -630,7 +639,7 @@ describe("ShellTool", () => {
|
|
|
(tmp) => {
|
|
|
reset()
|
|
|
return withSession(tmp.path, (registry) =>
|
|
|
- executeTool(registry, call({ command: timeoutOutputCommand, timeout: isWindows ? 3_000 : 50 })),
|
|
|
+ executeTool(registry, call({ command: timeoutOutputCommand, timeout: isWindows ? 3_000 : 500 })),
|
|
|
).pipe(
|
|
|
Effect.andThen((settled) =>
|
|
|
Effect.sync(() => {
|