@voratiq/sandbox-runtime 0.0.29-voratiq0

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 (85) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +12 -0
  4. package/README.md +17 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +158 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/index.d.ts +12 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +9 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/sandbox/generate-seccomp-filter.d.ts +65 -0
  14. package/dist/sandbox/generate-seccomp-filter.d.ts.map +1 -0
  15. package/dist/sandbox/generate-seccomp-filter.js +185 -0
  16. package/dist/sandbox/generate-seccomp-filter.js.map +1 -0
  17. package/dist/sandbox/http-proxy.d.ts +14 -0
  18. package/dist/sandbox/http-proxy.d.ts.map +1 -0
  19. package/dist/sandbox/http-proxy.js +238 -0
  20. package/dist/sandbox/http-proxy.js.map +1 -0
  21. package/dist/sandbox/linux-sandbox-utils.d.ts +121 -0
  22. package/dist/sandbox/linux-sandbox-utils.d.ts.map +1 -0
  23. package/dist/sandbox/linux-sandbox-utils.js +723 -0
  24. package/dist/sandbox/linux-sandbox-utils.js.map +1 -0
  25. package/dist/sandbox/macos-sandbox-utils.d.ts +57 -0
  26. package/dist/sandbox/macos-sandbox-utils.d.ts.map +1 -0
  27. package/dist/sandbox/macos-sandbox-utils.js +611 -0
  28. package/dist/sandbox/macos-sandbox-utils.js.map +1 -0
  29. package/dist/sandbox/observability.d.ts +56 -0
  30. package/dist/sandbox/observability.d.ts.map +1 -0
  31. package/dist/sandbox/observability.js +140 -0
  32. package/dist/sandbox/observability.js.map +1 -0
  33. package/dist/sandbox/sandbox-config.d.ts +277 -0
  34. package/dist/sandbox/sandbox-config.d.ts.map +1 -0
  35. package/dist/sandbox/sandbox-config.js +166 -0
  36. package/dist/sandbox/sandbox-config.js.map +1 -0
  37. package/dist/sandbox/sandbox-manager.d.ts +50 -0
  38. package/dist/sandbox/sandbox-manager.d.ts.map +1 -0
  39. package/dist/sandbox/sandbox-manager.js +816 -0
  40. package/dist/sandbox/sandbox-manager.js.map +1 -0
  41. package/dist/sandbox/sandbox-schemas.d.ts +53 -0
  42. package/dist/sandbox/sandbox-schemas.d.ts.map +1 -0
  43. package/dist/sandbox/sandbox-schemas.js +3 -0
  44. package/dist/sandbox/sandbox-schemas.js.map +1 -0
  45. package/dist/sandbox/sandbox-utils.d.ts +83 -0
  46. package/dist/sandbox/sandbox-utils.d.ts.map +1 -0
  47. package/dist/sandbox/sandbox-utils.js +343 -0
  48. package/dist/sandbox/sandbox-utils.js.map +1 -0
  49. package/dist/sandbox/sandbox-violation-store.d.ts +19 -0
  50. package/dist/sandbox/sandbox-violation-store.d.ts.map +1 -0
  51. package/dist/sandbox/sandbox-violation-store.js +54 -0
  52. package/dist/sandbox/sandbox-violation-store.js.map +1 -0
  53. package/dist/sandbox/socks-proxy.d.ts +14 -0
  54. package/dist/sandbox/socks-proxy.d.ts.map +1 -0
  55. package/dist/sandbox/socks-proxy.js +109 -0
  56. package/dist/sandbox/socks-proxy.js.map +1 -0
  57. package/dist/utils/config-loader.d.ts +11 -0
  58. package/dist/utils/config-loader.d.ts.map +1 -0
  59. package/dist/utils/config-loader.js +60 -0
  60. package/dist/utils/config-loader.js.map +1 -0
  61. package/dist/utils/debug.d.ts +7 -0
  62. package/dist/utils/debug.d.ts.map +1 -0
  63. package/dist/utils/debug.js +25 -0
  64. package/dist/utils/debug.js.map +1 -0
  65. package/dist/utils/platform.d.ts +15 -0
  66. package/dist/utils/platform.d.ts.map +1 -0
  67. package/dist/utils/platform.js +49 -0
  68. package/dist/utils/platform.js.map +1 -0
  69. package/dist/utils/ripgrep.d.ts +20 -0
  70. package/dist/utils/ripgrep.d.ts.map +1 -0
  71. package/dist/utils/ripgrep.js +51 -0
  72. package/dist/utils/ripgrep.js.map +1 -0
  73. package/dist/vendor/seccomp/arm64/apply-seccomp +0 -0
  74. package/dist/vendor/seccomp/arm64/unix-block.bpf +0 -0
  75. package/dist/vendor/seccomp/x64/apply-seccomp +0 -0
  76. package/dist/vendor/seccomp/x64/unix-block.bpf +0 -0
  77. package/dist/vendor/seccomp-src/apply-seccomp.c +98 -0
  78. package/dist/vendor/seccomp-src/seccomp-unix-block.c +97 -0
  79. package/package.json +90 -0
  80. package/vendor/seccomp/arm64/apply-seccomp +0 -0
  81. package/vendor/seccomp/arm64/unix-block.bpf +0 -0
  82. package/vendor/seccomp/x64/apply-seccomp +0 -0
  83. package/vendor/seccomp/x64/unix-block.bpf +0 -0
  84. package/vendor/seccomp-src/apply-seccomp.c +98 -0
  85. package/vendor/seccomp-src/seccomp-unix-block.c +97 -0
@@ -0,0 +1,56 @@
1
+ export type NetworkDecision = 'allow' | 'deny';
2
+ export type NetworkDecisionReason = 'allowlist' | 'denylist' | 'no-match';
3
+ export type NetworkRoute = 'direct' | 'mitm';
4
+ export interface NetworkEvent {
5
+ type: 'network';
6
+ ts: number;
7
+ correlation_id: string;
8
+ host: string;
9
+ port: number;
10
+ decision: NetworkDecision;
11
+ reason: NetworkDecisionReason;
12
+ route: NetworkRoute;
13
+ }
14
+ export type FsViolationOperation = 'read' | 'write';
15
+ export type FsViolationReason = 'denyRead' | 'denyWrite' | 'no-allowWrite';
16
+ export interface FsViolationEvent {
17
+ type: 'fs_violation';
18
+ ts: number;
19
+ correlation_id: string;
20
+ path: string;
21
+ operation: FsViolationOperation;
22
+ reason: FsViolationReason;
23
+ }
24
+ export type SandboxEvent = NetworkEvent | FsViolationEvent;
25
+ export interface SandboxEvents {
26
+ onEvent?: (event: SandboxEvent) => void;
27
+ }
28
+ export interface NetworkFilterResult {
29
+ allowed: boolean;
30
+ reason: NetworkDecisionReason;
31
+ }
32
+ type SandboxEventContext = {
33
+ correlationId?: string;
34
+ onEvent?: (event: SandboxEvent) => void;
35
+ };
36
+ export declare function pushSandboxEventContext(context: SandboxEventContext): () => void;
37
+ export declare function getSandboxEventContextDepth(): number;
38
+ export declare function scrubSecrets(value: unknown): unknown;
39
+ export declare function emitNetworkDecisionEvent(params: {
40
+ host: string;
41
+ port: number;
42
+ decision: NetworkDecision;
43
+ reason: NetworkDecisionReason;
44
+ route: NetworkRoute;
45
+ correlationId?: string;
46
+ ts?: number;
47
+ }): void;
48
+ export declare function emitFsViolationEvent(params: {
49
+ path: string;
50
+ operation: FsViolationOperation;
51
+ reason: FsViolationReason;
52
+ correlationId?: string;
53
+ ts?: number;
54
+ }): void;
55
+ export {};
56
+ //# sourceMappingURL=observability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../../src/sandbox/observability.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAAA;AAC9C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAA;AACzE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE5C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAA;IACf,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,eAAe,CAAA;IACzB,MAAM,EAAE,qBAAqB,CAAA;IAC7B,KAAK,EAAE,YAAY,CAAA;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,CAAA;AACnD,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,GAAG,eAAe,CAAA;AAE1E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,IAA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DACTED]';
2
+ const CLI_FLAG_NAMES = ['token', 'password', 'secret', 'key', 'auth'];
3
+ const SENSITIVE_HEADER_NAMES = [
4
+ 'authorization',
5
+ 'cookie',
6
+ 'x-api-key',
7
+ 'proxy-authorization',
8
+ ];
9
+ const SENSITIVE_QUERY_PARAMS = ['token', 'key', 'secret', 'password', 'auth'];
10
+ const SENSITIVE_ENV_SUFFIXES = [
11
+ '_TOKEN',
12
+ '_KEY',
13
+ '_SECRET',
14
+ '_PASSWORD',
15
+ '_CREDENTIAL',
16
+ ];
17
+ const contextStack = [];
18
+ export function pushSandboxEventContext(context) {
19
+ contextStack.push(context);
20
+ let popped = false;
21
+ return () => {
22
+ if (popped)
23
+ return;
24
+ popped = true;
25
+ const idx = contextStack.lastIndexOf(context);
26
+ if (idx !== -1) {
27
+ contextStack.splice(idx, 1);
28
+ }
29
+ };
30
+ }
31
+ export function getSandboxEventContextDepth() {
32
+ return contextStack.length;
33
+ }
34
+ function getCurrentContext() {
35
+ return contextStack.at(-1);
36
+ }
37
+ function scrubCliFlags(input) {
38
+ let out = input;
39
+ for (const name of CLI_FLAG_NAMES) {
40
+ const re = new RegExp(`(--${name})(\\s+|=)([^\\s]+)`, 'gi');
41
+ out = out.replace(re, `$1$2${REDACTED}`);
42
+ }
43
+ return out;
44
+ }
45
+ function scrubUrlQueryParams(input) {
46
+ const qIndex = input.indexOf('?');
47
+ if (qIndex === -1)
48
+ return input;
49
+ const hashIndex = input.indexOf('#', qIndex);
50
+ const base = input.slice(0, qIndex);
51
+ const query = input.slice(qIndex + 1, hashIndex === -1 ? undefined : hashIndex);
52
+ const hash = hashIndex === -1 ? '' : input.slice(hashIndex);
53
+ const parts = query.split('&').map(part => {
54
+ const eq = part.indexOf('=');
55
+ const rawKey = eq === -1 ? part : part.slice(0, eq);
56
+ const rawValue = eq === -1 ? '' : part.slice(eq + 1);
57
+ let decodedKey = rawKey;
58
+ try {
59
+ decodedKey = decodeURIComponent(rawKey);
60
+ }
61
+ catch {
62
+ // Leave as-is if it contains invalid percent-encoding
63
+ }
64
+ const key = decodedKey.toLowerCase();
65
+ if (SENSITIVE_QUERY_PARAMS.includes(key)) {
66
+ return `${rawKey}=${encodeURIComponent(REDACTED)}`;
67
+ }
68
+ return eq === -1 ? rawKey : `${rawKey}=${rawValue}`;
69
+ });
70
+ return `${base}?${parts.join('&')}${hash}`;
71
+ }
72
+ function scrubString(input) {
73
+ return scrubUrlQueryParams(scrubCliFlags(input));
74
+ }
75
+ function isSensitiveHeaderKey(key) {
76
+ return SENSITIVE_HEADER_NAMES.includes(key.toLowerCase());
77
+ }
78
+ function isSensitiveEnvKey(key) {
79
+ const upper = key.toUpperCase();
80
+ return SENSITIVE_ENV_SUFFIXES.some(suffix => upper.endsWith(suffix));
81
+ }
82
+ export function scrubSecrets(value) {
83
+ if (typeof value === 'string') {
84
+ return scrubString(value);
85
+ }
86
+ if (Array.isArray(value)) {
87
+ return value.map(scrubSecrets);
88
+ }
89
+ if (value && typeof value === 'object') {
90
+ const out = {};
91
+ for (const [key, nested] of Object.entries(value)) {
92
+ if (isSensitiveHeaderKey(key) || isSensitiveEnvKey(key)) {
93
+ out[key] = REDACTED;
94
+ continue;
95
+ }
96
+ out[key] = scrubSecrets(nested);
97
+ }
98
+ return out;
99
+ }
100
+ return value;
101
+ }
102
+ function emitEvent(event) {
103
+ const ctx = getCurrentContext();
104
+ if (!ctx?.onEvent)
105
+ return;
106
+ try {
107
+ const scrubbed = scrubSecrets(event);
108
+ ctx.onEvent(scrubbed);
109
+ }
110
+ catch {
111
+ // Never allow observability to break sandbox enforcement paths
112
+ }
113
+ }
114
+ export function emitNetworkDecisionEvent(params) {
115
+ const ctx = getCurrentContext();
116
+ const correlationId = params.correlationId ?? ctx?.correlationId ?? '';
117
+ emitEvent({
118
+ type: 'network',
119
+ ts: params.ts ?? Date.now(),
120
+ correlation_id: correlationId,
121
+ host: params.host,
122
+ port: params.port,
123
+ decision: params.decision,
124
+ reason: params.reason,
125
+ route: params.route,
126
+ });
127
+ }
128
+ export function emitFsViolationEvent(params) {
129
+ const ctx = getCurrentContext();
130
+ const correlationId = params.correlationId ?? ctx?.correlationId ?? '';
131
+ emitEvent({
132
+ type: 'fs_violation',
133
+ ts: params.ts ?? Date.now(),
134
+ correlation_id: correlationId,
135
+ path: params.path,
136
+ operation: params.operation,
137
+ reason: params.reason,
138
+ });
139
+ }
140
+ //# sourceMappingURL=observability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observability.js","sourceRoot":"","sources":["../../src/sandbox/observability.ts"],"names":[],"mappings":"AAsCA,MAAM,QAAQ,GAAG,YAAY,CAAA;AAE7B,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAU,CAAA;AAC9E,MAAM,sBAAsB,GAAG;IAC7B,eAAe;IACf,QAAQ;IACR,WAAW;IACX,qBAAqB;CACb,CAAA;AACV,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;AAC7E,MAAM,sBAAsB,GAAG;IAC7B,QAAQ;IACR,MAAM;IACN,SAAS;IACT,WAAW;IACX,aAAa;CACL,CAAA;AAOV,MAAM,YAAY,GAA0B,EAAE,CAAA;AAE9C,MAAM,UAAU,uBAAuB,CACrC,OAA4B;IAE5B,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,OAAO,GAAG,EAAE;QACV,IAAI,MAAM;YAAE,OAAM;QAClB,MAAM,GAAG,IAAI,CAAA;QACb,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAC7C,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC,CAAA;AACH,CAAC;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wB,CAAC,MAQxC;IACC,MAAM,GAAG,GAAG,iBAAiB,EAAE,CAAA;IAC/B,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,GAAG,EAAE,aAAa,IAAI,EAAE,CAAA;IAEtE,SAAS,CAAC;QACR,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;QAC3B,cAAc,EAAE,aAAa;QAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAMpC;IACC,MAAM,GAAG,GAAG,iBAAiB,EAAE,CAAA;IAC/B,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,GAAG,EAAE,aAAa,IAAI,EAAE,CAAA;IAEtE,SAAS,CAAC;QACR,IAAI,EAAE,cAAc;QACpB,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;QAC3B,cAAc,EAAE,aAAa;QAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,277 @@
1
+ /**
2
+ * Configuration for Sandbox Runtime
3
+ * This is the main configuration interface that consumers pass to SandboxManager.initialize()
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Schema for MITM proxy configuration
8
+ * Allows routing specific domains through an upstream MITM proxy via Unix socket
9
+ */
10
+ declare const MitmProxyConfigSchema: z.ZodObject<{
11
+ socketPath: z.ZodString;
12
+ domains: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
13
+ }, "strip", z.ZodTypeAny, {
14
+ socketPath: string;
15
+ domains: string[];
16
+ }, {
17
+ socketPath: string;
18
+ domains: string[];
19
+ }>;
20
+ /**
21
+ * Network configuration schema for validation
22
+ */
23
+ export declare const NetworkConfigSchema: z.ZodObject<{
24
+ allowedDomains: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
25
+ deniedDomains: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
26
+ allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
27
+ allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
28
+ allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
29
+ httpProxyPort: z.ZodOptional<z.ZodNumber>;
30
+ socksProxyPort: z.ZodOptional<z.ZodNumber>;
31
+ mitmProxy: z.ZodOptional<z.ZodObject<{
32
+ socketPath: z.ZodString;
33
+ domains: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
34
+ }, "strip", z.ZodTypeAny, {
35
+ socketPath: string;
36
+ domains: string[];
37
+ }, {
38
+ socketPath: string;
39
+ domains: string[];
40
+ }>>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ allowedDomains: string[];
43
+ deniedDomains: string[];
44
+ allowUnixSockets?: string[] | undefined;
45
+ allowAllUnixSockets?: boolean | undefined;
46
+ allowLocalBinding?: boolean | undefined;
47
+ httpProxyPort?: number | undefined;
48
+ socksProxyPort?: number | undefined;
49
+ mitmProxy?: {
50
+ socketPath: string;
51
+ domains: string[];
52
+ } | undefined;
53
+ }, {
54
+ allowedDomains: string[];
55
+ deniedDomains: string[];
56
+ allowUnixSockets?: string[] | undefined;
57
+ allowAllUnixSockets?: boolean | undefined;
58
+ allowLocalBinding?: boolean | undefined;
59
+ httpProxyPort?: number | undefined;
60
+ socksProxyPort?: number | undefined;
61
+ mitmProxy?: {
62
+ socketPath: string;
63
+ domains: string[];
64
+ } | undefined;
65
+ }>;
66
+ /**
67
+ * Filesystem configuration schema for validation
68
+ */
69
+ export declare const FilesystemConfigSchema: z.ZodObject<{
70
+ denyRead: z.ZodArray<z.ZodString, "many">;
71
+ allowWrite: z.ZodArray<z.ZodString, "many">;
72
+ denyWrite: z.ZodArray<z.ZodString, "many">;
73
+ allowGitConfig: z.ZodOptional<z.ZodBoolean>;
74
+ }, "strip", z.ZodTypeAny, {
75
+ denyRead: string[];
76
+ denyWrite: string[];
77
+ allowWrite: string[];
78
+ allowGitConfig?: boolean | undefined;
79
+ }, {
80
+ denyRead: string[];
81
+ denyWrite: string[];
82
+ allowWrite: string[];
83
+ allowGitConfig?: boolean | undefined;
84
+ }>;
85
+ /**
86
+ * Configuration schema for ignoring specific sandbox violations
87
+ * Maps command patterns to filesystem paths to ignore violations for.
88
+ */
89
+ export declare const IgnoreViolationsConfigSchema: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>;
90
+ /**
91
+ * Ripgrep configuration schema
92
+ */
93
+ export declare const RipgrepConfigSchema: z.ZodObject<{
94
+ command: z.ZodString;
95
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
96
+ }, "strip", z.ZodTypeAny, {
97
+ command: string;
98
+ args?: string[] | undefined;
99
+ }, {
100
+ command: string;
101
+ args?: string[] | undefined;
102
+ }>;
103
+ /**
104
+ * Seccomp configuration schema (Linux only)
105
+ * Allows specifying custom paths to seccomp binaries
106
+ */
107
+ export declare const SeccompConfigSchema: z.ZodObject<{
108
+ bpfPath: z.ZodOptional<z.ZodString>;
109
+ applyPath: z.ZodOptional<z.ZodString>;
110
+ }, "strip", z.ZodTypeAny, {
111
+ bpfPath?: string | undefined;
112
+ applyPath?: string | undefined;
113
+ }, {
114
+ bpfPath?: string | undefined;
115
+ applyPath?: string | undefined;
116
+ }>;
117
+ /**
118
+ * Main configuration schema for Sandbox Runtime validation
119
+ */
120
+ export declare const SandboxRuntimeConfigSchema: z.ZodObject<{
121
+ network: z.ZodObject<{
122
+ allowedDomains: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
123
+ deniedDomains: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
124
+ allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
125
+ allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
126
+ allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
127
+ httpProxyPort: z.ZodOptional<z.ZodNumber>;
128
+ socksProxyPort: z.ZodOptional<z.ZodNumber>;
129
+ mitmProxy: z.ZodOptional<z.ZodObject<{
130
+ socketPath: z.ZodString;
131
+ domains: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
132
+ }, "strip", z.ZodTypeAny, {
133
+ socketPath: string;
134
+ domains: string[];
135
+ }, {
136
+ socketPath: string;
137
+ domains: string[];
138
+ }>>;
139
+ }, "strip", z.ZodTypeAny, {
140
+ allowedDomains: string[];
141
+ deniedDomains: string[];
142
+ allowUnixSockets?: string[] | undefined;
143
+ allowAllUnixSockets?: boolean | undefined;
144
+ allowLocalBinding?: boolean | undefined;
145
+ httpProxyPort?: number | undefined;
146
+ socksProxyPort?: number | undefined;
147
+ mitmProxy?: {
148
+ socketPath: string;
149
+ domains: string[];
150
+ } | undefined;
151
+ }, {
152
+ allowedDomains: string[];
153
+ deniedDomains: string[];
154
+ allowUnixSockets?: string[] | undefined;
155
+ allowAllUnixSockets?: boolean | undefined;
156
+ allowLocalBinding?: boolean | undefined;
157
+ httpProxyPort?: number | undefined;
158
+ socksProxyPort?: number | undefined;
159
+ mitmProxy?: {
160
+ socketPath: string;
161
+ domains: string[];
162
+ } | undefined;
163
+ }>;
164
+ filesystem: z.ZodObject<{
165
+ denyRead: z.ZodArray<z.ZodString, "many">;
166
+ allowWrite: z.ZodArray<z.ZodString, "many">;
167
+ denyWrite: z.ZodArray<z.ZodString, "many">;
168
+ allowGitConfig: z.ZodOptional<z.ZodBoolean>;
169
+ }, "strip", z.ZodTypeAny, {
170
+ denyRead: string[];
171
+ denyWrite: string[];
172
+ allowWrite: string[];
173
+ allowGitConfig?: boolean | undefined;
174
+ }, {
175
+ denyRead: string[];
176
+ denyWrite: string[];
177
+ allowWrite: string[];
178
+ allowGitConfig?: boolean | undefined;
179
+ }>;
180
+ ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
181
+ enableWeakerNestedSandbox: z.ZodOptional<z.ZodBoolean>;
182
+ ripgrep: z.ZodOptional<z.ZodObject<{
183
+ command: z.ZodString;
184
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ command: string;
187
+ args?: string[] | undefined;
188
+ }, {
189
+ command: string;
190
+ args?: string[] | undefined;
191
+ }>>;
192
+ mandatoryDenySearchDepth: z.ZodOptional<z.ZodNumber>;
193
+ allowPty: z.ZodOptional<z.ZodBoolean>;
194
+ seccomp: z.ZodOptional<z.ZodObject<{
195
+ bpfPath: z.ZodOptional<z.ZodString>;
196
+ applyPath: z.ZodOptional<z.ZodString>;
197
+ }, "strip", z.ZodTypeAny, {
198
+ bpfPath?: string | undefined;
199
+ applyPath?: string | undefined;
200
+ }, {
201
+ bpfPath?: string | undefined;
202
+ applyPath?: string | undefined;
203
+ }>>;
204
+ }, "strip", z.ZodTypeAny, {
205
+ network: {
206
+ allowedDomains: string[];
207
+ deniedDomains: string[];
208
+ allowUnixSockets?: string[] | undefined;
209
+ allowAllUnixSockets?: boolean | undefined;
210
+ allowLocalBinding?: boolean | undefined;
211
+ httpProxyPort?: number | undefined;
212
+ socksProxyPort?: number | undefined;
213
+ mitmProxy?: {
214
+ socketPath: string;
215
+ domains: string[];
216
+ } | undefined;
217
+ };
218
+ filesystem: {
219
+ denyRead: string[];
220
+ denyWrite: string[];
221
+ allowWrite: string[];
222
+ allowGitConfig?: boolean | undefined;
223
+ };
224
+ ignoreViolations?: Record<string, string[]> | undefined;
225
+ enableWeakerNestedSandbox?: boolean | undefined;
226
+ ripgrep?: {
227
+ command: string;
228
+ args?: string[] | undefined;
229
+ } | undefined;
230
+ mandatoryDenySearchDepth?: number | undefined;
231
+ allowPty?: boolean | undefined;
232
+ seccomp?: {
233
+ bpfPath?: string | undefined;
234
+ applyPath?: string | undefined;
235
+ } | undefined;
236
+ }, {
237
+ network: {
238
+ allowedDomains: string[];
239
+ deniedDomains: string[];
240
+ allowUnixSockets?: string[] | undefined;
241
+ allowAllUnixSockets?: boolean | undefined;
242
+ allowLocalBinding?: boolean | undefined;
243
+ httpProxyPort?: number | undefined;
244
+ socksProxyPort?: number | undefined;
245
+ mitmProxy?: {
246
+ socketPath: string;
247
+ domains: string[];
248
+ } | undefined;
249
+ };
250
+ filesystem: {
251
+ denyRead: string[];
252
+ denyWrite: string[];
253
+ allowWrite: string[];
254
+ allowGitConfig?: boolean | undefined;
255
+ };
256
+ ignoreViolations?: Record<string, string[]> | undefined;
257
+ enableWeakerNestedSandbox?: boolean | undefined;
258
+ ripgrep?: {
259
+ command: string;
260
+ args?: string[] | undefined;
261
+ } | undefined;
262
+ mandatoryDenySearchDepth?: number | undefined;
263
+ allowPty?: boolean | undefined;
264
+ seccomp?: {
265
+ bpfPath?: string | undefined;
266
+ applyPath?: string | undefined;
267
+ } | undefined;
268
+ }>;
269
+ export type MitmProxyConfig = z.infer<typeof MitmProxyConfigSchema>;
270
+ export type NetworkConfig = z.infer<typeof NetworkConfigSchema>;
271
+ export type FilesystemConfig = z.infer<typeof FilesystemConfigSchema>;
272
+ export type IgnoreViolationsConfig = z.infer<typeof IgnoreViolationsConfigSchema>;
273
+ export type RipgrepConfig = z.infer<typeof RipgrepConfigSchema>;
274
+ export type SeccompConfig = z.infer<typeof SeccompConfigSchema>;
275
+ export type SandboxRuntimeConfig = z.infer<typeof SandboxRuntimeConfigSchema>;
276
+ export {};
277
+ //# sourceMappingURL=sandbox-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-config.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox-config.ts"],"names":[],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AAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Configuration for Sandbox Runtime
3
+ * This is the main configuration interface that consumers pass to SandboxManager.initialize()
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Schema for domain patterns (e.g., "example.com", "*.npmjs.org")
8
+ * Validates that domain patterns are safe and don't include overly broad wildcards
9
+ */
10
+ const domainPatternSchema = z.string().refine(val => {
11
+ // Reject protocols, paths, ports, etc.
12
+ if (val.includes('://') || val.includes('/') || val.includes(':')) {
13
+ return false;
14
+ }
15
+ // Allow localhost
16
+ if (val === 'localhost')
17
+ return true;
18
+ // Allow wildcard domains like *.example.com
19
+ if (val.startsWith('*.')) {
20
+ const domain = val.slice(2);
21
+ // After the *. there must be a valid domain with at least one more dot
22
+ // e.g., *.example.com is valid, *.com is not (too broad)
23
+ if (!domain.includes('.') ||
24
+ domain.startsWith('.') ||
25
+ domain.endsWith('.')) {
26
+ return false;
27
+ }
28
+ // Count dots - must have at least 2 parts after the wildcard (e.g., example.com)
29
+ const parts = domain.split('.');
30
+ return parts.length >= 2 && parts.every(p => p.length > 0);
31
+ }
32
+ // Reject any other use of wildcards (e.g., *, *., etc.)
33
+ if (val.includes('*')) {
34
+ return false;
35
+ }
36
+ // Regular domains must have at least one dot and only valid characters
37
+ return val.includes('.') && !val.startsWith('.') && !val.endsWith('.');
38
+ }, {
39
+ message: 'Invalid domain pattern. Must be a valid domain (e.g., "example.com") or wildcard (e.g., "*.example.com"). Overly broad patterns like "*.com" or "*" are not allowed for security reasons.',
40
+ });
41
+ /**
42
+ * Schema for filesystem paths
43
+ */
44
+ const filesystemPathSchema = z.string().min(1, 'Path cannot be empty');
45
+ /**
46
+ * Schema for MITM proxy configuration
47
+ * Allows routing specific domains through an upstream MITM proxy via Unix socket
48
+ */
49
+ const MitmProxyConfigSchema = z.object({
50
+ socketPath: z.string().min(1).describe('Unix socket path to the MITM proxy'),
51
+ domains: z
52
+ .array(domainPatternSchema)
53
+ .min(1)
54
+ .describe('Domains to route through the MITM proxy (e.g., ["api.example.com", "*.internal.org"])'),
55
+ });
56
+ /**
57
+ * Network configuration schema for validation
58
+ */
59
+ export const NetworkConfigSchema = z.object({
60
+ allowedDomains: z
61
+ .array(domainPatternSchema)
62
+ .describe('List of allowed domains (e.g., ["github.com", "*.npmjs.org"])'),
63
+ deniedDomains: z
64
+ .array(domainPatternSchema)
65
+ .describe('List of denied domains'),
66
+ allowUnixSockets: z
67
+ .array(z.string())
68
+ .optional()
69
+ .describe('Unix socket paths that are allowed (macOS only)'),
70
+ allowAllUnixSockets: z
71
+ .boolean()
72
+ .optional()
73
+ .describe('Allow ALL Unix sockets (Linux only - disables Unix socket blocking)'),
74
+ allowLocalBinding: z
75
+ .boolean()
76
+ .optional()
77
+ .describe('Whether to allow binding to local ports (default: false)'),
78
+ httpProxyPort: z
79
+ .number()
80
+ .int()
81
+ .min(1)
82
+ .max(65535)
83
+ .optional()
84
+ .describe('Port of an external HTTP proxy to use instead of starting a local one. When provided, the library will skip starting its own HTTP proxy and use this port. The external proxy must handle domain filtering.'),
85
+ socksProxyPort: z
86
+ .number()
87
+ .int()
88
+ .min(1)
89
+ .max(65535)
90
+ .optional()
91
+ .describe('Port of an external SOCKS proxy to use instead of starting a local one. When provided, the library will skip starting its own SOCKS proxy and use this port. The external proxy must handle domain filtering.'),
92
+ mitmProxy: MitmProxyConfigSchema.optional().describe('Optional MITM proxy configuration. Routes matching domains through an upstream proxy via Unix socket while SRT still handles allow/deny filtering.'),
93
+ });
94
+ /**
95
+ * Filesystem configuration schema for validation
96
+ */
97
+ export const FilesystemConfigSchema = z.object({
98
+ denyRead: z.array(filesystemPathSchema).describe('Paths denied for reading'),
99
+ allowWrite: z
100
+ .array(filesystemPathSchema)
101
+ .describe('Paths allowed for writing'),
102
+ denyWrite: z
103
+ .array(filesystemPathSchema)
104
+ .describe('Paths denied for writing (takes precedence over allowWrite)'),
105
+ allowGitConfig: z
106
+ .boolean()
107
+ .optional()
108
+ .describe('Allow writes to .git/config files (default: false). Enables git remote URL updates while keeping .git/hooks protected.'),
109
+ });
110
+ /**
111
+ * Configuration schema for ignoring specific sandbox violations
112
+ * Maps command patterns to filesystem paths to ignore violations for.
113
+ */
114
+ export const IgnoreViolationsConfigSchema = z
115
+ .record(z.string(), z.array(z.string()))
116
+ .describe('Map of command patterns to filesystem paths to ignore violations for. Use "*" to match all commands');
117
+ /**
118
+ * Ripgrep configuration schema
119
+ */
120
+ export const RipgrepConfigSchema = z.object({
121
+ command: z
122
+ .string()
123
+ .describe('The ripgrep command to execute (e.g., "rg", "claude")'),
124
+ args: z
125
+ .array(z.string())
126
+ .optional()
127
+ .describe('Additional arguments to pass before ripgrep args (e.g., ["--ripgrep"])'),
128
+ });
129
+ /**
130
+ * Seccomp configuration schema (Linux only)
131
+ * Allows specifying custom paths to seccomp binaries
132
+ */
133
+ export const SeccompConfigSchema = z.object({
134
+ bpfPath: z
135
+ .string()
136
+ .optional()
137
+ .describe('Path to the unix-block.bpf filter file'),
138
+ applyPath: z.string().optional().describe('Path to the apply-seccomp binary'),
139
+ });
140
+ /**
141
+ * Main configuration schema for Sandbox Runtime validation
142
+ */
143
+ export const SandboxRuntimeConfigSchema = z.object({
144
+ network: NetworkConfigSchema.describe('Network restrictions configuration'),
145
+ filesystem: FilesystemConfigSchema.describe('Filesystem restrictions configuration'),
146
+ ignoreViolations: IgnoreViolationsConfigSchema.optional().describe('Optional configuration for ignoring specific violations'),
147
+ enableWeakerNestedSandbox: z
148
+ .boolean()
149
+ .optional()
150
+ .describe('Enable weaker nested sandbox mode (for Docker environments)'),
151
+ ripgrep: RipgrepConfigSchema.optional().describe('Custom ripgrep configuration (default: { command: "rg" })'),
152
+ mandatoryDenySearchDepth: z
153
+ .number()
154
+ .int()
155
+ .min(1)
156
+ .max(10)
157
+ .optional()
158
+ .describe('Maximum directory depth to search for dangerous files on Linux (default: 3). ' +
159
+ 'Higher values provide more protection but slower performance.'),
160
+ allowPty: z
161
+ .boolean()
162
+ .optional()
163
+ .describe('Allow pseudo-terminal (pty) operations (macOS only)'),
164
+ seccomp: SeccompConfigSchema.optional().describe('Custom seccomp binary paths (Linux only).'),
165
+ });
166
+ //# sourceMappingURL=sandbox-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-config.js","sourceRoot":"","sources":["../../src/sandbox/sandbox-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAC3C,GAAG,CAAC,EAAE;IACJ,uCAAuC;IACvC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAClE,OAAO,KAAK,CAAA;IACd,CAAC;IAED,kBAAkB;IAClB,IAAI,GAAG,KAAK,WAAW;QAAE,OAAO,IAAI,CAAA;IAEpC,4CAA4C;IAC5C,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC3B,uEAAuE;QACvE,yDAAyD;QACzD,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;YACrB,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;YACtB,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EACpB,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,iFAAiF;QACjF,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC/B,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,E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