@voratiq/sandbox-runtime 0.7.0-voratiq1
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/CHANGELOG.md +10 -0
- package/LICENSE +201 -0
- package/NOTICE +11 -0
- package/README.md +17 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +243 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox/generate-seccomp-filter.d.ts +56 -0
- package/dist/sandbox/generate-seccomp-filter.d.ts.map +1 -0
- package/dist/sandbox/generate-seccomp-filter.js +158 -0
- package/dist/sandbox/generate-seccomp-filter.js.map +1 -0
- package/dist/sandbox/http-proxy.d.ts +12 -0
- package/dist/sandbox/http-proxy.d.ts.map +1 -0
- package/dist/sandbox/http-proxy.js +489 -0
- package/dist/sandbox/http-proxy.js.map +1 -0
- package/dist/sandbox/linux-sandbox-utils.d.ts +111 -0
- package/dist/sandbox/linux-sandbox-utils.d.ts.map +1 -0
- package/dist/sandbox/linux-sandbox-utils.js +518 -0
- package/dist/sandbox/linux-sandbox-utils.js.map +1 -0
- package/dist/sandbox/macos-sandbox-utils.d.ts +54 -0
- package/dist/sandbox/macos-sandbox-utils.d.ts.map +1 -0
- package/dist/sandbox/macos-sandbox-utils.js +559 -0
- package/dist/sandbox/macos-sandbox-utils.js.map +1 -0
- package/dist/sandbox/sandbox-config.d.ts +170 -0
- package/dist/sandbox/sandbox-config.d.ts.map +1 -0
- package/dist/sandbox/sandbox-config.js +126 -0
- package/dist/sandbox/sandbox-config.js.map +1 -0
- package/dist/sandbox/sandbox-manager.d.ts +35 -0
- package/dist/sandbox/sandbox-manager.d.ts.map +1 -0
- package/dist/sandbox/sandbox-manager.js +666 -0
- package/dist/sandbox/sandbox-manager.js.map +1 -0
- package/dist/sandbox/sandbox-schemas.d.ts +17 -0
- package/dist/sandbox/sandbox-schemas.d.ts.map +1 -0
- package/dist/sandbox/sandbox-schemas.js +2 -0
- package/dist/sandbox/sandbox-schemas.js.map +1 -0
- package/dist/sandbox/sandbox-utils.d.ts +53 -0
- package/dist/sandbox/sandbox-utils.d.ts.map +1 -0
- package/dist/sandbox/sandbox-utils.js +368 -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 +54 -0
- package/dist/sandbox/sandbox-violation-store.js.map +1 -0
- package/dist/sandbox/socks-proxy.d.ts +18 -0
- package/dist/sandbox/socks-proxy.d.ts.map +1 -0
- package/dist/sandbox/socks-proxy.js +242 -0
- package/dist/sandbox/socks-proxy.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 +22 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/platform.d.ts +6 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +16 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/ripgrep.d.ts +20 -0
- package/dist/utils/ripgrep.d.ts.map +1 -0
- package/dist/utils/ripgrep.js +51 -0
- package/dist/utils/ripgrep.js.map +1 -0
- package/dist/utils/telemetry.d.ts +67 -0
- package/dist/utils/telemetry.d.ts.map +1 -0
- package/dist/utils/telemetry.js +249 -0
- package/dist/utils/telemetry.js.map +1 -0
- package/dist/vendor/seccomp/arm64/apply-seccomp +0 -0
- package/dist/vendor/seccomp/arm64/unix-block.bpf +0 -0
- package/dist/vendor/seccomp/x64/apply-seccomp +0 -0
- package/dist/vendor/seccomp/x64/unix-block.bpf +0 -0
- package/dist/vendor/seccomp-src/apply-seccomp.c +98 -0
- package/dist/vendor/seccomp-src/seccomp-unix-block.c +97 -0
- package/package.json +80 -0
- package/vendor/seccomp/arm64/apply-seccomp +0 -0
- package/vendor/seccomp/arm64/unix-block.bpf +0 -0
- package/vendor/seccomp/x64/apply-seccomp +0 -0
- package/vendor/seccomp/x64/unix-block.bpf +0 -0
- package/vendor/seccomp-src/apply-seccomp.c +98 -0
- package/vendor/seccomp-src/seccomp-unix-block.c +97 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this Voratiq-maintained fork are documented here.
|
|
4
|
+
|
|
5
|
+
## 0.7.0-voratiq1 - 2025-11-10
|
|
6
|
+
|
|
7
|
+
- Upstream baseline: 1bafa663538b0b7ef62758fce6f03648ca8f605e.
|
|
8
|
+
- Rebases Voratiq branding + telemetry work on top of upstream ripgrep customization and dependency preflight checks.
|
|
9
|
+
- Keeps macOS sandbox allowance for `com.apple.SystemConfiguration.configd` while adopting upstream sandbox schema changes. This permission is required to run Codex.
|
|
10
|
+
- Validation: `npm run build` (pass), `npm run typecheck` (pass), `npm run lint:check` (pass), `bun test`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Anthropic
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Voratiq Sandbox Runtime
|
|
2
|
+
Copyright (c) 2025 Voratiq
|
|
3
|
+
|
|
4
|
+
This distribution includes substantial portions of the Anthropic Sandbox Runtime,
|
|
5
|
+
which is Copyright (c) 2025 Anthropic PBC and licensed under the Apache License,
|
|
6
|
+
Version 2.0. The original project is available at
|
|
7
|
+
https://github.com/anthropic-experimental/sandbox-runtime.
|
|
8
|
+
|
|
9
|
+
This software may include third-party components distributed under their own
|
|
10
|
+
licenses. See `package.json` and the accompanying license files in the vendor
|
|
11
|
+
directory for additional details.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
> This is the Voratiq-maintained fork of the Anthropic Sandbox Runtime. It tracks `anthropic-experimental/sandbox-runtime` while layering in Voratiq branding, macOS `configd` allowances, and optional debug telemetry.
|
|
2
|
+
|
|
3
|
+
# Anthropic Sandbox Runtime (srt)
|
|
4
|
+
|
|
5
|
+
A lightweight sandboxing tool for enforcing filesystem and network restrictions on arbitrary processes at the OS level, without requiring a container.
|
|
6
|
+
|
|
7
|
+
`srt` uses native OS sandboxing primitives (`sandbox-exec` on macOS, `bubblewrap` on Linux) and proxy-based network filtering. It can be used to sandbox the behaviour of agents, local MCP servers, bash commands and arbitrary processes.
|
|
8
|
+
|
|
9
|
+
> **Beta Research Preview**
|
|
10
|
+
>
|
|
11
|
+
> The Sandbox Runtime is a research preview developed for [Claude Code](https://www.claude.com/product/claude-code) to enable safer AI agents. It's being made available as an early open source preview to help the broader ecosystem build more secure agentic systems. As this is an early research preview, APIs and configuration formats may evolve. We welcome feedback and contributions to make AI agents safer by default!
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @voratiq/sandbox-runtime
|
|
17
|
+
```
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { SandboxManager } from './index.js';
|
|
4
|
+
import { SandboxRuntimeConfigSchema, } from './sandbox/sandbox-config.js';
|
|
5
|
+
import { spawn } from 'child_process';
|
|
6
|
+
import { logForDebugging } from './utils/debug.js';
|
|
7
|
+
import { initializeTelemetry, emitTelemetryEvent, sanitizeCommandArgs, isTelemetryEnabled, } from './utils/telemetry.js';
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
import * as os from 'os';
|
|
11
|
+
import { performance } from 'node:perf_hooks';
|
|
12
|
+
import { createRequire } from 'module';
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
const { version } = require('../package.json');
|
|
15
|
+
/**
|
|
16
|
+
* Load and validate sandbox configuration from a file
|
|
17
|
+
*/
|
|
18
|
+
function loadConfig(filePath) {
|
|
19
|
+
try {
|
|
20
|
+
if (!fs.existsSync(filePath)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
24
|
+
if (content.trim() === '') {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
// Parse JSON
|
|
28
|
+
const parsed = JSON.parse(content);
|
|
29
|
+
// Validate with zod schema
|
|
30
|
+
const result = SandboxRuntimeConfigSchema.safeParse(parsed);
|
|
31
|
+
if (!result.success) {
|
|
32
|
+
console.error(`Invalid configuration in ${filePath}:`);
|
|
33
|
+
result.error.issues.forEach(issue => {
|
|
34
|
+
const path = issue.path.join('.');
|
|
35
|
+
console.error(` - ${path}: ${issue.message}`);
|
|
36
|
+
});
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return result.data;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
// Log parse errors to help users debug invalid config files
|
|
43
|
+
if (error instanceof SyntaxError) {
|
|
44
|
+
console.error(`Invalid JSON in config file ${filePath}: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.error(`Failed to load config from ${filePath}: ${error}`);
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get default config path
|
|
54
|
+
*/
|
|
55
|
+
function getDefaultConfigPath() {
|
|
56
|
+
return path.join(os.homedir(), '.srt-settings.json');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a minimal default config if no config file exists
|
|
60
|
+
*/
|
|
61
|
+
function getDefaultConfig() {
|
|
62
|
+
return {
|
|
63
|
+
network: {
|
|
64
|
+
allowedDomains: [],
|
|
65
|
+
deniedDomains: [],
|
|
66
|
+
},
|
|
67
|
+
filesystem: {
|
|
68
|
+
denyRead: [],
|
|
69
|
+
allowWrite: [],
|
|
70
|
+
denyWrite: [],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function main() {
|
|
75
|
+
const program = new Command();
|
|
76
|
+
program
|
|
77
|
+
.name('srt')
|
|
78
|
+
.description('Run commands in a sandbox with network and filesystem restrictions')
|
|
79
|
+
.version(version);
|
|
80
|
+
// Default command - run command in sandbox
|
|
81
|
+
program
|
|
82
|
+
.argument('<command...>', 'command to run in the sandbox')
|
|
83
|
+
.option('-d, --debug', 'enable debug logging')
|
|
84
|
+
.option('-s, --settings <path>', 'path to config file (default: ~/.srt-settings.json)')
|
|
85
|
+
.allowUnknownOption()
|
|
86
|
+
.action(async (commandArgs, options) => {
|
|
87
|
+
try {
|
|
88
|
+
const sanitizedCommand = sanitizeCommandArgs(commandArgs);
|
|
89
|
+
const debugEnabled = Boolean(options.debug);
|
|
90
|
+
if (debugEnabled && !process.env.DEBUG) {
|
|
91
|
+
process.env.DEBUG = 'true';
|
|
92
|
+
}
|
|
93
|
+
const traceId = initializeTelemetry({
|
|
94
|
+
debugEnabled,
|
|
95
|
+
commandArgs,
|
|
96
|
+
});
|
|
97
|
+
if (traceId && isTelemetryEnabled()) {
|
|
98
|
+
emitTelemetryEvent({
|
|
99
|
+
stage: 'start',
|
|
100
|
+
status: 'success',
|
|
101
|
+
attempt: 0,
|
|
102
|
+
command: sanitizedCommand,
|
|
103
|
+
sandbox_verdict: {
|
|
104
|
+
decision: 'allow',
|
|
105
|
+
reason: 'cli_invocation',
|
|
106
|
+
policy_tag: 'command.execution',
|
|
107
|
+
},
|
|
108
|
+
egress_type: 'command',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// Load config from file
|
|
112
|
+
const configPath = options.settings || getDefaultConfigPath();
|
|
113
|
+
let runtimeConfig = loadConfig(configPath);
|
|
114
|
+
if (!runtimeConfig) {
|
|
115
|
+
logForDebugging(`No config found at ${configPath}, using default config`);
|
|
116
|
+
runtimeConfig = getDefaultConfig();
|
|
117
|
+
}
|
|
118
|
+
// Initialize sandbox with config
|
|
119
|
+
logForDebugging('Initializing sandbox...');
|
|
120
|
+
await SandboxManager.initialize(runtimeConfig);
|
|
121
|
+
// Join command arguments into a single command string
|
|
122
|
+
const command = commandArgs.join(' ');
|
|
123
|
+
logForDebugging(`Original command: ${command}`);
|
|
124
|
+
const commandStart = performance.now();
|
|
125
|
+
logForDebugging(JSON.stringify(SandboxManager.getNetworkRestrictionConfig(), null, 2));
|
|
126
|
+
// Wrap the command with sandbox restrictions
|
|
127
|
+
const sandboxedCommand = await SandboxManager.wrapWithSandbox(command);
|
|
128
|
+
// Execute the sandboxed command
|
|
129
|
+
console.log(`Running: ${command}`);
|
|
130
|
+
if (isTelemetryEnabled()) {
|
|
131
|
+
emitTelemetryEvent({
|
|
132
|
+
stage: 'attempt',
|
|
133
|
+
status: 'success',
|
|
134
|
+
attempt: 0,
|
|
135
|
+
command: sanitizedCommand,
|
|
136
|
+
sandbox_verdict: {
|
|
137
|
+
decision: 'allow',
|
|
138
|
+
reason: 'sandbox_wrap',
|
|
139
|
+
policy_tag: 'command.execution',
|
|
140
|
+
},
|
|
141
|
+
egress_type: 'command',
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const child = spawn(sandboxedCommand, {
|
|
145
|
+
shell: true,
|
|
146
|
+
stdio: 'inherit',
|
|
147
|
+
});
|
|
148
|
+
// Handle process exit
|
|
149
|
+
child.on('exit', (code, signal) => {
|
|
150
|
+
const latency = performance.now() - commandStart;
|
|
151
|
+
if (signal) {
|
|
152
|
+
console.error(`Process killed by signal: ${signal}`);
|
|
153
|
+
if (isTelemetryEnabled()) {
|
|
154
|
+
emitTelemetryEvent({
|
|
155
|
+
stage: 'completion',
|
|
156
|
+
status: 'cancelled',
|
|
157
|
+
attempt: 0,
|
|
158
|
+
status_code: null,
|
|
159
|
+
command: sanitizedCommand,
|
|
160
|
+
sandbox_verdict: {
|
|
161
|
+
decision: 'allow',
|
|
162
|
+
reason: `terminated_by_${signal.toLowerCase()}`,
|
|
163
|
+
policy_tag: 'command.execution',
|
|
164
|
+
},
|
|
165
|
+
latency_ms: latency,
|
|
166
|
+
egress_type: 'command',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
if (isTelemetryEnabled()) {
|
|
172
|
+
emitTelemetryEvent({
|
|
173
|
+
stage: 'completion',
|
|
174
|
+
status: code === 0 ? 'success' : 'failed',
|
|
175
|
+
attempt: 0,
|
|
176
|
+
status_code: code ?? null,
|
|
177
|
+
command: sanitizedCommand,
|
|
178
|
+
sandbox_verdict: {
|
|
179
|
+
decision: 'allow',
|
|
180
|
+
reason: 'process_exit',
|
|
181
|
+
policy_tag: 'command.execution',
|
|
182
|
+
},
|
|
183
|
+
latency_ms: latency,
|
|
184
|
+
egress_type: 'command',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
process.exit(code ?? 0);
|
|
188
|
+
});
|
|
189
|
+
child.on('error', error => {
|
|
190
|
+
console.error(`Failed to execute command: ${error.message}`);
|
|
191
|
+
if (isTelemetryEnabled()) {
|
|
192
|
+
emitTelemetryEvent({
|
|
193
|
+
stage: 'failure',
|
|
194
|
+
status: 'failed',
|
|
195
|
+
attempt: 0,
|
|
196
|
+
status_code: null,
|
|
197
|
+
command: sanitizedCommand,
|
|
198
|
+
sandbox_verdict: {
|
|
199
|
+
decision: 'allow',
|
|
200
|
+
reason: 'process_spawn_error',
|
|
201
|
+
policy_tag: 'command.execution',
|
|
202
|
+
},
|
|
203
|
+
latency_ms: performance.now() - commandStart,
|
|
204
|
+
egress_type: 'command',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
process.exit(1);
|
|
208
|
+
});
|
|
209
|
+
// Handle cleanup on interrupt
|
|
210
|
+
process.on('SIGINT', () => {
|
|
211
|
+
child.kill('SIGINT');
|
|
212
|
+
});
|
|
213
|
+
process.on('SIGTERM', () => {
|
|
214
|
+
child.kill('SIGTERM');
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
219
|
+
if (isTelemetryEnabled()) {
|
|
220
|
+
emitTelemetryEvent({
|
|
221
|
+
stage: 'failure',
|
|
222
|
+
status: 'failed',
|
|
223
|
+
attempt: 0,
|
|
224
|
+
status_code: null,
|
|
225
|
+
sandbox_verdict: {
|
|
226
|
+
decision: null,
|
|
227
|
+
reason: 'cli_error',
|
|
228
|
+
policy_tag: 'command.execution',
|
|
229
|
+
},
|
|
230
|
+
latency_ms: null,
|
|
231
|
+
egress_type: 'command',
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
program.parse();
|
|
238
|
+
}
|
|
239
|
+
main().catch(error => {
|
|
240
|
+
console.error('Fatal error:', error);
|
|
241
|
+
process.exit(1);
|
|
242
|
+
});
|
|
243
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EACL,0BAA0B,GAE3B,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AC;IACH,CAAC,CACF,CAAA;IAEH,OAAO,CAAC,KAAK,EAAE,CAAA;AACjB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;IACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SandboxManager } from './sandbox/sandbox-manager.js';
|
|
2
|
+
export { SandboxViolationStore } from './sandbox/sandbox-violation-store.js';
|
|
3
|
+
export type { SandboxRuntimeConfig, NetworkConfig, FilesystemConfig, IgnoreViolationsConfig, } from './sandbox/sandbox-config.js';
|
|
4
|
+
export { SandboxRuntimeConfigSchema, NetworkConfigSchema, FilesystemConfigSchema, IgnoreViolationsConfigSchema, RipgrepConfigSchema, } from './sandbox/sandbox-config.js';
|
|
5
|
+
export type { SandboxAskCallback, FsReadRestrictionConfig, FsWriteRestrictionConfig, NetworkRestrictionConfig, NetworkHostPattern, } from './sandbox/sandbox-schemas.js';
|
|
6
|
+
export type { SandboxViolationEvent } from './sandbox/macos-sandbox-utils.js';
|
|
7
|
+
export { getDefaultWritePaths } from './sandbox/sandbox-utils.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAG5E,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,6BAA6B,CAAA;AAGpC,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,8BAA8B,CAAA;AAGrC,YAAY,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAG7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Library exports
|
|
2
|
+
export { SandboxManager } from './sandbox/sandbox-manager.js';
|
|
3
|
+
export { SandboxViolationStore } from './sandbox/sandbox-violation-store.js';
|
|
4
|
+
export { SandboxRuntimeConfigSchema, NetworkConfigSchema, FilesystemConfigSchema, IgnoreViolationsConfigSchema, RipgrepConfigSchema, } from './sandbox/sandbox-config.js';
|
|
5
|
+
// Utility functions
|
|
6
|
+
export { getDefaultWritePaths } from './sandbox/sandbox-utils.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAU5E,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,6BAA6B,CAAA;AAcpC,oBAAoB;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the path to a pre-generated BPF filter file from the vendor directory
|
|
3
|
+
* Returns the path if it exists, null otherwise
|
|
4
|
+
*
|
|
5
|
+
* Pre-generated BPF files are organized by architecture:
|
|
6
|
+
* - vendor/seccomp/{x64,arm64}/unix-block.bpf
|
|
7
|
+
*
|
|
8
|
+
* Tries multiple paths for resilience:
|
|
9
|
+
* 1. ../../vendor/seccomp/{arch}/unix-block.bpf (package root - standard npm installs)
|
|
10
|
+
* 2. ../vendor/seccomp/{arch}/unix-block.bpf (dist/vendor - for bundlers)
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPreGeneratedBpfPath(): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Get the path to the apply-seccomp binary from the vendor directory
|
|
15
|
+
* Returns the path if it exists, null otherwise
|
|
16
|
+
*
|
|
17
|
+
* Pre-built apply-seccomp binaries are organized by architecture:
|
|
18
|
+
* - vendor/seccomp/{x64,arm64}/apply-seccomp
|
|
19
|
+
*
|
|
20
|
+
* Tries multiple paths for resilience:
|
|
21
|
+
* 1. ../../vendor/seccomp/{arch}/apply-seccomp (package root - standard npm installs)
|
|
22
|
+
* 2. ../vendor/seccomp/{arch}/apply-seccomp (dist/vendor - for bundlers)
|
|
23
|
+
*/
|
|
24
|
+
export declare function getApplySeccompBinaryPath(): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Get the path to a pre-generated seccomp BPF filter that blocks Unix domain socket creation
|
|
27
|
+
* Returns the path to the BPF filter file, or null if not available
|
|
28
|
+
*
|
|
29
|
+
* The filter blocks socket(AF_UNIX, ...) syscalls while allowing all other syscalls.
|
|
30
|
+
* This prevents creation of new Unix domain socket file descriptors.
|
|
31
|
+
*
|
|
32
|
+
* Security scope:
|
|
33
|
+
* - Blocks: socket(AF_UNIX, ...) syscall (creating new Unix socket FDs)
|
|
34
|
+
* - Does NOT block: Operations on inherited Unix socket FDs (bind, connect, sendto, etc.)
|
|
35
|
+
* - Does NOT block: Unix socket FDs passed via SCM_RIGHTS
|
|
36
|
+
* - For most sandboxing scenarios, blocking socket creation is sufficient
|
|
37
|
+
*
|
|
38
|
+
* Note: This blocks ALL Unix socket creation, regardless of path. The allowUnixSockets
|
|
39
|
+
* configuration is not supported on Linux due to seccomp-bpf limitations (it cannot
|
|
40
|
+
* read user-space memory to inspect socket paths).
|
|
41
|
+
*
|
|
42
|
+
* Requirements:
|
|
43
|
+
* - Pre-generated BPF filters included for x64 and ARM64 only
|
|
44
|
+
* - Other architectures are not supported
|
|
45
|
+
*
|
|
46
|
+
* @returns Path to the pre-generated BPF filter file, or null if not available
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateSeccompFilter(): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Clean up a seccomp filter file
|
|
51
|
+
* Since we only use pre-generated BPF files from vendor/, this is a no-op.
|
|
52
|
+
* Pre-generated files are never deleted.
|
|
53
|
+
* Kept for backward compatibility with existing code that calls it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function cleanupSeccompFilter(_filterPath: string): void;
|
|
56
|
+
//# sourceMappingURL=generate-seccomp-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-seccomp-filter.d.ts","sourceRoot":"","sources":["../../src/sandbox/generate-seccomp-filter.ts"],"names":[],"mappings":"AAgDA;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAoCtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,GAAG,IAAI,CAsCzD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CAarD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAE9D"}
|