@capybara-hq/plugin-sdk 0.1.0-rc.3 → 0.1.0-rc.31
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.
- package/agent-docs/agent-templates.md +15 -3
- package/agent-docs/concepts.md +5 -0
- package/agent-docs/connector-templates.md +2 -1
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/config-source.md +1 -1
- package/agent-docs/extension-points/connector.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/counter.md +1 -1
- package/agent-docs/extension-points/directory.md +1 -1
- package/agent-docs/extension-points/file-preview.md +1 -1
- package/agent-docs/extension-points/identity-source.md +1 -1
- package/agent-docs/extension-points/model-provider.md +4 -2
- package/agent-docs/extension-points/object-store.md +3 -1
- package/agent-docs/extension-points/sandbox.md +3 -3
- package/agent-docs/extension-points/secret-store.md +1 -1
- package/agent-docs/extension-points/web-fetch.md +1 -1
- package/agent-docs/extension-points/web-search.md +1 -1
- package/agent-docs/extensions.md +29 -4
- package/agent-docs/plugin-format.md +43 -3
- package/agent-docs/setup.md +46 -0
- package/agent-docs/skills.md +1 -1
- package/agent-docs/tool-naming.md +1 -1
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/bootstrap.d.ts +15 -1
- package/dist/bootstrap.js +17 -1
- package/dist/cards.d.ts +56 -13
- package/dist/cards.js +90 -20
- package/dist/channel.d.ts +111 -48
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +22 -0
- package/dist/config-ui.js +64 -4
- package/dist/connector-auth.d.ts +7 -2
- package/dist/connector-auth.js +29 -8
- package/dist/connector.d.ts +74 -32
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +135 -26
- package/dist/define-extension.d.ts +26 -12
- package/dist/define-extension.js +11 -4
- package/dist/device-protocol-v3.d.ts +117 -0
- package/dist/device-protocol-v3.js +409 -0
- package/dist/device-protocol.d.ts +330 -0
- package/dist/device-protocol.js +567 -0
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +5 -2
- package/dist/file-preview.d.ts +1 -1
- package/dist/git-hosts.d.ts +44 -0
- package/dist/git-hosts.js +81 -0
- package/dist/hooks.d.ts +111 -21
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +52 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +22 -9
- package/dist/index.d.ts +23 -1
- package/dist/index.js +24 -1
- package/dist/marketplace.d.ts +26 -0
- package/dist/marketplace.js +43 -1
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +180 -71
- package/dist/model.js +71 -19
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/permissions.d.ts +42 -20
- package/dist/permissions.js +97 -40
- package/dist/plugin-manifest.d.ts +45 -5
- package/dist/plugin-manifest.js +169 -6
- package/dist/plugin-package.d.ts +82 -38
- package/dist/plugin-package.js +61 -29
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +1886 -0
- package/dist/sandbox-native-runtime-source.d.ts +8 -0
- package/dist/sandbox-native-runtime-source.js +325 -0
- package/dist/sandbox-operation.d.ts +248 -0
- package/dist/sandbox-operation.js +245 -0
- package/dist/sandbox-runtime-source.d.ts +19 -0
- package/dist/sandbox-runtime-source.js +28 -0
- package/dist/sandbox-write-denies.d.ts +60 -0
- package/dist/sandbox-write-denies.js +630 -0
- package/dist/sandbox.d.ts +201 -16
- package/dist/sandbox.js +89 -14
- package/dist/secret.d.ts +4 -1
- package/dist/secret.js +4 -1
- package/dist/setup-check.d.ts +115 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +350 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +94 -0
- package/dist/setup-guide.js +336 -0
- package/dist/skill-invocation.d.ts +4 -3
- package/dist/skill-invocation.js +5 -4
- package/dist/skill.d.ts +34 -21
- package/dist/skill.js +48 -31
- package/dist/storage.d.ts +52 -25
- package/dist/theme-assets.d.ts +39 -0
- package/dist/theme-assets.js +449 -0
- package/dist/theme-readability.d.ts +37 -0
- package/dist/theme-readability.js +145 -0
- package/dist/theme-tokens.generated.d.ts +279 -0
- package/dist/theme-tokens.generated.js +174 -0
- package/dist/theme.d.ts +152 -0
- package/dist/theme.js +392 -0
- package/dist/tool.d.ts +69 -26
- package/dist/tool.js +29 -9
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +337 -0
- package/dist/ui-resolve.d.ts +35 -0
- package/dist/ui-resolve.js +42 -0
- package/dist/ui-slots.d.ts +53 -0
- package/dist/ui-slots.js +238 -0
- package/dist/ui.d.ts +191 -79
- package/dist/ui.js +101 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/package.json +7 -1
- package/schemas/bootstrap.v1.schema.json +6 -0
- package/schemas/connector-template.v1.schema.json +35 -0
- package/schemas/marketplace.v1.schema.json +14 -0
- package/schemas/plugin.v1.schema.json +115 -3
- package/schemas/theme.v1.schema.json +225 -0
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What restricted execution may never write inside a granted root: one policy for every consumer
|
|
3
|
+
* (the Linux launcher's broker, `native-files.py`, the device agent and, as far as its glob
|
|
4
|
+
* patterns can express it, the macOS runtime). It keeps a later unsandboxed tool run by the owner
|
|
5
|
+
* from executing what a restricted command left behind.
|
|
6
|
+
*
|
|
7
|
+
* 1. {@link SANDBOX_MANDATORY_WRITE_DENIES}: component sequences denied wherever they appear (the
|
|
8
|
+
* entry and everything beneath it): shell startup files, git's global files, direnv and npm
|
|
9
|
+
* configuration, editor and agent configuration.
|
|
10
|
+
* 2. Inside a `.git` directory (the first `.git` component of a path) only git's ordinary
|
|
11
|
+
* internals are writable, an allowlist ({@link SANDBOX_GIT_ALLOWED_DIRECTORIES},
|
|
12
|
+
* {@link SANDBOX_GIT_ALLOWED_FILES}, `info/exclude`). Everything else there is denied:
|
|
13
|
+
* `config`, `config.worktree`, `commondir`, `gitdir`, `hooks/**`, `info/attributes`, unknown
|
|
14
|
+
* names. The gitdirs of submodules (`modules/<name>/`, where a name may contain `/`) and
|
|
15
|
+
* worktrees (`worktrees/<name>/`) follow the same allowlist; a submodule path is refused when
|
|
16
|
+
* any reading of its name would make it a denied internal.
|
|
17
|
+
* 3. Outside `.git`, a file named `HEAD` is denied: with `objects/` and `refs/` it would make a
|
|
18
|
+
* bare-repository lookalike whose configuration git honours.
|
|
19
|
+
* 4. Moves ({@link isSandboxMoveDenied}): nothing leaves a protected name (`.git`, `.claude`, …)
|
|
20
|
+
* except within the same protected directory; a directory is not moved under a protected name
|
|
21
|
+
* from outside it; no non-directory becomes `.git` (a `gitdir:` pointer).
|
|
22
|
+
*
|
|
23
|
+
* 5. Inside an allowlisted subtree nothing can make a repository: no `.git`, no `HEAD` except
|
|
24
|
+
* where git keeps one (`logs/HEAD`, `refs/remotes/<r>/HEAD`, …), and no `objects`, `commondir`
|
|
25
|
+
* or `gitdir` beside such a `HEAD`.
|
|
26
|
+
*
|
|
27
|
+
* Names are compared after Unicode NFKC normalization and full case folding
|
|
28
|
+
* ({@link sandboxFoldName}, identical to Python's `casefold`). Known limitations: a
|
|
29
|
+
* restricted command cannot `git init`, add a submodule or worktree, or create a bare repository;
|
|
30
|
+
* continuing an operation it started (`git rebase --continue`) runs the todo list it wrote, like
|
|
31
|
+
* any script it wrote; files that tools execute by convention without configuration (for example
|
|
32
|
+
* `package.json` scripts) are not covered; a forged rebase or cherry-pick in progress is possible
|
|
33
|
+
* (its state directories are writable for git's own use) and continuing it runs its `exec` lines.
|
|
34
|
+
* The macOS worker expresses this policy as ordered Seatbelt regex rules
|
|
35
|
+
* (`packages/device/src/exec/mac-write-policy.ts`).
|
|
36
|
+
*/
|
|
37
|
+
export const SANDBOX_MANDATORY_WRITE_DENIES = Object.freeze([
|
|
38
|
+
[".gitconfig"],
|
|
39
|
+
[".gitmodules"],
|
|
40
|
+
[".bashrc"],
|
|
41
|
+
[".bash_profile"],
|
|
42
|
+
[".zshrc"],
|
|
43
|
+
[".zprofile"],
|
|
44
|
+
[".profile"],
|
|
45
|
+
[".ripgreprc"],
|
|
46
|
+
[".mcp.json"],
|
|
47
|
+
[".envrc"],
|
|
48
|
+
[".npmrc"],
|
|
49
|
+
[".vscode"],
|
|
50
|
+
[".idea"],
|
|
51
|
+
[".claude", "commands"],
|
|
52
|
+
[".claude", "agents"],
|
|
53
|
+
// hook managers: hooks git runs (through a manager) from files in the working tree
|
|
54
|
+
[".husky"],
|
|
55
|
+
[".huskyrc"],
|
|
56
|
+
[".huskyrc.json"],
|
|
57
|
+
[".huskyrc.js"],
|
|
58
|
+
["husky.config.js"],
|
|
59
|
+
[".pre-commit-config.yaml"],
|
|
60
|
+
[".pre-commit-config.yml"],
|
|
61
|
+
["lefthook.yml"],
|
|
62
|
+
["lefthook.yaml"],
|
|
63
|
+
["lefthook.json"],
|
|
64
|
+
["lefthook.toml"],
|
|
65
|
+
[".lefthook.yml"],
|
|
66
|
+
[".lefthook.yaml"],
|
|
67
|
+
[".lefthook.json"],
|
|
68
|
+
[".lefthook.toml"],
|
|
69
|
+
["lefthook-local.yml"],
|
|
70
|
+
["lefthook-local.yaml"],
|
|
71
|
+
["lefthook-local.json"],
|
|
72
|
+
["lefthook-local.toml"],
|
|
73
|
+
[".lefthook-local.yml"],
|
|
74
|
+
[".lefthook-local.yaml"],
|
|
75
|
+
[".lefthook-local.json"],
|
|
76
|
+
[".lefthook-local.toml"],
|
|
77
|
+
[".lefthook"],
|
|
78
|
+
[".lefthook-local"],
|
|
79
|
+
[".config", "lefthook.yml"],
|
|
80
|
+
[".config", "lefthook.yaml"],
|
|
81
|
+
[".config", "lefthook.json"],
|
|
82
|
+
[".config", "lefthook.toml"],
|
|
83
|
+
[".overcommit.yml"],
|
|
84
|
+
[".simple-git-hooks.json"],
|
|
85
|
+
[".simple-git-hooks.js"],
|
|
86
|
+
[".simple-git-hooks.cjs"],
|
|
87
|
+
["simple-git-hooks.json"],
|
|
88
|
+
["simple-git-hooks.js"],
|
|
89
|
+
["simple-git-hooks.cjs"],
|
|
90
|
+
// the conventional core.hooksPath directory a repository's existing config may name
|
|
91
|
+
[".githooks"],
|
|
92
|
+
].map((entry) => Object.freeze(entry)));
|
|
93
|
+
/** Directories inside a gitdir whose whole subtree is writable (objects, refs, operation state). */
|
|
94
|
+
export const SANDBOX_GIT_ALLOWED_DIRECTORIES = Object.freeze([
|
|
95
|
+
"objects",
|
|
96
|
+
"refs",
|
|
97
|
+
"logs",
|
|
98
|
+
"rebase-merge",
|
|
99
|
+
"rebase-apply",
|
|
100
|
+
"sequencer",
|
|
101
|
+
]);
|
|
102
|
+
/** Entries directly in a gitdir that are writable, each also with a `.lock` suffix. */
|
|
103
|
+
export const SANDBOX_GIT_ALLOWED_FILES = Object.freeze([
|
|
104
|
+
"index",
|
|
105
|
+
"head",
|
|
106
|
+
"orig_head",
|
|
107
|
+
"fetch_head",
|
|
108
|
+
"merge_head",
|
|
109
|
+
"merge_msg",
|
|
110
|
+
"merge_mode",
|
|
111
|
+
"merge_rr",
|
|
112
|
+
"auto_merge",
|
|
113
|
+
"cherry_pick_head",
|
|
114
|
+
"revert_head",
|
|
115
|
+
"rebase_head",
|
|
116
|
+
"bisect_log",
|
|
117
|
+
"bisect_start",
|
|
118
|
+
"bisect_expected_rev",
|
|
119
|
+
"bisect_ancestors_ok",
|
|
120
|
+
"bisect_names",
|
|
121
|
+
"bisect_terms",
|
|
122
|
+
"packed-refs",
|
|
123
|
+
"packed-refs.new",
|
|
124
|
+
"merge_autostash",
|
|
125
|
+
"commit_editmsg",
|
|
126
|
+
"tag_editmsg",
|
|
127
|
+
"squash_msg",
|
|
128
|
+
"shallow",
|
|
129
|
+
"description",
|
|
130
|
+
"gc.pid",
|
|
131
|
+
"gc.log",
|
|
132
|
+
"info",
|
|
133
|
+
"modules",
|
|
134
|
+
"worktrees",
|
|
135
|
+
]);
|
|
136
|
+
/** Gitdir entries a submodule path must never be readable as. */
|
|
137
|
+
const GIT_DANGER = new Set(["config", "config.worktree", "commondir", "gitdir", "hooks", "info"]);
|
|
138
|
+
/**
|
|
139
|
+
* For consumers that can only express denies as path patterns (the macOS runtime): the gitdir
|
|
140
|
+
* internals that run or redirect code, denied at any depth below `.git`. Such a consumer cannot
|
|
141
|
+
* express the allowlist or the `HEAD` rule exactly; see the rules above.
|
|
142
|
+
*/
|
|
143
|
+
export const SANDBOX_GIT_DENIED_INTERNALS = Object.freeze([
|
|
144
|
+
"config",
|
|
145
|
+
"config.worktree",
|
|
146
|
+
"commondir",
|
|
147
|
+
"gitdir",
|
|
148
|
+
"hooks",
|
|
149
|
+
"info/attributes",
|
|
150
|
+
]);
|
|
151
|
+
/** Names nothing leaves, and no directory is moved under, from outside. */
|
|
152
|
+
export const SANDBOX_PROTECTED_PATH_NAMES = Object.freeze([
|
|
153
|
+
".git",
|
|
154
|
+
...new Set(SANDBOX_MANDATORY_WRITE_DENIES.map((entry) => entry[0])),
|
|
155
|
+
]);
|
|
156
|
+
/**
|
|
157
|
+
* Python's `str.casefold` where it differs from `toLowerCase` (full case folding, Unicode 15.1),
|
|
158
|
+
* so both implementations fold identically: `ß`→`ss`, `ſ`→`s`, final sigma, Cherokee, ….
|
|
159
|
+
*/
|
|
160
|
+
const CASEFOLD_DIFF = Object.freeze({
|
|
161
|
+
181: "\u03bc",
|
|
162
|
+
223: "ss",
|
|
163
|
+
329: "\u02bcn",
|
|
164
|
+
383: "s",
|
|
165
|
+
496: "j\u030c",
|
|
166
|
+
837: "\u03b9",
|
|
167
|
+
912: "\u03b9\u0308\u0301",
|
|
168
|
+
944: "\u03c5\u0308\u0301",
|
|
169
|
+
962: "\u03c3",
|
|
170
|
+
976: "\u03b2",
|
|
171
|
+
977: "\u03b8",
|
|
172
|
+
981: "\u03c6",
|
|
173
|
+
982: "\u03c0",
|
|
174
|
+
1008: "\u03ba",
|
|
175
|
+
1009: "\u03c1",
|
|
176
|
+
1013: "\u03b5",
|
|
177
|
+
1415: "\u0565\u0582",
|
|
178
|
+
5024: "\u13a0",
|
|
179
|
+
5025: "\u13a1",
|
|
180
|
+
5026: "\u13a2",
|
|
181
|
+
5027: "\u13a3",
|
|
182
|
+
5028: "\u13a4",
|
|
183
|
+
5029: "\u13a5",
|
|
184
|
+
5030: "\u13a6",
|
|
185
|
+
5031: "\u13a7",
|
|
186
|
+
5032: "\u13a8",
|
|
187
|
+
5033: "\u13a9",
|
|
188
|
+
5034: "\u13aa",
|
|
189
|
+
5035: "\u13ab",
|
|
190
|
+
5036: "\u13ac",
|
|
191
|
+
5037: "\u13ad",
|
|
192
|
+
5038: "\u13ae",
|
|
193
|
+
5039: "\u13af",
|
|
194
|
+
5040: "\u13b0",
|
|
195
|
+
5041: "\u13b1",
|
|
196
|
+
5042: "\u13b2",
|
|
197
|
+
5043: "\u13b3",
|
|
198
|
+
5044: "\u13b4",
|
|
199
|
+
5045: "\u13b5",
|
|
200
|
+
5046: "\u13b6",
|
|
201
|
+
5047: "\u13b7",
|
|
202
|
+
5048: "\u13b8",
|
|
203
|
+
5049: "\u13b9",
|
|
204
|
+
5050: "\u13ba",
|
|
205
|
+
5051: "\u13bb",
|
|
206
|
+
5052: "\u13bc",
|
|
207
|
+
5053: "\u13bd",
|
|
208
|
+
5054: "\u13be",
|
|
209
|
+
5055: "\u13bf",
|
|
210
|
+
5056: "\u13c0",
|
|
211
|
+
5057: "\u13c1",
|
|
212
|
+
5058: "\u13c2",
|
|
213
|
+
5059: "\u13c3",
|
|
214
|
+
5060: "\u13c4",
|
|
215
|
+
5061: "\u13c5",
|
|
216
|
+
5062: "\u13c6",
|
|
217
|
+
5063: "\u13c7",
|
|
218
|
+
5064: "\u13c8",
|
|
219
|
+
5065: "\u13c9",
|
|
220
|
+
5066: "\u13ca",
|
|
221
|
+
5067: "\u13cb",
|
|
222
|
+
5068: "\u13cc",
|
|
223
|
+
5069: "\u13cd",
|
|
224
|
+
5070: "\u13ce",
|
|
225
|
+
5071: "\u13cf",
|
|
226
|
+
5072: "\u13d0",
|
|
227
|
+
5073: "\u13d1",
|
|
228
|
+
5074: "\u13d2",
|
|
229
|
+
5075: "\u13d3",
|
|
230
|
+
5076: "\u13d4",
|
|
231
|
+
5077: "\u13d5",
|
|
232
|
+
5078: "\u13d6",
|
|
233
|
+
5079: "\u13d7",
|
|
234
|
+
5080: "\u13d8",
|
|
235
|
+
5081: "\u13d9",
|
|
236
|
+
5082: "\u13da",
|
|
237
|
+
5083: "\u13db",
|
|
238
|
+
5084: "\u13dc",
|
|
239
|
+
5085: "\u13dd",
|
|
240
|
+
5086: "\u13de",
|
|
241
|
+
5087: "\u13df",
|
|
242
|
+
5088: "\u13e0",
|
|
243
|
+
5089: "\u13e1",
|
|
244
|
+
5090: "\u13e2",
|
|
245
|
+
5091: "\u13e3",
|
|
246
|
+
5092: "\u13e4",
|
|
247
|
+
5093: "\u13e5",
|
|
248
|
+
5094: "\u13e6",
|
|
249
|
+
5095: "\u13e7",
|
|
250
|
+
5096: "\u13e8",
|
|
251
|
+
5097: "\u13e9",
|
|
252
|
+
5098: "\u13ea",
|
|
253
|
+
5099: "\u13eb",
|
|
254
|
+
5100: "\u13ec",
|
|
255
|
+
5101: "\u13ed",
|
|
256
|
+
5102: "\u13ee",
|
|
257
|
+
5103: "\u13ef",
|
|
258
|
+
5104: "\u13f0",
|
|
259
|
+
5105: "\u13f1",
|
|
260
|
+
5106: "\u13f2",
|
|
261
|
+
5107: "\u13f3",
|
|
262
|
+
5108: "\u13f4",
|
|
263
|
+
5109: "\u13f5",
|
|
264
|
+
5112: "\u13f0",
|
|
265
|
+
5113: "\u13f1",
|
|
266
|
+
5114: "\u13f2",
|
|
267
|
+
5115: "\u13f3",
|
|
268
|
+
5116: "\u13f4",
|
|
269
|
+
5117: "\u13f5",
|
|
270
|
+
7296: "\u0432",
|
|
271
|
+
7297: "\u0434",
|
|
272
|
+
7298: "\u043e",
|
|
273
|
+
7299: "\u0441",
|
|
274
|
+
7300: "\u0442",
|
|
275
|
+
7301: "\u0442",
|
|
276
|
+
7302: "\u044a",
|
|
277
|
+
7303: "\u0463",
|
|
278
|
+
7304: "\ua64b",
|
|
279
|
+
7830: "h\u0331",
|
|
280
|
+
7831: "t\u0308",
|
|
281
|
+
7832: "w\u030a",
|
|
282
|
+
7833: "y\u030a",
|
|
283
|
+
7834: "a\u02be",
|
|
284
|
+
7835: "\u1e61",
|
|
285
|
+
7838: "ss",
|
|
286
|
+
8016: "\u03c5\u0313",
|
|
287
|
+
8018: "\u03c5\u0313\u0300",
|
|
288
|
+
8020: "\u03c5\u0313\u0301",
|
|
289
|
+
8022: "\u03c5\u0313\u0342",
|
|
290
|
+
8064: "\u1f00\u03b9",
|
|
291
|
+
8065: "\u1f01\u03b9",
|
|
292
|
+
8066: "\u1f02\u03b9",
|
|
293
|
+
8067: "\u1f03\u03b9",
|
|
294
|
+
8068: "\u1f04\u03b9",
|
|
295
|
+
8069: "\u1f05\u03b9",
|
|
296
|
+
8070: "\u1f06\u03b9",
|
|
297
|
+
8071: "\u1f07\u03b9",
|
|
298
|
+
8072: "\u1f00\u03b9",
|
|
299
|
+
8073: "\u1f01\u03b9",
|
|
300
|
+
8074: "\u1f02\u03b9",
|
|
301
|
+
8075: "\u1f03\u03b9",
|
|
302
|
+
8076: "\u1f04\u03b9",
|
|
303
|
+
8077: "\u1f05\u03b9",
|
|
304
|
+
8078: "\u1f06\u03b9",
|
|
305
|
+
8079: "\u1f07\u03b9",
|
|
306
|
+
8080: "\u1f20\u03b9",
|
|
307
|
+
8081: "\u1f21\u03b9",
|
|
308
|
+
8082: "\u1f22\u03b9",
|
|
309
|
+
8083: "\u1f23\u03b9",
|
|
310
|
+
8084: "\u1f24\u03b9",
|
|
311
|
+
8085: "\u1f25\u03b9",
|
|
312
|
+
8086: "\u1f26\u03b9",
|
|
313
|
+
8087: "\u1f27\u03b9",
|
|
314
|
+
8088: "\u1f20\u03b9",
|
|
315
|
+
8089: "\u1f21\u03b9",
|
|
316
|
+
8090: "\u1f22\u03b9",
|
|
317
|
+
8091: "\u1f23\u03b9",
|
|
318
|
+
8092: "\u1f24\u03b9",
|
|
319
|
+
8093: "\u1f25\u03b9",
|
|
320
|
+
8094: "\u1f26\u03b9",
|
|
321
|
+
8095: "\u1f27\u03b9",
|
|
322
|
+
8096: "\u1f60\u03b9",
|
|
323
|
+
8097: "\u1f61\u03b9",
|
|
324
|
+
8098: "\u1f62\u03b9",
|
|
325
|
+
8099: "\u1f63\u03b9",
|
|
326
|
+
8100: "\u1f64\u03b9",
|
|
327
|
+
8101: "\u1f65\u03b9",
|
|
328
|
+
8102: "\u1f66\u03b9",
|
|
329
|
+
8103: "\u1f67\u03b9",
|
|
330
|
+
8104: "\u1f60\u03b9",
|
|
331
|
+
8105: "\u1f61\u03b9",
|
|
332
|
+
8106: "\u1f62\u03b9",
|
|
333
|
+
8107: "\u1f63\u03b9",
|
|
334
|
+
8108: "\u1f64\u03b9",
|
|
335
|
+
8109: "\u1f65\u03b9",
|
|
336
|
+
8110: "\u1f66\u03b9",
|
|
337
|
+
8111: "\u1f67\u03b9",
|
|
338
|
+
8114: "\u1f70\u03b9",
|
|
339
|
+
8115: "\u03b1\u03b9",
|
|
340
|
+
8116: "\u03ac\u03b9",
|
|
341
|
+
8118: "\u03b1\u0342",
|
|
342
|
+
8119: "\u03b1\u0342\u03b9",
|
|
343
|
+
8124: "\u03b1\u03b9",
|
|
344
|
+
8126: "\u03b9",
|
|
345
|
+
8130: "\u1f74\u03b9",
|
|
346
|
+
8131: "\u03b7\u03b9",
|
|
347
|
+
8132: "\u03ae\u03b9",
|
|
348
|
+
8134: "\u03b7\u0342",
|
|
349
|
+
8135: "\u03b7\u0342\u03b9",
|
|
350
|
+
8140: "\u03b7\u03b9",
|
|
351
|
+
8146: "\u03b9\u0308\u0300",
|
|
352
|
+
8147: "\u03b9\u0308\u0301",
|
|
353
|
+
8150: "\u03b9\u0342",
|
|
354
|
+
8151: "\u03b9\u0308\u0342",
|
|
355
|
+
8162: "\u03c5\u0308\u0300",
|
|
356
|
+
8163: "\u03c5\u0308\u0301",
|
|
357
|
+
8164: "\u03c1\u0313",
|
|
358
|
+
8166: "\u03c5\u0342",
|
|
359
|
+
8167: "\u03c5\u0308\u0342",
|
|
360
|
+
8178: "\u1f7c\u03b9",
|
|
361
|
+
8179: "\u03c9\u03b9",
|
|
362
|
+
8180: "\u03ce\u03b9",
|
|
363
|
+
8182: "\u03c9\u0342",
|
|
364
|
+
8183: "\u03c9\u0342\u03b9",
|
|
365
|
+
8188: "\u03c9\u03b9",
|
|
366
|
+
43888: "\u13a0",
|
|
367
|
+
43889: "\u13a1",
|
|
368
|
+
43890: "\u13a2",
|
|
369
|
+
43891: "\u13a3",
|
|
370
|
+
43892: "\u13a4",
|
|
371
|
+
43893: "\u13a5",
|
|
372
|
+
43894: "\u13a6",
|
|
373
|
+
43895: "\u13a7",
|
|
374
|
+
43896: "\u13a8",
|
|
375
|
+
43897: "\u13a9",
|
|
376
|
+
43898: "\u13aa",
|
|
377
|
+
43899: "\u13ab",
|
|
378
|
+
43900: "\u13ac",
|
|
379
|
+
43901: "\u13ad",
|
|
380
|
+
43902: "\u13ae",
|
|
381
|
+
43903: "\u13af",
|
|
382
|
+
43904: "\u13b0",
|
|
383
|
+
43905: "\u13b1",
|
|
384
|
+
43906: "\u13b2",
|
|
385
|
+
43907: "\u13b3",
|
|
386
|
+
43908: "\u13b4",
|
|
387
|
+
43909: "\u13b5",
|
|
388
|
+
43910: "\u13b6",
|
|
389
|
+
43911: "\u13b7",
|
|
390
|
+
43912: "\u13b8",
|
|
391
|
+
43913: "\u13b9",
|
|
392
|
+
43914: "\u13ba",
|
|
393
|
+
43915: "\u13bb",
|
|
394
|
+
43916: "\u13bc",
|
|
395
|
+
43917: "\u13bd",
|
|
396
|
+
43918: "\u13be",
|
|
397
|
+
43919: "\u13bf",
|
|
398
|
+
43920: "\u13c0",
|
|
399
|
+
43921: "\u13c1",
|
|
400
|
+
43922: "\u13c2",
|
|
401
|
+
43923: "\u13c3",
|
|
402
|
+
43924: "\u13c4",
|
|
403
|
+
43925: "\u13c5",
|
|
404
|
+
43926: "\u13c6",
|
|
405
|
+
43927: "\u13c7",
|
|
406
|
+
43928: "\u13c8",
|
|
407
|
+
43929: "\u13c9",
|
|
408
|
+
43930: "\u13ca",
|
|
409
|
+
43931: "\u13cb",
|
|
410
|
+
43932: "\u13cc",
|
|
411
|
+
43933: "\u13cd",
|
|
412
|
+
43934: "\u13ce",
|
|
413
|
+
43935: "\u13cf",
|
|
414
|
+
43936: "\u13d0",
|
|
415
|
+
43937: "\u13d1",
|
|
416
|
+
43938: "\u13d2",
|
|
417
|
+
43939: "\u13d3",
|
|
418
|
+
43940: "\u13d4",
|
|
419
|
+
43941: "\u13d5",
|
|
420
|
+
43942: "\u13d6",
|
|
421
|
+
43943: "\u13d7",
|
|
422
|
+
43944: "\u13d8",
|
|
423
|
+
43945: "\u13d9",
|
|
424
|
+
43946: "\u13da",
|
|
425
|
+
43947: "\u13db",
|
|
426
|
+
43948: "\u13dc",
|
|
427
|
+
43949: "\u13dd",
|
|
428
|
+
43950: "\u13de",
|
|
429
|
+
43951: "\u13df",
|
|
430
|
+
43952: "\u13e0",
|
|
431
|
+
43953: "\u13e1",
|
|
432
|
+
43954: "\u13e2",
|
|
433
|
+
43955: "\u13e3",
|
|
434
|
+
43956: "\u13e4",
|
|
435
|
+
43957: "\u13e5",
|
|
436
|
+
43958: "\u13e6",
|
|
437
|
+
43959: "\u13e7",
|
|
438
|
+
43960: "\u13e8",
|
|
439
|
+
43961: "\u13e9",
|
|
440
|
+
43962: "\u13ea",
|
|
441
|
+
43963: "\u13eb",
|
|
442
|
+
43964: "\u13ec",
|
|
443
|
+
43965: "\u13ed",
|
|
444
|
+
43966: "\u13ee",
|
|
445
|
+
43967: "\u13ef",
|
|
446
|
+
64256: "ff",
|
|
447
|
+
64257: "fi",
|
|
448
|
+
64258: "fl",
|
|
449
|
+
64259: "ffi",
|
|
450
|
+
64260: "ffl",
|
|
451
|
+
64261: "st",
|
|
452
|
+
64262: "st",
|
|
453
|
+
64275: "\u0574\u0576",
|
|
454
|
+
64276: "\u0574\u0565",
|
|
455
|
+
64277: "\u0574\u056b",
|
|
456
|
+
64278: "\u057e\u0576",
|
|
457
|
+
64279: "\u0574\u056d",
|
|
458
|
+
});
|
|
459
|
+
/** NFKC, then full case folding: the same as Python's `normalize("NFKC", s).casefold()`. */
|
|
460
|
+
export function sandboxFoldName(name) {
|
|
461
|
+
let out = "";
|
|
462
|
+
for (const ch of name.normalize("NFKC"))
|
|
463
|
+
out += CASEFOLD_DIFF[ch.codePointAt(0)] ?? ch.toLowerCase();
|
|
464
|
+
return out;
|
|
465
|
+
}
|
|
466
|
+
const fold = sandboxFoldName;
|
|
467
|
+
const parts = (path) => path
|
|
468
|
+
.split("/")
|
|
469
|
+
.filter((part) => part !== "")
|
|
470
|
+
.map(fold);
|
|
471
|
+
/**
|
|
472
|
+
* Whether `prefix` (below the allowlisted directory `head`) is a directory where git itself keeps
|
|
473
|
+
* a `HEAD`: `logs/HEAD`, `logs/refs/remotes/<r>/HEAD`, `refs/remotes/<r>/HEAD`, `sequencer/head`.
|
|
474
|
+
*/
|
|
475
|
+
function holdsHead(head, prefix) {
|
|
476
|
+
if (head === "logs")
|
|
477
|
+
return (prefix.length === 0 ||
|
|
478
|
+
(prefix.length === 3 && prefix[0] === "refs" && prefix[1] === "remotes"));
|
|
479
|
+
if (head === "refs")
|
|
480
|
+
return prefix.length === 2 && prefix[0] === "remotes";
|
|
481
|
+
return head === "sequencer" && prefix.length === 0;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Inside an allowlisted subtree no repository can be forged: no `.git` component, no `HEAD`
|
|
485
|
+
* except where git keeps one, and next to such a `HEAD` no `objects`, `commondir` or `gitdir`
|
|
486
|
+
* (what git needs beside a `HEAD` to take a directory for a gitdir).
|
|
487
|
+
*/
|
|
488
|
+
function subtreeAllowed(head, rest) {
|
|
489
|
+
return rest.every((name, k) => {
|
|
490
|
+
if (name === ".git")
|
|
491
|
+
return false;
|
|
492
|
+
if (name === "head")
|
|
493
|
+
return k === rest.length - 1 && holdsHead(head, rest.slice(0, k));
|
|
494
|
+
if (["objects", "commondir", "gitdir"].includes(name))
|
|
495
|
+
return !holdsHead(head, rest.slice(0, k));
|
|
496
|
+
return true;
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function gitInternalAllowed(rel) {
|
|
500
|
+
if (rel.length === 0)
|
|
501
|
+
return true;
|
|
502
|
+
const head = rel[0];
|
|
503
|
+
if (SANDBOX_GIT_ALLOWED_DIRECTORIES.includes(head))
|
|
504
|
+
return subtreeAllowed(head, rel.slice(1));
|
|
505
|
+
if ((head === "modules" || head === "worktrees") && rel.length > 1) {
|
|
506
|
+
const rest = rel.slice(1);
|
|
507
|
+
if (head === "worktrees")
|
|
508
|
+
return gitInternalAllowed(rest.slice(1));
|
|
509
|
+
const readings = rest.map((_, k) => rest.slice(k + 1));
|
|
510
|
+
if (readings.some((r) => r.length > 0 && GIT_DANGER.has(r[0]) && !gitInternalAllowed(r)))
|
|
511
|
+
return false;
|
|
512
|
+
return readings.some((r) => r.length > 0 && gitInternalAllowed(r));
|
|
513
|
+
}
|
|
514
|
+
if (rel.length === 1) {
|
|
515
|
+
const base = head.endsWith(".lock") ? head.slice(0, -5) : head;
|
|
516
|
+
// git stash's temporary index: index.stash.<pid>
|
|
517
|
+
return SANDBOX_GIT_ALLOWED_FILES.includes(base) || /^index\.stash\.[0-9]+$/.test(base);
|
|
518
|
+
}
|
|
519
|
+
return (head === "info" && rel.length === 2 && ["exclude", "exclude.lock"].includes(rel[1]));
|
|
520
|
+
}
|
|
521
|
+
/** Whether restricted execution may never write `path` (an absolute, normalized path). */
|
|
522
|
+
export function isSandboxWriteDenied(path) {
|
|
523
|
+
const names = parts(path);
|
|
524
|
+
for (const entry of SANDBOX_MANDATORY_WRITE_DENIES)
|
|
525
|
+
for (let i = 0; i + entry.length <= names.length; i++)
|
|
526
|
+
if (entry.every((name, j) => names[i + j] === name))
|
|
527
|
+
return true;
|
|
528
|
+
const git = names.indexOf(".git");
|
|
529
|
+
if (git >= 0)
|
|
530
|
+
return !gitInternalAllowed(names.slice(git + 1));
|
|
531
|
+
return names[names.length - 1] === "head";
|
|
532
|
+
}
|
|
533
|
+
/** Whether a restricted rename or link of `source` to `destination` is refused (rule 4). */
|
|
534
|
+
export function isSandboxMoveDenied(source, destination, sourceIsDirectory) {
|
|
535
|
+
const from = parts(source);
|
|
536
|
+
const to = parts(destination);
|
|
537
|
+
const protectedAt = (names) => names.findIndex((n) => SANDBOX_PROTECTED_PATH_NAMES.includes(n));
|
|
538
|
+
const i = protectedAt(from);
|
|
539
|
+
const samePrefix = (n) => n >= 0 && to.length > n + 1 && from.slice(0, n + 1).every((name, k) => to[k] === name);
|
|
540
|
+
if (i >= 0 && !samePrefix(i))
|
|
541
|
+
return true;
|
|
542
|
+
const j = protectedAt(to);
|
|
543
|
+
if (sourceIsDirectory && j >= 0 && !(i === j && samePrefix(j)))
|
|
544
|
+
return true;
|
|
545
|
+
return !sourceIsDirectory && to[to.length - 1] === ".git";
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* The same policy for the Python consumers (`linux-sandbox.py`, `native-files.py`): defines
|
|
549
|
+
* `write_denied(path)` and `move_denied(source, destination, is_dir)` with identical rules.
|
|
550
|
+
*/
|
|
551
|
+
export const SANDBOX_WRITE_POLICY_PYTHON = `
|
|
552
|
+
import unicodedata as _unicodedata
|
|
553
|
+
WRITE_DENIES = [[_unicodedata.normalize("NFKC", n).casefold() for n in e] for e in ${JSON.stringify(SANDBOX_MANDATORY_WRITE_DENIES)}]
|
|
554
|
+
GIT_ALLOWED_DIRECTORIES = set(${JSON.stringify(SANDBOX_GIT_ALLOWED_DIRECTORIES)})
|
|
555
|
+
GIT_ALLOWED_FILES = set(${JSON.stringify(SANDBOX_GIT_ALLOWED_FILES)})
|
|
556
|
+
GIT_DANGER = set(${JSON.stringify([...GIT_DANGER])})
|
|
557
|
+
PROTECTED_PATH_NAMES = set(${JSON.stringify(SANDBOX_PROTECTED_PATH_NAMES)})
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
def _fold_parts(path):
|
|
561
|
+
return [_unicodedata.normalize("NFKC", p).casefold() for p in path.split("/") if p]
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def _holds_head(head, prefix):
|
|
565
|
+
if head == "logs":
|
|
566
|
+
return not prefix or (len(prefix) == 3 and prefix[0] == "refs" and prefix[1] == "remotes")
|
|
567
|
+
if head == "refs":
|
|
568
|
+
return len(prefix) == 2 and prefix[0] == "remotes"
|
|
569
|
+
return head == "sequencer" and not prefix
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
def _subtree_allowed(head, rest):
|
|
573
|
+
for k, name in enumerate(rest):
|
|
574
|
+
if name == ".git":
|
|
575
|
+
return False
|
|
576
|
+
if name == "head" and not (k == len(rest) - 1 and _holds_head(head, rest[:k])):
|
|
577
|
+
return False
|
|
578
|
+
if name in ("objects", "commondir", "gitdir") and _holds_head(head, rest[:k]):
|
|
579
|
+
return False
|
|
580
|
+
return True
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def _git_internal_allowed(rel):
|
|
584
|
+
if not rel:
|
|
585
|
+
return True
|
|
586
|
+
head = rel[0]
|
|
587
|
+
if head in GIT_ALLOWED_DIRECTORIES:
|
|
588
|
+
return _subtree_allowed(head, rel[1:])
|
|
589
|
+
if head in ("modules", "worktrees") and len(rel) > 1:
|
|
590
|
+
rest = rel[1:]
|
|
591
|
+
if head == "worktrees":
|
|
592
|
+
return _git_internal_allowed(rest[1:])
|
|
593
|
+
readings = [rest[k + 1:] for k in range(len(rest))]
|
|
594
|
+
if any(r and r[0] in GIT_DANGER and not _git_internal_allowed(r) for r in readings):
|
|
595
|
+
return False
|
|
596
|
+
return any(r and _git_internal_allowed(r) for r in readings)
|
|
597
|
+
if len(rel) == 1:
|
|
598
|
+
base = head[:-5] if head.endswith(".lock") else head
|
|
599
|
+
stash = base.startswith("index.stash.") and base[12:].isascii() and base[12:].isdigit()
|
|
600
|
+
return base in GIT_ALLOWED_FILES or stash
|
|
601
|
+
return head == "info" and len(rel) == 2 and rel[1] in ("exclude", "exclude.lock")
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def write_denied(path):
|
|
605
|
+
names = _fold_parts(path)
|
|
606
|
+
for entry in WRITE_DENIES:
|
|
607
|
+
for i in range(len(names) - len(entry) + 1):
|
|
608
|
+
if names[i:i + len(entry)] == entry:
|
|
609
|
+
return True
|
|
610
|
+
if ".git" in names:
|
|
611
|
+
return not _git_internal_allowed(names[names.index(".git") + 1:])
|
|
612
|
+
return bool(names) and names[-1] == "head"
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
def move_denied(source, destination, is_dir):
|
|
616
|
+
src, dst = _fold_parts(source), _fold_parts(destination)
|
|
617
|
+
|
|
618
|
+
def protected_at(names):
|
|
619
|
+
return next((k for k, n in enumerate(names) if n in PROTECTED_PATH_NAMES), -1)
|
|
620
|
+
|
|
621
|
+
def same_prefix(n):
|
|
622
|
+
return n >= 0 and len(dst) > n + 1 and dst[:n + 1] == src[:n + 1]
|
|
623
|
+
i = protected_at(src)
|
|
624
|
+
if i >= 0 and not same_prefix(i):
|
|
625
|
+
return True
|
|
626
|
+
j = protected_at(dst)
|
|
627
|
+
if is_dir and j >= 0 and not (i == j and same_prefix(j)):
|
|
628
|
+
return True
|
|
629
|
+
return (not is_dir) and bool(dst) and dst[-1] == ".git"
|
|
630
|
+
`;
|