@f5-sales-demo/xcsh 20.3.2 → 20.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +8 -8
  3. package/src/cli/resource-cli.ts +134 -0
  4. package/src/cli/sandbox-check.ts +84 -21
  5. package/src/cli/update-cli.ts +1 -1
  6. package/src/cli.ts +8 -0
  7. package/src/commands/apply.ts +21 -0
  8. package/src/commands/create.ts +21 -0
  9. package/src/commands/delete.ts +32 -0
  10. package/src/commands/diff.ts +20 -0
  11. package/src/commands/export.ts +36 -0
  12. package/src/commands/get.ts +30 -0
  13. package/src/commands/resource-flags.ts +30 -0
  14. package/src/commands/self-update.ts +18 -0
  15. package/src/commands/update.ts +14 -14
  16. package/src/commands/validate.ts +20 -0
  17. package/src/internal-urls/build-info.generated.ts +8 -8
  18. package/src/locales/ar.json +1 -1
  19. package/src/locales/de.json +1 -1
  20. package/src/locales/en.json +1 -1
  21. package/src/locales/es.json +1 -1
  22. package/src/locales/fr.json +1 -1
  23. package/src/locales/hi.json +1 -1
  24. package/src/locales/it.json +1 -1
  25. package/src/locales/ja.json +1 -1
  26. package/src/locales/ko.json +1 -1
  27. package/src/locales/pt-br.json +1 -1
  28. package/src/locales/th.json +1 -1
  29. package/src/locales/zh-cn.json +1 -1
  30. package/src/locales/zh-tw.json +1 -1
  31. package/src/main.ts +1 -1
  32. package/src/prompts/internal-urls/containment.md +16 -17
  33. package/src/resource-management/index.ts +8 -0
  34. package/src/sandbox/command-operands.ts +20 -290
  35. package/src/sandbox/containment.ts +41 -42
  36. package/src/sandbox/enforce.ts +45 -280
  37. package/src/sandbox/session-fence.ts +7 -0
  38. package/src/slash-commands/resource-commands.ts +63 -93
  39. package/src/tools/bash.ts +9 -3
  40. package/src/tools/shell-lex.ts +8 -10
package/src/tools/bash.ts CHANGED
@@ -24,6 +24,7 @@ import {
24
24
  SANDBOX_CHECK_NAMED_SIBLING_ENV,
25
25
  SANDBOX_OPERATOR_HOME_ENV,
26
26
  SANDBOX_SESSION_ROOT_ENV,
27
+ sandboxCheckSiblingRoot,
27
28
  } from "../sandbox/session-fence";
28
29
  import { SECRET_ENV_PATTERNS, type SecretObfuscator } from "../secrets";
29
30
  import { DEFAULT_MAX_BYTES, TailBuffer } from "../session/streaming-output";
@@ -658,12 +659,14 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
658
659
  // Keep these values host-owned: tool-supplied env cannot replace them.
659
660
  let env = requestedEnv;
660
661
  let trustedSessionRoot = containmentRoot;
662
+ let trustedOperatorHome = os.homedir();
661
663
  if (fence !== undefined) {
662
- const [canonicalSessionRoot, trustedOperatorHome] = await Promise.all([
664
+ const [canonicalSessionRoot, canonicalOperatorHome] = await Promise.all([
663
665
  canonicalizeSandboxContextPath(containmentRoot),
664
- canonicalizeSandboxContextPath(os.homedir()),
666
+ canonicalizeSandboxContextPath(trustedOperatorHome),
665
667
  ]);
666
668
  trustedSessionRoot = canonicalSessionRoot;
669
+ trustedOperatorHome = canonicalOperatorHome;
667
670
  env = {
668
671
  ...requestedEnv,
669
672
  [SANDBOX_SESSION_ROOT_ENV]: trustedSessionRoot,
@@ -799,7 +802,10 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
799
802
  // sibling before the child is confined so the diagnostic measures reachability, not whether a
800
803
  // nested sandbox can widen itself. The host owns both this path and its cleanup.
801
804
  sandboxCheckSibling = await fs.promises.mkdtemp(
802
- path.join(path.dirname(trustedSessionRoot), ".xcsh-sandbox-check-live-sibling-"),
805
+ path.join(
806
+ sandboxCheckSiblingRoot(trustedSessionRoot, trustedOperatorHome),
807
+ ".xcsh-sandbox-check-live-sibling-",
808
+ ),
803
809
  );
804
810
  await Bun.write(path.join(sandboxCheckSibling, "named.txt"), "sibling\n");
805
811
  env = { ...env, [SANDBOX_CHECK_NAMED_SIBLING_ENV]: sandboxCheckSibling };
@@ -1,23 +1,21 @@
1
1
  /**
2
2
  * Shell-aware tokenizer for bash command strings.
3
3
  *
4
- * Two subsystems used to scan raw command text with regexes and got argument *data* wrong in
5
- * opposite directions: internal-URL expansion rewrote `xcsh://` tokens sitting inside quoted
6
- * strings (#2468), and the sandbox read-boundary check reported `sed` regex addresses as
7
- * filesystem paths (#2470). Both need to know where a shell *word* starts and ends.
4
+ * Raw command-text regexes get argument *data* wrong. Internal-URL expansion rewrote `xcsh://`
5
+ * tokens sitting inside quoted strings (#2468), while sandbox enforcement needs to identify only
6
+ * explicit redirections, write operands, and directory changes. Both need to know where a shell
7
+ * *word* starts and ends.
8
8
  *
9
9
  * This module answers only that question. It deliberately does NOT decide anything:
10
10
  *
11
11
  * - #2468 uses `text` plus `start`/`end` to tell "this whole word is the URL" from "the URL is
12
12
  * mentioned inside this word", and to splice a replacement over the exact source span.
13
- * - #2470 uses `name` and `operandStart` to *locate* a script operand it may exempt, and to
14
- * report a real word instead of a fragment like `` /a/p'; ``. The sandbox's safety still rests
15
- * on its own coverage floor, never on this lexer being complete — see
16
- * `sandbox/command-operands.ts`.
13
+ * - Sandbox enforcement uses `name`, `operandStart`, and redirect metadata only for filesystem
14
+ * effects whose meaning is known without interpreting arbitrary argument text.
17
15
  *
18
16
  * Scope: enough POSIX shell to describe the commands an agent actually writes. Heredoc bodies are
19
- * consumed as data and never re-lexed, which is shell-correct but means a `bash <<EOF` body is
20
- * invisible here; that is exactly why the sandbox keeps a floor rather than trusting these words.
17
+ * consumed as data and never re-lexed, which is shell-correct: source and heredoc text are left to
18
+ * the runtime fence rather than scanned for path-looking strings.
21
19
  */
22
20
 
23
21
  /** How a word was quoted. `mixed` when built from differently-quoted segments, as in `a"b"'c'`. */