sandboxbox 1.2.1 â 2.0.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/Dockerfile +80 -24
- package/README.md +180 -99
- package/cli.js +125 -160
- package/package.json +11 -12
- package/BUBBLEWRAP-REALITY.md +0 -210
- package/USAGE.md +0 -111
- package/container.js +0 -608
- package/debug-cli.js +0 -15
- package/lib/bubblewrap.js +0 -203
- package/playwright.sh +0 -183
- package/run.sh +0 -12
- package/scripts/build.js +0 -303
- package/scripts/download-bubblewrap.js +0 -186
- package/test-cli.js +0 -72
- package/test-project/Dockerfile.sandboxbox +0 -20
@@ -1,186 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Download bubblewrap binary during npm install
|
5
|
-
* Makes SandboxBox completely self-contained
|
6
|
-
*/
|
7
|
-
|
8
|
-
import https from 'https';
|
9
|
-
import fs from 'fs';
|
10
|
-
import path from 'path';
|
11
|
-
import { execSync } from 'child_process';
|
12
|
-
import { fileURLToPath } from 'url';
|
13
|
-
import { dirname } from 'path';
|
14
|
-
|
15
|
-
const __filename = fileURLToPath(import.meta.url);
|
16
|
-
const __dirname = dirname(__filename);
|
17
|
-
|
18
|
-
const BINARY_DIR = path.join(__dirname, '..', 'bin');
|
19
|
-
const BWRAP_VERSION = '0.8.0';
|
20
|
-
|
21
|
-
console.log('đĻ Setting up SandboxBox with bubblewrap...');
|
22
|
-
|
23
|
-
async function downloadBubblewrap() {
|
24
|
-
// Create binary directory
|
25
|
-
if (!fs.existsSync(BINARY_DIR)) {
|
26
|
-
fs.mkdirSync(BINARY_DIR, { recursive: true });
|
27
|
-
}
|
28
|
-
|
29
|
-
const binaryPath = path.join(BINARY_DIR, 'bwrap');
|
30
|
-
|
31
|
-
// Skip download on non-Linux platforms
|
32
|
-
if (process.platform !== 'linux') {
|
33
|
-
console.log('âšī¸ Skipping bubblewrap download on non-Linux platform');
|
34
|
-
console.log(' SandboxBox works on Linux only');
|
35
|
-
return;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Try to use system bubblewrap first (fastest option)
|
39
|
-
try {
|
40
|
-
const systemBwrap = execSync('which bwrap', { encoding: 'utf8' }).trim();
|
41
|
-
if (systemBwrap && fs.existsSync(systemBwrap)) {
|
42
|
-
fs.copyFileSync(systemBwrap, binaryPath);
|
43
|
-
fs.chmodSync(binaryPath, 0o755);
|
44
|
-
console.log('â
Using system bubblewrap:', systemBwrap);
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
} catch (e) {
|
48
|
-
// System bwrap not found, continue with download
|
49
|
-
}
|
50
|
-
|
51
|
-
// Try to download pre-built binary
|
52
|
-
const arch = process.arch === 'x64' ? 'x86_64' : process.arch;
|
53
|
-
const binaryUrl = `https://github.com/containers/bubblewrap/releases/download/v${BWRAP_VERSION}/bubblewrap-${BWRAP_VERSION}.${arch}.tar.xz`;
|
54
|
-
|
55
|
-
try {
|
56
|
-
console.log('đĨ Downloading bubblewrap binary...');
|
57
|
-
|
58
|
-
// Download with fallback
|
59
|
-
await new Promise((resolve, reject) => {
|
60
|
-
const file = fs.createWriteStream(path.join(BINARY_DIR, `bubblewrap-${BWRAP_VERSION}.tar.xz`));
|
61
|
-
|
62
|
-
https.get(binaryUrl, (response) => {
|
63
|
-
if (response.statusCode !== 200) {
|
64
|
-
reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`));
|
65
|
-
return;
|
66
|
-
}
|
67
|
-
|
68
|
-
response.pipe(file);
|
69
|
-
|
70
|
-
file.on('finish', () => {
|
71
|
-
file.close();
|
72
|
-
console.log('đĻ Extracting bubblewrap...');
|
73
|
-
|
74
|
-
// Extract binary
|
75
|
-
try {
|
76
|
-
execSync(`tar -xf "${path.join(BINARY_DIR, `bubblewrap-${BWRAP_VERSION}.tar.xz`)}" -C "${BINARY_DIR}" --strip-components=1`, { stdio: 'inherit' });
|
77
|
-
|
78
|
-
// Move binary to expected location
|
79
|
-
const extractedBinary = path.join(BINARY_DIR, 'bin', 'bwrap');
|
80
|
-
if (fs.existsSync(extractedBinary)) {
|
81
|
-
fs.renameSync(extractedBinary, binaryPath);
|
82
|
-
} else {
|
83
|
-
// Try alternative extraction pattern
|
84
|
-
const altBinary = path.join(BINARY_DIR, 'bubblewrap-0.8.0', 'bwrap');
|
85
|
-
if (fs.existsSync(altBinary)) {
|
86
|
-
fs.renameSync(altBinary, binaryPath);
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
// Set executable permissions
|
91
|
-
fs.chmodSync(binaryPath, 0o755);
|
92
|
-
|
93
|
-
// Cleanup
|
94
|
-
fs.rmSync(path.join(BINARY_DIR, `bubblewrap-${BWRAP_VERSION}.tar.xz`), { force: true });
|
95
|
-
fs.rmSync(path.join(BINARY_DIR, 'bubblewrap-0.8.0'), { recursive: true, force: true });
|
96
|
-
|
97
|
-
console.log('â
Bubblewrap downloaded successfully');
|
98
|
-
resolve();
|
99
|
-
} catch (extractError) {
|
100
|
-
reject(new Error(`Failed to extract: ${extractError.message}`));
|
101
|
-
}
|
102
|
-
});
|
103
|
-
}).on('error', reject);
|
104
|
-
});
|
105
|
-
|
106
|
-
} catch (downloadError) {
|
107
|
-
console.log('â ī¸ Download failed, trying to compile from source...');
|
108
|
-
try {
|
109
|
-
await compileBubblewrap(binaryPath);
|
110
|
-
} catch (compileError) {
|
111
|
-
console.log('â Both download and compilation failed');
|
112
|
-
console.log('');
|
113
|
-
console.log('đĄ Easy solutions:');
|
114
|
-
console.log(' 1. Install system bubblewrap: sudo apt-get install bubblewrap');
|
115
|
-
console.log(' 2. Install build tools: sudo apt-get install build-essential xz-utils');
|
116
|
-
console.log(' 3. Use a Linux system with bubblewrap pre-installed');
|
117
|
-
console.log('');
|
118
|
-
console.log('SandboxBox will work with system bubblewrap if available.');
|
119
|
-
console.log('Continuing without bundled binary...');
|
120
|
-
return; // Don't exit, just continue without bundled binary
|
121
|
-
}
|
122
|
-
}
|
123
|
-
}
|
124
|
-
|
125
|
-
async function compileBubblewrap(binaryPath) {
|
126
|
-
try {
|
127
|
-
console.log('đ¨ Compiling bubblewrap from source...');
|
128
|
-
|
129
|
-
const tmpDir = fs.mkdtempSync(path.join(process.env.TMPDIR || '/tmp', 'bwrap-build-'));
|
130
|
-
|
131
|
-
try {
|
132
|
-
// Download source
|
133
|
-
execSync(`
|
134
|
-
cd "${tmpDir}" &&
|
135
|
-
wget -q https://github.com/containers/bubblewrap/releases/download/v${BWRAP_VERSION}/bubblewrap-${BWRAP_VERSION}.tar.xz &&
|
136
|
-
tar -xf bubblewrap-${BWRAP_VERSION}.tar.xz
|
137
|
-
`, { stdio: 'inherit' });
|
138
|
-
|
139
|
-
// Build dependencies check
|
140
|
-
try {
|
141
|
-
execSync('which gcc', { stdio: 'ignore' });
|
142
|
-
} catch (e) {
|
143
|
-
console.log('â GCC not found. Please install build-essential:');
|
144
|
-
console.log(' Ubuntu/Debian: sudo apt-get install build-essential');
|
145
|
-
console.log(' CentOS/RHEL: sudo yum groupinstall "Development Tools"');
|
146
|
-
console.log(' Or install bubblewrap system-wide: sudo apt-get install bubblewrap');
|
147
|
-
process.exit(1);
|
148
|
-
}
|
149
|
-
|
150
|
-
// Compile
|
151
|
-
execSync(`
|
152
|
-
cd "${tmpDir}/bubblewrap-${BWRAP_VERSION}" &&
|
153
|
-
./configure --prefix="${tmpDir}/install" &&
|
154
|
-
make -j$(nproc 2>/dev/null || echo 4) &&
|
155
|
-
make install
|
156
|
-
`, { stdio: 'inherit' });
|
157
|
-
|
158
|
-
// Copy binary
|
159
|
-
fs.copyFileSync(path.join(tmpDir, 'install', 'bin', 'bwrap'), binaryPath);
|
160
|
-
fs.chmodSync(binaryPath, 0o755);
|
161
|
-
|
162
|
-
console.log('â
Bubblewrap compiled successfully');
|
163
|
-
|
164
|
-
} finally {
|
165
|
-
// Cleanup
|
166
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
167
|
-
}
|
168
|
-
|
169
|
-
} catch (compileError) {
|
170
|
-
console.log('â Failed to compile bubblewrap');
|
171
|
-
console.log('đĄ Please install bubblewrap system-wide:');
|
172
|
-
console.log(' sudo apt-get install bubblewrap # Ubuntu/Debian');
|
173
|
-
console.log(' sudo apk add bubblewrap # Alpine');
|
174
|
-
console.log(' sudo yum install bubblewrap # CentOS/RHEL');
|
175
|
-
console.log('');
|
176
|
-
console.log('Then try installing SandboxBox again.');
|
177
|
-
throw compileError; // Re-throw to let the caller handle it
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
// Run the download
|
182
|
-
downloadBubblewrap().catch(error => {
|
183
|
-
console.error('â Setup failed:', error.message);
|
184
|
-
// Don't exit with error code 1, just warn and continue
|
185
|
-
console.log('âšī¸ SandboxBox will use system bubblewrap if available');
|
186
|
-
});
|
package/test-cli.js
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
console.log('đ SandboxBox test starting...');
|
4
|
-
console.log('Platform:', process.platform);
|
5
|
-
console.log('Node.js:', process.version);
|
6
|
-
|
7
|
-
const args = process.argv.slice(2);
|
8
|
-
|
9
|
-
// Handle --help and no arguments
|
10
|
-
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
11
|
-
showHelp();
|
12
|
-
process.exit(0);
|
13
|
-
}
|
14
|
-
|
15
|
-
// Handle version
|
16
|
-
if (args.includes('--version') || args[0] === 'version') {
|
17
|
-
console.log('SandboxBox v1.0.4');
|
18
|
-
console.log('Zero-privilege containers with Playwright support');
|
19
|
-
process.exit(0);
|
20
|
-
}
|
21
|
-
|
22
|
-
if (process.platform !== 'linux') {
|
23
|
-
console.log('â SandboxBox only works on Linux systems');
|
24
|
-
console.log('đ§ Required: Linux with bubblewrap (bwrap)');
|
25
|
-
console.log('');
|
26
|
-
console.log('đĄ Alternatives for Windows users:');
|
27
|
-
console.log(' âĸ Use WSL2 (Windows Subsystem for Linux 2)');
|
28
|
-
console.log(' âĸ Use Docker Desktop with Linux containers');
|
29
|
-
console.log(' âĸ Use GitHub Actions (ubuntu-latest runners)');
|
30
|
-
console.log(' âĸ Use a cloud Linux instance (AWS, GCP, Azure)');
|
31
|
-
console.log('');
|
32
|
-
console.log('â
On Linux/WSL2, simply run: npx sandboxbox --help');
|
33
|
-
process.exit(1);
|
34
|
-
}
|
35
|
-
|
36
|
-
console.log('â
Platform check passed - you are on Linux!');
|
37
|
-
console.log('đĻ SandboxBox - Zero-Privilege Container Runner');
|
38
|
-
console.log('âââââââââââââââââââââââââââââââââââââââââââââââââââââ');
|
39
|
-
console.log('');
|
40
|
-
console.log('â ī¸ This is a simplified test version.');
|
41
|
-
console.log('đ§ Full SandboxBox features are available on Linux systems.');
|
42
|
-
console.log('');
|
43
|
-
console.log('đ 8ms startup âĸ True isolation âĸ Playwright ready');
|
44
|
-
|
45
|
-
function showHelp() {
|
46
|
-
console.log('đĻ SandboxBox - Zero-Privilege Container Runner');
|
47
|
-
console.log('âââââââââââââââââââââââââââââââââââââââââââââââââââââ');
|
48
|
-
console.log('');
|
49
|
-
console.log('Usage: npx sandboxbox <command> [options]');
|
50
|
-
console.log('');
|
51
|
-
console.log('Commands:');
|
52
|
-
console.log(' setup Set up Alpine Linux environment (one-time)');
|
53
|
-
console.log(' build <dockerfile> Build container from Dockerfile');
|
54
|
-
console.log(' run <project-dir> Run Playwright tests in isolation');
|
55
|
-
console.log(' shell <project-dir> Start interactive shell in container');
|
56
|
-
console.log(' quick-test <project-dir> Quick test with sample Dockerfile');
|
57
|
-
console.log(' version Show version information');
|
58
|
-
console.log('');
|
59
|
-
console.log('Examples:');
|
60
|
-
console.log(' npx sandboxbox setup');
|
61
|
-
console.log(' npx sandboxbox build ./Dockerfile');
|
62
|
-
console.log(' npx sandboxbox run ./my-project');
|
63
|
-
console.log(' npx sandboxbox shell ./my-project');
|
64
|
-
console.log(' npx sandboxbox quick-test ./my-app');
|
65
|
-
console.log('');
|
66
|
-
console.log('Requirements:');
|
67
|
-
console.log(' - Linux system (WSL2 on Windows works great!)');
|
68
|
-
console.log(' - bubblewrap (bwrap): sudo apt-get install bubblewrap');
|
69
|
-
console.log(' - No root privileges needed after installation!');
|
70
|
-
console.log('');
|
71
|
-
console.log('đ 8ms startup âĸ True isolation âĸ Playwright ready');
|
72
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# Sample Dockerfile for SandboxBox
|
2
|
-
FROM alpine
|
3
|
-
|
4
|
-
# Install Node.js and test dependencies
|
5
|
-
RUN apk add --no-cache nodejs npm
|
6
|
-
|
7
|
-
# Set working directory
|
8
|
-
WORKDIR /app
|
9
|
-
|
10
|
-
# Copy package files (if they exist)
|
11
|
-
COPY package*.json ./
|
12
|
-
|
13
|
-
# Install dependencies (if package.json exists)
|
14
|
-
RUN if [ -f package.json ]; then npm install; fi
|
15
|
-
|
16
|
-
# Copy application code
|
17
|
-
COPY . .
|
18
|
-
|
19
|
-
# Default command - run tests or start app
|
20
|
-
CMD ["npm", "test"]
|