isol8 0.8.2 → 0.9.0-alpha.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/dist/cli.js +399 -79
- package/dist/docker/proxy-handler.sh +8 -0
- package/dist/docker/proxy.sh +3 -0
- package/dist/index.js +325 -13
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/engine/audit.d.ts +31 -0
- package/dist/src/engine/audit.d.ts.map +1 -0
- package/dist/src/engine/docker.d.ts +9 -0
- package/dist/src/engine/docker.d.ts.map +1 -1
- package/dist/src/engine/image-builder.d.ts.map +1 -1
- package/dist/src/engine/stats.d.ts +35 -0
- package/dist/src/engine/stats.d.ts.map +1 -0
- package/dist/src/engine/utils.d.ts +9 -0
- package/dist/src/engine/utils.d.ts.map +1 -1
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +85 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/schema/isol8.config.schema.json +47 -0
package/dist/cli.js
CHANGED
|
@@ -5038,23 +5038,23 @@ var require_nacl_fast = __commonJS((exports, module) => {
|
|
|
5038
5038
|
randombytes = fn;
|
|
5039
5039
|
};
|
|
5040
5040
|
(function() {
|
|
5041
|
-
var
|
|
5042
|
-
if (
|
|
5041
|
+
var crypto2 = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
|
|
5042
|
+
if (crypto2 && crypto2.getRandomValues) {
|
|
5043
5043
|
var QUOTA = 65536;
|
|
5044
5044
|
nacl.setPRNG(function(x, n) {
|
|
5045
5045
|
var i, v = new Uint8Array(n);
|
|
5046
5046
|
for (i = 0;i < n; i += QUOTA) {
|
|
5047
|
-
|
|
5047
|
+
crypto2.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
|
|
5048
5048
|
}
|
|
5049
5049
|
for (i = 0;i < n; i++)
|
|
5050
5050
|
x[i] = v[i];
|
|
5051
5051
|
cleanup(v);
|
|
5052
5052
|
});
|
|
5053
5053
|
} else if (true) {
|
|
5054
|
-
|
|
5055
|
-
if (
|
|
5054
|
+
crypto2 = __require("crypto");
|
|
5055
|
+
if (crypto2 && crypto2.randomBytes) {
|
|
5056
5056
|
nacl.setPRNG(function(x, n) {
|
|
5057
|
-
var i, v =
|
|
5057
|
+
var i, v = crypto2.randomBytes(n);
|
|
5058
5058
|
for (i = 0;i < n; i++)
|
|
5059
5059
|
x[i] = v[i];
|
|
5060
5060
|
cleanup(v);
|
|
@@ -6318,7 +6318,7 @@ var require_bcrypt_pbkdf = __commonJS((exports, module) => {
|
|
|
6318
6318
|
|
|
6319
6319
|
// node_modules/cpu-features/build/Release/cpufeatures.node
|
|
6320
6320
|
var require_cpufeatures = __commonJS((exports, module) => {
|
|
6321
|
-
module.exports = __require("./cpufeatures-
|
|
6321
|
+
module.exports = __require("./cpufeatures-8g73ch7n.node");
|
|
6322
6322
|
});
|
|
6323
6323
|
|
|
6324
6324
|
// node_modules/cpu-features/lib/index.js
|
|
@@ -6329,14 +6329,14 @@ var require_lib2 = __commonJS((exports, module) => {
|
|
|
6329
6329
|
|
|
6330
6330
|
// node_modules/ssh2/lib/protocol/constants.js
|
|
6331
6331
|
var require_constants = __commonJS((exports, module) => {
|
|
6332
|
-
var
|
|
6332
|
+
var crypto2 = __require("crypto");
|
|
6333
6333
|
var cpuInfo;
|
|
6334
6334
|
try {
|
|
6335
6335
|
cpuInfo = require_lib2()();
|
|
6336
6336
|
} catch {}
|
|
6337
6337
|
var { bindingAvailable, CIPHER_INFO, MAC_INFO } = require_crypto();
|
|
6338
6338
|
var eddsaSupported = (() => {
|
|
6339
|
-
if (typeof
|
|
6339
|
+
if (typeof crypto2.sign === "function" && typeof crypto2.verify === "function") {
|
|
6340
6340
|
const key = `-----BEGIN PRIVATE KEY-----\r
|
|
6341
6341
|
MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD` + `/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
|
|
6342
6342
|
-----END PRIVATE KEY-----`;
|
|
@@ -6344,14 +6344,14 @@ MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD` + `/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
|
|
|
6344
6344
|
let sig;
|
|
6345
6345
|
let verified;
|
|
6346
6346
|
try {
|
|
6347
|
-
sig =
|
|
6348
|
-
verified =
|
|
6347
|
+
sig = crypto2.sign(null, data, key);
|
|
6348
|
+
verified = crypto2.verify(null, data, key, sig);
|
|
6349
6349
|
} catch {}
|
|
6350
6350
|
return Buffer.isBuffer(sig) && sig.length === 64 && verified === true;
|
|
6351
6351
|
}
|
|
6352
6352
|
return false;
|
|
6353
6353
|
})();
|
|
6354
|
-
var curve25519Supported = typeof
|
|
6354
|
+
var curve25519Supported = typeof crypto2.diffieHellman === "function" && typeof crypto2.generateKeyPairSync === "function" && typeof crypto2.createPublicKey === "function";
|
|
6355
6355
|
var DEFAULT_KEX = [
|
|
6356
6356
|
"ecdh-sha2-nistp256",
|
|
6357
6357
|
"ecdh-sha2-nistp384",
|
|
@@ -6386,7 +6386,7 @@ MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD` + `/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
|
|
|
6386
6386
|
"ssh-dss"
|
|
6387
6387
|
]);
|
|
6388
6388
|
var canUseCipher = (() => {
|
|
6389
|
-
const ciphers =
|
|
6389
|
+
const ciphers = crypto2.getCiphers();
|
|
6390
6390
|
return (name) => ciphers.includes(CIPHER_INFO[name].sslName);
|
|
6391
6391
|
})();
|
|
6392
6392
|
var DEFAULT_CIPHER = [
|
|
@@ -6421,7 +6421,7 @@ MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD` + `/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
|
|
|
6421
6421
|
"arcfour"
|
|
6422
6422
|
].filter(canUseCipher));
|
|
6423
6423
|
var canUseMAC = (() => {
|
|
6424
|
-
const hashes =
|
|
6424
|
+
const hashes = crypto2.getHashes();
|
|
6425
6425
|
return (name) => hashes.includes(MAC_INFO[name].sslName);
|
|
6426
6426
|
})();
|
|
6427
6427
|
var DEFAULT_MAC = [
|
|
@@ -6931,12 +6931,12 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
6931
6931
|
|
|
6932
6932
|
// node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node
|
|
6933
6933
|
var require_sshcrypto = __commonJS((exports, module) => {
|
|
6934
|
-
module.exports = __require("./sshcrypto-
|
|
6934
|
+
module.exports = __require("./sshcrypto-f6atjna1.node");
|
|
6935
6935
|
});
|
|
6936
6936
|
|
|
6937
6937
|
// node_modules/ssh2/lib/protocol/crypto/poly1305.js
|
|
6938
6938
|
var require_poly1305 = __commonJS((exports, module) => {
|
|
6939
|
-
var __dirname = "/
|
|
6939
|
+
var __dirname = "/Users/dhruv/Developer/Projects/isol8/node_modules/ssh2/lib/protocol/crypto", __filename = "/Users/dhruv/Developer/Projects/isol8/node_modules/ssh2/lib/protocol/crypto/poly1305.js";
|
|
6940
6940
|
var createPoly1305 = function() {
|
|
6941
6941
|
var _scriptDir = typeof document !== "undefined" && document.currentScript ? document.currentScript.src : undefined;
|
|
6942
6942
|
if (typeof __filename !== "undefined")
|
|
@@ -8681,7 +8681,7 @@ ${formatted}-----END ${type} KEY-----`;
|
|
|
8681
8681
|
}
|
|
8682
8682
|
return Buffer.from(hex, "hex");
|
|
8683
8683
|
}
|
|
8684
|
-
return function
|
|
8684
|
+
return function genOpenSSLRSAPriv(n, e, d, iqmp, p, q) {
|
|
8685
8685
|
const bn_d = bigIntFromBuffer(d);
|
|
8686
8686
|
const dmp1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(p) - 1n));
|
|
8687
8687
|
const dmq1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(q) - 1n));
|
|
@@ -9709,7 +9709,7 @@ ${formatted}-----END ${type} KEY-----`;
|
|
|
9709
9709
|
|
|
9710
9710
|
// node_modules/ssh2/lib/agent.js
|
|
9711
9711
|
var require_agent = __commonJS((exports, module) => {
|
|
9712
|
-
var __dirname = "/
|
|
9712
|
+
var __dirname = "/Users/dhruv/Developer/Projects/isol8/node_modules/ssh2/lib";
|
|
9713
9713
|
var { Socket } = __require("net");
|
|
9714
9714
|
var { Duplex } = __require("stream");
|
|
9715
9715
|
var { resolve } = __require("path");
|
|
@@ -21682,7 +21682,7 @@ var require__stream_writable = __commonJS((exports, module) => {
|
|
|
21682
21682
|
}
|
|
21683
21683
|
});
|
|
21684
21684
|
} else {
|
|
21685
|
-
realHasInstance = function
|
|
21685
|
+
realHasInstance = function realHasInstance(object) {
|
|
21686
21686
|
return object instanceof this;
|
|
21687
21687
|
};
|
|
21688
21688
|
}
|
|
@@ -22480,28 +22480,28 @@ var require_end_of_stream = __commonJS((exports, module) => {
|
|
|
22480
22480
|
callback = once(callback || noop);
|
|
22481
22481
|
var readable = opts.readable || opts.readable !== false && stream.readable;
|
|
22482
22482
|
var writable = opts.writable || opts.writable !== false && stream.writable;
|
|
22483
|
-
var onlegacyfinish = function
|
|
22483
|
+
var onlegacyfinish = function onlegacyfinish() {
|
|
22484
22484
|
if (!stream.writable)
|
|
22485
22485
|
onfinish();
|
|
22486
22486
|
};
|
|
22487
22487
|
var writableEnded = stream._writableState && stream._writableState.finished;
|
|
22488
|
-
var onfinish = function
|
|
22488
|
+
var onfinish = function onfinish() {
|
|
22489
22489
|
writable = false;
|
|
22490
22490
|
writableEnded = true;
|
|
22491
22491
|
if (!readable)
|
|
22492
22492
|
callback.call(stream);
|
|
22493
22493
|
};
|
|
22494
22494
|
var readableEnded = stream._readableState && stream._readableState.endEmitted;
|
|
22495
|
-
var onend = function
|
|
22495
|
+
var onend = function onend() {
|
|
22496
22496
|
readable = false;
|
|
22497
22497
|
readableEnded = true;
|
|
22498
22498
|
if (!writable)
|
|
22499
22499
|
callback.call(stream);
|
|
22500
22500
|
};
|
|
22501
|
-
var onerror = function
|
|
22501
|
+
var onerror = function onerror(err) {
|
|
22502
22502
|
callback.call(stream, err);
|
|
22503
22503
|
};
|
|
22504
|
-
var onclose = function
|
|
22504
|
+
var onclose = function onclose() {
|
|
22505
22505
|
var err;
|
|
22506
22506
|
if (readable && !readableEnded) {
|
|
22507
22507
|
if (!stream._readableState || !stream._readableState.ended)
|
|
@@ -22514,7 +22514,7 @@ var require_end_of_stream = __commonJS((exports, module) => {
|
|
|
22514
22514
|
return callback.call(stream, err);
|
|
22515
22515
|
}
|
|
22516
22516
|
};
|
|
22517
|
-
var onrequest = function
|
|
22517
|
+
var onrequest = function onrequest() {
|
|
22518
22518
|
stream.req.on("finish", onfinish);
|
|
22519
22519
|
};
|
|
22520
22520
|
if (isRequest(stream)) {
|
|
@@ -22671,7 +22671,7 @@ var require_async_iterator = __commonJS((exports, module) => {
|
|
|
22671
22671
|
});
|
|
22672
22672
|
});
|
|
22673
22673
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
22674
|
-
var createReadableStreamAsyncIterator = function
|
|
22674
|
+
var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
|
|
22675
22675
|
var _Object$create;
|
|
22676
22676
|
var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
|
|
22677
22677
|
value: stream,
|
|
@@ -22860,7 +22860,7 @@ var require__stream_readable = __commonJS((exports, module) => {
|
|
|
22860
22860
|
var Duplex;
|
|
22861
22861
|
Readable.ReadableState = ReadableState;
|
|
22862
22862
|
var EE = __require("events").EventEmitter;
|
|
22863
|
-
var EElistenerCount = function
|
|
22863
|
+
var EElistenerCount = function EElistenerCount(emitter, type) {
|
|
22864
22864
|
return emitter.listeners(type).length;
|
|
22865
22865
|
};
|
|
22866
22866
|
var Stream = __require("stream");
|
|
@@ -22877,7 +22877,7 @@ var require__stream_readable = __commonJS((exports, module) => {
|
|
|
22877
22877
|
if (debugUtil && debugUtil.debuglog) {
|
|
22878
22878
|
debug = debugUtil.debuglog("stream");
|
|
22879
22879
|
} else {
|
|
22880
|
-
debug = function
|
|
22880
|
+
debug = function debug() {};
|
|
22881
22881
|
}
|
|
22882
22882
|
var BufferList = require_buffer_list();
|
|
22883
22883
|
var destroyImpl = require_destroy();
|
|
@@ -25535,14 +25535,14 @@ var require_BufferList = __commonJS((exports, module) => {
|
|
|
25535
25535
|
if (srcEnd <= 0) {
|
|
25536
25536
|
return dst || Buffer2.alloc(0);
|
|
25537
25537
|
}
|
|
25538
|
-
const
|
|
25538
|
+
const copy = !!dst;
|
|
25539
25539
|
const off = this._offset(srcStart);
|
|
25540
25540
|
const len = srcEnd - srcStart;
|
|
25541
25541
|
let bytes = len;
|
|
25542
|
-
let bufoff =
|
|
25542
|
+
let bufoff = copy && dstStart || 0;
|
|
25543
25543
|
let start = off[1];
|
|
25544
25544
|
if (srcStart === 0 && srcEnd === this.length) {
|
|
25545
|
-
if (!
|
|
25545
|
+
if (!copy) {
|
|
25546
25546
|
return this._bufs.length === 1 ? this._bufs[0] : Buffer2.concat(this._bufs, this.length);
|
|
25547
25547
|
}
|
|
25548
25548
|
for (let i = 0;i < this._bufs.length; i++) {
|
|
@@ -25552,9 +25552,9 @@ var require_BufferList = __commonJS((exports, module) => {
|
|
|
25552
25552
|
return dst;
|
|
25553
25553
|
}
|
|
25554
25554
|
if (bytes <= this._bufs[off[0]].length - start) {
|
|
25555
|
-
return
|
|
25555
|
+
return copy ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes) : this._bufs[off[0]].slice(start, start + bytes);
|
|
25556
25556
|
}
|
|
25557
|
-
if (!
|
|
25557
|
+
if (!copy) {
|
|
25558
25558
|
dst = Buffer2.allocUnsafe(len);
|
|
25559
25559
|
}
|
|
25560
25560
|
for (let i = off[0];i < this._bufs.length; i++) {
|
|
@@ -25776,7 +25776,7 @@ var require_bl = __commonJS((exports, module) => {
|
|
|
25776
25776
|
}
|
|
25777
25777
|
if (typeof callback === "function") {
|
|
25778
25778
|
this._callback = callback;
|
|
25779
|
-
const piper = function
|
|
25779
|
+
const piper = function piper(err) {
|
|
25780
25780
|
if (this._callback) {
|
|
25781
25781
|
this._callback(err);
|
|
25782
25782
|
this._callback = null;
|
|
@@ -34839,7 +34839,7 @@ var require_writer2 = __commonJS((exports, module) => {
|
|
|
34839
34839
|
this.tail = this.head;
|
|
34840
34840
|
this.states = null;
|
|
34841
34841
|
}
|
|
34842
|
-
var create = function
|
|
34842
|
+
var create = function create() {
|
|
34843
34843
|
return util.Buffer ? function create_buffer_setup() {
|
|
34844
34844
|
return (Writer.create = function create_buffer() {
|
|
34845
34845
|
return new BufferWriter;
|
|
@@ -35063,12 +35063,12 @@ var require_reader2 = __commonJS((exports, module) => {
|
|
|
35063
35063
|
if (buffer instanceof Uint8Array || Array.isArray(buffer))
|
|
35064
35064
|
return new Reader(buffer);
|
|
35065
35065
|
throw Error("illegal buffer");
|
|
35066
|
-
} : function
|
|
35066
|
+
} : function create_array(buffer) {
|
|
35067
35067
|
if (Array.isArray(buffer))
|
|
35068
35068
|
return new Reader(buffer);
|
|
35069
35069
|
throw Error("illegal buffer");
|
|
35070
35070
|
};
|
|
35071
|
-
var create = function
|
|
35071
|
+
var create = function create() {
|
|
35072
35072
|
return util.Buffer ? function create_buffer_setup(buffer) {
|
|
35073
35073
|
return (Reader.create = function create_buffer(buffer2) {
|
|
35074
35074
|
return util.Buffer.isBuffer(buffer2) ? new BufferReader(buffer2) : create_array(buffer2);
|
|
@@ -35494,10 +35494,10 @@ var require_fetch = __commonJS((exports, module) => {
|
|
|
35494
35494
|
// node_modules/@protobufjs/path/index.js
|
|
35495
35495
|
var require_path = __commonJS((exports) => {
|
|
35496
35496
|
var path = exports;
|
|
35497
|
-
var isAbsolute = path.isAbsolute = function
|
|
35497
|
+
var isAbsolute = path.isAbsolute = function isAbsolute(path2) {
|
|
35498
35498
|
return /^(?:\/|\w+:)/.test(path2);
|
|
35499
35499
|
};
|
|
35500
|
-
var normalize = path.normalize = function
|
|
35500
|
+
var normalize = path.normalize = function normalize(path2) {
|
|
35501
35501
|
path2 = path2.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
35502
35502
|
var parts = path2.split("/"), absolute = isAbsolute(path2), prefix = "";
|
|
35503
35503
|
if (absolute)
|
|
@@ -35662,7 +35662,7 @@ var require_namespace = __commonJS((exports, module) => {
|
|
|
35662
35662
|
object.onRemove(this);
|
|
35663
35663
|
return clearCache(this);
|
|
35664
35664
|
};
|
|
35665
|
-
Namespace.prototype.define = function
|
|
35665
|
+
Namespace.prototype.define = function define(path, json) {
|
|
35666
35666
|
if (util.isString(path))
|
|
35667
35667
|
path = path.split(".");
|
|
35668
35668
|
else if (!Array.isArray(path))
|
|
@@ -42478,7 +42478,7 @@ var require_src3 = __commonJS((exports) => {
|
|
|
42478
42478
|
|
|
42479
42479
|
// node_modules/@grpc/grpc-js/build/src/channelz.js
|
|
42480
42480
|
var require_channelz = __commonJS((exports) => {
|
|
42481
|
-
var __dirname = "/
|
|
42481
|
+
var __dirname = "/Users/dhruv/Developer/Projects/isol8/node_modules/@grpc/grpc-js/build/src";
|
|
42482
42482
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42483
42483
|
exports.registerChannelzSocket = exports.registerChannelzServer = exports.registerChannelzSubchannel = exports.registerChannelzChannel = exports.ChannelzCallTrackerStub = exports.ChannelzCallTracker = exports.ChannelzChildrenTrackerStub = exports.ChannelzChildrenTracker = exports.ChannelzTrace = exports.ChannelzTraceStub = undefined;
|
|
42484
42484
|
exports.unregisterChannelzRef = unregisterChannelzRef;
|
|
@@ -47881,7 +47881,7 @@ var require_duration = __commonJS((exports) => {
|
|
|
47881
47881
|
|
|
47882
47882
|
// node_modules/@grpc/grpc-js/build/src/orca.js
|
|
47883
47883
|
var require_orca = __commonJS((exports) => {
|
|
47884
|
-
var __dirname = "/
|
|
47884
|
+
var __dirname = "/Users/dhruv/Developer/Projects/isol8/node_modules/@grpc/grpc-js/build/src";
|
|
47885
47885
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47886
47886
|
exports.OrcaOobMetricsSubchannelWrapper = exports.GRPC_METRICS_HEADER = exports.ServerMetricRecorder = exports.PerRequestMetricRecorder = undefined;
|
|
47887
47887
|
exports.createOrcaClient = createOrcaClient;
|
|
@@ -53270,7 +53270,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
53270
53270
|
|
|
53271
53271
|
// node_modules/dockerode/lib/session.js
|
|
53272
53272
|
var require_session = __commonJS((exports, module) => {
|
|
53273
|
-
var __dirname = "/
|
|
53273
|
+
var __dirname = "/Users/dhruv/Developer/Projects/isol8/node_modules/dockerode/lib";
|
|
53274
53274
|
var grpc = require_src4();
|
|
53275
53275
|
var protoLoader = require_src5();
|
|
53276
53276
|
var path = __require("path");
|
|
@@ -54496,7 +54496,7 @@ var require_docker = __commonJS((exports, module) => {
|
|
|
54496
54496
|
stream: true,
|
|
54497
54497
|
stdout: true,
|
|
54498
54498
|
stderr: true
|
|
54499
|
-
}, function
|
|
54499
|
+
}, function handler(err2, stream) {
|
|
54500
54500
|
if (err2)
|
|
54501
54501
|
return callback(err2, null, container);
|
|
54502
54502
|
hub.emit("stream", stream);
|
|
@@ -54803,6 +54803,10 @@ function mergeConfig(defaults, overrides) {
|
|
|
54803
54803
|
seccomp: overrides.security?.seccomp ?? defaults.security.seccomp,
|
|
54804
54804
|
customProfilePath: overrides.security?.customProfilePath ?? defaults.security.customProfilePath
|
|
54805
54805
|
},
|
|
54806
|
+
audit: {
|
|
54807
|
+
...defaults.audit,
|
|
54808
|
+
...overrides.audit
|
|
54809
|
+
},
|
|
54806
54810
|
debug: overrides.debug ?? defaults.debug
|
|
54807
54811
|
};
|
|
54808
54812
|
}
|
|
@@ -54830,6 +54834,16 @@ var init_config = __esm(() => {
|
|
|
54830
54834
|
security: {
|
|
54831
54835
|
seccomp: "strict"
|
|
54832
54836
|
},
|
|
54837
|
+
audit: {
|
|
54838
|
+
enabled: false,
|
|
54839
|
+
destination: "filesystem",
|
|
54840
|
+
logDir: undefined,
|
|
54841
|
+
postLogScript: undefined,
|
|
54842
|
+
trackResources: true,
|
|
54843
|
+
retentionDays: 90,
|
|
54844
|
+
includeCode: false,
|
|
54845
|
+
includeOutput: false
|
|
54846
|
+
},
|
|
54833
54847
|
debug: false
|
|
54834
54848
|
};
|
|
54835
54849
|
});
|
|
@@ -55022,6 +55036,144 @@ var init_logger = __esm(() => {
|
|
|
55022
55036
|
logger = new Logger;
|
|
55023
55037
|
});
|
|
55024
55038
|
|
|
55039
|
+
// src/engine/audit.ts
|
|
55040
|
+
import { spawn } from "node:child_process";
|
|
55041
|
+
import { appendFileSync, existsSync as existsSync2, mkdirSync, readdirSync, statSync, unlinkSync } from "node:fs";
|
|
55042
|
+
import { join as join2 } from "node:path";
|
|
55043
|
+
|
|
55044
|
+
class AuditLogger {
|
|
55045
|
+
config;
|
|
55046
|
+
auditFile;
|
|
55047
|
+
constructor(config) {
|
|
55048
|
+
this.config = config;
|
|
55049
|
+
const auditDir = config.logDir ?? process.env.ISOL8_AUDIT_DIR ?? join2(process.cwd(), "./.isol8_audit");
|
|
55050
|
+
this.auditFile = join2(auditDir, "executions.log");
|
|
55051
|
+
if (!existsSync2(auditDir)) {
|
|
55052
|
+
try {
|
|
55053
|
+
mkdirSync(auditDir, { recursive: true });
|
|
55054
|
+
} catch (err) {
|
|
55055
|
+
logger.error("Failed to create audit dir:", err);
|
|
55056
|
+
}
|
|
55057
|
+
}
|
|
55058
|
+
this.cleanupOldLogs();
|
|
55059
|
+
}
|
|
55060
|
+
cleanupOldLogs() {
|
|
55061
|
+
if (!this.config.enabled || this.config.retentionDays <= 0) {
|
|
55062
|
+
return;
|
|
55063
|
+
}
|
|
55064
|
+
try {
|
|
55065
|
+
const auditDir = join2(this.auditFile, "..");
|
|
55066
|
+
if (!existsSync2(auditDir)) {
|
|
55067
|
+
return;
|
|
55068
|
+
}
|
|
55069
|
+
const cutoffTime = Date.now() - this.config.retentionDays * 24 * 60 * 60 * 1000;
|
|
55070
|
+
const files = readdirSync(auditDir);
|
|
55071
|
+
let cleanedCount = 0;
|
|
55072
|
+
for (const file of files) {
|
|
55073
|
+
if (file.endsWith(".log") || file.endsWith(".jsonl")) {
|
|
55074
|
+
const filePath = join2(auditDir, file);
|
|
55075
|
+
try {
|
|
55076
|
+
const stats = statSync(filePath);
|
|
55077
|
+
if (stats.mtimeMs < cutoffTime) {
|
|
55078
|
+
unlinkSync(filePath);
|
|
55079
|
+
cleanedCount++;
|
|
55080
|
+
logger.debug(`Cleaned up old audit log: ${file}`);
|
|
55081
|
+
}
|
|
55082
|
+
} catch (err) {
|
|
55083
|
+
logger.debug(`Failed to check/remove old log file ${file}:`, err);
|
|
55084
|
+
}
|
|
55085
|
+
}
|
|
55086
|
+
}
|
|
55087
|
+
if (cleanedCount > 0) {
|
|
55088
|
+
logger.info(`Audit log cleanup: removed ${cleanedCount} old log files`);
|
|
55089
|
+
}
|
|
55090
|
+
} catch (err) {
|
|
55091
|
+
logger.error("Failed to cleanup old audit logs:", err);
|
|
55092
|
+
}
|
|
55093
|
+
}
|
|
55094
|
+
record(audit) {
|
|
55095
|
+
if (!this.config.enabled) {
|
|
55096
|
+
return;
|
|
55097
|
+
}
|
|
55098
|
+
try {
|
|
55099
|
+
const filteredAudit = this.filterAuditData(audit);
|
|
55100
|
+
const line = `${JSON.stringify(filteredAudit)}
|
|
55101
|
+
`;
|
|
55102
|
+
switch (this.config.destination) {
|
|
55103
|
+
case "file":
|
|
55104
|
+
case "filesystem":
|
|
55105
|
+
appendFileSync(this.auditFile, line, { encoding: "utf-8" });
|
|
55106
|
+
break;
|
|
55107
|
+
case "stdout":
|
|
55108
|
+
console.log("AUDIT_LOG:", filteredAudit);
|
|
55109
|
+
break;
|
|
55110
|
+
default:
|
|
55111
|
+
logger.error(`Unsupported audit destination: ${this.config.destination}`);
|
|
55112
|
+
return;
|
|
55113
|
+
}
|
|
55114
|
+
logger.debug("Audit record written:", audit.executionId);
|
|
55115
|
+
if (this.config.postLogScript) {
|
|
55116
|
+
this.runPostLogScript();
|
|
55117
|
+
}
|
|
55118
|
+
} catch (err) {
|
|
55119
|
+
logger.error("Failed to write audit record:", err);
|
|
55120
|
+
}
|
|
55121
|
+
}
|
|
55122
|
+
runPostLogScript() {
|
|
55123
|
+
if (!this.config.postLogScript) {
|
|
55124
|
+
return;
|
|
55125
|
+
}
|
|
55126
|
+
try {
|
|
55127
|
+
const child = spawn(this.config.postLogScript, [this.auditFile], {
|
|
55128
|
+
detached: true,
|
|
55129
|
+
stdio: "ignore"
|
|
55130
|
+
});
|
|
55131
|
+
child.on("error", (err) => {
|
|
55132
|
+
logger.error("Failed to run post-log script:", err);
|
|
55133
|
+
});
|
|
55134
|
+
child.unref();
|
|
55135
|
+
} catch (err) {
|
|
55136
|
+
logger.error("Failed to spawn post-log script:", err);
|
|
55137
|
+
}
|
|
55138
|
+
}
|
|
55139
|
+
filterAuditData(audit) {
|
|
55140
|
+
const result = {
|
|
55141
|
+
executionId: audit.executionId,
|
|
55142
|
+
userId: audit.userId,
|
|
55143
|
+
timestamp: audit.timestamp,
|
|
55144
|
+
runtime: audit.runtime,
|
|
55145
|
+
codeHash: audit.codeHash,
|
|
55146
|
+
containerId: audit.containerId,
|
|
55147
|
+
exitCode: audit.exitCode,
|
|
55148
|
+
durationMs: audit.durationMs
|
|
55149
|
+
};
|
|
55150
|
+
if (audit.resourceUsage !== undefined) {
|
|
55151
|
+
result.resourceUsage = audit.resourceUsage;
|
|
55152
|
+
}
|
|
55153
|
+
if (audit.securityEvents !== undefined) {
|
|
55154
|
+
result.securityEvents = audit.securityEvents;
|
|
55155
|
+
}
|
|
55156
|
+
if (audit.metadata !== undefined) {
|
|
55157
|
+
result.metadata = audit.metadata;
|
|
55158
|
+
}
|
|
55159
|
+
if (this.config.includeCode && audit.code !== undefined) {
|
|
55160
|
+
result.code = audit.code;
|
|
55161
|
+
}
|
|
55162
|
+
if (this.config.includeOutput) {
|
|
55163
|
+
if (audit.stdout !== undefined) {
|
|
55164
|
+
result.stdout = audit.stdout;
|
|
55165
|
+
}
|
|
55166
|
+
if (audit.stderr !== undefined) {
|
|
55167
|
+
result.stderr = audit.stderr;
|
|
55168
|
+
}
|
|
55169
|
+
}
|
|
55170
|
+
return result;
|
|
55171
|
+
}
|
|
55172
|
+
}
|
|
55173
|
+
var init_audit = __esm(() => {
|
|
55174
|
+
init_logger();
|
|
55175
|
+
});
|
|
55176
|
+
|
|
55025
55177
|
// src/engine/concurrency.ts
|
|
55026
55178
|
class Semaphore {
|
|
55027
55179
|
max;
|
|
@@ -55180,9 +55332,55 @@ var init_pool = __esm(() => {
|
|
|
55180
55332
|
init_logger();
|
|
55181
55333
|
});
|
|
55182
55334
|
|
|
55335
|
+
// src/engine/stats.ts
|
|
55336
|
+
function calculateCPUPercent(stats) {
|
|
55337
|
+
const cpuDelta = stats.cpu_stats.cpu_usage.total_usage - stats.precpu_stats.cpu_usage.total_usage;
|
|
55338
|
+
const systemDelta = stats.cpu_stats.system_cpu_usage - stats.precpu_stats.system_cpu_usage;
|
|
55339
|
+
if (systemDelta === 0 || cpuDelta === 0) {
|
|
55340
|
+
return 0;
|
|
55341
|
+
}
|
|
55342
|
+
const numCores = stats.cpu_stats.online_cpus ?? stats.cpu_stats.cpu_usage.percpu_usage?.length ?? 1;
|
|
55343
|
+
return cpuDelta / systemDelta * numCores * 100;
|
|
55344
|
+
}
|
|
55345
|
+
function calculateNetworkStats(stats) {
|
|
55346
|
+
if (!stats.networks) {
|
|
55347
|
+
return { in: 0, out: 0 };
|
|
55348
|
+
}
|
|
55349
|
+
let rxBytes = 0;
|
|
55350
|
+
let txBytes = 0;
|
|
55351
|
+
for (const iface of Object.values(stats.networks)) {
|
|
55352
|
+
rxBytes += iface.rx_bytes;
|
|
55353
|
+
txBytes += iface.tx_bytes;
|
|
55354
|
+
}
|
|
55355
|
+
return { in: rxBytes, out: txBytes };
|
|
55356
|
+
}
|
|
55357
|
+
async function getContainerStats(container) {
|
|
55358
|
+
const stats = await container.stats({
|
|
55359
|
+
stream: false
|
|
55360
|
+
});
|
|
55361
|
+
const cpuPercent = calculateCPUPercent(stats);
|
|
55362
|
+
const memoryBytes = stats.memory_stats.usage;
|
|
55363
|
+
const network = calculateNetworkStats(stats);
|
|
55364
|
+
return {
|
|
55365
|
+
cpuPercent: Math.round(cpuPercent * 100) / 100,
|
|
55366
|
+
memoryMB: Math.round(memoryBytes / (1024 * 1024)),
|
|
55367
|
+
networkBytesIn: network.in,
|
|
55368
|
+
networkBytesOut: network.out
|
|
55369
|
+
};
|
|
55370
|
+
}
|
|
55371
|
+
function calculateResourceDelta(before, after) {
|
|
55372
|
+
return {
|
|
55373
|
+
cpuPercent: after.cpuPercent,
|
|
55374
|
+
memoryMB: after.memoryMB,
|
|
55375
|
+
networkBytesIn: after.networkBytesIn - before.networkBytesIn,
|
|
55376
|
+
networkBytesOut: after.networkBytesOut - before.networkBytesOut
|
|
55377
|
+
};
|
|
55378
|
+
}
|
|
55379
|
+
|
|
55183
55380
|
// src/engine/utils.ts
|
|
55184
55381
|
var exports_utils = {};
|
|
55185
55382
|
__export(exports_utils, {
|
|
55383
|
+
validatePackageName: () => validatePackageName,
|
|
55186
55384
|
truncateOutput: () => truncateOutput,
|
|
55187
55385
|
parseMemoryLimit: () => parseMemoryLimit,
|
|
55188
55386
|
maskSecrets: () => maskSecrets,
|
|
@@ -55277,20 +55475,26 @@ function extractFromTar(tarBuffer, targetPath) {
|
|
|
55277
55475
|
}
|
|
55278
55476
|
throw new Error(`File "${targetPath}" not found in tar archive`);
|
|
55279
55477
|
}
|
|
55478
|
+
function validatePackageName(name) {
|
|
55479
|
+
if (!/^[@a-zA-Z0-9_./\-=]+$/.test(name)) {
|
|
55480
|
+
throw new Error(`Invalid package name: "${name}". Only alphanumeric, -, _, ., /, @, and = are allowed.`);
|
|
55481
|
+
}
|
|
55482
|
+
return name;
|
|
55483
|
+
}
|
|
55280
55484
|
|
|
55281
55485
|
// src/engine/docker.ts
|
|
55282
55486
|
var exports_docker = {};
|
|
55283
55487
|
__export(exports_docker, {
|
|
55284
55488
|
DockerIsol8: () => DockerIsol8
|
|
55285
55489
|
});
|
|
55286
|
-
import { spawn } from "node:child_process";
|
|
55490
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
55287
55491
|
import { randomUUID } from "node:crypto";
|
|
55288
|
-
import { existsSync as
|
|
55492
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "node:fs";
|
|
55289
55493
|
import { PassThrough } from "node:stream";
|
|
55290
55494
|
async function writeFileViaExec(container, filePath, content) {
|
|
55291
55495
|
const data = typeof content === "string" ? Buffer.from(content, "utf-8") : content;
|
|
55292
55496
|
return new Promise((resolve2, reject) => {
|
|
55293
|
-
const child =
|
|
55497
|
+
const child = spawn2("docker", ["exec", "-i", "-u", "sandbox", container.id, "sh", "-c", `cat > ${filePath}`], {
|
|
55294
55498
|
stdio: ["pipe", "ignore", "pipe"]
|
|
55295
55499
|
});
|
|
55296
55500
|
child.on("error", (err) => {
|
|
@@ -55476,6 +55680,7 @@ class DockerIsol8 {
|
|
|
55476
55680
|
tmpSize;
|
|
55477
55681
|
security;
|
|
55478
55682
|
persist;
|
|
55683
|
+
auditLogger;
|
|
55479
55684
|
container = null;
|
|
55480
55685
|
persistentRuntime = null;
|
|
55481
55686
|
pool = null;
|
|
@@ -55497,6 +55702,9 @@ class DockerIsol8 {
|
|
|
55497
55702
|
this.tmpSize = options.tmpSize ?? "256m";
|
|
55498
55703
|
this.persist = options.persist ?? false;
|
|
55499
55704
|
this.security = options.security ?? { seccomp: "strict" };
|
|
55705
|
+
if (options.audit) {
|
|
55706
|
+
this.auditLogger = new AuditLogger(options.audit);
|
|
55707
|
+
}
|
|
55500
55708
|
if (options.debug) {
|
|
55501
55709
|
logger.setDebug(true);
|
|
55502
55710
|
}
|
|
@@ -55520,12 +55728,79 @@ class DockerIsol8 {
|
|
|
55520
55728
|
}
|
|
55521
55729
|
async execute(req) {
|
|
55522
55730
|
await this.semaphore.acquire();
|
|
55731
|
+
const startTime = Date.now();
|
|
55523
55732
|
try {
|
|
55524
|
-
|
|
55733
|
+
const result = this.mode === "persistent" ? await this.executePersistent(req, startTime) : await this.executeEphemeral(req, startTime);
|
|
55734
|
+
return result;
|
|
55525
55735
|
} finally {
|
|
55526
55736
|
this.semaphore.release();
|
|
55527
55737
|
}
|
|
55528
55738
|
}
|
|
55739
|
+
async recordAudit(req, result, startTime, container) {
|
|
55740
|
+
try {
|
|
55741
|
+
const enc = new TextEncoder;
|
|
55742
|
+
const data = enc.encode(req.code);
|
|
55743
|
+
const digest = await crypto.subtle.digest("SHA-256", data);
|
|
55744
|
+
const codeHash = Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
55745
|
+
let securityEvents;
|
|
55746
|
+
if (container && this.network === "filtered") {
|
|
55747
|
+
securityEvents = await this.collectSecurityEvents(container);
|
|
55748
|
+
if (securityEvents.length === 0) {
|
|
55749
|
+
securityEvents = undefined;
|
|
55750
|
+
}
|
|
55751
|
+
}
|
|
55752
|
+
const audit = {
|
|
55753
|
+
executionId: result.executionId,
|
|
55754
|
+
userId: req.metadata?.userId || "",
|
|
55755
|
+
timestamp: new Date(startTime).toISOString(),
|
|
55756
|
+
runtime: result.runtime,
|
|
55757
|
+
codeHash,
|
|
55758
|
+
containerId: result.containerId || "",
|
|
55759
|
+
exitCode: result.exitCode,
|
|
55760
|
+
durationMs: result.durationMs,
|
|
55761
|
+
resourceUsage: result.resourceUsage,
|
|
55762
|
+
securityEvents,
|
|
55763
|
+
metadata: req.metadata
|
|
55764
|
+
};
|
|
55765
|
+
this.auditLogger.record(audit);
|
|
55766
|
+
} catch (err) {
|
|
55767
|
+
logger.error("Failed to record audit log:", err);
|
|
55768
|
+
}
|
|
55769
|
+
}
|
|
55770
|
+
async collectSecurityEvents(container) {
|
|
55771
|
+
const events = [];
|
|
55772
|
+
try {
|
|
55773
|
+
const exec = await container.exec({
|
|
55774
|
+
Cmd: ["cat", "/tmp/isol8-proxy/security-events.jsonl"],
|
|
55775
|
+
AttachStdout: true,
|
|
55776
|
+
AttachStderr: false,
|
|
55777
|
+
User: "root"
|
|
55778
|
+
});
|
|
55779
|
+
const stream = await exec.start({ Tty: false });
|
|
55780
|
+
const chunks = [];
|
|
55781
|
+
for await (const chunk of stream) {
|
|
55782
|
+
chunks.push(chunk);
|
|
55783
|
+
}
|
|
55784
|
+
const output = Buffer.concat(chunks).toString("utf-8").trim();
|
|
55785
|
+
if (output) {
|
|
55786
|
+
for (const line of output.split(`
|
|
55787
|
+
`)) {
|
|
55788
|
+
if (line.trim()) {
|
|
55789
|
+
try {
|
|
55790
|
+
const event = JSON.parse(line);
|
|
55791
|
+
events.push({
|
|
55792
|
+
type: event.type || "unknown",
|
|
55793
|
+
message: `Security event: ${event.type}`,
|
|
55794
|
+
details: event.details || {},
|
|
55795
|
+
timestamp: event.timestamp || new Date().toISOString()
|
|
55796
|
+
});
|
|
55797
|
+
} catch {}
|
|
55798
|
+
}
|
|
55799
|
+
}
|
|
55800
|
+
}
|
|
55801
|
+
} catch {}
|
|
55802
|
+
return events;
|
|
55803
|
+
}
|
|
55529
55804
|
async putFile(path, content) {
|
|
55530
55805
|
if (!this.container) {
|
|
55531
55806
|
throw new Error("No active container. Call execute() first in persistent mode.");
|
|
@@ -55633,7 +55908,7 @@ class DockerIsol8 {
|
|
|
55633
55908
|
return adapter.image;
|
|
55634
55909
|
}
|
|
55635
55910
|
}
|
|
55636
|
-
async executeEphemeral(req) {
|
|
55911
|
+
async executeEphemeral(req, startTime) {
|
|
55637
55912
|
const adapter = this.getAdapter(req.runtime);
|
|
55638
55913
|
const timeoutMs = req.timeoutMs ?? this.defaultTimeoutMs;
|
|
55639
55914
|
const image = await this.resolveImage(adapter);
|
|
@@ -55652,6 +55927,14 @@ class DockerIsol8 {
|
|
|
55652
55927
|
});
|
|
55653
55928
|
}
|
|
55654
55929
|
const container = await this.pool.acquire(image);
|
|
55930
|
+
let startStats;
|
|
55931
|
+
if (this.auditLogger) {
|
|
55932
|
+
try {
|
|
55933
|
+
startStats = await getContainerStats(container);
|
|
55934
|
+
} catch (err) {
|
|
55935
|
+
logger.debug("Failed to collect baseline stats:", err);
|
|
55936
|
+
}
|
|
55937
|
+
}
|
|
55655
55938
|
try {
|
|
55656
55939
|
if (this.network === "filtered") {
|
|
55657
55940
|
await startProxy(container, this.networkFilter);
|
|
@@ -55692,7 +55975,16 @@ class DockerIsol8 {
|
|
|
55692
55975
|
const { stdout, stderr, truncated } = await this.collectExecOutput(execStream, container, timeoutMs);
|
|
55693
55976
|
const durationMs = Math.round(performance.now() - start);
|
|
55694
55977
|
const inspectResult = await exec.inspect();
|
|
55695
|
-
|
|
55978
|
+
let resourceUsage;
|
|
55979
|
+
if (startStats) {
|
|
55980
|
+
try {
|
|
55981
|
+
const endStats = await getContainerStats(container);
|
|
55982
|
+
resourceUsage = calculateResourceDelta(startStats, endStats);
|
|
55983
|
+
} catch (err) {
|
|
55984
|
+
logger.debug("Failed to collect final stats:", err);
|
|
55985
|
+
}
|
|
55986
|
+
}
|
|
55987
|
+
const result = {
|
|
55696
55988
|
stdout: this.postProcessOutput(stdout, truncated),
|
|
55697
55989
|
stderr: this.postProcessOutput(stderr, false),
|
|
55698
55990
|
exitCode: inspectResult.ExitCode ?? 1,
|
|
@@ -55702,8 +55994,13 @@ class DockerIsol8 {
|
|
|
55702
55994
|
runtime: req.runtime,
|
|
55703
55995
|
timestamp: new Date().toISOString(),
|
|
55704
55996
|
containerId: container.id,
|
|
55997
|
+
...resourceUsage ? { resourceUsage } : {},
|
|
55705
55998
|
...req.outputPaths ? { files: await this.retrieveFiles(container, req.outputPaths) } : {}
|
|
55706
55999
|
};
|
|
56000
|
+
if (this.auditLogger) {
|
|
56001
|
+
await this.recordAudit(req, result, startTime, container);
|
|
56002
|
+
}
|
|
56003
|
+
return result;
|
|
55707
56004
|
} finally {
|
|
55708
56005
|
if (this.persist) {
|
|
55709
56006
|
logger.debug(`[Persist] Leaving container running for inspection: ${container.id}`);
|
|
@@ -55712,7 +56009,7 @@ class DockerIsol8 {
|
|
|
55712
56009
|
}
|
|
55713
56010
|
}
|
|
55714
56011
|
}
|
|
55715
|
-
async executePersistent(req) {
|
|
56012
|
+
async executePersistent(req, startTime) {
|
|
55716
56013
|
const adapter = this.getAdapter(req.runtime);
|
|
55717
56014
|
const timeoutMs = req.timeoutMs ?? this.defaultTimeoutMs;
|
|
55718
56015
|
if (!this.container) {
|
|
@@ -55766,7 +56063,21 @@ class DockerIsol8 {
|
|
|
55766
56063
|
const { stdout, stderr, truncated } = await this.collectExecOutput(execStream, this.container, timeoutMs);
|
|
55767
56064
|
const durationMs = Math.round(performance.now() - start);
|
|
55768
56065
|
const inspectResult = await exec.inspect();
|
|
55769
|
-
|
|
56066
|
+
let resourceUsage;
|
|
56067
|
+
if (this.auditLogger) {
|
|
56068
|
+
try {
|
|
56069
|
+
const endStats = await getContainerStats(this.container);
|
|
56070
|
+
resourceUsage = {
|
|
56071
|
+
cpuPercent: endStats.cpuPercent,
|
|
56072
|
+
memoryMB: endStats.memoryMB,
|
|
56073
|
+
networkBytesIn: endStats.networkBytesIn,
|
|
56074
|
+
networkBytesOut: endStats.networkBytesOut
|
|
56075
|
+
};
|
|
56076
|
+
} catch (err) {
|
|
56077
|
+
logger.debug("Failed to collect resource stats:", err);
|
|
56078
|
+
}
|
|
56079
|
+
}
|
|
56080
|
+
const result = {
|
|
55770
56081
|
stdout: this.postProcessOutput(stdout, truncated),
|
|
55771
56082
|
stderr: this.postProcessOutput(stderr, false),
|
|
55772
56083
|
exitCode: inspectResult.ExitCode ?? 1,
|
|
@@ -55776,8 +56087,13 @@ class DockerIsol8 {
|
|
|
55776
56087
|
runtime: req.runtime,
|
|
55777
56088
|
timestamp: new Date().toISOString(),
|
|
55778
56089
|
containerId: this.container?.id,
|
|
56090
|
+
...resourceUsage ? { resourceUsage } : {},
|
|
55779
56091
|
...req.outputPaths ? { files: await this.retrieveFiles(this.container, req.outputPaths) } : {}
|
|
55780
56092
|
};
|
|
56093
|
+
if (this.auditLogger) {
|
|
56094
|
+
await this.recordAudit(req, result, startTime, this.container);
|
|
56095
|
+
}
|
|
56096
|
+
return result;
|
|
55781
56097
|
}
|
|
55782
56098
|
async retrieveFiles(container, paths) {
|
|
55783
56099
|
const files = {};
|
|
@@ -55869,11 +56185,11 @@ class DockerIsol8 {
|
|
|
55869
56185
|
}
|
|
55870
56186
|
loadDefaultSeccompProfile() {
|
|
55871
56187
|
const devPath = new URL("../../docker/seccomp-profile.json", import.meta.url);
|
|
55872
|
-
if (
|
|
56188
|
+
if (existsSync3(devPath)) {
|
|
55873
56189
|
return readFileSync2(devPath, "utf-8");
|
|
55874
56190
|
}
|
|
55875
56191
|
const prodPath = new URL("./docker/seccomp-profile.json", import.meta.url);
|
|
55876
|
-
if (
|
|
56192
|
+
if (existsSync3(prodPath)) {
|
|
55877
56193
|
return readFileSync2(prodPath, "utf-8");
|
|
55878
56194
|
}
|
|
55879
56195
|
logger.warn("Could not locate default seccomp profile. Running without seccomp filter.");
|
|
@@ -56077,10 +56393,11 @@ class DockerIsol8 {
|
|
|
56077
56393
|
}
|
|
56078
56394
|
var import_dockerode, SANDBOX_WORKDIR = "/sandbox", MAX_OUTPUT_BYTES, PROXY_PORT = 8118, PROXY_STARTUP_TIMEOUT_MS = 5000, PROXY_POLL_INTERVAL_MS = 100;
|
|
56079
56395
|
var init_docker = __esm(() => {
|
|
56396
|
+
import_dockerode = __toESM(require_docker(), 1);
|
|
56080
56397
|
init_runtime();
|
|
56081
56398
|
init_logger();
|
|
56399
|
+
init_audit();
|
|
56082
56400
|
init_pool();
|
|
56083
|
-
import_dockerode = __toESM(require_docker(), 1);
|
|
56084
56401
|
MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
56085
56402
|
});
|
|
56086
56403
|
|
|
@@ -56089,7 +56406,7 @@ var package_default;
|
|
|
56089
56406
|
var init_package = __esm(() => {
|
|
56090
56407
|
package_default = {
|
|
56091
56408
|
name: "isol8",
|
|
56092
|
-
version: "0.
|
|
56409
|
+
version: "0.9.0",
|
|
56093
56410
|
description: "Secure code execution engine for AI agents",
|
|
56094
56411
|
author: "Illusion47586",
|
|
56095
56412
|
license: "MIT",
|
|
@@ -56130,6 +56447,7 @@ var init_package = __esm(() => {
|
|
|
56130
56447
|
"build:server": "bun run scripts/build-server.ts",
|
|
56131
56448
|
"build:server:all": "bun run scripts/build-server.ts --all",
|
|
56132
56449
|
test: "bun test",
|
|
56450
|
+
"test:prod": "bun test tests/production/",
|
|
56133
56451
|
"lint:check": "ultracite check",
|
|
56134
56452
|
"lint:fix": "ultracite fix",
|
|
56135
56453
|
bench: "bunx tsx benchmarks/spawn.ts",
|
|
@@ -57847,7 +58165,8 @@ async function createServer(options) {
|
|
|
57847
58165
|
sandboxSize: config.defaults.sandboxSize,
|
|
57848
58166
|
tmpSize: config.defaults.tmpSize,
|
|
57849
58167
|
...body.options,
|
|
57850
|
-
mode: body.sessionId ? "persistent" : "ephemeral"
|
|
58168
|
+
mode: body.sessionId ? "persistent" : "ephemeral",
|
|
58169
|
+
audit: config.audit
|
|
57851
58170
|
};
|
|
57852
58171
|
let engine;
|
|
57853
58172
|
if (body.sessionId) {
|
|
@@ -58018,15 +58337,15 @@ var init_server = __esm(() => {
|
|
|
58018
58337
|
// src/cli.ts
|
|
58019
58338
|
import {
|
|
58020
58339
|
chmodSync,
|
|
58021
|
-
existsSync as
|
|
58022
|
-
mkdirSync,
|
|
58340
|
+
existsSync as existsSync5,
|
|
58341
|
+
mkdirSync as mkdirSync2,
|
|
58023
58342
|
readFileSync as readFileSync3,
|
|
58024
58343
|
renameSync,
|
|
58025
|
-
unlinkSync,
|
|
58344
|
+
unlinkSync as unlinkSync2,
|
|
58026
58345
|
writeFileSync
|
|
58027
58346
|
} from "node:fs";
|
|
58028
58347
|
import { arch, homedir as homedir2, platform } from "node:os";
|
|
58029
|
-
import { join as
|
|
58348
|
+
import { join as join3, resolve as resolve2 } from "node:path";
|
|
58030
58349
|
|
|
58031
58350
|
// node_modules/commander/esm.mjs
|
|
58032
58351
|
var import__ = __toESM(require_commander(), 1);
|
|
@@ -58623,7 +58942,7 @@ onetime.callCount = (function_) => {
|
|
|
58623
58942
|
};
|
|
58624
58943
|
var onetime_default = onetime;
|
|
58625
58944
|
|
|
58626
|
-
// node_modules/signal-exit/dist/mjs/signals.js
|
|
58945
|
+
// node_modules/restore-cursor/node_modules/signal-exit/dist/mjs/signals.js
|
|
58627
58946
|
var signals = [];
|
|
58628
58947
|
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
58629
58948
|
if (process.platform !== "win32") {
|
|
@@ -58633,7 +58952,7 @@ if (process.platform === "linux") {
|
|
|
58633
58952
|
signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
58634
58953
|
}
|
|
58635
58954
|
|
|
58636
|
-
// node_modules/signal-exit/dist/mjs/index.js
|
|
58955
|
+
// node_modules/restore-cursor/node_modules/signal-exit/dist/mjs/index.js
|
|
58637
58956
|
var processOk = (process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
58638
58957
|
var kExitEmitter = Symbol.for("signal-exit emitter");
|
|
58639
58958
|
var global2 = globalThis;
|
|
@@ -61420,10 +61739,10 @@ init_docker();
|
|
|
61420
61739
|
|
|
61421
61740
|
// src/engine/image-builder.ts
|
|
61422
61741
|
init_runtime();
|
|
61423
|
-
import { existsSync as
|
|
61742
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
61424
61743
|
function resolveDockerDir() {
|
|
61425
|
-
const fromBundled = new URL("
|
|
61426
|
-
if (
|
|
61744
|
+
const fromBundled = new URL("./docker", import.meta.url).pathname;
|
|
61745
|
+
if (existsSync4(fromBundled)) {
|
|
61427
61746
|
return fromBundled;
|
|
61428
61747
|
}
|
|
61429
61748
|
return new URL("../../docker", import.meta.url).pathname;
|
|
@@ -61502,8 +61821,9 @@ async function buildCustomImage(docker, runtime, packages, onProgress) {
|
|
|
61502
61821
|
const dockerfileContent = `FROM isol8:${runtime}
|
|
61503
61822
|
${installCmd}
|
|
61504
61823
|
`;
|
|
61505
|
-
const { createTarBuffer: createTarBuffer2 } = await Promise.resolve().then(() => exports_utils);
|
|
61824
|
+
const { createTarBuffer: createTarBuffer2, validatePackageName: validatePackageName2 } = await Promise.resolve().then(() => exports_utils);
|
|
61506
61825
|
const { Readable } = await import("node:stream");
|
|
61826
|
+
packages.forEach(validatePackageName2);
|
|
61507
61827
|
const tarBuffer = createTarBuffer2("Dockerfile", dockerfileContent);
|
|
61508
61828
|
const stream = await docker.buildImage(Readable.from(tarBuffer), {
|
|
61509
61829
|
t: tag,
|
|
@@ -61775,7 +62095,7 @@ function getServerBinaryName() {
|
|
|
61775
62095
|
return `isol8-server-${resolvedOs}-${resolvedArch}`;
|
|
61776
62096
|
}
|
|
61777
62097
|
async function getServerBinaryVersion(binaryPath) {
|
|
61778
|
-
if (!
|
|
62098
|
+
if (!existsSync5(binaryPath)) {
|
|
61779
62099
|
logger.debug(`[Serve] No binary found at ${binaryPath}`);
|
|
61780
62100
|
return null;
|
|
61781
62101
|
}
|
|
@@ -61808,8 +62128,8 @@ async function downloadServerBinary(binaryPath) {
|
|
|
61808
62128
|
}
|
|
61809
62129
|
process.exit(1);
|
|
61810
62130
|
}
|
|
61811
|
-
const binDir =
|
|
61812
|
-
|
|
62131
|
+
const binDir = join3(homedir2(), ".isol8", "bin");
|
|
62132
|
+
mkdirSync2(binDir, { recursive: true });
|
|
61813
62133
|
const tmpPath = `${binaryPath}.tmp`;
|
|
61814
62134
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
61815
62135
|
writeFileSync(tmpPath, buffer);
|
|
@@ -61820,8 +62140,8 @@ async function downloadServerBinary(binaryPath) {
|
|
|
61820
62140
|
} catch (err) {
|
|
61821
62141
|
spinner.fail("Failed to download server binary");
|
|
61822
62142
|
const tmpPath = `${binaryPath}.tmp`;
|
|
61823
|
-
if (
|
|
61824
|
-
|
|
62143
|
+
if (existsSync5(tmpPath)) {
|
|
62144
|
+
unlinkSync2(tmpPath);
|
|
61825
62145
|
}
|
|
61826
62146
|
throw err;
|
|
61827
62147
|
}
|
|
@@ -61840,8 +62160,8 @@ async function promptYesNo(question) {
|
|
|
61840
62160
|
return normalized === "" || normalized === "y" || normalized === "yes";
|
|
61841
62161
|
}
|
|
61842
62162
|
async function ensureServerBinary(forceUpdate) {
|
|
61843
|
-
const binDir =
|
|
61844
|
-
const binaryPath =
|
|
62163
|
+
const binDir = join3(homedir2(), ".isol8", "bin");
|
|
62164
|
+
const binaryPath = join3(binDir, "isol8-server");
|
|
61845
62165
|
logger.debug(`[Serve] Binary path: ${binaryPath}, forceUpdate: ${forceUpdate}`);
|
|
61846
62166
|
if (forceUpdate) {
|
|
61847
62167
|
logger.debug("[Serve] Force update requested");
|
|
@@ -61871,10 +62191,10 @@ async function ensureServerBinary(forceUpdate) {
|
|
|
61871
62191
|
program2.command("config").description("Show the resolved isol8 configuration").option("--json", "Output as raw JSON").action((opts) => {
|
|
61872
62192
|
const config = loadConfig();
|
|
61873
62193
|
const searchPaths = [
|
|
61874
|
-
|
|
61875
|
-
|
|
62194
|
+
join3(resolve2(process.cwd()), "isol8.config.json"),
|
|
62195
|
+
join3(homedir2(), ".isol8", "config.json")
|
|
61876
62196
|
];
|
|
61877
|
-
const loadedFrom = searchPaths.find((p) =>
|
|
62197
|
+
const loadedFrom = searchPaths.find((p) => existsSync5(p));
|
|
61878
62198
|
logger.debug(`[Config] Config source: ${loadedFrom ?? "defaults"}`);
|
|
61879
62199
|
logger.debug(`[Config] Resolved config: ${JSON.stringify(config)}`);
|
|
61880
62200
|
if (opts.json) {
|
|
@@ -62009,7 +62329,7 @@ async function resolveRunInput(file, opts) {
|
|
|
62009
62329
|
} else if (file) {
|
|
62010
62330
|
const filePath = resolve2(file);
|
|
62011
62331
|
logger.debug(`[Run] Reading file: ${filePath}`);
|
|
62012
|
-
if (!
|
|
62332
|
+
if (!existsSync5(filePath)) {
|
|
62013
62333
|
console.error(`[ERR] File not found: ${file}`);
|
|
62014
62334
|
process.exit(1);
|
|
62015
62335
|
}
|
|
@@ -62096,4 +62416,4 @@ if (!process.argv.slice(2).length) {
|
|
|
62096
62416
|
}
|
|
62097
62417
|
program2.parse();
|
|
62098
62418
|
|
|
62099
|
-
//# debugId=
|
|
62419
|
+
//# debugId=A0037469D709994964756E2164756E21
|