@bramvanoploo/sandbox-runtime 0.0.0-stage → 0.5.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.
- package/LICENSE +201 -0
- package/README.md +93 -2
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +285 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox/credential-decode.d.ts +87 -0
- package/dist/sandbox/credential-decode.d.ts.map +1 -0
- package/dist/sandbox/credential-decode.js +143 -0
- package/dist/sandbox/credential-decode.js.map +1 -0
- package/dist/sandbox/credential-extract.d.ts +67 -0
- package/dist/sandbox/credential-extract.d.ts.map +1 -0
- package/dist/sandbox/credential-extract.js +122 -0
- package/dist/sandbox/credential-extract.js.map +1 -0
- package/dist/sandbox/credential-mask-env.d.ts +33 -0
- package/dist/sandbox/credential-mask-env.d.ts.map +1 -0
- package/dist/sandbox/credential-mask-env.js +155 -0
- package/dist/sandbox/credential-mask-env.js.map +1 -0
- package/dist/sandbox/credential-mask-files.d.ts +120 -0
- package/dist/sandbox/credential-mask-files.d.ts.map +1 -0
- package/dist/sandbox/credential-mask-files.js +285 -0
- package/dist/sandbox/credential-mask-files.js.map +1 -0
- package/dist/sandbox/credential-sentinel.d.ts +88 -0
- package/dist/sandbox/credential-sentinel.d.ts.map +1 -0
- package/dist/sandbox/credential-sentinel.js +177 -0
- package/dist/sandbox/credential-sentinel.js.map +1 -0
- package/dist/sandbox/domain-pattern.d.ts +36 -0
- package/dist/sandbox/domain-pattern.d.ts.map +1 -0
- package/dist/sandbox/domain-pattern.js +60 -0
- package/dist/sandbox/domain-pattern.js.map +1 -0
- package/dist/sandbox/generate-seccomp-filter.d.ts +20 -0
- package/dist/sandbox/generate-seccomp-filter.d.ts.map +1 -0
- package/dist/sandbox/generate-seccomp-filter.js +168 -0
- package/dist/sandbox/generate-seccomp-filter.js.map +1 -0
- package/dist/sandbox/http-proxy.d.ts +85 -0
- package/dist/sandbox/http-proxy.d.ts.map +1 -0
- package/dist/sandbox/http-proxy.js +379 -0
- package/dist/sandbox/http-proxy.js.map +1 -0
- package/dist/sandbox/linux-sandbox-utils.d.ts +162 -0
- package/dist/sandbox/linux-sandbox-utils.d.ts.map +1 -0
- package/dist/sandbox/linux-sandbox-utils.js +1179 -0
- package/dist/sandbox/linux-sandbox-utils.js.map +1 -0
- package/dist/sandbox/linux-violation-monitor.d.ts +48 -0
- package/dist/sandbox/linux-violation-monitor.d.ts.map +1 -0
- package/dist/sandbox/linux-violation-monitor.js +168 -0
- package/dist/sandbox/linux-violation-monitor.js.map +1 -0
- package/dist/sandbox/listen-in-range.d.ts +12 -0
- package/dist/sandbox/listen-in-range.d.ts.map +1 -0
- package/dist/sandbox/listen-in-range.js +43 -0
- package/dist/sandbox/listen-in-range.js.map +1 -0
- package/dist/sandbox/macos-sandbox-utils.d.ts +57 -0
- package/dist/sandbox/macos-sandbox-utils.d.ts.map +1 -0
- package/dist/sandbox/macos-sandbox-utils.js +810 -0
- package/dist/sandbox/macos-sandbox-utils.js.map +1 -0
- package/dist/sandbox/mitm-ca.d.ts +112 -0
- package/dist/sandbox/mitm-ca.d.ts.map +1 -0
- package/dist/sandbox/mitm-ca.js +380 -0
- package/dist/sandbox/mitm-ca.js.map +1 -0
- package/dist/sandbox/mitm-leaf.d.ts +28 -0
- package/dist/sandbox/mitm-leaf.d.ts.map +1 -0
- package/dist/sandbox/mitm-leaf.js +132 -0
- package/dist/sandbox/mitm-leaf.js.map +1 -0
- package/dist/sandbox/mux-proxy.d.ts +59 -0
- package/dist/sandbox/mux-proxy.d.ts.map +1 -0
- package/dist/sandbox/mux-proxy.js +161 -0
- package/dist/sandbox/mux-proxy.js.map +1 -0
- package/dist/sandbox/parent-proxy.d.ts +118 -0
- package/dist/sandbox/parent-proxy.d.ts.map +1 -0
- package/dist/sandbox/parent-proxy.js +469 -0
- package/dist/sandbox/parent-proxy.js.map +1 -0
- package/dist/sandbox/request-filter.d.ts +56 -0
- package/dist/sandbox/request-filter.d.ts.map +1 -0
- package/dist/sandbox/request-filter.js +109 -0
- package/dist/sandbox/request-filter.js.map +1 -0
- package/dist/sandbox/sandbox-config.d.ts +1347 -0
- package/dist/sandbox/sandbox-config.d.ts.map +1 -0
- package/dist/sandbox/sandbox-config.js +917 -0
- package/dist/sandbox/sandbox-config.js.map +1 -0
- package/dist/sandbox/sandbox-manager.d.ts +48 -0
- package/dist/sandbox/sandbox-manager.d.ts.map +1 -0
- package/dist/sandbox/sandbox-manager.js +1498 -0
- package/dist/sandbox/sandbox-manager.js.map +1 -0
- package/dist/sandbox/sandbox-schemas.d.ts +90 -0
- package/dist/sandbox/sandbox-schemas.d.ts.map +1 -0
- package/dist/sandbox/sandbox-schemas.js +3 -0
- package/dist/sandbox/sandbox-schemas.js.map +1 -0
- package/dist/sandbox/sandbox-temp-dir.d.ts +9 -0
- package/dist/sandbox/sandbox-temp-dir.d.ts.map +1 -0
- package/dist/sandbox/sandbox-temp-dir.js +73 -0
- package/dist/sandbox/sandbox-temp-dir.js.map +1 -0
- package/dist/sandbox/sandbox-utils.d.ts +121 -0
- package/dist/sandbox/sandbox-utils.d.ts.map +1 -0
- package/dist/sandbox/sandbox-utils.js +642 -0
- package/dist/sandbox/sandbox-utils.js.map +1 -0
- package/dist/sandbox/sandbox-violation-store.d.ts +19 -0
- package/dist/sandbox/sandbox-violation-store.d.ts.map +1 -0
- package/dist/sandbox/sandbox-violation-store.js +57 -0
- package/dist/sandbox/sandbox-violation-store.js.map +1 -0
- package/dist/sandbox/socks-proxy.d.ts +38 -0
- package/dist/sandbox/socks-proxy.d.ts.map +1 -0
- package/dist/sandbox/socks-proxy.js +123 -0
- package/dist/sandbox/socks-proxy.js.map +1 -0
- package/dist/sandbox/tls-terminate-proxy.d.ts +63 -0
- package/dist/sandbox/tls-terminate-proxy.d.ts.map +1 -0
- package/dist/sandbox/tls-terminate-proxy.js +332 -0
- package/dist/sandbox/tls-terminate-proxy.js.map +1 -0
- package/dist/sandbox/windows-sandbox-utils.d.ts +625 -0
- package/dist/sandbox/windows-sandbox-utils.d.ts.map +1 -0
- package/dist/sandbox/windows-sandbox-utils.js +982 -0
- package/dist/sandbox/windows-sandbox-utils.js.map +1 -0
- package/dist/utils/config-loader.d.ts +24 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +65 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/debug.d.ts +7 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +25 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/platform.d.ts +15 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +52 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell-quote.d.ts +27 -0
- package/dist/utils/shell-quote.d.ts.map +1 -0
- package/dist/utils/shell-quote.js +47 -0
- package/dist/utils/shell-quote.js.map +1 -0
- package/dist/utils/which.d.ts +9 -0
- package/dist/utils/which.d.ts.map +1 -0
- package/dist/utils/which.js +28 -0
- package/dist/utils/which.js.map +1 -0
- package/package.json +85 -4
- package/vendor/seccomp/x64/apply-seccomp +0 -0
|
@@ -0,0 +1,642 @@
|
|
|
1
|
+
import { homedir } from 'os';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import { getPlatform } from '../utils/platform.js';
|
|
5
|
+
import { logForDebugging } from '../utils/debug.js';
|
|
6
|
+
import { DEFAULT_SANDBOX_TMPDIR, resolveSandboxTmpdir, } from './sandbox-temp-dir.js';
|
|
7
|
+
/**
|
|
8
|
+
* Check if a path pattern contains glob characters
|
|
9
|
+
*/
|
|
10
|
+
export function containsGlobChars(pathPattern) {
|
|
11
|
+
return (pathPattern.includes('*') ||
|
|
12
|
+
pathPattern.includes('?') ||
|
|
13
|
+
pathPattern.includes('[') ||
|
|
14
|
+
pathPattern.includes(']'));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Windows-specific glob-char check. `[` and `]` are NOT
|
|
18
|
+
* metachars here — they are legal in Win32 filenames, so a
|
|
19
|
+
* literal `C:\app\[prod].env` must route to the literal-path
|
|
20
|
+
* branch, not glob expansion (where it would match nothing and
|
|
21
|
+
* be silently dropped). Only `*` and `?` trigger expansion.
|
|
22
|
+
*/
|
|
23
|
+
export function containsGlobCharsWin(p) {
|
|
24
|
+
return p.includes('*') || p.includes('?');
|
|
25
|
+
}
|
|
26
|
+
/** Platform-appropriate glob-char check. */
|
|
27
|
+
function containsGlobCharsForPlatform(p) {
|
|
28
|
+
return getPlatform() === 'windows'
|
|
29
|
+
? containsGlobCharsWin(p)
|
|
30
|
+
: containsGlobChars(p);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Strip the Win32 `\\?\` extended-path prefix so the residue is
|
|
34
|
+
* a conventional absolute path (drive-letter or UNC) with no `?`
|
|
35
|
+
* for the glob-char check to misclassify. `\\?\UNC\srv\share\f`
|
|
36
|
+
* → `\\srv\share\f`; `\\?\C:\f` → `C:\f`; anything else → input.
|
|
37
|
+
* The UNC marker is matched case-insensitively (Windows accepts
|
|
38
|
+
* `\\?\unc\…` in any casing; a case-sensitive check would fall
|
|
39
|
+
* through to the 4-char strip and yield a cwd-relative residue).
|
|
40
|
+
*/
|
|
41
|
+
export function stripExtendedPathPrefix(p) {
|
|
42
|
+
if (/^\\\\\?\\unc\\/i.test(p))
|
|
43
|
+
return '\\\\' + p.slice(8);
|
|
44
|
+
if (p.startsWith('\\\\?\\'))
|
|
45
|
+
return p.slice(4);
|
|
46
|
+
return p;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Remove trailing /** (or \** on Windows) glob suffix from a path pattern
|
|
50
|
+
* when no earlier glob metacharacters remain, since dir/** just means
|
|
51
|
+
* "directory and everything under it". If earlier glob characters are present
|
|
52
|
+
* (e.g. /Users/*\/.ssh/**), keep the suffix so regex/expansion still matches
|
|
53
|
+
* descendants.
|
|
54
|
+
*/
|
|
55
|
+
export function removeTrailingGlobSuffix(pathPattern) {
|
|
56
|
+
const stripped = getPlatform() === 'windows'
|
|
57
|
+
? pathPattern.replace(/[/\\]\*\*$/, '')
|
|
58
|
+
: pathPattern.replace(/\/\*\*$/, '');
|
|
59
|
+
if (stripped === pathPattern)
|
|
60
|
+
return pathPattern || '/';
|
|
61
|
+
if (containsGlobCharsForPlatform(stripped))
|
|
62
|
+
return pathPattern;
|
|
63
|
+
return stripped || '/';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract the static base directory before any glob characters, or undefined
|
|
67
|
+
* if the glob starts at the filesystem root (or Windows drive root).
|
|
68
|
+
*/
|
|
69
|
+
export function globBaseDir(normalizedPattern, isWindows = getPlatform() === 'windows') {
|
|
70
|
+
const splitRe = isWindows ? /[*?]/ : /[*?[\]]/;
|
|
71
|
+
const staticPrefix = normalizedPattern.split(splitRe)[0];
|
|
72
|
+
if (!staticPrefix || staticPrefix === '/')
|
|
73
|
+
return undefined;
|
|
74
|
+
let baseDir;
|
|
75
|
+
if (staticPrefix.endsWith('/') ||
|
|
76
|
+
(isWindows && staticPrefix.endsWith('\\'))) {
|
|
77
|
+
baseDir = /^[A-Za-z]:[/\\]$/.test(staticPrefix)
|
|
78
|
+
? staticPrefix
|
|
79
|
+
: staticPrefix.slice(0, -1);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
baseDir = isWindows
|
|
83
|
+
? path.win32.dirname(staticPrefix)
|
|
84
|
+
: path.dirname(staticPrefix);
|
|
85
|
+
}
|
|
86
|
+
if (!baseDir ||
|
|
87
|
+
baseDir === '/' ||
|
|
88
|
+
(isWindows && /^[A-Za-z]:[/\\]?$/.test(baseDir))) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return baseDir;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if a symlink resolution crosses expected path boundaries.
|
|
95
|
+
*
|
|
96
|
+
* When resolving symlinks for sandbox path normalization, we need to ensure
|
|
97
|
+
* the resolved path doesn't unexpectedly broaden the scope. This function
|
|
98
|
+
* returns true if the resolved path is an ancestor of the original path
|
|
99
|
+
* or resolves to a system root, which would indicate the symlink points
|
|
100
|
+
* outside expected boundaries.
|
|
101
|
+
*
|
|
102
|
+
* @param originalPath - The original path before symlink resolution
|
|
103
|
+
* @param resolvedPath - The path after fs.realpathSync() resolution
|
|
104
|
+
* @returns true if the resolved path is outside expected boundaries
|
|
105
|
+
*/
|
|
106
|
+
export function isSymlinkOutsideBoundary(originalPath, resolvedPath) {
|
|
107
|
+
const toSlash = (p) => getPlatform() === 'windows' ? p.replace(/\\/g, '/') : p;
|
|
108
|
+
const normalizedOriginal = toSlash(path.normalize(originalPath));
|
|
109
|
+
const normalizedResolved = toSlash(path.normalize(resolvedPath));
|
|
110
|
+
// Same path after normalization - OK
|
|
111
|
+
if (normalizedResolved === normalizedOriginal) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
// Handle macOS /tmp -> /private/tmp and /var -> /private/var canonical resolution
|
|
115
|
+
if (normalizedOriginal.startsWith('/tmp/') &&
|
|
116
|
+
normalizedResolved === '/private' + normalizedOriginal) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (normalizedOriginal.startsWith('/var/') &&
|
|
120
|
+
normalizedResolved === '/private' + normalizedOriginal) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
// If resolved path is root ("/" or "C:/") it's outside expected boundaries
|
|
124
|
+
if (normalizedResolved === '/' || /^[A-Za-z]:\/?$/.test(normalizedResolved)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
// If resolved path is very short (single component like /tmp, /usr, /var, or C:/Windows),
|
|
128
|
+
// it's likely outside expected boundaries
|
|
129
|
+
const resolvedParts = normalizedResolved.split('/').filter(Boolean);
|
|
130
|
+
const minDepth = /^[A-Za-z]:/.test(normalizedResolved) ? 2 : 1;
|
|
131
|
+
if (resolvedParts.length <= minDepth) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
// If original path starts with resolved path, the resolved path is an ancestor
|
|
135
|
+
// e.g., /tmp/claude -> /tmp means the symlink points to a broader scope
|
|
136
|
+
const resolvedPrefix = normalizedResolved.endsWith('/')
|
|
137
|
+
? normalizedResolved
|
|
138
|
+
: normalizedResolved + '/';
|
|
139
|
+
if (normalizedOriginal.startsWith(resolvedPrefix)) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
// Also check the canonical form of the original path for macOS
|
|
143
|
+
// e.g., /tmp/claude should also be checked as /private/tmp/claude
|
|
144
|
+
let canonicalOriginal = normalizedOriginal;
|
|
145
|
+
if (normalizedOriginal.startsWith('/tmp/')) {
|
|
146
|
+
canonicalOriginal = '/private' + normalizedOriginal;
|
|
147
|
+
}
|
|
148
|
+
else if (normalizedOriginal.startsWith('/var/')) {
|
|
149
|
+
canonicalOriginal = '/private' + normalizedOriginal;
|
|
150
|
+
}
|
|
151
|
+
if (canonicalOriginal !== normalizedOriginal &&
|
|
152
|
+
canonicalOriginal.startsWith(resolvedPrefix)) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
// STRICT CHECK: Only allow resolutions that stay within the expected path tree
|
|
156
|
+
// (deeper under the original or canonical original path).
|
|
157
|
+
const originalPrefix = normalizedOriginal.endsWith('/')
|
|
158
|
+
? normalizedOriginal
|
|
159
|
+
: normalizedOriginal + '/';
|
|
160
|
+
const resolvedStartsWithOriginal = normalizedResolved.startsWith(originalPrefix);
|
|
161
|
+
const resolvedStartsWithCanonical = canonicalOriginal !== normalizedOriginal &&
|
|
162
|
+
normalizedResolved.startsWith(canonicalOriginal.endsWith('/')
|
|
163
|
+
? canonicalOriginal
|
|
164
|
+
: canonicalOriginal + '/');
|
|
165
|
+
if (!resolvedStartsWithOriginal && !resolvedStartsWithCanonical) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Expand a leading `~` to the home directory. Handles bare `~`,
|
|
172
|
+
* `~/…`, and (on Windows only) the `~\…` form so callers don't each
|
|
173
|
+
* open-code the variants. `~\` is gated to Windows because `\` is a
|
|
174
|
+
* valid POSIX filename byte — `~\foo` is a legal relative filename
|
|
175
|
+
* on Linux/macOS and must NOT tilde-expand there.
|
|
176
|
+
*/
|
|
177
|
+
export function expandTilde(p) {
|
|
178
|
+
if (p === '~')
|
|
179
|
+
return homedir();
|
|
180
|
+
if (p.startsWith('~/') ||
|
|
181
|
+
(process.platform === 'win32' && p.startsWith('~\\'))) {
|
|
182
|
+
return homedir() + p.slice(1);
|
|
183
|
+
}
|
|
184
|
+
return p;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Expand Windows-style `%USERPROFILE%` / `%HOMEDRIVE%` / `%HOMEPATH%`
|
|
188
|
+
* references to the real user's home directory. Case-insensitive;
|
|
189
|
+
* idempotent. Applied by {@link normalizePathForSandbox}'s Windows
|
|
190
|
+
* pre-processing so every filesystem-config path field
|
|
191
|
+
* (`allowRead`/`allowWrite`/`denyRead`/`denyWrite`) accepts these
|
|
192
|
+
* forms uniformly.
|
|
193
|
+
*
|
|
194
|
+
* `%HOMEPATH%` is drive-RELATIVE (`\Users\name`) and `%HOMEDRIVE%` is
|
|
195
|
+
* the drive-only (`C:`) — the split matches how cmd.exe defines them,
|
|
196
|
+
* so `%HOMEDRIVE%%HOMEPATH%` composes to the full home path.
|
|
197
|
+
*/
|
|
198
|
+
function expandWindowsEnvRefs(p) {
|
|
199
|
+
const home = homedir();
|
|
200
|
+
const drive = /^[A-Za-z]:/.test(home) ? home.slice(0, 2) : '';
|
|
201
|
+
const homePath = drive ? home.slice(2) : home;
|
|
202
|
+
return p
|
|
203
|
+
.replace(/%USERPROFILE%/gi, home)
|
|
204
|
+
.replace(/%HOMEDRIVE%/gi, drive)
|
|
205
|
+
.replace(/%HOMEPATH%/gi, homePath);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Normalize a path for use in sandbox configurations
|
|
209
|
+
* Handles:
|
|
210
|
+
* - Tilde (~) expansion for home directory
|
|
211
|
+
* - Relative paths (./foo, ../foo, etc.) converted to absolute
|
|
212
|
+
* - Absolute paths remain unchanged
|
|
213
|
+
* - Symlinks are resolved to their real paths for non-glob patterns
|
|
214
|
+
* - Glob patterns preserve wildcards after path normalization
|
|
215
|
+
*
|
|
216
|
+
* Returns the absolute path with symlinks resolved (or normalized glob pattern)
|
|
217
|
+
*/
|
|
218
|
+
export function normalizePathForSandbox(pathPattern) {
|
|
219
|
+
const cwd = process.cwd();
|
|
220
|
+
// Windows pre-processing: expand `%USERPROFILE%` / `%HOMEDRIVE%` /
|
|
221
|
+
// `%HOMEPATH%`, strip the `\\?\` / `\\?\UNC\` extended prefix (its
|
|
222
|
+
// `?` is a literal, not a glob char), and uppercase the drive
|
|
223
|
+
// letter so `c:\…` and `C:\…` normalize identically.
|
|
224
|
+
if (getPlatform() === 'windows') {
|
|
225
|
+
pathPattern = stripExtendedPathPrefix(expandWindowsEnvRefs(pathPattern));
|
|
226
|
+
if (/^[a-z]:/.test(pathPattern)) {
|
|
227
|
+
pathPattern = pathPattern[0].toUpperCase() + pathPattern.slice(1);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
let normalizedPath = expandTilde(pathPattern);
|
|
231
|
+
if (normalizedPath !== pathPattern) {
|
|
232
|
+
// tilde was expanded above
|
|
233
|
+
}
|
|
234
|
+
else if (pathPattern.startsWith('./') || pathPattern.startsWith('../')) {
|
|
235
|
+
// Convert relative to absolute based on current working directory
|
|
236
|
+
normalizedPath = path.resolve(cwd, pathPattern);
|
|
237
|
+
}
|
|
238
|
+
else if (!path.isAbsolute(pathPattern)) {
|
|
239
|
+
// Handle other relative paths (e.g., ".", "..", "foo/bar")
|
|
240
|
+
normalizedPath = path.resolve(cwd, pathPattern);
|
|
241
|
+
}
|
|
242
|
+
normalizedPath = path.normalize(normalizedPath);
|
|
243
|
+
// For glob patterns, resolve symlinks for the directory portion only
|
|
244
|
+
if (containsGlobCharsForPlatform(normalizedPath)) {
|
|
245
|
+
const baseDir = globBaseDir(normalizedPath);
|
|
246
|
+
if (baseDir) {
|
|
247
|
+
// Try to resolve symlinks for the base directory
|
|
248
|
+
try {
|
|
249
|
+
const resolvedBaseDir = fs.realpathSync(baseDir);
|
|
250
|
+
// Validate that resolution stays within expected boundaries
|
|
251
|
+
if (!isSymlinkOutsideBoundary(baseDir, resolvedBaseDir)) {
|
|
252
|
+
// Reconstruct the pattern with the resolved directory
|
|
253
|
+
const patternSuffix = normalizedPath.slice(baseDir.length);
|
|
254
|
+
return resolvedBaseDir + patternSuffix;
|
|
255
|
+
}
|
|
256
|
+
// If resolution would broaden scope, keep original pattern
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
// If directory doesn't exist or can't be resolved, keep the original pattern
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return normalizedPath;
|
|
263
|
+
}
|
|
264
|
+
// Resolve symlinks to real paths to avoid bwrap issues
|
|
265
|
+
// Validate that the resolution stays within expected boundaries
|
|
266
|
+
try {
|
|
267
|
+
const resolvedPath = fs.realpathSync(normalizedPath);
|
|
268
|
+
// Only use resolved path if it doesn't cross boundary (e.g., symlink to parent dir)
|
|
269
|
+
if (isSymlinkOutsideBoundary(normalizedPath, resolvedPath)) {
|
|
270
|
+
// Symlink points outside expected boundaries - keep original path
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
normalizedPath = resolvedPath;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
// If path doesn't exist or can't be resolved, keep the normalized path
|
|
278
|
+
}
|
|
279
|
+
return normalizedPath;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get recommended system paths that should be writable for commands to work properly
|
|
283
|
+
*
|
|
284
|
+
* WARNING: These default paths are intentionally broad for compatibility but may
|
|
285
|
+
* allow access to files from other processes. In highly security-sensitive
|
|
286
|
+
* environments, you should configure more restrictive write paths.
|
|
287
|
+
*/
|
|
288
|
+
export function getDefaultWritePaths() {
|
|
289
|
+
const homeDir = homedir();
|
|
290
|
+
const activeTmpdir = resolveSandboxTmpdir();
|
|
291
|
+
const recommendedPaths = [
|
|
292
|
+
'/dev/stdout',
|
|
293
|
+
'/dev/stderr',
|
|
294
|
+
'/dev/null',
|
|
295
|
+
'/dev/tty',
|
|
296
|
+
'/dev/dtracehelper',
|
|
297
|
+
'/dev/autofs_nowait',
|
|
298
|
+
DEFAULT_SANDBOX_TMPDIR,
|
|
299
|
+
`/private${DEFAULT_SANDBOX_TMPDIR}`,
|
|
300
|
+
...(activeTmpdir !== DEFAULT_SANDBOX_TMPDIR
|
|
301
|
+
? [activeTmpdir, `/private${activeTmpdir}`]
|
|
302
|
+
: []),
|
|
303
|
+
path.join(homeDir, '.npm/_logs'),
|
|
304
|
+
path.join(homeDir, '.claude/debug'),
|
|
305
|
+
];
|
|
306
|
+
return recommendedPaths;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Generate proxy environment variables for sandboxed processes
|
|
310
|
+
*/
|
|
311
|
+
/**
|
|
312
|
+
* Per-tool trust-store env vars set to the TLS-termination CA cert path so
|
|
313
|
+
* HTTPS clients in the sandboxed child accept proxy-minted certs.
|
|
314
|
+
*/
|
|
315
|
+
export const CA_TRUST_VARS = [
|
|
316
|
+
'NODE_EXTRA_CA_CERTS',
|
|
317
|
+
'SSL_CERT_FILE',
|
|
318
|
+
'CURL_CA_BUNDLE',
|
|
319
|
+
'REQUESTS_CA_BUNDLE',
|
|
320
|
+
'PIP_CERT',
|
|
321
|
+
'GIT_SSL_CAINFO',
|
|
322
|
+
'AWS_CA_BUNDLE',
|
|
323
|
+
'CARGO_HTTP_CAINFO',
|
|
324
|
+
'DENO_CERT',
|
|
325
|
+
// gcloud ignores SSL_CERT_FILE/REQUESTS_CA_BUNDLE; this is its dedicated
|
|
326
|
+
// override (maps to core/custom_ca_certs_file).
|
|
327
|
+
'CLOUDSDK_CORE_CUSTOM_CA_CERTS_FILE',
|
|
328
|
+
// Nix-built binaries are patched to read this instead of SSL_CERT_FILE, and
|
|
329
|
+
// it's typically pre-set to the Nix system bundle in the parent env, so we
|
|
330
|
+
// must override it explicitly.
|
|
331
|
+
'NIX_SSL_CERT_FILE',
|
|
332
|
+
];
|
|
333
|
+
export function generateProxyEnvVars(httpProxyPort, socksProxyPort, caCertPath, proxyAuthToken, skipTmpdir) {
|
|
334
|
+
// When the proxy requires auth, embed the credential in the URL so clients
|
|
335
|
+
// send Proxy-Authorization automatically. Only the sandbox child sees this
|
|
336
|
+
// env, so the token never reaches host processes.
|
|
337
|
+
const auth = proxyAuthToken ? `srt:${proxyAuthToken}@` : '';
|
|
338
|
+
const envVars = [`SANDBOX_RUNTIME=1`];
|
|
339
|
+
// TMPDIR is overridden so temp-file writers land in a path the FS sandbox
|
|
340
|
+
// allows (getDefaultWritePaths). When filesystem policy is disabled
|
|
341
|
+
// (writeConfig === undefined → skipTmpdir), the host TMPDIR is already
|
|
342
|
+
// writable, so leave it untouched.
|
|
343
|
+
// CLAUDE_CODE_TMPDIR is the current name; CLAUDE_TMPDIR is kept for
|
|
344
|
+
// backwards compatibility (#141).
|
|
345
|
+
if (!skipTmpdir) {
|
|
346
|
+
envVars.push(`TMPDIR=${resolveSandboxTmpdir()}`);
|
|
347
|
+
}
|
|
348
|
+
// When TLS termination is configured, the child only ever sees proxy-minted
|
|
349
|
+
// certs signed by the configured CA. Point the common per-tool trust-store
|
|
350
|
+
// env vars at it so HTTPS clients accept those certs.
|
|
351
|
+
if (caCertPath) {
|
|
352
|
+
for (const v of CA_TRUST_VARS) {
|
|
353
|
+
envVars.push(`${v}=${caCertPath}`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// If no proxy ports provided, return minimal env vars
|
|
357
|
+
if (!httpProxyPort && !socksProxyPort) {
|
|
358
|
+
return envVars;
|
|
359
|
+
}
|
|
360
|
+
// Always set NO_PROXY to exclude localhost and private networks from
|
|
361
|
+
// proxying. *.local is intentionally absent: under network restriction the
|
|
362
|
+
// child has no usable resolver/routes (bwrap --unshare-net on Linux,
|
|
363
|
+
// loopback-only under seatbelt), so a NO_PROXY match makes the client try
|
|
364
|
+
// direct getaddrinfo() and fail. Routing .local hostnames through the proxy
|
|
365
|
+
// lets the parent resolve them (e.g. Kubernetes *.svc.cluster.local).
|
|
366
|
+
const noProxyAddresses = [
|
|
367
|
+
'localhost',
|
|
368
|
+
'127.0.0.1',
|
|
369
|
+
'::1',
|
|
370
|
+
'169.254.0.0/16', // Link-local
|
|
371
|
+
'10.0.0.0/8', // Private network
|
|
372
|
+
'172.16.0.0/12', // Private network
|
|
373
|
+
'192.168.0.0/16', // Private network
|
|
374
|
+
].join(',');
|
|
375
|
+
envVars.push(`NO_PROXY=${noProxyAddresses}`);
|
|
376
|
+
envVars.push(`no_proxy=${noProxyAddresses}`);
|
|
377
|
+
if (httpProxyPort) {
|
|
378
|
+
envVars.push(`HTTP_PROXY=http://${auth}localhost:${httpProxyPort}`);
|
|
379
|
+
envVars.push(`HTTPS_PROXY=http://${auth}localhost:${httpProxyPort}`);
|
|
380
|
+
// Lowercase versions for compatibility with some tools
|
|
381
|
+
envVars.push(`http_proxy=http://${auth}localhost:${httpProxyPort}`);
|
|
382
|
+
envVars.push(`https_proxy=http://${auth}localhost:${httpProxyPort}`);
|
|
383
|
+
if (proxyAuthToken) {
|
|
384
|
+
// Pre-send Basic so git never gets a 407 and never invokes a
|
|
385
|
+
// credential helper for the proxy URL (Windows GCM intercepts the
|
|
386
|
+
// challenge and the URL-embedded password doesn't survive it).
|
|
387
|
+
envVars.push(`GIT_CONFIG_PARAMETERS='http.proxyAuthMethod=basic'`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
// ALL_PROXY: prefer the HTTP proxy URL over SOCKS. httpx (and similar
|
|
391
|
+
// Python clients) eagerly import `socksio` at client construction when
|
|
392
|
+
// ALL_PROXY is a socks5h:// URL and crash with ImportError in envs that
|
|
393
|
+
// lack the package — before any bytes hit the wire, so the mux's
|
|
394
|
+
// protocol sniffing can't help. With the mux serving both protocols on
|
|
395
|
+
// one port, anything that actually speaks SOCKS to this URL still
|
|
396
|
+
// reaches the SOCKS handler, so nothing is lost by advertising http://.
|
|
397
|
+
// Falls back to socks5h:// only when no HTTP proxy port exists, which no
|
|
398
|
+
// current caller configures.
|
|
399
|
+
const allProxy = httpProxyPort
|
|
400
|
+
? `http://${auth}localhost:${httpProxyPort}`
|
|
401
|
+
: `socks5h://${auth}localhost:${socksProxyPort}`;
|
|
402
|
+
envVars.push(`ALL_PROXY=${allProxy}`);
|
|
403
|
+
envVars.push(`all_proxy=${allProxy}`);
|
|
404
|
+
if (socksProxyPort) {
|
|
405
|
+
// Configure Git to use SSH through the proxy so DNS resolution happens outside the sandbox.
|
|
406
|
+
// ControlMaster/ControlPath are disabled because SSH connection multiplexing breaks inside
|
|
407
|
+
// the sandbox: the mux socket path from the user's ssh config (typically under ~/.ssh) is
|
|
408
|
+
// not an allowed Unix socket path, and OpenSSH treats a mux listener bind failure as fatal
|
|
409
|
+
// even with ControlMaster=auto — it exits right after authentication, before running the
|
|
410
|
+
// git command. Command-line options take precedence over ssh_config, so this neutralizes
|
|
411
|
+
// any user ControlMaster setup. ControlPath=none is needed in addition to ControlMaster=no:
|
|
412
|
+
// with ControlMaster=no alone, ssh still tries to connect to an existing mux socket at the
|
|
413
|
+
// configured ControlPath.
|
|
414
|
+
const sshMuxOverride = '-o ControlMaster=no -o ControlPath=none';
|
|
415
|
+
const platform = getPlatform();
|
|
416
|
+
if (platform === 'macos') {
|
|
417
|
+
// macOS: use BSD nc SOCKS5 proxy support (-X 5 -x). nc has no SOCKS5
|
|
418
|
+
// auth, so when proxyAuthToken is set, git-over-ssh fails at the SOCKS
|
|
419
|
+
// handshake — use git-over-https (HTTP_PROXY carries the credential).
|
|
420
|
+
envVars.push(`GIT_SSH_COMMAND=ssh ${sshMuxOverride} -o ProxyCommand='nc -X 5 -x localhost:${socksProxyPort} %h %p'`);
|
|
421
|
+
}
|
|
422
|
+
else if (platform === 'linux' && httpProxyPort) {
|
|
423
|
+
// Linux: use socat HTTP CONNECT via the HTTP proxy bridge.
|
|
424
|
+
// socat is already a required Linux sandbox dependency, and PROXY: is
|
|
425
|
+
// portable across all socat versions (unlike SOCKS5-CONNECT which needs >= 1.8.0).
|
|
426
|
+
const socatAuth = proxyAuthToken ? `,proxyauth=srt:${proxyAuthToken}` : '';
|
|
427
|
+
envVars.push(`GIT_SSH_COMMAND=ssh ${sshMuxOverride} -o ProxyCommand='socat - PROXY:localhost:%h:%p,proxyport=${httpProxyPort}${socatAuth}'`);
|
|
428
|
+
}
|
|
429
|
+
// FTP proxy support (use socks5h for DNS resolution through proxy)
|
|
430
|
+
envVars.push(`FTP_PROXY=socks5h://${auth}localhost:${socksProxyPort}`);
|
|
431
|
+
envVars.push(`ftp_proxy=socks5h://${auth}localhost:${socksProxyPort}`);
|
|
432
|
+
// rsync proxy support — RSYNC_PROXY is host:port only, no userinfo. With
|
|
433
|
+
// proxy auth on, rsync via this var fails at the CONNECT (407); use SSH
|
|
434
|
+
// transport or wrap with proxychains instead.
|
|
435
|
+
envVars.push(`RSYNC_PROXY=localhost:${socksProxyPort}`);
|
|
436
|
+
// Database tools NOTE: Most database clients don't have built-in proxy support
|
|
437
|
+
// You typically need to use SSH tunneling or a SOCKS wrapper like tsocks/proxychains
|
|
438
|
+
// Docker CLI uses HTTP for the API
|
|
439
|
+
// This makes Docker use the HTTP proxy for registry operations
|
|
440
|
+
envVars.push(`DOCKER_HTTP_PROXY=http://${auth}localhost:${httpProxyPort || socksProxyPort}`);
|
|
441
|
+
envVars.push(`DOCKER_HTTPS_PROXY=http://${auth}localhost:${httpProxyPort || socksProxyPort}`);
|
|
442
|
+
// Kubernetes kubectl - uses standard HTTPS_PROXY
|
|
443
|
+
// kubectl respects HTTPS_PROXY which we already set above
|
|
444
|
+
// AWS CLI - uses standard HTTPS_PROXY (v2 supports it well)
|
|
445
|
+
// AWS CLI v2 respects HTTPS_PROXY which we already set above
|
|
446
|
+
// Google Cloud SDK - has specific proxy settings.
|
|
447
|
+
// proxy/type names the protocol the *proxy* speaks, not the traffic it
|
|
448
|
+
// tunnels. Our HTTP CONNECT proxy carries TLS to Google APIs, so the
|
|
449
|
+
// correct value is "http" (gcloud only accepts http, http_no_tunnel,
|
|
450
|
+
// socks4, socks5; "https" is rejected at startup).
|
|
451
|
+
if (httpProxyPort) {
|
|
452
|
+
envVars.push(`CLOUDSDK_PROXY_TYPE=http`);
|
|
453
|
+
envVars.push(`CLOUDSDK_PROXY_ADDRESS=localhost`);
|
|
454
|
+
envVars.push(`CLOUDSDK_PROXY_PORT=${httpProxyPort}`);
|
|
455
|
+
if (proxyAuthToken) {
|
|
456
|
+
envVars.push(`CLOUDSDK_PROXY_USERNAME=srt`);
|
|
457
|
+
envVars.push(`CLOUDSDK_PROXY_PASSWORD=${proxyAuthToken}`);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
// Azure CLI - uses HTTPS_PROXY
|
|
461
|
+
// Azure CLI respects HTTPS_PROXY which we already set above
|
|
462
|
+
// Terraform - uses standard HTTP/HTTPS proxy vars
|
|
463
|
+
// Terraform respects HTTP_PROXY/HTTPS_PROXY which we already set above
|
|
464
|
+
// gRPC-based tools - use standard proxy vars
|
|
465
|
+
envVars.push(`GRPC_PROXY=socks5h://${auth}localhost:${socksProxyPort}`);
|
|
466
|
+
envVars.push(`grpc_proxy=socks5h://${auth}localhost:${socksProxyPort}`);
|
|
467
|
+
}
|
|
468
|
+
// Do not set HTTP_PROXY/HTTPS_PROXY to SOCKS URLs in the SOCKS-only path:
|
|
469
|
+
// most HTTP clients reject socks*:// in those vars. ALL_PROXY (above)
|
|
470
|
+
// already carries the route for clients that read it.
|
|
471
|
+
return envVars;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Encode a command for sandbox monitoring
|
|
475
|
+
* Truncates to 100 chars and base64 encodes to avoid parsing issues
|
|
476
|
+
*/
|
|
477
|
+
export function encodeSandboxedCommand(command) {
|
|
478
|
+
const truncatedCommand = command.slice(0, 100);
|
|
479
|
+
return Buffer.from(truncatedCommand).toString('base64');
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Decode a base64-encoded command from sandbox monitoring
|
|
483
|
+
*/
|
|
484
|
+
export function decodeSandboxedCommand(encodedCommand) {
|
|
485
|
+
return Buffer.from(encodedCommand, 'base64').toString('utf8');
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Convert a glob pattern to a regular expression
|
|
489
|
+
*
|
|
490
|
+
* This implements gitignore-style pattern matching to match the behavior of the
|
|
491
|
+
* `ignore` library used by the permission system.
|
|
492
|
+
*
|
|
493
|
+
* Supported patterns:
|
|
494
|
+
* - * matches any characters except / (e.g., *.ts matches foo.ts but not foo/bar.ts)
|
|
495
|
+
* - ** matches any characters including / (e.g., src/**\/*.ts matches all .ts files in src/)
|
|
496
|
+
* - ? matches any single character except / (e.g., file?.txt matches file1.txt)
|
|
497
|
+
* - [abc] matches any character in the set (e.g., file[0-9].txt matches file3.txt)
|
|
498
|
+
*
|
|
499
|
+
* Exported for testing and shared between macOS sandbox profiles and Linux glob expansion.
|
|
500
|
+
*/
|
|
501
|
+
function isValidCharClassBody(body) {
|
|
502
|
+
if (!body)
|
|
503
|
+
return false;
|
|
504
|
+
let idx = 0;
|
|
505
|
+
if (body[0] === '!' || body[0] === '^')
|
|
506
|
+
idx++;
|
|
507
|
+
if (idx >= body.length)
|
|
508
|
+
return false;
|
|
509
|
+
// Check for reversed ranges like [z-a] (ignoring leading/trailing '-')
|
|
510
|
+
for (let k = idx + 1; k < body.length - 1; k++) {
|
|
511
|
+
if (body[k] === '-') {
|
|
512
|
+
const lo = body.charCodeAt(k - 1);
|
|
513
|
+
const hi = body.charCodeAt(k + 1);
|
|
514
|
+
if (lo > hi)
|
|
515
|
+
return false;
|
|
516
|
+
k++;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
export function globToRegex(globPattern, opts = {}) {
|
|
522
|
+
let out = '^';
|
|
523
|
+
for (let i = 0; i < globPattern.length; i++) {
|
|
524
|
+
const ch = globPattern[i];
|
|
525
|
+
if (ch === '*') {
|
|
526
|
+
if (globPattern[i + 1] === '*') {
|
|
527
|
+
if (globPattern[i + 2] === '/') {
|
|
528
|
+
out += '(.*/)?';
|
|
529
|
+
i += 2;
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
out += '.*';
|
|
533
|
+
i += 1;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
out += '[^/]*';
|
|
538
|
+
}
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
if (ch === '?') {
|
|
542
|
+
out += '[^/]';
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
if (ch === '[') {
|
|
546
|
+
if (opts.literalBrackets) {
|
|
547
|
+
out += '\\[';
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
const slashIdx = globPattern.indexOf('/', i + 1);
|
|
551
|
+
const closeIdx = globPattern.indexOf(']', i + 1);
|
|
552
|
+
if (closeIdx !== -1 &&
|
|
553
|
+
(slashIdx === -1 || closeIdx < slashIdx) &&
|
|
554
|
+
isValidCharClassBody(globPattern.slice(i + 1, closeIdx))) {
|
|
555
|
+
const rawBody = globPattern.slice(i + 1, closeIdx);
|
|
556
|
+
const neg = rawBody[0] === '!' ? '^' + rawBody.slice(1) : rawBody;
|
|
557
|
+
out += `[${neg.replace(/\\/g, '\\\\')}]`;
|
|
558
|
+
i = closeIdx;
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
out += '\\[';
|
|
562
|
+
}
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
if (ch === ']' && opts.literalBrackets) {
|
|
566
|
+
out += '\\]';
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
if ('.^$+{}()|\\'.includes(ch)) {
|
|
570
|
+
out += '\\' + ch;
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
out += ch;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return out + '$';
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Expand a glob pattern into concrete file paths.
|
|
580
|
+
*
|
|
581
|
+
* Used on Linux (where bubblewrap doesn't support glob patterns
|
|
582
|
+
* natively) and Windows (point-in-time expansion before `srt-win
|
|
583
|
+
* acl stamp`). Resolves the static directory prefix, lists matching
|
|
584
|
+
* directories, and filters using {@link globToRegex}.
|
|
585
|
+
*
|
|
586
|
+
* @param globPath - A path pattern containing glob characters (e.g., ~/test/*.env)
|
|
587
|
+
* @returns Array of absolute paths matching the glob pattern
|
|
588
|
+
*/
|
|
589
|
+
export function expandGlobPattern(globPath, opts = {}) {
|
|
590
|
+
const isWin = process.platform === 'win32';
|
|
591
|
+
// Normalize to `/` separators throughout so {@link globToRegex}
|
|
592
|
+
// (which treats `/` as the segment boundary) and the static-prefix
|
|
593
|
+
// split work on Windows paths. Gated to win32: `\` is a valid
|
|
594
|
+
// filename byte on POSIX, so rewriting it there would change the
|
|
595
|
+
// path (e.g. a Linux directory literally named `app\creds`).
|
|
596
|
+
const toFwd = (s) => (isWin ? s.replace(/\\/g, '/') : s);
|
|
597
|
+
const normalizedPattern = toFwd(normalizePathForSandbox(globPath));
|
|
598
|
+
const baseDir = globBaseDir(normalizedPattern, isWin);
|
|
599
|
+
if (!baseDir) {
|
|
600
|
+
logForDebugging(`[Sandbox] Glob pattern too broad, skipping: ${globPath}`);
|
|
601
|
+
return [];
|
|
602
|
+
}
|
|
603
|
+
if (!fs.existsSync(baseDir)) {
|
|
604
|
+
logForDebugging(`[Sandbox] Base directory for glob does not exist: ${baseDir}`);
|
|
605
|
+
return [];
|
|
606
|
+
}
|
|
607
|
+
const results = [];
|
|
608
|
+
try {
|
|
609
|
+
const regex = new RegExp(globToRegex(normalizedPattern, { literalBrackets: isWin }), opts.caseInsensitive ? 'i' : '');
|
|
610
|
+
const suffix = normalizedPattern.slice(baseDir.length).replace(/^\/+/, '');
|
|
611
|
+
const recursive = suffix.includes('**') || suffix.includes('/');
|
|
612
|
+
// Walk iteratively with per-directory try/catch so a single unreadable
|
|
613
|
+
// subdirectory (e.g., EACCES junction) skips only itself instead of
|
|
614
|
+
// dropping all matches across the pattern.
|
|
615
|
+
const stack = [baseDir];
|
|
616
|
+
while (stack.length > 0) {
|
|
617
|
+
const dir = stack.pop();
|
|
618
|
+
let entries;
|
|
619
|
+
try {
|
|
620
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
621
|
+
}
|
|
622
|
+
catch (err) {
|
|
623
|
+
logForDebugging(`[Sandbox] Skipping unreadable dir during glob expansion ${dir}: ${err}`);
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
for (const entry of entries) {
|
|
627
|
+
const fullPath = path.join(dir, entry.name);
|
|
628
|
+
if (regex.test(toFwd(fullPath))) {
|
|
629
|
+
results.push(fullPath);
|
|
630
|
+
}
|
|
631
|
+
if (recursive && entry.isDirectory()) {
|
|
632
|
+
stack.push(fullPath);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
catch (err) {
|
|
638
|
+
logForDebugging(`[Sandbox] Error expanding glob pattern ${globPath}: ${err}`);
|
|
639
|
+
}
|
|
640
|
+
return results;
|
|
641
|
+
}
|
|
642
|
+
//# sourceMappingURL=sandbox-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-utils.js","sourceRoot":"","sources":["../../src/sandbox/sandbox-utils.ts"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