@smthrs/platform-node 0.0.0-stage → 1.0.0-rc.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 +211 -0
- package/LICENSE +21 -0
- package/README.md +165 -2
- package/bin/darwin-arm64/smithers-jj-export +0 -0
- package/bin/darwin-x64/smithers-jj-export +0 -0
- package/bin/linux-arm64/smithers-jj-export +0 -0
- package/bin/linux-x64/smithers-jj-export +4 -0
- package/bin/win32-x64/smithers-jj-export.exe +0 -0
- package/dist/cjs/AtomicFileSystem.d.ts +147 -0
- package/dist/cjs/AtomicFileSystem.d.ts.map +1 -0
- package/dist/cjs/AtomicFileSystem.js +234 -0
- package/dist/cjs/AtomicFileSystem.js.map +7 -0
- package/dist/cjs/EgressHttpClient.d.ts +106 -0
- package/dist/cjs/EgressHttpClient.d.ts.map +1 -0
- package/dist/cjs/EgressHttpClient.js +202 -0
- package/dist/cjs/EgressHttpClient.js.map +7 -0
- package/dist/cjs/HostLiveness.d.ts +81 -0
- package/dist/cjs/HostLiveness.d.ts.map +1 -0
- package/dist/cjs/HostLiveness.js +49 -0
- package/dist/cjs/HostLiveness.js.map +7 -0
- package/dist/cjs/NodeHost.d.ts +145 -0
- package/dist/cjs/NodeHost.d.ts.map +1 -0
- package/dist/cjs/NodeHost.js +128 -0
- package/dist/cjs/NodeHost.js.map +7 -0
- package/dist/cjs/ProcessConfinement.d.ts +61 -0
- package/dist/cjs/ProcessConfinement.d.ts.map +1 -0
- package/dist/cjs/ProcessConfinement.js +292 -0
- package/dist/cjs/ProcessConfinement.js.map +7 -0
- package/dist/cjs/ProcessReaper.d.ts +457 -0
- package/dist/cjs/ProcessReaper.d.ts.map +1 -0
- package/dist/cjs/ProcessReaper.js +349 -0
- package/dist/cjs/ProcessReaper.js.map +7 -0
- package/dist/cjs/ProcessSandbox.d.ts +391 -0
- package/dist/cjs/ProcessSandbox.d.ts.map +1 -0
- package/dist/cjs/ProcessSandbox.js +774 -0
- package/dist/cjs/ProcessSandbox.js.map +7 -0
- package/dist/cjs/ScopedProcess.d.ts +66 -0
- package/dist/cjs/ScopedProcess.d.ts.map +1 -0
- package/dist/cjs/ScopedProcess.js +87 -0
- package/dist/cjs/ScopedProcess.js.map +7 -0
- package/dist/cjs/index.d.ts +38 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/AtomicFileSystemExecutable.d.ts +61 -0
- package/dist/cjs/internal/AtomicFileSystemExecutable.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicFileSystemExecutable.js +250 -0
- package/dist/cjs/internal/AtomicFileSystemExecutable.js.map +7 -0
- package/dist/cjs/internal/AtomicFileSystemProtocol.d.ts +78 -0
- package/dist/cjs/internal/AtomicFileSystemProtocol.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicFileSystemProtocol.js +382 -0
- package/dist/cjs/internal/AtomicFileSystemProtocol.js.map +7 -0
- package/dist/cjs/internal/AtomicFileSystemTransport.d.ts +44 -0
- package/dist/cjs/internal/AtomicFileSystemTransport.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicFileSystemTransport.js +197 -0
- package/dist/cjs/internal/AtomicFileSystemTransport.js.map +7 -0
- package/dist/cjs/internal/AtomicHelperError.d.ts +35 -0
- package/dist/cjs/internal/AtomicHelperError.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicHelperError.js +45 -0
- package/dist/cjs/internal/AtomicHelperError.js.map +7 -0
- package/dist/cjs/internal/AtomicHelperFault.d.ts +59 -0
- package/dist/cjs/internal/AtomicHelperFault.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicHelperFault.js +66 -0
- package/dist/cjs/internal/AtomicHelperFault.js.map +7 -0
- package/dist/cjs/internal/PipedProcess.d.ts +35 -0
- package/dist/cjs/internal/PipedProcess.d.ts.map +1 -0
- package/dist/cjs/internal/PipedProcess.js +309 -0
- package/dist/cjs/internal/PipedProcess.js.map +7 -0
- package/dist/cjs/internal/ProcSnapshot.d.ts +85 -0
- package/dist/cjs/internal/ProcSnapshot.d.ts.map +1 -0
- package/dist/cjs/internal/ProcSnapshot.js +123 -0
- package/dist/cjs/internal/ProcSnapshot.js.map +7 -0
- package/dist/cjs/internal/ProcessCleanup.d.ts +64 -0
- package/dist/cjs/internal/ProcessCleanup.d.ts.map +1 -0
- package/dist/cjs/internal/ProcessCleanup.js +62 -0
- package/dist/cjs/internal/ProcessCleanup.js.map +7 -0
- package/dist/cjs/internal/ProcessCleanupPolicyError.d.ts +30 -0
- package/dist/cjs/internal/ProcessCleanupPolicyError.d.ts.map +1 -0
- package/dist/cjs/internal/ProcessCleanupPolicyError.js +33 -0
- package/dist/cjs/internal/ProcessCleanupPolicyError.js.map +7 -0
- package/dist/cjs/internal/ProcessFault.d.ts +63 -0
- package/dist/cjs/internal/ProcessFault.d.ts.map +1 -0
- package/dist/cjs/internal/ProcessFault.js +63 -0
- package/dist/cjs/internal/ProcessFault.js.map +7 -0
- package/dist/cjs/internal/ProcessSupervisor.d.ts +143 -0
- package/dist/cjs/internal/ProcessSupervisor.d.ts.map +1 -0
- package/dist/cjs/internal/ProcessSupervisor.js +685 -0
- package/dist/cjs/internal/ProcessSupervisor.js.map +7 -0
- package/dist/cjs/internal/SupervisorProgram.d.ts +9 -0
- package/dist/cjs/internal/SupervisorProgram.d.ts.map +1 -0
- package/dist/cjs/internal/SupervisorProgram.js +326 -0
- package/dist/cjs/internal/SupervisorProgram.js.map +7 -0
- package/dist/cjs/internal/WindowsProcessJob.d.ts +39 -0
- package/dist/cjs/internal/WindowsProcessJob.d.ts.map +1 -0
- package/dist/cjs/internal/WindowsProcessJob.js +113 -0
- package/dist/cjs/internal/WindowsProcessJob.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/AtomicFileSystem.d.ts +147 -0
- package/dist/esm/AtomicFileSystem.d.ts.map +1 -0
- package/dist/esm/AtomicFileSystem.js +290 -0
- package/dist/esm/AtomicFileSystem.js.map +1 -0
- package/dist/esm/EgressHttpClient.d.ts +106 -0
- package/dist/esm/EgressHttpClient.d.ts.map +1 -0
- package/dist/esm/EgressHttpClient.js +259 -0
- package/dist/esm/EgressHttpClient.js.map +1 -0
- package/dist/esm/HostLiveness.d.ts +81 -0
- package/dist/esm/HostLiveness.d.ts.map +1 -0
- package/dist/esm/HostLiveness.js +68 -0
- package/dist/esm/HostLiveness.js.map +1 -0
- package/dist/esm/NodeHost.d.ts +145 -0
- package/dist/esm/NodeHost.d.ts.map +1 -0
- package/dist/esm/NodeHost.js +162 -0
- package/dist/esm/NodeHost.js.map +1 -0
- package/dist/esm/ProcessConfinement.d.ts +61 -0
- package/dist/esm/ProcessConfinement.d.ts.map +1 -0
- package/dist/esm/ProcessConfinement.js +311 -0
- package/dist/esm/ProcessConfinement.js.map +1 -0
- package/dist/esm/ProcessReaper.d.ts +457 -0
- package/dist/esm/ProcessReaper.d.ts.map +1 -0
- package/dist/esm/ProcessReaper.js +711 -0
- package/dist/esm/ProcessReaper.js.map +1 -0
- package/dist/esm/ProcessSandbox.d.ts +391 -0
- package/dist/esm/ProcessSandbox.d.ts.map +1 -0
- package/dist/esm/ProcessSandbox.js +1043 -0
- package/dist/esm/ProcessSandbox.js.map +1 -0
- package/dist/esm/ScopedProcess.d.ts +66 -0
- package/dist/esm/ScopedProcess.d.ts.map +1 -0
- package/dist/esm/ScopedProcess.js +67 -0
- package/dist/esm/ScopedProcess.js.map +1 -0
- package/dist/esm/index.d.ts +38 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/AtomicFileSystemExecutable.d.ts +61 -0
- package/dist/esm/internal/AtomicFileSystemExecutable.d.ts.map +1 -0
- package/dist/esm/internal/AtomicFileSystemExecutable.js +350 -0
- package/dist/esm/internal/AtomicFileSystemExecutable.js.map +1 -0
- package/dist/esm/internal/AtomicFileSystemProtocol.d.ts +78 -0
- package/dist/esm/internal/AtomicFileSystemProtocol.d.ts.map +1 -0
- package/dist/esm/internal/AtomicFileSystemProtocol.js +412 -0
- package/dist/esm/internal/AtomicFileSystemProtocol.js.map +1 -0
- package/dist/esm/internal/AtomicFileSystemTransport.d.ts +44 -0
- package/dist/esm/internal/AtomicFileSystemTransport.d.ts.map +1 -0
- package/dist/esm/internal/AtomicFileSystemTransport.js +242 -0
- package/dist/esm/internal/AtomicFileSystemTransport.js.map +1 -0
- package/dist/esm/internal/AtomicHelperError.d.ts +35 -0
- package/dist/esm/internal/AtomicHelperError.d.ts.map +1 -0
- package/dist/esm/internal/AtomicHelperError.js +39 -0
- package/dist/esm/internal/AtomicHelperError.js.map +1 -0
- package/dist/esm/internal/AtomicHelperFault.d.ts +59 -0
- package/dist/esm/internal/AtomicHelperFault.d.ts.map +1 -0
- package/dist/esm/internal/AtomicHelperFault.js +66 -0
- package/dist/esm/internal/AtomicHelperFault.js.map +1 -0
- package/dist/esm/internal/PipedProcess.d.ts +35 -0
- package/dist/esm/internal/PipedProcess.d.ts.map +1 -0
- package/dist/esm/internal/PipedProcess.js +321 -0
- package/dist/esm/internal/PipedProcess.js.map +1 -0
- package/dist/esm/internal/ProcSnapshot.d.ts +85 -0
- package/dist/esm/internal/ProcSnapshot.d.ts.map +1 -0
- package/dist/esm/internal/ProcSnapshot.js +188 -0
- package/dist/esm/internal/ProcSnapshot.js.map +1 -0
- package/dist/esm/internal/ProcessCleanup.d.ts +64 -0
- package/dist/esm/internal/ProcessCleanup.d.ts.map +1 -0
- package/dist/esm/internal/ProcessCleanup.js +45 -0
- package/dist/esm/internal/ProcessCleanup.js.map +1 -0
- package/dist/esm/internal/ProcessCleanupPolicyError.d.ts +30 -0
- package/dist/esm/internal/ProcessCleanupPolicyError.d.ts.map +1 -0
- package/dist/esm/internal/ProcessCleanupPolicyError.js +25 -0
- package/dist/esm/internal/ProcessCleanupPolicyError.js.map +1 -0
- package/dist/esm/internal/ProcessFault.d.ts +63 -0
- package/dist/esm/internal/ProcessFault.d.ts.map +1 -0
- package/dist/esm/internal/ProcessFault.js +64 -0
- package/dist/esm/internal/ProcessFault.js.map +1 -0
- package/dist/esm/internal/ProcessSupervisor.d.ts +143 -0
- package/dist/esm/internal/ProcessSupervisor.d.ts.map +1 -0
- package/dist/esm/internal/ProcessSupervisor.js +689 -0
- package/dist/esm/internal/ProcessSupervisor.js.map +1 -0
- package/dist/esm/internal/SupervisorProgram.d.ts +9 -0
- package/dist/esm/internal/SupervisorProgram.d.ts.map +1 -0
- package/dist/esm/internal/SupervisorProgram.js +310 -0
- package/dist/esm/internal/SupervisorProgram.js.map +1 -0
- package/dist/esm/internal/WindowsProcessJob.d.ts +39 -0
- package/dist/esm/internal/WindowsProcessJob.d.ts.map +1 -0
- package/dist/esm/internal/WindowsProcessJob.js +115 -0
- package/dist/esm/internal/WindowsProcessJob.js.map +1 -0
- package/dist/vendor/adapters.json +1757 -0
- package/dist/vendor/chunk-2Y7WC4KU.js +109 -0
- package/dist/vendor/chunk-3GR5VZ2M.js +118 -0
- package/dist/vendor/chunk-42QKY6T6.js +40 -0
- package/dist/vendor/chunk-54RLBMTZ.js +61 -0
- package/dist/vendor/chunk-5ZMHBXIK.js +55 -0
- package/dist/vendor/chunk-6ME2W7TF.js +28 -0
- package/dist/vendor/chunk-AMQKOQNT.js +34 -0
- package/dist/vendor/chunk-B3FZ67QU.js +59 -0
- package/dist/vendor/chunk-BKTBUBQY.js +437 -0
- package/dist/vendor/chunk-DS7GF46S.js +34 -0
- package/dist/vendor/chunk-DVOAHXPG.js +104 -0
- package/dist/vendor/chunk-DWSHTSVX.js +229 -0
- package/dist/vendor/chunk-EGBNVEEW.js +14 -0
- package/dist/vendor/chunk-EZWY45HP.js +18 -0
- package/dist/vendor/chunk-FNZOJHSV.js +71 -0
- package/dist/vendor/chunk-GXCHI7BM.js +131 -0
- package/dist/vendor/chunk-IIJ52ZU6.js +20 -0
- package/dist/vendor/chunk-J7A4CZDO.js +92 -0
- package/dist/vendor/chunk-JG5TTWPT.js +85 -0
- package/dist/vendor/chunk-JJ24ARBQ.js +394 -0
- package/dist/vendor/chunk-KOZMM5PZ.js +426 -0
- package/dist/vendor/chunk-KUUXSID7.js +18 -0
- package/dist/vendor/chunk-LEUPYT3Q.js +36 -0
- package/dist/vendor/chunk-M32LDTW7.js +18 -0
- package/dist/vendor/chunk-M7CLUILA.js +0 -0
- package/dist/vendor/chunk-MBSKBQ5D.js +21 -0
- package/dist/vendor/chunk-MLKGABMK.js +9 -0
- package/dist/vendor/chunk-NBVRTDTV.js +129 -0
- package/dist/vendor/chunk-OXNGN5H7.js +81 -0
- package/dist/vendor/chunk-QPLDT6A6.js +564 -0
- package/dist/vendor/chunk-QYBKAIA6.js +18 -0
- package/dist/vendor/chunk-RO2R4MJH.js +62 -0
- package/dist/vendor/chunk-SIR62W3Y.js +398 -0
- package/dist/vendor/chunk-TFIKFFSC.js +26 -0
- package/dist/vendor/chunk-TXKLEBBL.js +143 -0
- package/dist/vendor/chunk-UFH5UUZK.js +48 -0
- package/dist/vendor/chunk-VANKHF46.js +96 -0
- package/dist/vendor/chunk-VZBDV3TV.js +18 -0
- package/dist/vendor/chunk-XDKNKFBW.js +22 -0
- package/dist/vendor/chunk-XH4U3JSV.js +249 -0
- package/dist/vendor/chunk-Y35ZAO5U.js +53 -0
- package/dist/vendor/chunk-ZJMRMY57.js +0 -0
- package/dist/vendor/cjs/node/NodeChildProcessSpawner.d.ts +7 -0
- package/dist/vendor/cjs/node/NodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node/NodeClusterHttp.d.ts +63 -0
- package/dist/vendor/cjs/node/NodeClusterHttp.js +1 -0
- package/dist/vendor/cjs/node/NodeClusterSocket.d.ts +79 -0
- package/dist/vendor/cjs/node/NodeClusterSocket.js +1 -0
- package/dist/vendor/cjs/node/NodeCrypto.d.ts +10 -0
- package/dist/vendor/cjs/node/NodeCrypto.js +1 -0
- package/dist/vendor/cjs/node/NodeFileSystem.d.ts +10 -0
- package/dist/vendor/cjs/node/NodeFileSystem.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpClient.d.ts +179 -0
- package/dist/vendor/cjs/node/NodeHttpClient.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpIncomingMessage.d.ts +62 -0
- package/dist/vendor/cjs/node/NodeHttpIncomingMessage.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpPlatform.d.ts +36 -0
- package/dist/vendor/cjs/node/NodeHttpPlatform.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpServer.d.ts +120 -0
- package/dist/vendor/cjs/node/NodeHttpServer.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpServerRequest.d.ts +29 -0
- package/dist/vendor/cjs/node/NodeHttpServerRequest.js +1 -0
- package/dist/vendor/cjs/node/NodeMultipart.d.ts +46 -0
- package/dist/vendor/cjs/node/NodeMultipart.js +1 -0
- package/dist/vendor/cjs/node/NodeMultipartParser.d.ts +97 -0
- package/dist/vendor/cjs/node/NodeMultipartParser.js +1 -0
- package/dist/vendor/cjs/node/NodePath.d.ts +27 -0
- package/dist/vendor/cjs/node/NodePath.js +1 -0
- package/dist/vendor/cjs/node/NodeRedis.d.ts +74 -0
- package/dist/vendor/cjs/node/NodeRedis.js +1 -0
- package/dist/vendor/cjs/node/NodeRuntime.d.ts +85 -0
- package/dist/vendor/cjs/node/NodeRuntime.js +1 -0
- package/dist/vendor/cjs/node/NodeServices.d.ts +34 -0
- package/dist/vendor/cjs/node/NodeServices.js +1 -0
- package/dist/vendor/cjs/node/NodeSink.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeSink.js +1 -0
- package/dist/vendor/cjs/node/NodeSocket.d.ts +38 -0
- package/dist/vendor/cjs/node/NodeSocket.js +1 -0
- package/dist/vendor/cjs/node/NodeSocketServer.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeSocketServer.js +1 -0
- package/dist/vendor/cjs/node/NodeStdio.d.ts +11 -0
- package/dist/vendor/cjs/node/NodeStdio.js +1 -0
- package/dist/vendor/cjs/node/NodeStream.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeStream.js +1 -0
- package/dist/vendor/cjs/node/NodeTerminal.d.ts +21 -0
- package/dist/vendor/cjs/node/NodeTerminal.js +1 -0
- package/dist/vendor/cjs/node/NodeWorker.d.ts +22 -0
- package/dist/vendor/cjs/node/NodeWorker.js +1 -0
- package/dist/vendor/cjs/node/NodeWorkerRunner.d.ts +12 -0
- package/dist/vendor/cjs/node/NodeWorkerRunner.js +1 -0
- package/dist/vendor/cjs/node/Undici.d.ts +28 -0
- package/dist/vendor/cjs/node/Undici.js +1 -0
- package/dist/vendor/cjs/node/index.d.ts +100 -0
- package/dist/vendor/cjs/node/index.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.d.ts +57 -0
- package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeClusterSocket.d.ts +22 -0
- package/dist/vendor/cjs/node-shared/NodeClusterSocket.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeCrypto.d.ts +27 -0
- package/dist/vendor/cjs/node-shared/NodeCrypto.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeFileSystem.d.ts +11 -0
- package/dist/vendor/cjs/node-shared/NodeFileSystem.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeHttpCompression.d.ts +36 -0
- package/dist/vendor/cjs/node-shared/NodeHttpCompression.js +1 -0
- package/dist/vendor/cjs/node-shared/NodePath.d.ts +27 -0
- package/dist/vendor/cjs/node-shared/NodePath.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeRuntime.d.ts +47 -0
- package/dist/vendor/cjs/node-shared/NodeRuntime.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSink.d.ts +69 -0
- package/dist/vendor/cjs/node-shared/NodeSink.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSocket.d.ts +134 -0
- package/dist/vendor/cjs/node-shared/NodeSocket.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSocketServer.d.ts +80 -0
- package/dist/vendor/cjs/node-shared/NodeSocketServer.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeStdio.d.ts +12 -0
- package/dist/vendor/cjs/node-shared/NodeStdio.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeStream.d.ts +179 -0
- package/dist/vendor/cjs/node-shared/NodeStream.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeTerminal.d.ts +22 -0
- package/dist/vendor/cjs/node-shared/NodeTerminal.js +1 -0
- package/dist/vendor/cjs/node-shared/index.d.ts +56 -0
- package/dist/vendor/cjs/node-shared/index.js +1 -0
- package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
- package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node-shared/internal/utils.d.ts +2 -0
- package/dist/vendor/cjs/node-shared/internal/utils.js +1 -0
- package/dist/vendor/cjs/package.json +1 -0
- package/dist/vendor/cjs/platform-node-shared.d.ts +56 -0
- package/dist/vendor/cjs/platform-node-shared.js +1 -0
- package/dist/vendor/cjs/platform-node.d.ts +100 -0
- package/dist/vendor/cjs/platform-node.js +1 -0
- package/dist/vendor/node/LICENSE +21 -0
- package/dist/vendor/node/NodeChildProcessSpawner.d.ts +7 -0
- package/dist/vendor/node/NodeChildProcessSpawner.js +14 -0
- package/dist/vendor/node/NodeClusterHttp.d.ts +63 -0
- package/dist/vendor/node/NodeClusterHttp.js +43 -0
- package/dist/vendor/node/NodeClusterSocket.d.ts +79 -0
- package/dist/vendor/node/NodeClusterSocket.js +30 -0
- package/dist/vendor/node/NodeCrypto.d.ts +10 -0
- package/dist/vendor/node/NodeCrypto.js +8 -0
- package/dist/vendor/node/NodeFileSystem.d.ts +10 -0
- package/dist/vendor/node/NodeFileSystem.js +9 -0
- package/dist/vendor/node/NodeHttpClient.d.ts +179 -0
- package/dist/vendor/node/NodeHttpClient.js +46 -0
- package/dist/vendor/node/NodeHttpIncomingMessage.d.ts +62 -0
- package/dist/vendor/node/NodeHttpIncomingMessage.js +10 -0
- package/dist/vendor/node/NodeHttpPlatform.d.ts +36 -0
- package/dist/vendor/node/NodeHttpPlatform.js +16 -0
- package/dist/vendor/node/NodeHttpServer.d.ts +120 -0
- package/dist/vendor/node/NodeHttpServer.js +46 -0
- package/dist/vendor/node/NodeHttpServerRequest.d.ts +29 -0
- package/dist/vendor/node/NodeHttpServerRequest.js +9 -0
- package/dist/vendor/node/NodeMultipart.d.ts +46 -0
- package/dist/vendor/node/NodeMultipart.js +15 -0
- package/dist/vendor/node/NodeMultipartParser.d.ts +97 -0
- package/dist/vendor/node/NodeMultipartParser.js +11 -0
- package/dist/vendor/node/NodePath.d.ts +27 -0
- package/dist/vendor/node/NodePath.js +12 -0
- package/dist/vendor/node/NodeRedis.d.ts +74 -0
- package/dist/vendor/node/NodeRedis.js +11 -0
- package/dist/vendor/node/NodeRuntime.d.ts +85 -0
- package/dist/vendor/node/NodeRuntime.js +8 -0
- package/dist/vendor/node/NodeServices.d.ts +34 -0
- package/dist/vendor/node/NodeServices.js +23 -0
- package/dist/vendor/node/NodeSink.d.ts +8 -0
- package/dist/vendor/node/NodeSink.js +12 -0
- package/dist/vendor/node/NodeSocket.d.ts +38 -0
- package/dist/vendor/node/NodeSocket.js +31 -0
- package/dist/vendor/node/NodeSocketServer.d.ts +8 -0
- package/dist/vendor/node/NodeSocketServer.js +21 -0
- package/dist/vendor/node/NodeStdio.d.ts +11 -0
- package/dist/vendor/node/NodeStdio.js +10 -0
- package/dist/vendor/node/NodeStream.d.ts +8 -0
- package/dist/vendor/node/NodeStream.js +27 -0
- package/dist/vendor/node/NodeTerminal.d.ts +21 -0
- package/dist/vendor/node/NodeTerminal.js +10 -0
- package/dist/vendor/node/NodeWorker.d.ts +22 -0
- package/dist/vendor/node/NodeWorker.js +9 -0
- package/dist/vendor/node/NodeWorkerRunner.d.ts +12 -0
- package/dist/vendor/node/NodeWorkerRunner.js +7 -0
- package/dist/vendor/node/Undici.d.ts +28 -0
- package/dist/vendor/node/Undici.js +9 -0
- package/dist/vendor/node/index.d.ts +100 -0
- package/dist/vendor/node/index.js +115 -0
- package/dist/vendor/node-shared/LICENSE +21 -0
- package/dist/vendor/node-shared/NodeChildProcessSpawner.d.ts +57 -0
- package/dist/vendor/node-shared/NodeChildProcessSpawner.js +13 -0
- package/dist/vendor/node-shared/NodeClusterSocket.d.ts +22 -0
- package/dist/vendor/node-shared/NodeClusterSocket.js +11 -0
- package/dist/vendor/node-shared/NodeCrypto.d.ts +27 -0
- package/dist/vendor/node-shared/NodeCrypto.js +9 -0
- package/dist/vendor/node-shared/NodeFileSystem.d.ts +11 -0
- package/dist/vendor/node-shared/NodeFileSystem.js +8 -0
- package/dist/vendor/node-shared/NodeHttpCompression.d.ts +36 -0
- package/dist/vendor/node-shared/NodeHttpCompression.js +13 -0
- package/dist/vendor/node-shared/NodePath.d.ts +27 -0
- package/dist/vendor/node-shared/NodePath.js +11 -0
- package/dist/vendor/node-shared/NodeRuntime.d.ts +47 -0
- package/dist/vendor/node-shared/NodeRuntime.js +7 -0
- package/dist/vendor/node-shared/NodeSink.d.ts +69 -0
- package/dist/vendor/node-shared/NodeSink.js +11 -0
- package/dist/vendor/node-shared/NodeSocket.d.ts +134 -0
- package/dist/vendor/node-shared/NodeSocket.js +23 -0
- package/dist/vendor/node-shared/NodeSocketServer.d.ts +80 -0
- package/dist/vendor/node-shared/NodeSocketServer.js +20 -0
- package/dist/vendor/node-shared/NodeStdio.d.ts +12 -0
- package/dist/vendor/node-shared/NodeStdio.js +9 -0
- package/dist/vendor/node-shared/NodeStream.d.ts +179 -0
- package/dist/vendor/node-shared/NodeStream.js +26 -0
- package/dist/vendor/node-shared/NodeTerminal.d.ts +22 -0
- package/dist/vendor/node-shared/NodeTerminal.js +9 -0
- package/dist/vendor/node-shared/index.d.ts +56 -0
- package/dist/vendor/node-shared/index.js +58 -0
- package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
- package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.js +7 -0
- package/dist/vendor/node-shared/internal/utils.d.ts +2 -0
- package/dist/vendor/node-shared/internal/utils.js +7 -0
- package/dist/vendor/platform-node-shared.d.ts +56 -0
- package/dist/vendor/platform-node-shared.js +58 -0
- package/dist/vendor/platform-node.d.ts +100 -0
- package/dist/vendor/platform-node.js +115 -0
- package/docs/README.md +129 -0
- package/docs/api.md +553 -0
- package/docs/concepts/descriptor-relative-filesystem.md +181 -0
- package/docs/concepts/host-bundle.md +125 -0
- package/docs/concepts/process-containment.md +190 -0
- package/docs/guides/answer-run-ownership.md +87 -0
- package/docs/guides/configure-the-filesystem-helper.md +152 -0
- package/docs/guides/contain-child-processes.md +139 -0
- package/docs/guides/match-files-with-glob.md +151 -0
- package/docs/installation.md +204 -0
- package/docs/quickstart.md +147 -0
- package/docs/troubleshooting.md +130 -0
- package/package.json +202 -3
- package/src/AtomicFileSystem.ts +415 -0
- package/src/EgressHttpClient.ts +327 -0
- package/src/HostLiveness.ts +103 -0
- package/src/NodeHost.ts +253 -0
- package/src/ProcessConfinement.ts +363 -0
- package/src/ProcessReaper.ts +951 -0
- package/src/ProcessSandbox.ts +1307 -0
- package/src/ScopedProcess.ts +124 -0
- package/src/index.ts +44 -0
- package/src/internal/AtomicFileSystemExecutable.ts +379 -0
- package/src/internal/AtomicFileSystemProtocol.ts +502 -0
- package/src/internal/AtomicFileSystemTransport.ts +272 -0
- package/src/internal/AtomicHelperError.ts +50 -0
- package/src/internal/AtomicHelperFault.ts +84 -0
- package/src/internal/PipedProcess.ts +357 -0
- package/src/internal/ProcSnapshot.ts +193 -0
- package/src/internal/ProcessCleanup.ts +99 -0
- package/src/internal/ProcessCleanupPolicyError.ts +30 -0
- package/src/internal/ProcessFault.ts +82 -0
- package/src/internal/ProcessSupervisor.ts +807 -0
- package/src/internal/SupervisorProgram.ts +309 -0
- package/src/internal/WindowsProcessJob.ts +114 -0
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var ProcessSandbox_exports = {};
|
|
30
|
+
__export(ProcessSandbox_exports, {
|
|
31
|
+
bubblewrap: () => bubblewrap,
|
|
32
|
+
diagnose: () => diagnose,
|
|
33
|
+
docker: () => docker,
|
|
34
|
+
environment: () => environment,
|
|
35
|
+
host: () => host,
|
|
36
|
+
isUnenforceable: () => isUnenforceable,
|
|
37
|
+
launcher: () => launcher,
|
|
38
|
+
plan: () => plan,
|
|
39
|
+
seatbelt: () => seatbelt,
|
|
40
|
+
select: () => select,
|
|
41
|
+
unenforceable: () => unenforceable,
|
|
42
|
+
validateWrites: () => validateWrites,
|
|
43
|
+
wrap: () => wrap
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(ProcessSandbox_exports);
|
|
46
|
+
var import_node_child_process = require("node:child_process");
|
|
47
|
+
var import_node_crypto = require("node:crypto");
|
|
48
|
+
var NodeFs = __toESM(require("node:fs"), 1);
|
|
49
|
+
var NodeOs = __toESM(require("node:os"), 1);
|
|
50
|
+
var NodePath = __toESM(require("node:path"), 1);
|
|
51
|
+
const isUnenforceable = (value) => typeof value === "object" && value !== null && value._tag === "@smthrs/platform-node/SandboxUnenforceable";
|
|
52
|
+
const unenforceable = (platform, mechanism, missing, detail) => ({
|
|
53
|
+
_tag: "@smthrs/platform-node/SandboxUnenforceable",
|
|
54
|
+
platform,
|
|
55
|
+
mechanism,
|
|
56
|
+
missing,
|
|
57
|
+
message: `sandbox: the declared confinement cannot be enforced on this ${platform} host: ${detail}.`
|
|
58
|
+
});
|
|
59
|
+
const pathSeparator = (platform) => platform === "win32" ? ";" : ":";
|
|
60
|
+
const ambientEnvironment = () => process.env;
|
|
61
|
+
const host = (env = ambientEnvironment()) => {
|
|
62
|
+
const platform = process.platform;
|
|
63
|
+
let developerDirectory = env["DEVELOPER_DIR"];
|
|
64
|
+
if (platform === "darwin" && developerDirectory === void 0) {
|
|
65
|
+
try {
|
|
66
|
+
developerDirectory = (0, import_node_child_process.execFileSync)("/usr/bin/xcode-select", ["-p"], { encoding: "utf8", timeout: 2e3 }).trim();
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const entries = (env["PATH"] ?? "").split(pathSeparator(platform)).filter((entry) => entry !== "");
|
|
71
|
+
const extensions = platform === "win32" ? (env["PATHEXT"] ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
72
|
+
return {
|
|
73
|
+
platform,
|
|
74
|
+
developerDirectory,
|
|
75
|
+
home: NodeOs.homedir(),
|
|
76
|
+
executable: (name) => {
|
|
77
|
+
if (NodePath.isAbsolute(name)) return isExecutable(name) ? name : void 0;
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
for (const extension of extensions) {
|
|
80
|
+
const candidate = NodePath.join(entry, name + extension);
|
|
81
|
+
if (isExecutable(candidate)) return candidate;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return void 0;
|
|
85
|
+
},
|
|
86
|
+
exists: (path) => NodeFs.existsSync(path),
|
|
87
|
+
isSymbolicLink,
|
|
88
|
+
isDirectory: (path) => {
|
|
89
|
+
try {
|
|
90
|
+
return NodeFs.statSync(path).isDirectory();
|
|
91
|
+
} catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
entries: (directory) => {
|
|
96
|
+
try {
|
|
97
|
+
return NodeFs.readdirSync(directory);
|
|
98
|
+
} catch {
|
|
99
|
+
return void 0;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
realpath: (path) => {
|
|
103
|
+
try {
|
|
104
|
+
return NodeFs.realpathSync(path);
|
|
105
|
+
} catch {
|
|
106
|
+
return void 0;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
shimTarget,
|
|
110
|
+
uid: typeof process.getuid === "function" ? process.getuid() : void 0,
|
|
111
|
+
gid: typeof process.getgid === "function" ? process.getgid() : void 0
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
const shimLimit = 64 * 1024;
|
|
115
|
+
const shimTarget = (path) => {
|
|
116
|
+
try {
|
|
117
|
+
if (NodeFs.statSync(path).size > shimLimit) return void 0;
|
|
118
|
+
const text = NodeFs.readFileSync(path, "utf8");
|
|
119
|
+
if (!text.startsWith("#!")) return void 0;
|
|
120
|
+
const target = /^# cmd-shim-target=(.+)$/m.exec(text)?.[1];
|
|
121
|
+
return target !== void 0 && NodePath.isAbsolute(target) ? target : void 0;
|
|
122
|
+
} catch {
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const isExecutable = (path) => {
|
|
127
|
+
try {
|
|
128
|
+
NodeFs.accessSync(path, NodeFs.constants.X_OK);
|
|
129
|
+
return NodeFs.statSync(path).isFile();
|
|
130
|
+
} catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const select = (request, hostFacts) => {
|
|
135
|
+
const declared = request.mechanism;
|
|
136
|
+
const platform = hostFacts.platform;
|
|
137
|
+
if (declared !== void 0 && declared._tag === "docker") {
|
|
138
|
+
const executable = hostFacts.executable("docker");
|
|
139
|
+
if (executable === void 0) {
|
|
140
|
+
return unenforceable(platform, "docker", "docker", "a docker mechanism is selected but docker is not on PATH");
|
|
141
|
+
}
|
|
142
|
+
return { _tag: "docker", executable, image: declared.image };
|
|
143
|
+
}
|
|
144
|
+
if (declared !== void 0 && platform !== "linux") {
|
|
145
|
+
return unenforceable(
|
|
146
|
+
platform,
|
|
147
|
+
"bubblewrap",
|
|
148
|
+
"linux",
|
|
149
|
+
"bubblewrap is selected but runs only on Linux; on macOS the seatbelt mechanism is selected when no mechanism is named"
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
if (platform === "linux") {
|
|
153
|
+
const executable = hostFacts.executable("bwrap");
|
|
154
|
+
if (executable === void 0) {
|
|
155
|
+
return unenforceable(platform, "bubblewrap", "bwrap", "bwrap is not on PATH (install the bubblewrap package)");
|
|
156
|
+
}
|
|
157
|
+
if (request.network === "loopback") {
|
|
158
|
+
return unenforceable(
|
|
159
|
+
platform,
|
|
160
|
+
"bubblewrap",
|
|
161
|
+
"network: true",
|
|
162
|
+
"bubblewrap cannot expose only the host loopback interface: sharing that interface also grants full host networking; open the whole network to opt into that access"
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return { _tag: "bubblewrap", executable };
|
|
166
|
+
}
|
|
167
|
+
if (platform === "darwin") {
|
|
168
|
+
const executable = hostFacts.executable("/usr/bin/sandbox-exec");
|
|
169
|
+
if (executable === void 0) {
|
|
170
|
+
return unenforceable(platform, "seatbelt", "/usr/bin/sandbox-exec", "/usr/bin/sandbox-exec is missing");
|
|
171
|
+
}
|
|
172
|
+
return { _tag: "seatbelt", executable };
|
|
173
|
+
}
|
|
174
|
+
return unenforceable(
|
|
175
|
+
platform,
|
|
176
|
+
"docker",
|
|
177
|
+
"docker image",
|
|
178
|
+
`${platform} has no process sandbox of its own; select a docker mechanism with an image`
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
const toPosix = (path) => path.split(NodePath.sep).join("/");
|
|
182
|
+
const realized = (path) => {
|
|
183
|
+
let head = path;
|
|
184
|
+
const tail = [];
|
|
185
|
+
while (head !== NodePath.dirname(head)) {
|
|
186
|
+
try {
|
|
187
|
+
const real = NodeFs.realpathSync(head);
|
|
188
|
+
return tail.length === 0 ? real : NodePath.join(real, ...tail);
|
|
189
|
+
} catch {
|
|
190
|
+
tail.unshift(NodePath.basename(head));
|
|
191
|
+
head = NodePath.dirname(head);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return path;
|
|
195
|
+
};
|
|
196
|
+
const insideRoot = (root, candidate) => {
|
|
197
|
+
const relative = NodePath.relative(root, candidate);
|
|
198
|
+
return relative === "" || relative !== ".." && !relative.startsWith(`..${NodePath.sep}`) && !NodePath.isAbsolute(relative);
|
|
199
|
+
};
|
|
200
|
+
const isSymbolicLink = (path) => {
|
|
201
|
+
try {
|
|
202
|
+
return NodeFs.lstatSync(path).isSymbolicLink();
|
|
203
|
+
} catch (cause) {
|
|
204
|
+
if (cause.code === "ENOENT") return false;
|
|
205
|
+
throw cause;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const safeWrite = (root, path, hostFacts) => {
|
|
209
|
+
if (!insideRoot(root, path)) return false;
|
|
210
|
+
try {
|
|
211
|
+
const realpath = hostFacts.realpath ?? NodeFs.realpathSync;
|
|
212
|
+
const link = hostFacts.isSymbolicLink ?? isSymbolicLink;
|
|
213
|
+
if (realpath(root) !== root) return false;
|
|
214
|
+
let current = root;
|
|
215
|
+
for (const component of NodePath.relative(root, path).split(NodePath.sep).filter(Boolean)) {
|
|
216
|
+
current = NodePath.join(current, component);
|
|
217
|
+
if (link(current)) return false;
|
|
218
|
+
if (hostFacts.exists(current) && realpath(current) !== current) return false;
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
} catch {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const unsafeWrite = (platform, mechanism, path) => unenforceable(
|
|
226
|
+
platform,
|
|
227
|
+
mechanism,
|
|
228
|
+
"canonical workspace write path",
|
|
229
|
+
`write path ${path} has a symbolic link, an unresolved ancestor, or leaves the canonical workspace`
|
|
230
|
+
);
|
|
231
|
+
const validateWrites = (confinement, hostFacts = host()) => {
|
|
232
|
+
for (const write of confinement.writes) {
|
|
233
|
+
if (!safeWrite(confinement.workspaceRoot, write, hostFacts)) {
|
|
234
|
+
throw unsafeWrite(hostFacts.platform, confinement.mechanism._tag, write);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const fold = (root, declared, alsoCovered, hostFacts) => {
|
|
239
|
+
const entries = hostFacts.entries;
|
|
240
|
+
if (entries === void 0) return { reads: declared, denies: [] };
|
|
241
|
+
const covered = /* @__PURE__ */ new Set([...declared, ...alsoCovered]);
|
|
242
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
243
|
+
for (const path of declared) {
|
|
244
|
+
let current = NodePath.dirname(path);
|
|
245
|
+
while (insideRoot(root, current) && current !== root && !candidates.has(current)) {
|
|
246
|
+
candidates.add(current);
|
|
247
|
+
current = NodePath.dirname(current);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const holdsCovered = /* @__PURE__ */ new Set();
|
|
251
|
+
for (const path of alsoCovered) {
|
|
252
|
+
let current = NodePath.dirname(path);
|
|
253
|
+
while (insideRoot(root, current) && current !== root && !holdsCovered.has(current)) {
|
|
254
|
+
holdsCovered.add(current);
|
|
255
|
+
current = NodePath.dirname(current);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const deepestFirst = [...candidates].sort((left, right) => right.length - left.length || (left < right ? -1 : 1));
|
|
259
|
+
const promoted = [];
|
|
260
|
+
const denies = [];
|
|
261
|
+
for (const directory of deepestFirst) {
|
|
262
|
+
if (covered.has(directory)) continue;
|
|
263
|
+
const children = entries(directory);
|
|
264
|
+
if (children === void 0 || children.length === 0) continue;
|
|
265
|
+
const uncovered = [];
|
|
266
|
+
let coveredCount = 0;
|
|
267
|
+
let partial = false;
|
|
268
|
+
for (const child of children) {
|
|
269
|
+
const path = NodePath.join(directory, child);
|
|
270
|
+
if (covered.has(path)) coveredCount += 1;
|
|
271
|
+
else if (candidates.has(path) || holdsCovered.has(path)) partial = true;
|
|
272
|
+
else uncovered.push(path);
|
|
273
|
+
}
|
|
274
|
+
if (partial || coveredCount === 0 || coveredCount < uncovered.length) continue;
|
|
275
|
+
covered.add(directory);
|
|
276
|
+
promoted.push(directory);
|
|
277
|
+
denies.push(...uncovered);
|
|
278
|
+
}
|
|
279
|
+
return { reads: [...declared, ...promoted], denies };
|
|
280
|
+
};
|
|
281
|
+
const bySubtree = (left, right) => {
|
|
282
|
+
const leftKey = left + NodePath.sep;
|
|
283
|
+
const rightKey = right + NodePath.sep;
|
|
284
|
+
return leftKey < rightKey ? -1 : 1;
|
|
285
|
+
};
|
|
286
|
+
const collapse = (paths) => {
|
|
287
|
+
const unique = [...new Set(paths)];
|
|
288
|
+
const kept = /* @__PURE__ */ new Set();
|
|
289
|
+
let ancestor;
|
|
290
|
+
for (const path of [...unique].sort(bySubtree)) {
|
|
291
|
+
if (ancestor !== void 0 && path.startsWith(ancestor + NodePath.sep)) continue;
|
|
292
|
+
kept.add(path);
|
|
293
|
+
ancestor = path;
|
|
294
|
+
}
|
|
295
|
+
return unique.filter((path) => kept.has(path)).sort(
|
|
296
|
+
(left, right) => left.length - right.length || (left < right ? -1 : 1)
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
const plan = (request, location, hostFacts) => {
|
|
300
|
+
const selected = select(request, hostFacts);
|
|
301
|
+
if (isUnenforceable(selected)) return selected;
|
|
302
|
+
let root;
|
|
303
|
+
try {
|
|
304
|
+
const canonical = (hostFacts.realpath ?? NodeFs.realpathSync)(location.workspaceRoot);
|
|
305
|
+
if (canonical === void 0) return unsafeWrite(hostFacts.platform, selected._tag, location.workspaceRoot);
|
|
306
|
+
root = canonical;
|
|
307
|
+
} catch {
|
|
308
|
+
return unsafeWrite(hostFacts.platform, selected._tag, location.workspaceRoot);
|
|
309
|
+
}
|
|
310
|
+
const anchor = (relative) => {
|
|
311
|
+
const absolute = NodePath.resolve(root, ...relative.split("/"));
|
|
312
|
+
return insideRoot(root, absolute) ? absolute : void 0;
|
|
313
|
+
};
|
|
314
|
+
const declared = [];
|
|
315
|
+
const externalReads = [];
|
|
316
|
+
for (const relative of request.reads) {
|
|
317
|
+
const absolute = anchor(relative);
|
|
318
|
+
if (absolute === void 0 || !hostFacts.exists(absolute)) continue;
|
|
319
|
+
declared.push(absolute);
|
|
320
|
+
const real = hostFacts.realpath?.(absolute);
|
|
321
|
+
if (real !== void 0 && real !== absolute && !insideRoot(root, real)) externalReads.push(real);
|
|
322
|
+
}
|
|
323
|
+
for (const path of request.externalReads ?? []) {
|
|
324
|
+
if (!NodePath.isAbsolute(path) || insideRoot(root, path) || !hostFacts.exists(path)) continue;
|
|
325
|
+
externalReads.push(hostFacts.realpath?.(path) ?? path);
|
|
326
|
+
}
|
|
327
|
+
const writes = [];
|
|
328
|
+
const add = (absolute) => {
|
|
329
|
+
if (!safeWrite(root, absolute, hostFacts)) return unsafeWrite(hostFacts.platform, selected._tag, absolute);
|
|
330
|
+
writes.push(absolute);
|
|
331
|
+
return void 0;
|
|
332
|
+
};
|
|
333
|
+
for (const relative of request.writes) {
|
|
334
|
+
const absolute = anchor(relative);
|
|
335
|
+
if (absolute === void 0) continue;
|
|
336
|
+
if (!safeWrite(root, absolute, hostFacts)) return unsafeWrite(hostFacts.platform, selected._tag, absolute);
|
|
337
|
+
const refusal = add(
|
|
338
|
+
hostFacts.exists(absolute) && !hostFacts.isDirectory(absolute) ? NodePath.dirname(absolute) : absolute
|
|
339
|
+
);
|
|
340
|
+
if (refusal !== void 0) return refusal;
|
|
341
|
+
}
|
|
342
|
+
for (const relative of request.writeFiles ?? []) {
|
|
343
|
+
const absolute = anchor(relative);
|
|
344
|
+
if (absolute === void 0) continue;
|
|
345
|
+
if (!safeWrite(root, absolute, hostFacts)) return unsafeWrite(hostFacts.platform, selected._tag, absolute);
|
|
346
|
+
const refusal = add(
|
|
347
|
+
hostFacts.exists(absolute) && hostFacts.isDirectory(absolute) ? absolute : NodePath.dirname(absolute)
|
|
348
|
+
);
|
|
349
|
+
if (refusal !== void 0) return refusal;
|
|
350
|
+
}
|
|
351
|
+
const readOnly = [];
|
|
352
|
+
for (const relative of request.readOnly ?? []) {
|
|
353
|
+
const absolute = anchor(relative);
|
|
354
|
+
if (absolute !== void 0) readOnly.push(absolute);
|
|
355
|
+
}
|
|
356
|
+
const folded = selected._tag === "seatbelt" ? fold(root, declared, [...writes, ...readOnly, location.tmp], hostFacts) : { reads: declared, denies: [] };
|
|
357
|
+
return {
|
|
358
|
+
mechanism: selected,
|
|
359
|
+
network: request.network,
|
|
360
|
+
unixSockets: request.unixSockets,
|
|
361
|
+
strict: request.strict,
|
|
362
|
+
workspaceRoot: root,
|
|
363
|
+
cwd: location.cwd,
|
|
364
|
+
reads: collapse(folded.reads),
|
|
365
|
+
readDenies: collapse(folded.denies),
|
|
366
|
+
writes: collapse(writes),
|
|
367
|
+
readOnly: collapse(readOnly),
|
|
368
|
+
externalReads: collapse(externalReads),
|
|
369
|
+
tmp: location.tmp,
|
|
370
|
+
uid: hostFacts.uid,
|
|
371
|
+
gid: hostFacts.gid
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
const corepackHome = (env, home) => {
|
|
375
|
+
const declared = env["COREPACK_HOME"];
|
|
376
|
+
if (declared !== void 0 && declared !== "") return declared;
|
|
377
|
+
const base = env["XDG_CACHE_HOME"] ?? env["LOCALAPPDATA"] ?? NodePath.join(home, process.platform === "win32" ? "AppData/Local" : ".cache");
|
|
378
|
+
return NodePath.join(base, "node", "corepack");
|
|
379
|
+
};
|
|
380
|
+
const environment = (confinement, hostEnv = ambientEnvironment(), hostHome = NodeOs.homedir()) => {
|
|
381
|
+
const tmp = confinement.mechanism._tag === "seatbelt" ? confinement.tmp : "/tmp";
|
|
382
|
+
const home = NodePath.posix.join(toPosix(tmp), "home");
|
|
383
|
+
return {
|
|
384
|
+
COREPACK_HOME: corepackHome(hostEnv, hostHome),
|
|
385
|
+
HOME: home,
|
|
386
|
+
TMPDIR: tmp,
|
|
387
|
+
TMP: tmp,
|
|
388
|
+
TEMP: tmp,
|
|
389
|
+
XDG_CACHE_HOME: NodePath.posix.join(toPosix(tmp), "cache"),
|
|
390
|
+
XDG_CONFIG_HOME: NodePath.posix.join(toPosix(tmp), "config"),
|
|
391
|
+
XDG_DATA_HOME: NodePath.posix.join(toPosix(tmp), "data"),
|
|
392
|
+
XDG_STATE_HOME: NodePath.posix.join(toPosix(tmp), "state")
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
const runtimeReads = (hostFacts) => {
|
|
396
|
+
const paths = [
|
|
397
|
+
"/usr",
|
|
398
|
+
"/bin",
|
|
399
|
+
"/sbin",
|
|
400
|
+
"/lib",
|
|
401
|
+
"/lib64",
|
|
402
|
+
"/nix/store",
|
|
403
|
+
"/opt/homebrew",
|
|
404
|
+
// A Smithers machine's toolchain layer: the repository's Node, pnpm, Go,
|
|
405
|
+
// Rust and Python, which the machine's environment puts first on PATH
|
|
406
|
+
// (packages/backend/microsandbox layers.go toolchainRoot). Never all of
|
|
407
|
+
// /opt/smithers, which holds the machine's environment and helpers.
|
|
408
|
+
"/opt/smithers/toolchain",
|
|
409
|
+
"/opt/smithers/rust",
|
|
410
|
+
"/System/Library",
|
|
411
|
+
"/System/Volumes/Preboot/Cryptexes/OS",
|
|
412
|
+
"/private/var/db/dyld",
|
|
413
|
+
// macOS shell and developer-tool dispatch read these system selectors.
|
|
414
|
+
"/var/select/sh",
|
|
415
|
+
"/private/var/select/sh",
|
|
416
|
+
"/var/select/developer_dir",
|
|
417
|
+
"/private/var/select/developer_dir",
|
|
418
|
+
"/Library/Apple",
|
|
419
|
+
"/Library/Developer",
|
|
420
|
+
"/Applications/Xcode.app/Contents/Developer",
|
|
421
|
+
"/Applications/Xcode.app/Contents/Info.plist",
|
|
422
|
+
"/Applications/Xcode.app/Contents/Frameworks",
|
|
423
|
+
"/Applications/Xcode.app/Contents/SharedFrameworks",
|
|
424
|
+
"/Applications/Xcode.app/Contents/PlugIns",
|
|
425
|
+
"/etc/ld.so.cache",
|
|
426
|
+
"/etc/ld.so.conf",
|
|
427
|
+
"/etc/ld.so.conf.d",
|
|
428
|
+
"/etc/localtime",
|
|
429
|
+
"/etc/ssl",
|
|
430
|
+
"/etc/hosts",
|
|
431
|
+
"/etc/resolv.conf",
|
|
432
|
+
"/etc/nsswitch.conf"
|
|
433
|
+
];
|
|
434
|
+
const developerDirectory = hostFacts.developerDirectory;
|
|
435
|
+
if (hostFacts.platform === "darwin" && developerDirectory !== void 0 && /^\/Applications\/Xcode[^/]*\.app\/Contents\/Developer$/.test(developerDirectory)) {
|
|
436
|
+
paths.push(developerDirectory);
|
|
437
|
+
}
|
|
438
|
+
if (hostFacts.home !== void 0) paths.push(NodePath.join(hostFacts.home, ".cache/node/corepack"));
|
|
439
|
+
for (const name of ["node", "bun"]) {
|
|
440
|
+
const executable = hostFacts.executable(name);
|
|
441
|
+
if (executable !== void 0) {
|
|
442
|
+
paths.push(executable);
|
|
443
|
+
const real = hostFacts.realpath?.(executable) ?? executable;
|
|
444
|
+
paths.push(real);
|
|
445
|
+
paths.push(NodePath.resolve(NodePath.dirname(real), "../lib/node_modules"));
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const present = paths.filter((path) => hostFacts.exists(path));
|
|
449
|
+
return collapse(present.flatMap((path) => [path, hostFacts.realpath?.(path) ?? path]));
|
|
450
|
+
};
|
|
451
|
+
const credentialPaths = (hostFacts) => {
|
|
452
|
+
const home = hostFacts.home;
|
|
453
|
+
if (home === void 0) return [];
|
|
454
|
+
return collapse([
|
|
455
|
+
".aws",
|
|
456
|
+
".ssh",
|
|
457
|
+
".gnupg",
|
|
458
|
+
".azure",
|
|
459
|
+
".kube",
|
|
460
|
+
".docker",
|
|
461
|
+
".config/gcloud",
|
|
462
|
+
".config/gh",
|
|
463
|
+
".npmrc",
|
|
464
|
+
".netrc",
|
|
465
|
+
".git-credentials"
|
|
466
|
+
].flatMap((relative) => {
|
|
467
|
+
const path = NodePath.join(home, relative);
|
|
468
|
+
return [path, hostFacts.realpath?.(path) ?? path];
|
|
469
|
+
}));
|
|
470
|
+
};
|
|
471
|
+
const launcher = (program, searchPath, granted, workspaceRoot, hostFacts) => {
|
|
472
|
+
const unchanged = { program, reads: [] };
|
|
473
|
+
if (program.includes("/") && !NodePath.isAbsolute(program)) return unchanged;
|
|
474
|
+
const found = NodePath.isAbsolute(program) ? hostFacts.executable(program) : searchPath === void 0 ? hostFacts.executable(program) : searchPath.split(":").filter((entry) => NodePath.isAbsolute(entry)).map((entry) => hostFacts.executable(NodePath.join(entry, program))).find((candidate) => candidate !== void 0);
|
|
475
|
+
if (found === void 0 || granted.some((parent) => insideRoot(parent, found))) return unchanged;
|
|
476
|
+
const resolved = hostFacts.realpath?.(found) ?? found;
|
|
477
|
+
const named = hostFacts.shimTarget?.(resolved);
|
|
478
|
+
const real = named === void 0 || hostFacts.executable(named) === void 0 ? resolved : hostFacts.realpath?.(named) ?? named;
|
|
479
|
+
if ([found, resolved, real].some((path) => insideRoot(workspaceRoot, path))) return unchanged;
|
|
480
|
+
if (granted.some((parent) => insideRoot(parent, real))) return { program: real, reads: [] };
|
|
481
|
+
let directory = NodePath.dirname(real);
|
|
482
|
+
for (let level = 0; level < 3; level++) {
|
|
483
|
+
if (directory === NodePath.dirname(directory) || directory === hostFacts.home) break;
|
|
484
|
+
if (hostFacts.exists(NodePath.join(directory, "package.json"))) return { program: real, reads: [directory] };
|
|
485
|
+
directory = NodePath.dirname(directory);
|
|
486
|
+
}
|
|
487
|
+
return { program: real, reads: [real] };
|
|
488
|
+
};
|
|
489
|
+
const bubblewrap = (confinement, argv, hostFacts = host(), searchPath) => {
|
|
490
|
+
if (confinement.mechanism._tag !== "bubblewrap") throw new Error("bubblewrap argv needs a bubblewrap plan");
|
|
491
|
+
validateWrites(confinement, hostFacts);
|
|
492
|
+
const home = "/tmp/home";
|
|
493
|
+
const out = [
|
|
494
|
+
confinement.mechanism.executable,
|
|
495
|
+
"--tmpfs",
|
|
496
|
+
"/"
|
|
497
|
+
];
|
|
498
|
+
const runtime = runtimeReads(hostFacts);
|
|
499
|
+
for (const read of runtime) out.push("--ro-bind", read, read);
|
|
500
|
+
out.push(
|
|
501
|
+
"--dev",
|
|
502
|
+
"/dev",
|
|
503
|
+
"--proc",
|
|
504
|
+
"/proc",
|
|
505
|
+
"--tmpfs",
|
|
506
|
+
"/tmp",
|
|
507
|
+
"--dir",
|
|
508
|
+
home,
|
|
509
|
+
"--dir",
|
|
510
|
+
"/tmp/cache",
|
|
511
|
+
"--tmpfs",
|
|
512
|
+
confinement.workspaceRoot,
|
|
513
|
+
"--dir",
|
|
514
|
+
confinement.cwd
|
|
515
|
+
);
|
|
516
|
+
for (const real of confinement.externalReads) out.push("--ro-bind", real, real);
|
|
517
|
+
const [program, ...args] = argv;
|
|
518
|
+
const launch = program === void 0 ? void 0 : launcher(
|
|
519
|
+
program,
|
|
520
|
+
searchPath,
|
|
521
|
+
[...runtime, ...confinement.reads, ...confinement.writes, ...confinement.externalReads],
|
|
522
|
+
confinement.workspaceRoot,
|
|
523
|
+
hostFacts
|
|
524
|
+
);
|
|
525
|
+
for (const read of launch?.reads ?? []) out.push("--ro-bind", read, read);
|
|
526
|
+
for (const read of confinement.reads) out.push("--ro-bind", read, read);
|
|
527
|
+
for (const write of confinement.writes) out.push("--bind", write, write);
|
|
528
|
+
for (const closed of confinement.readOnly) {
|
|
529
|
+
if (confinement.writes.some((write) => closed === write || closed.startsWith(write + NodePath.sep))) {
|
|
530
|
+
out.push("--ro-bind-try", closed, closed);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
const granted = [
|
|
534
|
+
...runtime,
|
|
535
|
+
...launch?.reads ?? [],
|
|
536
|
+
...confinement.reads,
|
|
537
|
+
...confinement.writes,
|
|
538
|
+
...confinement.externalReads
|
|
539
|
+
];
|
|
540
|
+
for (const path of credentialPaths(hostFacts)) {
|
|
541
|
+
if (!hostFacts.exists(path) || !granted.some((parent) => insideRoot(parent, path))) continue;
|
|
542
|
+
if (confinement.externalReads.some((parent) => insideRoot(parent, path))) continue;
|
|
543
|
+
const directory = hostFacts.isDirectory(path);
|
|
544
|
+
if (directory) out.push("--tmpfs", path);
|
|
545
|
+
else out.push("--ro-bind", "/dev/null", path);
|
|
546
|
+
for (const read of confinement.externalReads) {
|
|
547
|
+
if (insideRoot(path, read)) out.push("--ro-bind", read, read);
|
|
548
|
+
}
|
|
549
|
+
if (directory) out.push("--remount-ro", path);
|
|
550
|
+
}
|
|
551
|
+
if (!confinement.writes.includes(confinement.workspaceRoot)) out.push("--remount-ro", confinement.workspaceRoot);
|
|
552
|
+
out.push("--remount-ro", "/");
|
|
553
|
+
out.push("--chdir", confinement.cwd, "--unshare-all", "--new-session", "--die-with-parent");
|
|
554
|
+
if (confinement.network === "loopback") {
|
|
555
|
+
throw new Error("bubblewrap cannot render loopback-only networking");
|
|
556
|
+
}
|
|
557
|
+
if (confinement.network === "open") out.push("--share-net");
|
|
558
|
+
out.push("--", ...launch === void 0 ? argv : [launch.program, ...args]);
|
|
559
|
+
return out;
|
|
560
|
+
};
|
|
561
|
+
const sbpl = (value) => `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
562
|
+
const ancestors = (root, paths) => {
|
|
563
|
+
const found = /* @__PURE__ */ new Set([root]);
|
|
564
|
+
for (const path of paths) {
|
|
565
|
+
let current = NodePath.dirname(path);
|
|
566
|
+
while (current.length >= root.length && current !== NodePath.dirname(current)) {
|
|
567
|
+
found.add(current);
|
|
568
|
+
if (current === root) break;
|
|
569
|
+
current = NodePath.dirname(current);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return [...found].sort();
|
|
573
|
+
};
|
|
574
|
+
const seatbelt = (confinement, hostFacts = host()) => {
|
|
575
|
+
if (confinement.mechanism._tag !== "seatbelt") throw new Error("a seatbelt profile needs a seatbelt plan");
|
|
576
|
+
validateWrites(confinement, hostFacts);
|
|
577
|
+
const lines = ["(version 1)", confinement.strict === true ? "(deny default)" : "(allow default)"];
|
|
578
|
+
if (confinement.strict === true) {
|
|
579
|
+
lines.push(
|
|
580
|
+
"(allow process-exec)",
|
|
581
|
+
"(allow process-fork)",
|
|
582
|
+
"(allow signal (target same-sandbox))",
|
|
583
|
+
"(allow process-info* (target same-sandbox))",
|
|
584
|
+
'(allow sysctl-read (sysctl-name-prefix "hw.") (sysctl-name-prefix "machdep.cpu.") (sysctl-name "kern.argmax") (sysctl-name "kern.hostname") (sysctl-name "kern.maxfilesperproc") (sysctl-name "kern.maxproc") (sysctl-name "kern.osproductversion") (sysctl-name "kern.osrelease") (sysctl-name "kern.ostype") (sysctl-name "kern.osversion") (sysctl-name "kern.secure_kernel") (sysctl-name "kern.usrstack64") (sysctl-name "kern.version") (sysctl-name "sysctl.proc_cputype") (sysctl-name "vm.loadavg"))',
|
|
585
|
+
"(allow mach-host*)"
|
|
586
|
+
);
|
|
587
|
+
if (confinement.network === "open") lines.push("(allow network*)");
|
|
588
|
+
}
|
|
589
|
+
if (confinement.network !== "open") {
|
|
590
|
+
lines.push("(deny network*)");
|
|
591
|
+
if (confinement.unixSockets !== false) lines.push("(allow network* (local unix-socket))");
|
|
592
|
+
if (confinement.network === "loopback") {
|
|
593
|
+
lines.push(
|
|
594
|
+
'(allow network-bind (local ip "localhost:*"))',
|
|
595
|
+
'(allow network-inbound (local ip "localhost:*"))',
|
|
596
|
+
'(allow network-outbound (remote ip "localhost:*"))'
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
if (confinement.network === "open" && confinement.unixSockets === false) {
|
|
601
|
+
lines.push("(deny network* (local unix-socket))");
|
|
602
|
+
if (confinement.strict === true) {
|
|
603
|
+
lines.push('(allow network-outbound (literal "/private/var/run/mDNSResponder"))');
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
const writable = [...confinement.writes, confinement.tmp];
|
|
607
|
+
lines.push(
|
|
608
|
+
"(deny file-write*)",
|
|
609
|
+
`(allow file-write* ${confinement.strict === true ? '(literal "/dev/null")' : '(subpath "/dev")'} ${writable.map((path) => `(subpath ${sbpl(path)})`).join(" ")})`
|
|
610
|
+
);
|
|
611
|
+
if (confinement.readOnly.length > 0) {
|
|
612
|
+
lines.push(`(deny file-write* ${confinement.readOnly.map((path) => `(subpath ${sbpl(path)})`).join(" ")})`);
|
|
613
|
+
}
|
|
614
|
+
lines.push(
|
|
615
|
+
"(deny file-read*)",
|
|
616
|
+
confinement.strict === true ? '(allow file-read* (literal "/") (literal "/dev/null") (literal "/dev/zero") (literal "/dev/random") (literal "/dev/urandom"))' : '(allow file-read* (literal "/") (subpath "/dev"))',
|
|
617
|
+
// macOS's system aliases need readlink access before a shell can execute
|
|
618
|
+
// an admitted file through them. Literal grants expose the links only;
|
|
619
|
+
// their target directories still cannot be listed or read wholesale.
|
|
620
|
+
'(allow file-read* (literal "/tmp") (literal "/var") (literal "/etc"))'
|
|
621
|
+
);
|
|
622
|
+
const runtime = runtimeReads(hostFacts);
|
|
623
|
+
if (runtime.length > 0) lines.push(`(allow file-read* ${runtime.map((path) => `(subpath ${sbpl(path)})`).join(" ")})`);
|
|
624
|
+
const readable = [...confinement.reads, ...confinement.writes, confinement.tmp];
|
|
625
|
+
const traversable = ancestors("/", [...runtime, ...readable, ...confinement.externalReads]).filter((path) => !insideRoot(confinement.workspaceRoot, path));
|
|
626
|
+
lines.push(`(allow file-read-metadata ${traversable.map((path) => `(literal ${sbpl(path)})`).join(" ")})`);
|
|
627
|
+
const listable = ancestors(
|
|
628
|
+
confinement.workspaceRoot,
|
|
629
|
+
readable.filter((path) => insideRoot(confinement.workspaceRoot, path))
|
|
630
|
+
);
|
|
631
|
+
lines.push(
|
|
632
|
+
`(deny file-read* (subpath ${sbpl(confinement.workspaceRoot)}))`
|
|
633
|
+
);
|
|
634
|
+
if (confinement.strict === true) {
|
|
635
|
+
const metadata = [
|
|
636
|
+
.../* @__PURE__ */ new Set([
|
|
637
|
+
...listable,
|
|
638
|
+
...ancestors(confinement.workspaceRoot, [confinement.cwd]),
|
|
639
|
+
confinement.cwd
|
|
640
|
+
])
|
|
641
|
+
].sort();
|
|
642
|
+
lines.push(`(allow file-read-metadata ${metadata.map((path) => `(literal ${sbpl(path)})`).join(" ")})`);
|
|
643
|
+
} else {
|
|
644
|
+
lines.push(`(allow file-read-metadata (subpath ${sbpl(confinement.workspaceRoot)}))`);
|
|
645
|
+
}
|
|
646
|
+
lines.push(
|
|
647
|
+
`(allow file-read* ${[
|
|
648
|
+
...confinement.strict === true ? [] : listable.map((path) => `(literal ${sbpl(path)})`),
|
|
649
|
+
...readable.map((path) => `(subpath ${sbpl(path)})`)
|
|
650
|
+
].join(" ")})`
|
|
651
|
+
);
|
|
652
|
+
if (confinement.readDenies.length > 0) {
|
|
653
|
+
lines.push(`(deny file-read* ${confinement.readDenies.map((path) => `(subpath ${sbpl(path)})`).join(" ")})`);
|
|
654
|
+
}
|
|
655
|
+
const credentials = credentialPaths(hostFacts);
|
|
656
|
+
if (credentials.length > 0) {
|
|
657
|
+
lines.push(`(deny file-read* ${credentials.map((path) => `(subpath ${sbpl(path)})`).join(" ")})`);
|
|
658
|
+
if (confinement.strict === true) {
|
|
659
|
+
lines.push(`(deny file-write* ${credentials.map((path) => `(subpath ${sbpl(path)})`).join(" ")})`);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
if (confinement.externalReads.length > 0) {
|
|
663
|
+
lines.push(`(allow file-read* ${confinement.externalReads.map((path) => `(subpath ${sbpl(path)})`).join(" ")})`);
|
|
664
|
+
}
|
|
665
|
+
return lines.join("");
|
|
666
|
+
};
|
|
667
|
+
const mountField = (key, value) => {
|
|
668
|
+
const field = `${key}=${value}`;
|
|
669
|
+
return /[",\r\n]/.test(field) ? `"${field.replaceAll('"', '""')}"` : field;
|
|
670
|
+
};
|
|
671
|
+
const bindMount = (path, readonly) => ["type=bind", mountField("src", path), mountField("dst", toPosix(path)), ...readonly ? ["readonly"] : []].join(",");
|
|
672
|
+
const docker = (confinement, argv, env, hostFacts = host(), containerName = `smithers-${(0, import_node_crypto.randomUUID)()}`) => {
|
|
673
|
+
if (confinement.mechanism._tag !== "docker") throw new Error("docker argv needs a docker plan");
|
|
674
|
+
validateWrites(confinement, hostFacts);
|
|
675
|
+
const out = [
|
|
676
|
+
confinement.mechanism.executable,
|
|
677
|
+
"run",
|
|
678
|
+
"--rm",
|
|
679
|
+
"--init",
|
|
680
|
+
"--name",
|
|
681
|
+
containerName,
|
|
682
|
+
"--read-only",
|
|
683
|
+
"--tmpfs",
|
|
684
|
+
"/tmp:rw,exec",
|
|
685
|
+
"--network",
|
|
686
|
+
confinement.network === "open" ? "bridge" : "none",
|
|
687
|
+
"--workdir",
|
|
688
|
+
toPosix(confinement.cwd)
|
|
689
|
+
];
|
|
690
|
+
if (confinement.uid !== void 0 && confinement.gid !== void 0) {
|
|
691
|
+
out.push("--user", `${confinement.uid}:${confinement.gid}`);
|
|
692
|
+
}
|
|
693
|
+
for (const real of confinement.externalReads) out.push("--mount", bindMount(real, true));
|
|
694
|
+
for (const read of confinement.reads) out.push("--mount", bindMount(read, true));
|
|
695
|
+
for (const write of confinement.writes) out.push("--mount", bindMount(write, false));
|
|
696
|
+
for (const closed of confinement.readOnly) {
|
|
697
|
+
if (confinement.writes.some((write) => closed === write || closed.startsWith(write + NodePath.sep))) {
|
|
698
|
+
out.push("--mount", bindMount(closed, true));
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
for (const [name, value] of Object.entries(env).sort(([left], [right]) => left < right ? -1 : 1)) {
|
|
702
|
+
if (name === "PATH" || name === "HOME") continue;
|
|
703
|
+
out.push("--env", `${name}=${value}`);
|
|
704
|
+
}
|
|
705
|
+
out.push("--env", "HOME=/tmp/home", confinement.mechanism.image, ...argv);
|
|
706
|
+
return out;
|
|
707
|
+
};
|
|
708
|
+
const wrap = (confinement, argv, env, hostFacts = host()) => {
|
|
709
|
+
const extra = environment(confinement);
|
|
710
|
+
switch (confinement.mechanism._tag) {
|
|
711
|
+
case "bubblewrap":
|
|
712
|
+
return { argv: bubblewrap(confinement, argv, hostFacts, env["PATH"]), env: extra };
|
|
713
|
+
case "seatbelt": {
|
|
714
|
+
const profile = seatbelt(confinement, hostFacts);
|
|
715
|
+
return { argv: [confinement.mechanism.executable, "-p", profile, ...argv], env: extra };
|
|
716
|
+
}
|
|
717
|
+
case "docker": {
|
|
718
|
+
const containerName = `smithers-${(0, import_node_crypto.randomUUID)()}`;
|
|
719
|
+
return { argv: docker(confinement, argv, { ...env, ...extra }, hostFacts, containerName), env: {}, containerName };
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
const denialPatterns = [
|
|
724
|
+
{ pattern: /\b(?:EACCES|EPERM|ENOENT)\b[^'"\n]*['"]([^'"\n]+)['"]/g, write: false },
|
|
725
|
+
{ pattern: /\bEROFS\b[^'"\n]*['"]([^'"\n]+)['"]/g, write: true },
|
|
726
|
+
{
|
|
727
|
+
pattern: /(?:^|[\s:])((?:\/|\.{0,2}\/?)[^\s:'"]+): (?:Operation not permitted|Permission denied|No such file or directory|Directory nonexistent|Not a directory)/gm,
|
|
728
|
+
write: false
|
|
729
|
+
},
|
|
730
|
+
{ pattern: /(?:^|[\s:])((?:\/|\.{0,2}\/?)[^\s:'"]+): Read-only file system/gm, write: true },
|
|
731
|
+
{
|
|
732
|
+
pattern: /(?:Operation not permitted|Permission denied|No such file or directory|Directory nonexistent)[^\n]*?[:\s]['"]?((?:\/|[A-Za-z]:\\)[^'"\s:]+)/g,
|
|
733
|
+
write: false
|
|
734
|
+
},
|
|
735
|
+
{ pattern: /Read-only file system[^\n]*?[:\s]['"]?((?:\/|[A-Za-z]:\\)[^'"\s:]+)/g, write: true },
|
|
736
|
+
{
|
|
737
|
+
pattern: /cannot (?:create|write|touch|mkdir|remove) (?:directory )?['"]?((?:\/|[A-Za-z]:\\|\.{0,2}\/?)[^'":\s]+)/g,
|
|
738
|
+
write: true
|
|
739
|
+
},
|
|
740
|
+
{ pattern: /cannot (?:open|access|stat|read) ['"]?((?:\/|[A-Za-z]:\\|\.{0,2}\/?)[^'":\s]+)/g, write: false }
|
|
741
|
+
];
|
|
742
|
+
const diagnose = (confinement, text) => {
|
|
743
|
+
const named = /* @__PURE__ */ new Map();
|
|
744
|
+
for (const { pattern, write } of denialPatterns) {
|
|
745
|
+
for (const match of text.matchAll(pattern)) {
|
|
746
|
+
const raw = match[1];
|
|
747
|
+
const absolute = NodePath.isAbsolute(raw) ? raw : NodePath.resolve(confinement.cwd, raw);
|
|
748
|
+
if (insideRoot(confinement.workspaceRoot, absolute)) named.set(absolute, (named.get(absolute) ?? false) || write);
|
|
749
|
+
if (named.size >= 5) break;
|
|
750
|
+
}
|
|
751
|
+
if (named.size >= 5) break;
|
|
752
|
+
}
|
|
753
|
+
if (named.size === 0) return void 0;
|
|
754
|
+
const covered = (path, set) => set.some((entry) => entry === path || path.startsWith(entry + NodePath.sep));
|
|
755
|
+
const lines = [...named.entries()].sort(([left], [right]) => left < right ? -1 : 1).map(([path, write]) => {
|
|
756
|
+
const relative = toPosix(NodePath.relative(confinement.workspaceRoot, path));
|
|
757
|
+
const real = realized(path);
|
|
758
|
+
const escapes = !insideRoot(confinement.workspaceRoot, real);
|
|
759
|
+
const readable = !escapes && (covered(path, confinement.reads) || covered(path, confinement.writes));
|
|
760
|
+
const writable = !escapes && covered(path, confinement.writes) && !covered(path, confinement.readOnly);
|
|
761
|
+
if (escapes) {
|
|
762
|
+
return `sandbox: ${relative} resolves to ${real}, outside the declared ${write ? "write" : "read"} set`;
|
|
763
|
+
}
|
|
764
|
+
if (write) {
|
|
765
|
+
return writable ? `sandbox: ${relative} was denied inside the declared set` : `sandbox: ${relative} is outside the declared write set`;
|
|
766
|
+
}
|
|
767
|
+
if (!readable) return `sandbox: ${relative} is outside the declared read set`;
|
|
768
|
+
if (!writable) return `sandbox: ${relative} is outside the declared write set`;
|
|
769
|
+
return `sandbox: ${relative} was denied inside the declared set`;
|
|
770
|
+
});
|
|
771
|
+
return `${lines.join("\n")}
|
|
772
|
+
sandbox: ${confinement.mechanism._tag}, network ${confinement.network}, ${confinement.reads.length} read path(s), ${confinement.writes.length} write path(s)`;
|
|
773
|
+
};
|
|
774
|
+
//# sourceMappingURL=ProcessSandbox.js.map
|