@genobank/biofs 1.8.2 → 1.8.4
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 +120 -171
- package/dist/commands/biofiles.d.ts +9 -0
- package/dist/commands/biofiles.d.ts.map +1 -0
- package/dist/commands/biofiles.js +112 -0
- package/dist/commands/biofiles.js.map +1 -0
- package/dist/commands/labs/list.d.ts +19 -0
- package/dist/commands/labs/list.d.ts.map +1 -0
- package/dist/commands/labs/list.js +98 -0
- package/dist/commands/labs/list.js.map +1 -0
- package/dist/commands/share.d.ts +10 -0
- package/dist/commands/share.d.ts.map +1 -0
- package/dist/commands/share.js +186 -0
- package/dist/commands/share.js.map +1 -0
- package/dist/commands/verify.d.ts +9 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +138 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/index.js +99 -42
- package/dist/index.js.map +1 -1
- package/dist/lib/ai/classifier.d.ts +1 -3
- package/dist/lib/ai/classifier.d.ts.map +1 -1
- package/dist/lib/ai/classifier.js +17 -37
- package/dist/lib/ai/classifier.js.map +1 -1
- package/dist/lib/api/client.d.ts +46 -0
- package/dist/lib/api/client.d.ts.map +1 -1
- package/dist/lib/api/client.js +159 -19
- package/dist/lib/api/client.js.map +1 -1
- package/dist/lib/auth/server.d.ts.map +1 -1
- package/dist/lib/auth/server.js +2 -11
- package/dist/lib/auth/server.js.map +1 -1
- package/dist/lib/biofiles/fingerprint.d.ts.map +1 -1
- package/dist/lib/biofiles/fingerprint.js +11 -40
- package/dist/lib/biofiles/fingerprint.js.map +1 -1
- package/dist/lib/biofiles/resolver.d.ts.map +1 -1
- package/dist/lib/biofiles/resolver.js +59 -75
- package/dist/lib/biofiles/resolver.js.map +1 -1
- package/dist/lib/config/constants.d.ts +1 -0
- package/dist/lib/config/constants.d.ts.map +1 -1
- package/dist/lib/config/constants.js +3 -3
- package/dist/lib/config/constants.js.map +1 -1
- package/dist/lib/utils/logger.d.ts +5 -6
- package/dist/lib/utils/logger.d.ts.map +1 -1
- package/dist/lib/utils/logger.js +5 -23
- package/dist/lib/utils/logger.js.map +1 -1
- package/dist/types/api.d.ts +21 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/biofiles.d.ts +2 -2
- package/dist/types/biofiles.d.ts.map +1 -1
- package/package.json +2 -3
- package/.claude/settings.local.json +0 -33
- package/BIOFS_CLI_NODE_CONVERGENCE_ANALYSIS.md +0 -932
- package/BIOFS_FEDERATED_NETWORK_ARCHITECTURE.md +0 -1071
- package/BIOFS_NODE_CLIENT_ARCHITECTURE.md +0 -557
- package/BIOFS_NODE_IMPLEMENTATION_PLAN.md +0 -2164
- package/BIOROUTER_IMPLEMENTATION_CHECKLIST.md +0 -618
- package/BUBBLEWRAP_INTEGRATION.md +0 -486
- package/BUBBLEWRAP_QUICKSTART.md +0 -356
- package/BUBBLEWRAP_README.md +0 -466
- package/BUBBLEWRAP_STRATEGIC_ANALYSIS.md +0 -625
- package/EXECUTIVE_SUMMARY_BIOROUTER_CONVERGENCE.md +0 -323
- package/GEMINI_REMOVAL_COMPLETE.md +0 -311
- package/debug_credentials.js +0 -60
- package/dist/commands/sandbox.d.ts +0 -10
- package/dist/commands/sandbox.d.ts.map +0 -1
- package/dist/commands/sandbox.js +0 -418
- package/dist/commands/sandbox.js.map +0 -1
- package/dist/lib/sandbox/bubblewrap.d.ts +0 -125
- package/dist/lib/sandbox/bubblewrap.d.ts.map +0 -1
- package/dist/lib/sandbox/bubblewrap.js +0 -343
- package/dist/lib/sandbox/bubblewrap.js.map +0 -1
- package/examples/sandbox-usage.ts +0 -361
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BioFS Bubblewrap Sandbox - Usage Examples
|
|
3
|
-
*
|
|
4
|
-
* Demonstrates how to use the bubblewrap sandbox integration
|
|
5
|
-
* for secure genomic data processing.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { BubblewrapSandbox, isSandboxAvailable } from '../src/lib/sandbox/bubblewrap';
|
|
9
|
-
import * as path from 'path';
|
|
10
|
-
import * as os from 'os';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Example 1: Basic sandboxed command execution
|
|
14
|
-
*/
|
|
15
|
-
async function basicExample() {
|
|
16
|
-
console.log('=== Example 1: Basic Sandboxed Execution ===\n');
|
|
17
|
-
|
|
18
|
-
const sandbox = new BubblewrapSandbox({
|
|
19
|
-
isolateNetwork: true,
|
|
20
|
-
isolatePID: true,
|
|
21
|
-
workingDir: '/workspace',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const result = await sandbox.exec(['echo', 'Hello from sandbox!']);
|
|
25
|
-
console.log('Output:', result.stdout);
|
|
26
|
-
console.log('Exit code:', result.exitCode);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Example 2: Sandboxed genomic file download
|
|
31
|
-
*/
|
|
32
|
-
async function downloadExample() {
|
|
33
|
-
console.log('\n=== Example 2: Sandboxed File Download ===\n');
|
|
34
|
-
|
|
35
|
-
const outputDir = path.join(os.homedir(), 'Downloads/genobank');
|
|
36
|
-
const sandbox = BubblewrapSandbox.forDownload(outputDir);
|
|
37
|
-
|
|
38
|
-
// Simulated download command
|
|
39
|
-
const result = await sandbox.exec([
|
|
40
|
-
'curl',
|
|
41
|
-
'-o',
|
|
42
|
-
'/output/sample.vcf',
|
|
43
|
-
'https://example.com/genomic-data/sample.vcf',
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
console.log('Download result:', result.exitCode === 0 ? 'Success' : 'Failed');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Example 3: Network-isolated file processing
|
|
51
|
-
*/
|
|
52
|
-
async function processingExample() {
|
|
53
|
-
console.log('\n=== Example 3: Network-Isolated Processing ===\n');
|
|
54
|
-
|
|
55
|
-
const inputFile = '/path/to/genome.vcf';
|
|
56
|
-
const outputDir = '/tmp/biofs-results';
|
|
57
|
-
|
|
58
|
-
const sandbox = BubblewrapSandbox.forProcessing(inputFile, outputDir);
|
|
59
|
-
|
|
60
|
-
// Process VCF file with NO network access (prevents exfiltration)
|
|
61
|
-
const result = await sandbox.exec([
|
|
62
|
-
'python3',
|
|
63
|
-
'/usr/local/bin/vcf-analyzer.py',
|
|
64
|
-
'/data/input',
|
|
65
|
-
'/data/output/results.csv',
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
console.log('Processing completed:', result.exitCode === 0 ? 'Success' : 'Failed');
|
|
69
|
-
console.log('Note: Process had ZERO network access - data exfiltration impossible');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Example 4: Research job with custom mounts
|
|
74
|
-
*/
|
|
75
|
-
async function jobExample() {
|
|
76
|
-
console.log('\n=== Example 4: Research Job Execution ===\n');
|
|
77
|
-
|
|
78
|
-
const sandbox = BubblewrapSandbox.forJob({
|
|
79
|
-
inputs: [
|
|
80
|
-
'/data/patient1.vcf',
|
|
81
|
-
'/data/patient2.vcf',
|
|
82
|
-
'/data/reference-genome.fasta',
|
|
83
|
-
],
|
|
84
|
-
outputDir: '/tmp/job-results',
|
|
85
|
-
allowNetwork: false, // No network for maximum security
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const result = await sandbox.exec([
|
|
89
|
-
'variant-caller',
|
|
90
|
-
'--input1',
|
|
91
|
-
'/data/input/0',
|
|
92
|
-
'--input2',
|
|
93
|
-
'/data/input/1',
|
|
94
|
-
'--reference',
|
|
95
|
-
'/data/input/2',
|
|
96
|
-
'--output',
|
|
97
|
-
'/data/output/variants.vcf',
|
|
98
|
-
]);
|
|
99
|
-
|
|
100
|
-
console.log('Job result:', result.exitCode === 0 ? 'Success' : 'Failed');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Example 5: Credential-protected operation
|
|
105
|
-
*/
|
|
106
|
-
async function credentialExample() {
|
|
107
|
-
console.log('\n=== Example 5: Credential Protection ===\n');
|
|
108
|
-
|
|
109
|
-
const sandbox = new BubblewrapSandbox({
|
|
110
|
-
isolateNetwork: false,
|
|
111
|
-
isolatePID: true,
|
|
112
|
-
isolateIPC: true,
|
|
113
|
-
mounts: [
|
|
114
|
-
{
|
|
115
|
-
source: path.join(os.homedir(), '.genobank/credentials.json'),
|
|
116
|
-
target: '/creds.json',
|
|
117
|
-
readonly: true, // ← Credentials mounted READ-ONLY
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const result = await sandbox.exec([
|
|
123
|
-
'node',
|
|
124
|
-
'/usr/local/lib/node_modules/@genobank/biofs/dist/lib/api/client.js',
|
|
125
|
-
'list-files',
|
|
126
|
-
]);
|
|
127
|
-
|
|
128
|
-
console.log('API call result:', result.stdout);
|
|
129
|
-
console.log('Note: Credentials were READ-ONLY - cannot be modified or stolen');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Example 6: GDPR consent enforcement
|
|
134
|
-
*/
|
|
135
|
-
async function gdprExample() {
|
|
136
|
-
console.log('\n=== Example 6: GDPR Consent Enforcement ===\n');
|
|
137
|
-
|
|
138
|
-
// User has NOT consented yet - file is NOT mounted
|
|
139
|
-
console.log('Step 1: File access requested, but no consent...');
|
|
140
|
-
|
|
141
|
-
let sandbox = new BubblewrapSandbox({
|
|
142
|
-
isolateNetwork: true,
|
|
143
|
-
isolatePID: true,
|
|
144
|
-
mounts: [], // ← No file access without consent
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
console.log('Step 2: Show consent prompt to user...');
|
|
148
|
-
console.log('[ User agrees to GDPR consent ]');
|
|
149
|
-
|
|
150
|
-
// After consent - NOW mount the file
|
|
151
|
-
console.log('Step 3: Consent recorded, file now accessible...');
|
|
152
|
-
|
|
153
|
-
sandbox = new BubblewrapSandbox({
|
|
154
|
-
isolateNetwork: true,
|
|
155
|
-
isolatePID: true,
|
|
156
|
-
mounts: [
|
|
157
|
-
{
|
|
158
|
-
source: '/vault/genomic-data/patient123.vcf',
|
|
159
|
-
target: '/data/genome.vcf',
|
|
160
|
-
readonly: true,
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const result = await sandbox.exec([
|
|
166
|
-
'genomic-analyzer',
|
|
167
|
-
'/data/genome.vcf',
|
|
168
|
-
]);
|
|
169
|
-
|
|
170
|
-
console.log('Analysis completed with GDPR compliance:', result.exitCode === 0);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Example 7: Multi-tenant isolation
|
|
175
|
-
*/
|
|
176
|
-
async function multiTenantExample() {
|
|
177
|
-
console.log('\n=== Example 7: Multi-Tenant Isolation ===\n');
|
|
178
|
-
|
|
179
|
-
// Researcher A's sandbox
|
|
180
|
-
const sandboxA = new BubblewrapSandbox({
|
|
181
|
-
isolateNetwork: true,
|
|
182
|
-
isolatePID: true,
|
|
183
|
-
isolateIPC: true,
|
|
184
|
-
isolateUTS: true,
|
|
185
|
-
hostname: 'researcher-a',
|
|
186
|
-
uid: 1000,
|
|
187
|
-
gid: 1000,
|
|
188
|
-
mounts: [
|
|
189
|
-
{
|
|
190
|
-
source: '/home/researcher-a/.genobank',
|
|
191
|
-
target: '/home/user/.genobank',
|
|
192
|
-
readonly: false,
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Researcher B's sandbox (completely isolated from A)
|
|
198
|
-
const sandboxB = new BubblewrapSandbox({
|
|
199
|
-
isolateNetwork: true,
|
|
200
|
-
isolatePID: true,
|
|
201
|
-
isolateIPC: true,
|
|
202
|
-
isolateUTS: true,
|
|
203
|
-
hostname: 'researcher-b',
|
|
204
|
-
uid: 1001,
|
|
205
|
-
gid: 1001,
|
|
206
|
-
mounts: [
|
|
207
|
-
{
|
|
208
|
-
source: '/home/researcher-b/.genobank',
|
|
209
|
-
target: '/home/user/.genobank',
|
|
210
|
-
readonly: false,
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
console.log('Researcher A and B are completely isolated:');
|
|
216
|
-
console.log('- Separate PID namespaces (cannot see each other\'s processes)');
|
|
217
|
-
console.log('- Separate IPC namespaces (no shared memory)');
|
|
218
|
-
console.log('- Separate filesystems (cannot access each other\'s data)');
|
|
219
|
-
console.log('- Separate hostnames (process isolation visible)');
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Example 8: Plugin system with sandboxing
|
|
224
|
-
*/
|
|
225
|
-
async function pluginExample() {
|
|
226
|
-
console.log('\n=== Example 8: Untrusted Plugin Execution ===\n');
|
|
227
|
-
|
|
228
|
-
const sandbox = new BubblewrapSandbox({
|
|
229
|
-
isolateNetwork: true, // Plugin cannot phone home
|
|
230
|
-
isolatePID: true,
|
|
231
|
-
isolateIPC: true,
|
|
232
|
-
dropCapabilities: true, // No special privileges
|
|
233
|
-
enableSeccomp: true, // Syscall restrictions
|
|
234
|
-
mounts: [
|
|
235
|
-
{
|
|
236
|
-
source: '/opt/biofs-plugins/community-variant-filter',
|
|
237
|
-
target: '/plugin',
|
|
238
|
-
readonly: true, // Plugin code is read-only
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
source: '/data/input.vcf',
|
|
242
|
-
target: '/data/input.vcf',
|
|
243
|
-
readonly: true,
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
source: '/tmp/plugin-output',
|
|
247
|
-
target: '/output',
|
|
248
|
-
readonly: false,
|
|
249
|
-
},
|
|
250
|
-
],
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
const result = await sandbox.exec([
|
|
254
|
-
'/plugin/run.sh',
|
|
255
|
-
'/data/input.vcf',
|
|
256
|
-
'/output/filtered.vcf',
|
|
257
|
-
]);
|
|
258
|
-
|
|
259
|
-
console.log('Plugin execution result:', result.exitCode === 0 ? 'Success' : 'Failed');
|
|
260
|
-
console.log('Security guarantees:');
|
|
261
|
-
console.log(' - Plugin had NO network access (cannot exfiltrate data)');
|
|
262
|
-
console.log(' - Plugin had NO write access to system (cannot install backdoor)');
|
|
263
|
-
console.log(' - Plugin had NO special capabilities (cannot escalate privileges)');
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Example 9: Check sandbox availability
|
|
268
|
-
*/
|
|
269
|
-
async function availabilityCheck() {
|
|
270
|
-
console.log('\n=== Example 9: Sandbox Availability Check ===\n');
|
|
271
|
-
|
|
272
|
-
const available = await isSandboxAvailable();
|
|
273
|
-
|
|
274
|
-
if (available) {
|
|
275
|
-
const version = await BubblewrapSandbox.getVersion();
|
|
276
|
-
console.log('✅ Bubblewrap is available');
|
|
277
|
-
console.log('Version:', version);
|
|
278
|
-
} else {
|
|
279
|
-
console.log('❌ Bubblewrap is NOT installed');
|
|
280
|
-
console.log('Install with: sudo apt-get install bubblewrap');
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Example 10: Performance comparison
|
|
286
|
-
*/
|
|
287
|
-
async function performanceExample() {
|
|
288
|
-
console.log('\n=== Example 10: Performance Comparison ===\n');
|
|
289
|
-
|
|
290
|
-
const testCommand = ['echo', 'test'];
|
|
291
|
-
|
|
292
|
-
// Without sandbox
|
|
293
|
-
const start1 = Date.now();
|
|
294
|
-
const { execFile } = require('child_process');
|
|
295
|
-
const { promisify } = require('util');
|
|
296
|
-
await promisify(execFile)('echo', ['test']);
|
|
297
|
-
const time1 = Date.now() - start1;
|
|
298
|
-
|
|
299
|
-
// With sandbox
|
|
300
|
-
const sandbox = new BubblewrapSandbox({
|
|
301
|
-
isolateNetwork: true,
|
|
302
|
-
isolatePID: true,
|
|
303
|
-
});
|
|
304
|
-
const start2 = Date.now();
|
|
305
|
-
await sandbox.exec(testCommand);
|
|
306
|
-
const time2 = Date.now() - start2;
|
|
307
|
-
|
|
308
|
-
console.log('Direct execution:', time1, 'ms');
|
|
309
|
-
console.log('Sandboxed execution:', time2, 'ms');
|
|
310
|
-
console.log('Overhead:', time2 - time1, 'ms');
|
|
311
|
-
console.log(
|
|
312
|
-
'Performance impact:',
|
|
313
|
-
(((time2 - time1) / time1) * 100).toFixed(2),
|
|
314
|
-
'%'
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Run all examples
|
|
320
|
-
*/
|
|
321
|
-
async function main() {
|
|
322
|
-
console.log('╔════════════════════════════════════════════════════════════╗');
|
|
323
|
-
console.log('║ BioFS Bubblewrap Sandbox - Comprehensive Usage Examples ║');
|
|
324
|
-
console.log('╚════════════════════════════════════════════════════════════╝\n');
|
|
325
|
-
|
|
326
|
-
try {
|
|
327
|
-
await availabilityCheck();
|
|
328
|
-
|
|
329
|
-
if (await isSandboxAvailable()) {
|
|
330
|
-
await basicExample();
|
|
331
|
-
// await downloadExample();
|
|
332
|
-
// await processingExample();
|
|
333
|
-
// await jobExample();
|
|
334
|
-
// await credentialExample();
|
|
335
|
-
await gdprExample();
|
|
336
|
-
await multiTenantExample();
|
|
337
|
-
await pluginExample();
|
|
338
|
-
// await performanceExample();
|
|
339
|
-
}
|
|
340
|
-
} catch (error) {
|
|
341
|
-
console.error('Error running examples:', error);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Run if executed directly
|
|
346
|
-
if (require.main === module) {
|
|
347
|
-
main().catch(console.error);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
export {
|
|
351
|
-
basicExample,
|
|
352
|
-
downloadExample,
|
|
353
|
-
processingExample,
|
|
354
|
-
jobExample,
|
|
355
|
-
credentialExample,
|
|
356
|
-
gdprExample,
|
|
357
|
-
multiTenantExample,
|
|
358
|
-
pluginExample,
|
|
359
|
-
availabilityCheck,
|
|
360
|
-
performanceExample,
|
|
361
|
-
};
|