Skip to content

Commit b805290

Browse files
committed
structure commands
1 parent 96849de commit b805290

1 file changed

Lines changed: 63 additions & 48 deletions

File tree

  • x-pack/platform/plugins/shared/agent_builder/server/services/execution/run_agent/bash

x-pack/platform/plugins/shared/agent_builder/server/services/execution/run_agent/bash/allowed_commands.ts

Lines changed: 63 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,91 +10,106 @@ import type { CommandName } from 'just-bash';
1010
/**
1111
* Explicit allowlist of just-bash built-in commands enabled in Agent Builder.
1212
*
13+
* Organized by the same categories as just-bash's README so the list can be
14+
* cross-referenced against upstream at a glance.
15+
*
1316
* Intentionally excluded:
1417
* - sqlite3 — depends on sql.js WASM (import.meta.url) which doesn't load via CJS
1518
* - python, python3 — Python via CPython WASM; same WASM issue + security surface
1619
* - js-exec, node — JS/TS via QuickJS; security surface, not needed
1720
* - curl, html-to-markdown — network access, needs explicit security model
18-
* - ln, readlink — symlinks aren't supported by workspace volume / persistence,
19-
* - tar — pulls in `node-liblzma` and `@mongodb-js/zstd`for compressed-archive support. Disabled until we
21+
* - ln, readlink — symlinks aren't supported by workspace volume / persistence
22+
* - tar — pulls in `node-liblzma` (LGPL-3.0) and `@mongodb-js/zstd` for
23+
* compressed-archive support; disabled until those deps are reviewed
2024
*/
2125
export const ALLOWED_BASH_COMMANDS: readonly CommandName[] = [
22-
'alias',
26+
// File operations
27+
'cat',
28+
'cp',
29+
'file',
30+
'ls',
31+
'mkdir',
32+
'mv',
33+
'rm',
34+
'rmdir',
35+
'split',
36+
'stat',
37+
'touch',
38+
'tree',
39+
40+
// Text processing
2341
'awk',
2442
'base64',
25-
'basename',
26-
'bash',
27-
'cat',
28-
'chmod',
29-
'clear',
3043
'column',
3144
'comm',
32-
'cp',
3345
'cut',
34-
'date',
3546
'diff',
36-
'dirname',
37-
'du',
38-
'echo',
39-
'egrep',
40-
'env',
4147
'expand',
42-
'expr',
43-
'false',
44-
'fgrep',
45-
'file',
46-
'find',
4748
'fold',
4849
'grep',
49-
'gunzip',
50-
'gzip',
50+
'egrep',
51+
'fgrep',
5152
'head',
52-
'help',
53-
'history',
54-
'hostname',
5553
'join',
56-
'jq',
57-
'ls',
5854
'md5sum',
59-
'mkdir',
60-
'mv',
6155
'nl',
6256
'od',
6357
'paste',
64-
'printenv',
6558
'printf',
66-
'pwd',
6759
'rev',
6860
'rg',
69-
'rm',
70-
'rmdir',
7161
'sed',
72-
'seq',
73-
'sh',
7462
'sha1sum',
7563
'sha256sum',
76-
'sleep',
7764
'sort',
78-
'split',
79-
'stat',
8065
'strings',
8166
'tac',
8267
'tail',
83-
'tee',
84-
'time',
85-
'timeout',
86-
'touch',
8768
'tr',
88-
'tree',
89-
'true',
90-
'unalias',
9169
'unexpand',
9270
'uniq',
9371
'wc',
94-
'which',
95-
'whoami',
96-
'xan',
9772
'xargs',
73+
74+
// Data processing
75+
'jq',
76+
'xan',
9877
'yq',
78+
79+
// Compression & archives
80+
'gzip',
81+
'gunzip',
9982
'zcat',
83+
84+
// Navigation & environment
85+
'basename',
86+
'dirname',
87+
'du',
88+
'echo',
89+
'env',
90+
'find',
91+
'hostname',
92+
'printenv',
93+
'pwd',
94+
'tee',
95+
96+
// Shell utilities
97+
'alias',
98+
'bash',
99+
'chmod',
100+
'clear',
101+
'date',
102+
'expr',
103+
'false',
104+
'help',
105+
'history',
106+
'seq',
107+
'sh',
108+
'sleep',
109+
'time',
110+
'timeout',
111+
'true',
112+
'unalias',
113+
'which',
114+
'whoami',
100115
] as const satisfies readonly CommandName[];

0 commit comments

Comments
 (0)