@genobank/biofs 1.6.1 → 1.6.3
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/.claude/settings.local.json +33 -0
- package/BIOFS_FEDERATED_NETWORK_ARCHITECTURE.md +1071 -0
- package/BIOFS_NODE_CLIENT_ARCHITECTURE.md +557 -0
- package/BIOFS_NODE_IMPLEMENTATION_PLAN.md +2164 -0
- package/BUBBLEWRAP_INTEGRATION.md +486 -0
- package/BUBBLEWRAP_QUICKSTART.md +356 -0
- package/BUBBLEWRAP_README.md +466 -0
- package/BUBBLEWRAP_STRATEGIC_ANALYSIS.md +625 -0
- package/CHANGELOG.md +22 -1
- package/GEMINI_REMOVAL_COMPLETE.md +311 -0
- package/dist/commands/sandbox.d.ts +10 -0
- package/dist/commands/sandbox.d.ts.map +1 -0
- package/dist/commands/sandbox.js +418 -0
- package/dist/commands/sandbox.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/lib/ai/classifier.d.ts +3 -1
- package/dist/lib/ai/classifier.d.ts.map +1 -1
- package/dist/lib/ai/classifier.js +37 -14
- package/dist/lib/ai/classifier.js.map +1 -1
- package/dist/lib/config/constants.d.ts +0 -1
- 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/sandbox/bubblewrap.d.ts +125 -0
- package/dist/lib/sandbox/bubblewrap.d.ts.map +1 -0
- package/dist/lib/sandbox/bubblewrap.js +343 -0
- package/dist/lib/sandbox/bubblewrap.js.map +1 -0
- package/dist/lib/utils/logger.d.ts +6 -5
- package/dist/lib/utils/logger.d.ts.map +1 -1
- package/dist/lib/utils/logger.js +23 -5
- package/dist/lib/utils/logger.js.map +1 -1
- package/examples/sandbox-usage.ts +361 -0
- package/package.json +2 -2
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bubblewrap Sandbox Integration for BioFS-CLI
|
|
3
|
+
*
|
|
4
|
+
* Provides secure isolation for genomic data processing operations
|
|
5
|
+
* using Linux namespaces via bubblewrap.
|
|
6
|
+
*
|
|
7
|
+
* Security guarantees:
|
|
8
|
+
* - Process isolation (PID namespace)
|
|
9
|
+
* - Network isolation (NET namespace)
|
|
10
|
+
* - Filesystem isolation (MOUNT namespace)
|
|
11
|
+
* - IPC isolation (IPC namespace)
|
|
12
|
+
* - Seccomp syscall filtering
|
|
13
|
+
* - Capability dropping
|
|
14
|
+
*
|
|
15
|
+
* @module lib/sandbox/bubblewrap
|
|
16
|
+
*/
|
|
17
|
+
export interface MountConfig {
|
|
18
|
+
source: string;
|
|
19
|
+
target: string;
|
|
20
|
+
readonly?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface SandboxConfig {
|
|
23
|
+
/** Isolate network namespace (blocks all network access) */
|
|
24
|
+
isolateNetwork?: boolean;
|
|
25
|
+
/** Isolate PID namespace (process cannot see other processes) */
|
|
26
|
+
isolatePID?: boolean;
|
|
27
|
+
/** Isolate IPC namespace (no shared memory/semaphores) */
|
|
28
|
+
isolateIPC?: boolean;
|
|
29
|
+
/** Isolate UTS namespace (separate hostname) */
|
|
30
|
+
isolateUTS?: boolean;
|
|
31
|
+
/** Enable seccomp syscall filtering */
|
|
32
|
+
enableSeccomp?: boolean;
|
|
33
|
+
/** Drop all Linux capabilities */
|
|
34
|
+
dropCapabilities?: boolean;
|
|
35
|
+
/** Custom hostname for isolated environment */
|
|
36
|
+
hostname?: string;
|
|
37
|
+
/** Working directory inside sandbox */
|
|
38
|
+
workingDir?: string;
|
|
39
|
+
/** Environment variables to set */
|
|
40
|
+
env?: Record<string, string>;
|
|
41
|
+
/** Filesystem mounts */
|
|
42
|
+
mounts?: MountConfig[];
|
|
43
|
+
/** Allow access to /dev devices */
|
|
44
|
+
allowDevices?: boolean;
|
|
45
|
+
/** Allow /proc filesystem */
|
|
46
|
+
allowProc?: boolean;
|
|
47
|
+
/** Create temporary /tmp filesystem */
|
|
48
|
+
useTmpfs?: boolean;
|
|
49
|
+
/** Die when parent process exits */
|
|
50
|
+
dieWithParent?: boolean;
|
|
51
|
+
/** Create new session (prevents TIOCSTI attacks) */
|
|
52
|
+
newSession?: boolean;
|
|
53
|
+
/** UID to run as (default: current user) */
|
|
54
|
+
uid?: number;
|
|
55
|
+
/** GID to run as (default: current group) */
|
|
56
|
+
gid?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface ExecResult {
|
|
59
|
+
stdout: string;
|
|
60
|
+
stderr: string;
|
|
61
|
+
exitCode: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Bubblewrap sandbox wrapper for secure genomic data processing
|
|
65
|
+
*/
|
|
66
|
+
export declare class BubblewrapSandbox {
|
|
67
|
+
private config;
|
|
68
|
+
constructor(config?: SandboxConfig);
|
|
69
|
+
/**
|
|
70
|
+
* Check if bubblewrap is available on the system
|
|
71
|
+
*/
|
|
72
|
+
static isAvailable(): Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Get bubblewrap version
|
|
75
|
+
*/
|
|
76
|
+
static getVersion(): Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* Execute a command in a sandboxed environment
|
|
79
|
+
*/
|
|
80
|
+
exec(command: string[], options?: {
|
|
81
|
+
stdin?: string;
|
|
82
|
+
timeout?: number;
|
|
83
|
+
maxBuffer?: number;
|
|
84
|
+
}): Promise<ExecResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Build bubblewrap argument array from config
|
|
87
|
+
*/
|
|
88
|
+
private buildBwrapArgs;
|
|
89
|
+
/**
|
|
90
|
+
* Create seccomp filter for syscall restrictions
|
|
91
|
+
*
|
|
92
|
+
* Allows safe syscalls for file I/O, memory management, and process control
|
|
93
|
+
* Blocks dangerous syscalls like ptrace, mount, kexec, etc.
|
|
94
|
+
*/
|
|
95
|
+
private createSeccompFilter;
|
|
96
|
+
/**
|
|
97
|
+
* Create a pre-configured sandbox for genomic file download
|
|
98
|
+
*/
|
|
99
|
+
static forDownload(outputDir: string): BubblewrapSandbox;
|
|
100
|
+
/**
|
|
101
|
+
* Create a pre-configured sandbox for genomic file upload
|
|
102
|
+
*/
|
|
103
|
+
static forUpload(inputPath: string, tempDir: string): BubblewrapSandbox;
|
|
104
|
+
/**
|
|
105
|
+
* Create a pre-configured sandbox for local file processing (no network)
|
|
106
|
+
*/
|
|
107
|
+
static forProcessing(inputPath: string, outputDir: string): BubblewrapSandbox;
|
|
108
|
+
/**
|
|
109
|
+
* Create a pre-configured sandbox for research job execution
|
|
110
|
+
*/
|
|
111
|
+
static forJob(jobConfig: {
|
|
112
|
+
inputs: string[];
|
|
113
|
+
outputDir: string;
|
|
114
|
+
allowNetwork?: boolean;
|
|
115
|
+
}): BubblewrapSandbox;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Convenience function to check if sandboxing is available
|
|
119
|
+
*/
|
|
120
|
+
export declare function isSandboxAvailable(): Promise<boolean>;
|
|
121
|
+
/**
|
|
122
|
+
* Convenience function to get sandbox version info
|
|
123
|
+
*/
|
|
124
|
+
export declare function getSandboxVersion(): Promise<string>;
|
|
125
|
+
//# sourceMappingURL=bubblewrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubblewrap.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/bubblewrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAWH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,iEAAiE;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAA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L,OAAO,CAAC,UAAU,CAAC;IA6CtB;;OAEG;YACW,cAAc;IAmH5B;;;;;OAKG;YACW,mBAAmB;IAMjC;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB;IAiBxD;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAkBvE;;OAEG;IACH,MAAM,CAAC,aAAa,CAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,iBAAiB;IAapB;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;QACvB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,GAAG,iBAAiB;CAqBtB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAE3D;AAED;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEzD"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bubblewrap Sandbox Integration for BioFS-CLI
|
|
4
|
+
*
|
|
5
|
+
* Provides secure isolation for genomic data processing operations
|
|
6
|
+
* using Linux namespaces via bubblewrap.
|
|
7
|
+
*
|
|
8
|
+
* Security guarantees:
|
|
9
|
+
* - Process isolation (PID namespace)
|
|
10
|
+
* - Network isolation (NET namespace)
|
|
11
|
+
* - Filesystem isolation (MOUNT namespace)
|
|
12
|
+
* - IPC isolation (IPC namespace)
|
|
13
|
+
* - Seccomp syscall filtering
|
|
14
|
+
* - Capability dropping
|
|
15
|
+
*
|
|
16
|
+
* @module lib/sandbox/bubblewrap
|
|
17
|
+
*/
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
30
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
31
|
+
}) : function(o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
35
|
+
var ownKeys = function(o) {
|
|
36
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
37
|
+
var ar = [];
|
|
38
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
41
|
+
return ownKeys(o);
|
|
42
|
+
};
|
|
43
|
+
return function (mod) {
|
|
44
|
+
if (mod && mod.__esModule) return mod;
|
|
45
|
+
var result = {};
|
|
46
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
47
|
+
__setModuleDefault(result, mod);
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
})();
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.BubblewrapSandbox = void 0;
|
|
53
|
+
exports.isSandboxAvailable = isSandboxAvailable;
|
|
54
|
+
exports.getSandboxVersion = getSandboxVersion;
|
|
55
|
+
const child_process_1 = require("child_process");
|
|
56
|
+
const util_1 = require("util");
|
|
57
|
+
const fs = __importStar(require("fs-extra"));
|
|
58
|
+
const path = __importStar(require("path"));
|
|
59
|
+
const os = __importStar(require("os"));
|
|
60
|
+
const logger_1 = require("../utils/logger");
|
|
61
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
62
|
+
/**
|
|
63
|
+
* Bubblewrap sandbox wrapper for secure genomic data processing
|
|
64
|
+
*/
|
|
65
|
+
class BubblewrapSandbox {
|
|
66
|
+
constructor(config = {}) {
|
|
67
|
+
// Secure defaults for genomic data processing
|
|
68
|
+
this.config = {
|
|
69
|
+
isolateNetwork: config.isolateNetwork ?? true,
|
|
70
|
+
isolatePID: config.isolatePID ?? true,
|
|
71
|
+
isolateIPC: config.isolateIPC ?? true,
|
|
72
|
+
isolateUTS: config.isolateUTS ?? true,
|
|
73
|
+
enableSeccomp: config.enableSeccomp ?? true,
|
|
74
|
+
dropCapabilities: config.dropCapabilities ?? true,
|
|
75
|
+
hostname: config.hostname ?? 'biofs-sandbox',
|
|
76
|
+
workingDir: config.workingDir ?? '/workspace',
|
|
77
|
+
env: config.env ?? {},
|
|
78
|
+
mounts: config.mounts ?? [],
|
|
79
|
+
allowDevices: config.allowDevices ?? true,
|
|
80
|
+
allowProc: config.allowProc ?? true,
|
|
81
|
+
useTmpfs: config.useTmpfs ?? true,
|
|
82
|
+
dieWithParent: config.dieWithParent ?? true,
|
|
83
|
+
newSession: config.newSession ?? true,
|
|
84
|
+
uid: config.uid ?? os.userInfo().uid,
|
|
85
|
+
gid: config.gid ?? os.userInfo().gid,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Check if bubblewrap is available on the system
|
|
90
|
+
*/
|
|
91
|
+
static async isAvailable() {
|
|
92
|
+
try {
|
|
93
|
+
await execFileAsync('which', ['bwrap']);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get bubblewrap version
|
|
102
|
+
*/
|
|
103
|
+
static async getVersion() {
|
|
104
|
+
try {
|
|
105
|
+
const { stdout } = await execFileAsync('bwrap', ['--version']);
|
|
106
|
+
return stdout.trim();
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
throw new Error(`Failed to get bubblewrap version: ${error}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Execute a command in a sandboxed environment
|
|
114
|
+
*/
|
|
115
|
+
async exec(command, options = {}) {
|
|
116
|
+
if (!await BubblewrapSandbox.isAvailable()) {
|
|
117
|
+
throw new Error('bubblewrap is not installed. Install with: sudo apt-get install bubblewrap');
|
|
118
|
+
}
|
|
119
|
+
const bwrapArgs = await this.buildBwrapArgs(command);
|
|
120
|
+
logger_1.Logger.debug('Executing sandboxed command:', {
|
|
121
|
+
command: command.join(' '),
|
|
122
|
+
config: this.config,
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
const { stdout, stderr } = await execFileAsync('bwrap', bwrapArgs, {
|
|
126
|
+
timeout: options.timeout,
|
|
127
|
+
maxBuffer: options.maxBuffer ?? 10 * 1024 * 1024, // 10MB default
|
|
128
|
+
encoding: 'utf8',
|
|
129
|
+
});
|
|
130
|
+
return {
|
|
131
|
+
stdout,
|
|
132
|
+
stderr,
|
|
133
|
+
exitCode: 0,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
logger_1.Logger.error('Sandboxed command failed:', {
|
|
138
|
+
command: command.join(' '),
|
|
139
|
+
error: error.message,
|
|
140
|
+
stderr: error.stderr,
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
stdout: error.stdout || '',
|
|
144
|
+
stderr: error.stderr || error.message,
|
|
145
|
+
exitCode: error.code || 1,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Build bubblewrap argument array from config
|
|
151
|
+
*/
|
|
152
|
+
async buildBwrapArgs(command) {
|
|
153
|
+
const args = [];
|
|
154
|
+
// Essential system mounts (read-only)
|
|
155
|
+
args.push('--ro-bind', '/usr', '/usr');
|
|
156
|
+
args.push('--ro-bind', '/lib', '/lib');
|
|
157
|
+
if (await fs.pathExists('/lib64')) {
|
|
158
|
+
args.push('--ro-bind', '/lib64', '/lib64');
|
|
159
|
+
}
|
|
160
|
+
if (await fs.pathExists('/bin')) {
|
|
161
|
+
args.push('--ro-bind', '/bin', '/bin');
|
|
162
|
+
}
|
|
163
|
+
if (await fs.pathExists('/sbin')) {
|
|
164
|
+
args.push('--ro-bind', '/sbin', '/sbin');
|
|
165
|
+
}
|
|
166
|
+
// /proc filesystem
|
|
167
|
+
if (this.config.allowProc) {
|
|
168
|
+
args.push('--proc', '/proc');
|
|
169
|
+
}
|
|
170
|
+
// /dev devices
|
|
171
|
+
if (this.config.allowDevices) {
|
|
172
|
+
args.push('--dev', '/dev');
|
|
173
|
+
}
|
|
174
|
+
// Temporary filesystem for /tmp
|
|
175
|
+
if (this.config.useTmpfs) {
|
|
176
|
+
args.push('--tmpfs', '/tmp');
|
|
177
|
+
}
|
|
178
|
+
// Custom mounts
|
|
179
|
+
for (const mount of this.config.mounts) {
|
|
180
|
+
const mountFlag = mount.readonly ? '--ro-bind' : '--bind';
|
|
181
|
+
const resolvedSource = path.resolve(mount.source);
|
|
182
|
+
// Verify source exists
|
|
183
|
+
if (!await fs.pathExists(resolvedSource)) {
|
|
184
|
+
throw new Error(`Mount source does not exist: ${resolvedSource}`);
|
|
185
|
+
}
|
|
186
|
+
args.push(mountFlag, resolvedSource, mount.target);
|
|
187
|
+
}
|
|
188
|
+
// Working directory
|
|
189
|
+
if (this.config.workingDir) {
|
|
190
|
+
args.push('--chdir', this.config.workingDir);
|
|
191
|
+
}
|
|
192
|
+
// Network isolation
|
|
193
|
+
if (this.config.isolateNetwork) {
|
|
194
|
+
args.push('--unshare-net');
|
|
195
|
+
}
|
|
196
|
+
// PID isolation
|
|
197
|
+
if (this.config.isolatePID) {
|
|
198
|
+
args.push('--unshare-pid');
|
|
199
|
+
}
|
|
200
|
+
// IPC isolation
|
|
201
|
+
if (this.config.isolateIPC) {
|
|
202
|
+
args.push('--unshare-ipc');
|
|
203
|
+
}
|
|
204
|
+
// UTS isolation (hostname)
|
|
205
|
+
if (this.config.isolateUTS) {
|
|
206
|
+
args.push('--unshare-uts');
|
|
207
|
+
args.push('--hostname', this.config.hostname);
|
|
208
|
+
}
|
|
209
|
+
// User namespace
|
|
210
|
+
args.push('--unshare-user');
|
|
211
|
+
args.push('--uid', this.config.uid.toString());
|
|
212
|
+
args.push('--gid', this.config.gid.toString());
|
|
213
|
+
// Drop capabilities
|
|
214
|
+
if (this.config.dropCapabilities) {
|
|
215
|
+
args.push('--cap-drop', 'ALL');
|
|
216
|
+
}
|
|
217
|
+
// Seccomp filter
|
|
218
|
+
if (this.config.enableSeccomp) {
|
|
219
|
+
// Create temporary seccomp filter file
|
|
220
|
+
const seccompFilter = await this.createSeccompFilter();
|
|
221
|
+
args.push('--seccomp', '3');
|
|
222
|
+
// TODO: Pass seccomp filter via fd 3
|
|
223
|
+
}
|
|
224
|
+
// Die with parent
|
|
225
|
+
if (this.config.dieWithParent) {
|
|
226
|
+
args.push('--die-with-parent');
|
|
227
|
+
}
|
|
228
|
+
// New session
|
|
229
|
+
if (this.config.newSession) {
|
|
230
|
+
args.push('--new-session');
|
|
231
|
+
}
|
|
232
|
+
// Environment variables
|
|
233
|
+
for (const [key, value] of Object.entries(this.config.env)) {
|
|
234
|
+
args.push('--setenv', key, value);
|
|
235
|
+
}
|
|
236
|
+
// Command separator
|
|
237
|
+
args.push('--');
|
|
238
|
+
// Actual command to execute
|
|
239
|
+
args.push(...command);
|
|
240
|
+
return args;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Create seccomp filter for syscall restrictions
|
|
244
|
+
*
|
|
245
|
+
* Allows safe syscalls for file I/O, memory management, and process control
|
|
246
|
+
* Blocks dangerous syscalls like ptrace, mount, kexec, etc.
|
|
247
|
+
*/
|
|
248
|
+
async createSeccompFilter() {
|
|
249
|
+
// TODO: Implement seccomp BPF filter
|
|
250
|
+
// For now, bubblewrap's default filter is sufficient
|
|
251
|
+
return '';
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create a pre-configured sandbox for genomic file download
|
|
255
|
+
*/
|
|
256
|
+
static forDownload(outputDir) {
|
|
257
|
+
return new BubblewrapSandbox({
|
|
258
|
+
isolateNetwork: false, // Need network for S3/IPFS
|
|
259
|
+
isolatePID: true,
|
|
260
|
+
isolateIPC: true,
|
|
261
|
+
mounts: [
|
|
262
|
+
{ source: outputDir, target: '/output', readonly: false },
|
|
263
|
+
{
|
|
264
|
+
source: path.join(os.homedir(), '.genobank/credentials.json'),
|
|
265
|
+
target: '/credentials.json',
|
|
266
|
+
readonly: true,
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
workingDir: '/output',
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Create a pre-configured sandbox for genomic file upload
|
|
274
|
+
*/
|
|
275
|
+
static forUpload(inputPath, tempDir) {
|
|
276
|
+
return new BubblewrapSandbox({
|
|
277
|
+
isolateNetwork: false, // Need network for S3
|
|
278
|
+
isolatePID: true,
|
|
279
|
+
isolateIPC: true,
|
|
280
|
+
mounts: [
|
|
281
|
+
{ source: inputPath, target: '/input', readonly: true },
|
|
282
|
+
{ source: tempDir, target: '/temp', readonly: false },
|
|
283
|
+
{
|
|
284
|
+
source: path.join(os.homedir(), '.genobank/credentials.json'),
|
|
285
|
+
target: '/credentials.json',
|
|
286
|
+
readonly: true,
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
workingDir: '/temp',
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Create a pre-configured sandbox for local file processing (no network)
|
|
294
|
+
*/
|
|
295
|
+
static forProcessing(inputPath, outputDir) {
|
|
296
|
+
return new BubblewrapSandbox({
|
|
297
|
+
isolateNetwork: true, // NO NETWORK - prevent exfiltration
|
|
298
|
+
isolatePID: true,
|
|
299
|
+
isolateIPC: true,
|
|
300
|
+
mounts: [
|
|
301
|
+
{ source: inputPath, target: '/data/input', readonly: true },
|
|
302
|
+
{ source: outputDir, target: '/data/output', readonly: false },
|
|
303
|
+
],
|
|
304
|
+
workingDir: '/data',
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Create a pre-configured sandbox for research job execution
|
|
309
|
+
*/
|
|
310
|
+
static forJob(jobConfig) {
|
|
311
|
+
const mounts = jobConfig.inputs.map((input, index) => ({
|
|
312
|
+
source: input,
|
|
313
|
+
target: `/data/input/${index}`,
|
|
314
|
+
readonly: true,
|
|
315
|
+
}));
|
|
316
|
+
mounts.push({
|
|
317
|
+
source: jobConfig.outputDir,
|
|
318
|
+
target: '/data/output',
|
|
319
|
+
readonly: false,
|
|
320
|
+
});
|
|
321
|
+
return new BubblewrapSandbox({
|
|
322
|
+
isolateNetwork: !jobConfig.allowNetwork,
|
|
323
|
+
isolatePID: true,
|
|
324
|
+
isolateIPC: true,
|
|
325
|
+
mounts,
|
|
326
|
+
workingDir: '/data',
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
exports.BubblewrapSandbox = BubblewrapSandbox;
|
|
331
|
+
/**
|
|
332
|
+
* Convenience function to check if sandboxing is available
|
|
333
|
+
*/
|
|
334
|
+
async function isSandboxAvailable() {
|
|
335
|
+
return BubblewrapSandbox.isAvailable();
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Convenience function to get sandbox version info
|
|
339
|
+
*/
|
|
340
|
+
async function getSandboxVersion() {
|
|
341
|
+
return BubblewrapSandbox.getVersion();
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=bubblewrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubblewr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,MAAM,EAAE,eAAe,KAAK,EAAE;YAC9B,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC,CAAC;QAEJ,MAAM,CAAC,IAAI,CAAC;YACV,MAAM,EAAE,SAAS,CAAC,SAAS;YAC3B,MAAM,EAAE,cAAc;YACtB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;QAEH,OAAO,IAAI,iBAAiB,CAAC;YAC3B,cAAc,EAAE,CAAC,SAAS,CAAC,YAAY;YACvC,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,MAAM;YACN,UAAU,EAAE,OAAO;SACpB,CAAC,CAAC;IACL,CAAC;CACF;AAnUD,8CAmUC;AAED;;GAEG;AACI,KAAK,UAAU,kBAAkB;IACtC,OAAO,iBAAiB,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,iBAAiB;IACrC,OAAO,iBAAiB,CAAC,UAAU,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Ora } from 'ora';
|
|
2
2
|
export declare class Logger {
|
|
3
|
-
static success(message: string): void;
|
|
4
|
-
static error(message: string): void;
|
|
5
|
-
static warning(message: string): void;
|
|
6
|
-
static
|
|
7
|
-
static
|
|
3
|
+
static success(message: string, context?: any): void;
|
|
4
|
+
static error(message: string, context?: any): void;
|
|
5
|
+
static warning(message: string, context?: any): void;
|
|
6
|
+
static warn(message: string, context?: any): void;
|
|
7
|
+
static info(message: string, context?: any): void;
|
|
8
|
+
static debug(message: string, context?: any): void;
|
|
8
9
|
static box(content: string, title?: string): void;
|
|
9
10
|
static table(headers: string[], rows: string[][]): void;
|
|
10
11
|
static spinner(text: string): Ora;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/logger.ts"],"names":[],"mappings":"AAEA,OAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B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C,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;CAW1C"}
|
package/dist/lib/utils/logger.js
CHANGED
|
@@ -8,21 +8,39 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const boxen_1 = __importDefault(require("boxen"));
|
|
9
9
|
const ora_1 = __importDefault(require("ora"));
|
|
10
10
|
class Logger {
|
|
11
|
-
static success(message) {
|
|
11
|
+
static success(message, context) {
|
|
12
12
|
console.log(chalk_1.default.green(`✅ ${message}`));
|
|
13
|
+
if (context && process.env.DEBUG) {
|
|
14
|
+
console.log(chalk_1.default.gray(JSON.stringify(context, null, 2)));
|
|
15
|
+
}
|
|
13
16
|
}
|
|
14
|
-
static error(message) {
|
|
17
|
+
static error(message, context) {
|
|
15
18
|
console.log(chalk_1.default.red(`❌ ${message}`));
|
|
19
|
+
if (context) {
|
|
20
|
+
console.error(chalk_1.default.red(typeof context === 'string' ? context : JSON.stringify(context, null, 2)));
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
|
-
static warning(message) {
|
|
23
|
+
static warning(message, context) {
|
|
18
24
|
console.log(chalk_1.default.yellow(`⚠️ ${message}`));
|
|
25
|
+
if (context && process.env.DEBUG) {
|
|
26
|
+
console.log(chalk_1.default.gray(JSON.stringify(context, null, 2)));
|
|
27
|
+
}
|
|
19
28
|
}
|
|
20
|
-
static
|
|
29
|
+
static warn(message, context) {
|
|
30
|
+
this.warning(message, context);
|
|
31
|
+
}
|
|
32
|
+
static info(message, context) {
|
|
21
33
|
console.log(chalk_1.default.blue(`ℹ️ ${message}`));
|
|
34
|
+
if (context && process.env.DEBUG) {
|
|
35
|
+
console.log(chalk_1.default.gray(JSON.stringify(context, null, 2)));
|
|
36
|
+
}
|
|
22
37
|
}
|
|
23
|
-
static debug(message) {
|
|
38
|
+
static debug(message, context) {
|
|
24
39
|
if (process.env.DEBUG) {
|
|
25
40
|
console.log(chalk_1.default.gray(`🔍 ${message}`));
|
|
41
|
+
if (context) {
|
|
42
|
+
console.log(chalk_1.default.gray(JSON.stringify(context, null, 2)));
|
|
43
|
+
}
|
|
26
44
|
}
|
|
27
45
|
}
|
|
28
46
|
static box(content, title) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/lib/utils/logger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,kDAA0B;AAC1B,8CAA+B;AAE/B,MAAa,MAAM;IACjB,MAAM,CAAC,OAAO,CAAC,OAAe;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/lib/utils/logger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,kDAA0B;AAC1B,8CAA+B;AAE/B,MAAa,MAAM;IACjB,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,OAAa;QAC3C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;QACzC,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAe,EAAE,OAAa;QACzC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;QACvC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACrG,CAAC;IACH,CAAC;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