just-bash 3.4.0 → 3.4.1
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 +6 -0
- package/dist/bin/chunks/{awk2-DZN2ZRSE.js → awk2-C4A37H5N.js} +1 -1
- package/dist/bin/{shell/chunks/base64-TP4NUOEB.js → chunks/base64-FLJ4YPHB.js} +1 -1
- package/dist/bin/chunks/{cat-A3REFE6L.js → cat-2J5MA5PY.js} +1 -1
- package/dist/bin/{shell/chunks/chmod-PHPDPTZD.js → chunks/chmod-ZM5WLMZI.js} +1 -1
- package/dist/bin/chunks/{chunk-ODPB5AH7.js → chunk-2HFDEZUY.js} +1 -1
- package/dist/bin/chunks/{chunk-DX5LO7JF.js → chunk-2INNLNI5.js} +1 -1
- package/dist/bin/chunks/{chunk-57BWX3A3.js → chunk-2ND6MMXN.js} +1 -1
- package/dist/bin/chunks/{chunk-QUWWWM4E.js → chunk-2ORJ5HTY.js} +1 -1
- package/dist/bin/chunks/{chunk-SOKKZSUV.js → chunk-3SCW7PD5.js} +1 -1
- package/dist/bin/chunks/{chunk-TKBTWIXO.js → chunk-42AMF6EE.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-NFYXRUSI.js → chunks/chunk-44MQ5AXA.js} +1 -1
- package/dist/bin/chunks/{chunk-GE5ERIO2.js → chunk-4APSDE57.js} +1 -1
- package/dist/bin/chunks/{chunk-ODCVIRIN.js → chunk-74TZ7ZF7.js} +1 -1
- package/dist/bin/chunks/{chunk-OD2SHTFL.js → chunk-7WBCA2BB.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-MOCKUJD6.js → chunks/chunk-APV27ZZW.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-YB3A42T5.js → chunks/chunk-BCQSUELK.js} +1 -1
- package/dist/bin/chunks/{chunk-FC5CC5UP.js → chunk-BJRT4VKD.js} +1 -1
- package/dist/bin/chunks/{chunk-6WNZWDBA.js → chunk-BOYPCOSV.js} +1 -1
- package/dist/bin/chunks/{chunk-KHS7PCAP.js → chunk-BZWGVRFA.js} +2 -2
- package/dist/bin/chunks/{chunk-BPMGKB5E.js → chunk-EXGPMLIE.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-MLJZPRDV.js → chunks/chunk-FB44CW33.js} +1 -1
- package/dist/bin/chunks/{chunk-35BSNGJK.js → chunk-GRP7L2EL.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-3DCUOX7D.js → chunks/chunk-GTULZ3ZD.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-O5R7J45W.js → chunks/chunk-HL7NFZVQ.js} +1 -1
- package/dist/bin/chunks/chunk-HWI42GQO.js +7 -0
- package/dist/bin/{shell/chunks/chunk-TY77F4UM.js → chunks/chunk-ISOWCECJ.js} +1 -1
- package/dist/bin/chunks/{chunk-TIYIKCEZ.js → chunk-JQM3DKCH.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-NWBQ75GZ.js → chunks/chunk-MF3GVFLC.js} +1 -1
- package/dist/bin/chunks/{chunk-6KTOOQK6.js → chunk-MHAGHCSO.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-62NF3462.js → chunks/chunk-MNSMZU47.js} +1 -1
- package/dist/bin/chunks/{chunk-GGPUS2B4.js → chunk-MRPJL3ZK.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-IHS3YLRI.js → chunks/chunk-MYEPQX6Y.js} +1 -1
- package/dist/bin/chunks/{chunk-EJIZDPMG.js → chunk-PPVF2N6C.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-7NMBLWZ5.js → chunks/chunk-QFTZKD5O.js} +1 -1
- package/dist/bin/chunks/{chunk-YABXNPH6.js → chunk-TIHFGNPS.js} +1 -1
- package/dist/bin/chunks/{chunk-YBTJPT3R.js → chunk-UHNV55NF.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-XG7YUZ3R.js → chunks/chunk-UNKX6YM6.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-BXDEO6VY.js → chunks/chunk-VKTV45AP.js} +1 -1
- package/dist/bin/{shell/chunks/expr-FAB3XEIB.js → chunks/expr-TDF3B6QJ.js} +1 -1
- package/dist/bin/{shell/chunks/file-ZHL2YACR.js → chunks/file-AJGG7RYT.js} +1 -1
- package/dist/bin/chunks/{flag-coverage-SPPGTKG3.js → flag-coverage-DOLZIUQ7.js} +1 -1
- package/dist/bin/{shell/chunks/grep-FBVRTH4M.js → chunks/grep-WUZMZDGY.js} +1 -1
- package/dist/bin/chunks/{gzip-AWQGRTSF.js → gzip-JA7JQBUS.js} +1 -1
- package/dist/bin/chunks/{head-A7CPWX7R.js → head-YGKW3HS4.js} +1 -1
- package/dist/bin/{shell/chunks/html-to-markdown-EMODJ24M.js → chunks/html-to-markdown-ZWL7LZIP.js} +1 -1
- package/dist/bin/chunks/{jq-DXL4NMI5.js → jq-5MI4V3G5.js} +1 -1
- package/dist/bin/chunks/{js-exec-BFLXGNPQ.js → js-exec-DJQLXWCS.js} +1 -1
- package/dist/bin/chunks/js-exec-worker.js +60 -4
- package/dist/bin/{shell/chunks/od-ZPR6FUOW.js → chunks/od-YCY27MMO.js} +1 -1
- package/dist/bin/{shell/chunks/paste-RQKXCKQO.js → chunks/paste-ACKOG3XS.js} +1 -1
- package/dist/bin/{shell/chunks/python3-WKVKCO33.js → chunks/python3-JCJHSX4Z.js} +1 -1
- package/dist/bin/chunks/{rg-34TWIR7N.js → rg-A3E7YM2A.js} +1 -1
- package/dist/bin/{shell/chunks/sed-SW74NKGU.js → chunks/sed-KJWKB22J.js} +1 -1
- package/dist/bin/chunks/{sleep-J2AVORMB.js → sleep-DVFE2GSF.js} +1 -1
- package/dist/bin/chunks/{split-EDDYGW4A.js → split-XMXBXL5Q.js} +1 -1
- package/dist/bin/chunks/{sqlite3-AZ27WWV7.js → sqlite3-DNH2VLVN.js} +1 -1
- package/dist/bin/chunks/sqlite3-worker.js +60 -4
- package/dist/bin/{shell/chunks/stat-XNGV2W6W.js → chunks/stat-5PUSTPTK.js} +1 -1
- package/dist/bin/chunks/{tail-H2WOZSEI.js → tail-4MB7HHIZ.js} +1 -1
- package/dist/bin/chunks/{tar-MZP7QXR4.js → tar-FRDUJZDN.js} +1 -1
- package/dist/bin/{shell/chunks/timeout-GH6S72QX.js → chunks/timeout-YGFHQJKX.js} +1 -1
- package/dist/bin/chunks/{tr-RVCBERJ4.js → tr-Z6N34HZM.js} +1 -1
- package/dist/bin/chunks/worker.js +60 -4
- package/dist/bin/chunks/{xan-BSNJF6SH.js → xan-VSF6ZQGZ.js} +1 -1
- package/dist/bin/chunks/{xan-view-H3LNQ72O.js → xan-view-UEFBHYVN.js} +1 -1
- package/dist/bin/chunks/{yq-GNMXK6OP.js → yq-K5N5JD4N.js} +1 -1
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/{awk2-DZN2ZRSE.js → awk2-C4A37H5N.js} +1 -1
- package/dist/bin/{chunks/base64-TP4NUOEB.js → shell/chunks/base64-FLJ4YPHB.js} +1 -1
- package/dist/bin/shell/chunks/{cat-A3REFE6L.js → cat-2J5MA5PY.js} +1 -1
- package/dist/bin/{chunks/chmod-PHPDPTZD.js → shell/chunks/chmod-ZM5WLMZI.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-ODPB5AH7.js → chunk-2HFDEZUY.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-DX5LO7JF.js → chunk-2INNLNI5.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-57BWX3A3.js → chunk-2ND6MMXN.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-QUWWWM4E.js → chunk-2ORJ5HTY.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-SOKKZSUV.js → chunk-3SCW7PD5.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-TKBTWIXO.js → chunk-42AMF6EE.js} +1 -1
- package/dist/bin/{chunks/chunk-NFYXRUSI.js → shell/chunks/chunk-44MQ5AXA.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-GE5ERIO2.js → chunk-4APSDE57.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-ODCVIRIN.js → chunk-74TZ7ZF7.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-OD2SHTFL.js → chunk-7WBCA2BB.js} +1 -1
- package/dist/bin/{chunks/chunk-MOCKUJD6.js → shell/chunks/chunk-APV27ZZW.js} +1 -1
- package/dist/bin/{chunks/chunk-YB3A42T5.js → shell/chunks/chunk-BCQSUELK.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-FC5CC5UP.js → chunk-BJRT4VKD.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-6WNZWDBA.js → chunk-BOYPCOSV.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-KHS7PCAP.js → chunk-BZWGVRFA.js} +2 -2
- package/dist/bin/shell/chunks/{chunk-BPMGKB5E.js → chunk-EXGPMLIE.js} +1 -1
- package/dist/bin/{chunks/chunk-MLJZPRDV.js → shell/chunks/chunk-FB44CW33.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-35BSNGJK.js → chunk-GRP7L2EL.js} +1 -1
- package/dist/bin/{chunks/chunk-3DCUOX7D.js → shell/chunks/chunk-GTULZ3ZD.js} +1 -1
- package/dist/bin/{chunks/chunk-O5R7J45W.js → shell/chunks/chunk-HL7NFZVQ.js} +1 -1
- package/dist/bin/shell/chunks/chunk-HWI42GQO.js +7 -0
- package/dist/bin/{chunks/chunk-TY77F4UM.js → shell/chunks/chunk-ISOWCECJ.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-TIYIKCEZ.js → chunk-JQM3DKCH.js} +1 -1
- package/dist/bin/{chunks/chunk-NWBQ75GZ.js → shell/chunks/chunk-MF3GVFLC.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-6KTOOQK6.js → chunk-MHAGHCSO.js} +1 -1
- package/dist/bin/{chunks/chunk-62NF3462.js → shell/chunks/chunk-MNSMZU47.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-GGPUS2B4.js → chunk-MRPJL3ZK.js} +1 -1
- package/dist/bin/{chunks/chunk-IHS3YLRI.js → shell/chunks/chunk-MYEPQX6Y.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-EJIZDPMG.js → chunk-PPVF2N6C.js} +1 -1
- package/dist/bin/{chunks/chunk-7NMBLWZ5.js → shell/chunks/chunk-QFTZKD5O.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-YABXNPH6.js → chunk-TIHFGNPS.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-YBTJPT3R.js → chunk-UHNV55NF.js} +1 -1
- package/dist/bin/{chunks/chunk-XG7YUZ3R.js → shell/chunks/chunk-UNKX6YM6.js} +1 -1
- package/dist/bin/{chunks/chunk-BXDEO6VY.js → shell/chunks/chunk-VKTV45AP.js} +1 -1
- package/dist/bin/{chunks/expr-FAB3XEIB.js → shell/chunks/expr-TDF3B6QJ.js} +1 -1
- package/dist/bin/{chunks/file-ZHL2YACR.js → shell/chunks/file-AJGG7RYT.js} +1 -1
- package/dist/bin/shell/chunks/{flag-coverage-SPPGTKG3.js → flag-coverage-DOLZIUQ7.js} +1 -1
- package/dist/bin/{chunks/grep-FBVRTH4M.js → shell/chunks/grep-WUZMZDGY.js} +1 -1
- package/dist/bin/shell/chunks/{gzip-AWQGRTSF.js → gzip-JA7JQBUS.js} +1 -1
- package/dist/bin/shell/chunks/{head-A7CPWX7R.js → head-YGKW3HS4.js} +1 -1
- package/dist/bin/{chunks/html-to-markdown-EMODJ24M.js → shell/chunks/html-to-markdown-ZWL7LZIP.js} +1 -1
- package/dist/bin/shell/chunks/{jq-DXL4NMI5.js → jq-5MI4V3G5.js} +1 -1
- package/dist/bin/shell/chunks/{js-exec-BFLXGNPQ.js → js-exec-DJQLXWCS.js} +1 -1
- package/dist/bin/{chunks/od-ZPR6FUOW.js → shell/chunks/od-YCY27MMO.js} +1 -1
- package/dist/bin/{chunks/paste-RQKXCKQO.js → shell/chunks/paste-ACKOG3XS.js} +1 -1
- package/dist/bin/{chunks/python3-WKVKCO33.js → shell/chunks/python3-JCJHSX4Z.js} +1 -1
- package/dist/bin/shell/chunks/{rg-34TWIR7N.js → rg-A3E7YM2A.js} +1 -1
- package/dist/bin/{chunks/sed-SW74NKGU.js → shell/chunks/sed-KJWKB22J.js} +1 -1
- package/dist/bin/shell/chunks/{sleep-J2AVORMB.js → sleep-DVFE2GSF.js} +1 -1
- package/dist/bin/shell/chunks/{split-EDDYGW4A.js → split-XMXBXL5Q.js} +1 -1
- package/dist/bin/shell/chunks/{sqlite3-AZ27WWV7.js → sqlite3-DNH2VLVN.js} +1 -1
- package/dist/bin/{chunks/stat-XNGV2W6W.js → shell/chunks/stat-5PUSTPTK.js} +1 -1
- package/dist/bin/shell/chunks/{tail-H2WOZSEI.js → tail-4MB7HHIZ.js} +1 -1
- package/dist/bin/shell/chunks/{tar-MZP7QXR4.js → tar-FRDUJZDN.js} +1 -1
- package/dist/bin/{chunks/timeout-GH6S72QX.js → shell/chunks/timeout-YGFHQJKX.js} +1 -1
- package/dist/bin/shell/chunks/{tr-RVCBERJ4.js → tr-Z6N34HZM.js} +1 -1
- package/dist/bin/shell/chunks/{xan-BSNJF6SH.js → xan-VSF6ZQGZ.js} +1 -1
- package/dist/bin/shell/chunks/{xan-view-H3LNQ72O.js → xan-view-UEFBHYVN.js} +1 -1
- package/dist/bin/shell/chunks/{yq-GNMXK6OP.js → yq-K5N5JD4N.js} +1 -1
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/browser.js +446 -444
- package/dist/bundle/chunks/{awk2-IDCJYLV2.js → awk2-NPLZQ3K7.js} +1 -1
- package/dist/bundle/chunks/{base64-3XQZ3ADB.js → base64-2BAITDZF.js} +1 -1
- package/dist/bundle/chunks/{cat-XWS72C47.js → cat-33KGN4MZ.js} +1 -1
- package/dist/bundle/chunks/{chmod-6FVWFWKL.js → chmod-APOXUPXW.js} +1 -1
- package/dist/bundle/chunks/{chunk-JQL34RLH.js → chunk-3CBCABOZ.js} +1 -1
- package/dist/bundle/chunks/{chunk-EZFSCUSP.js → chunk-5ELNHAAJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-M7DIEMEN.js → chunk-6DTD75TR.js} +1 -1
- package/dist/bundle/chunks/{chunk-5GI2HJYO.js → chunk-6KK46B7Q.js} +1 -1
- package/dist/bundle/chunks/{chunk-264HW33U.js → chunk-7IFSXTCJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-4MPKG4PJ.js → chunk-A3D7NRT6.js} +1 -1
- package/dist/bundle/chunks/{chunk-EVJMYTCY.js → chunk-ALOFNPKY.js} +2 -2
- package/dist/bundle/chunks/{chunk-QKQP2SCP.js → chunk-BKUWXPEM.js} +1 -1
- package/dist/bundle/chunks/{chunk-W4IV5QW4.js → chunk-CFBEDNHJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-CVMQI27W.js → chunk-DMWNBCXJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-VQCA62JK.js → chunk-FNEG7DFQ.js} +1 -1
- package/dist/bundle/chunks/{chunk-ENMIHC6G.js → chunk-GVKYQN5J.js} +1 -1
- package/dist/bundle/chunks/{chunk-QNXJ5FEA.js → chunk-ICQYTW7W.js} +1 -1
- package/dist/bundle/chunks/{chunk-4X2R47I5.js → chunk-JA6EY7US.js} +1 -1
- package/dist/bundle/chunks/{chunk-XJWBSZIU.js → chunk-MHY57JTL.js} +1 -1
- package/dist/bundle/chunks/{chunk-XZZSXYTK.js → chunk-N3A4JVFJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-HZYCWAEC.js → chunk-N3FZSEG7.js} +1 -1
- package/dist/bundle/chunks/{chunk-MP3NNO6W.js → chunk-Q6JV5CBB.js} +1 -1
- package/dist/bundle/chunks/{chunk-2TLWENMK.js → chunk-QE275OWT.js} +1 -1
- package/dist/bundle/chunks/{chunk-GP3D65AC.js → chunk-QPZVR6ZN.js} +1 -1
- package/dist/bundle/chunks/{chunk-CA7HMEGG.js → chunk-SI5VPVOA.js} +1 -1
- package/dist/bundle/chunks/{chunk-LDCENVG4.js → chunk-TVJ6JVK4.js} +1 -1
- package/dist/bundle/chunks/{chunk-UGU4ZDZA.js → chunk-UL6YJ7FT.js} +1 -1
- package/dist/bundle/chunks/{chunk-CYCUGNN7.js → chunk-USNDURQI.js} +1 -1
- package/dist/bundle/chunks/{chunk-VPJHPG6G.js → chunk-UXHSH7BM.js} +1 -1
- package/dist/bundle/chunks/{chunk-6D2ZCRTO.js → chunk-V2SOLEQN.js} +1 -1
- package/dist/bundle/chunks/{chunk-QXYDKHGI.js → chunk-WXPNKIIH.js} +1 -1
- package/dist/bundle/chunks/{chunk-XW6UBSKO.js → chunk-X3TZEFQG.js} +1 -1
- package/dist/bundle/chunks/{chunk-73DVPW3C.js → chunk-XMMV24SP.js} +1 -1
- package/dist/bundle/chunks/{chunk-FFNWVPYL.js → chunk-XPDOK3XY.js} +1 -1
- package/dist/bundle/chunks/{chunk-MMSRUX6V.js → chunk-XV2V56NQ.js} +1 -1
- package/dist/bundle/chunks/{chunk-XOBSBDA5.js → chunk-YDR2IWKO.js} +1 -1
- package/dist/bundle/chunks/{chunk-KESUKNUF.js → chunk-YJKHREBZ.js} +1 -1
- package/dist/bundle/chunks/chunk-ZBUZKIPX.js +6 -0
- package/dist/bundle/chunks/{expr-VKQHAJNO.js → expr-UMT2OHZ7.js} +1 -1
- package/dist/bundle/chunks/{file-WGI2QYXG.js → file-VEGKTTSF.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-6LWPOTGE.js → flag-coverage-I6UJUKQ4.js} +1 -1
- package/dist/bundle/chunks/{grep-SAEHL7UZ.js → grep-5UPEO42U.js} +1 -1
- package/dist/bundle/chunks/{gzip-2SHFSHNB.js → gzip-ZINVK3M6.js} +1 -1
- package/dist/bundle/chunks/{head-RMKV5HCV.js → head-CFENJILH.js} +1 -1
- package/dist/bundle/chunks/{html-to-markdown-GEKF6U7Z.js → html-to-markdown-GGVR4YGL.js} +1 -1
- package/dist/bundle/chunks/{jq-MW2VEOCW.js → jq-X2P7Q64K.js} +1 -1
- package/dist/bundle/chunks/{js-exec-J4DLDAWY.js → js-exec-XKF2B7C3.js} +1 -1
- package/dist/bundle/chunks/js-exec-worker.js +60 -4
- package/dist/bundle/chunks/{od-26HTHXXM.js → od-BI6XJPXY.js} +1 -1
- package/dist/bundle/chunks/{paste-WIDT5N6N.js → paste-LLZ3ZQR2.js} +1 -1
- package/dist/bundle/chunks/{python3-4Q7M5CDT.js → python3-F5S5TYGS.js} +1 -1
- package/dist/bundle/chunks/{rg-IA4UE2UF.js → rg-UQE6KUBP.js} +1 -1
- package/dist/bundle/chunks/{sed-LSWWSQ6J.js → sed-JW2JDLSI.js} +1 -1
- package/dist/bundle/chunks/{sleep-YMKR4HFQ.js → sleep-PPRBTSVR.js} +1 -1
- package/dist/bundle/chunks/{split-EATPU6Q7.js → split-2SD6EP72.js} +1 -1
- package/dist/bundle/chunks/{sqlite3-XXXHFJGP.js → sqlite3-UVVRYDAL.js} +1 -1
- package/dist/bundle/chunks/sqlite3-worker.js +60 -4
- package/dist/bundle/chunks/{stat-AKB6X3TV.js → stat-6KILP5AL.js} +1 -1
- package/dist/bundle/chunks/{tail-OEM7DTYC.js → tail-BDNMS4FR.js} +1 -1
- package/dist/bundle/chunks/{tar-26DH77YN.js → tar-6365WH6H.js} +1 -1
- package/dist/bundle/chunks/{timeout-FOKHN3GQ.js → timeout-C6WDYPLV.js} +1 -1
- package/dist/bundle/chunks/{tr-VUNRKFC3.js → tr-3I4MDKIF.js} +1 -1
- package/dist/bundle/chunks/worker.js +60 -4
- package/dist/bundle/chunks/{xan-LUEGYXLV.js → xan-HUOXKUQA.js} +1 -1
- package/dist/bundle/chunks/{xan-view-MDMZTFFI.js → xan-view-RT2WKDOQ.js} +1 -1
- package/dist/bundle/chunks/{yq-B7E6UX7Y.js → yq-MI27NZ2U.js} +1 -1
- package/dist/bundle/index.cjs +874 -872
- package/dist/bundle/index.js +1 -1
- package/dist/commands/sqlite3/worker.js +60 -4
- package/package.json +1 -1
- package/dist/bin/chunks/chunk-SHAOH2UJ.js +0 -5
- package/dist/bin/shell/chunks/chunk-SHAOH2UJ.js +0 -5
- package/dist/bundle/chunks/chunk-RT7ROXPF.js +0 -4
package/dist/bundle/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a as Rt,b as Ot,c as it}from"./chunks/chunk-WNH3HOQA.js";import{a as Nr}from"./chunks/chunk-BRJERIF4.js";import{c as ei,e as ya}from"./chunks/chunk-KIGPB52X.js";import{a as $r,b as Cr,c as Yn,d as Jn}from"./chunks/chunk-QXYDKHGI.js";import{a as Vt}from"./chunks/chunk-J2OBOJ64.js";import{a as Js}from"./chunks/chunk-L2UW7DWF.js";import{a as Wt,b as Xe,c as nr}from"./chunks/chunk-DLL7UR66.js";import{a as tr,b as ma}from"./chunks/chunk-QKQP2SCP.js";import{a as ge}from"./chunks/chunk-KVG5FR5F.js";import{a as _t,b as Ce}from"./chunks/chunk-RT7ROXPF.js";import"./chunks/chunk-6D3WD6YU.js";import{c as Ft,d as Pn}from"./chunks/chunk-AH7VTVWU.js";import"./chunks/chunk-STHBFACM.js";import{a as W,b as Ct,c as z,d as xn,e as Bt,f as Nt,g as $n}from"./chunks/chunk-YUSFCOM7.js";import{a as kn,b as He,c as Qe,d as Te,e as We,f as Ve,g as G,h as ce,i as Ke,j as Lt,k as Rr,l as x,m as ze,n as Mt,o as Or,p as st}from"./chunks/chunk-EFORKKSH.js";import{a as B,b as er,c as cn,d as Vf,e as Tt,f as Xs,g as vn,h as zf,i as xt,j as Ys,k as Uf,l as jf}from"./chunks/chunk-GN6CQ3J4.js";import{a as wt}from"./chunks/chunk-FOCWZZDE.js";import{a as $t}from"./chunks/chunk-W5DWRFSU.js";import{a as Ks}from"./chunks/chunk-NCUTH6QL.js";var un=[{name:"echo",load:async()=>(await import("./chunks/echo-PLLZYM2L.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-XWS72C47.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-V42QCPHL.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-R5CQLZQM.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-WDDKK2P3.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-WZKAT6M5.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-W4DF6Z4T.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-JQ4GDKDD.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-FKTQRFYJ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-XSJA2FNL.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-VYDFOFNO.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-6FVWFWKL.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-76BPYV5F.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-IY6QKK2P.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-RMKV5HCV.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-OEM7DTYC.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-RUR7HE5O.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-AKB6X3TV.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-SAEHL7UZ.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-SAEHL7UZ.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-SAEHL7UZ.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-IA4UE2UF.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-LSWWSQ6J.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-IDCJYLV2.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-PV2NEQHF.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-OVOW532K.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-DTWKU2MC.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-RWPUW5FY.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-WIDT5N6N.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-VUNRKFC3.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-EPOS3MFH.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-RFXH2GNX.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-QJBPHRFJ.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-2BPPGGSM.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-YD5BWFH4.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-WTD7Q2EF.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-EATPU6Q7.js")).split},{name:"column",load:async()=>(await import("./chunks/column-LKMDIDCH.js")).column},{name:"join",load:async()=>(await import("./chunks/join-KQ4Z5OD4.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-OOWSWHRQ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-PM3TD7V4.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-SJZQ5W65.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-Z2ZMOOW2.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-7OOL2MH6.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-PR3M44X6.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-VUUMB47B.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-VUUMB47B.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-T5TO5GWK.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-T5TO5GWK.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-3N762S3K.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-L7TJHOJT.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-QUBPEGGU.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-QUBPEGGU.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-KPIUNI6K.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-HIEWVHJ2.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-HIEWVHJ2.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-MW2VEOCW.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-3XQZ3ADB.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-CSARC7WF.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-FN2DXAEE.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-YMKR4HFQ.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-FOKHN3GQ.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-NERE2JJ2.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-5R2GKXC6.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-VKQHAJNO.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-JEDX55KS.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BLPZJ6MP.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-VJZ4PHQ4.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-WGI2QYXG.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-GEKF6U7Z.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-QDDMBDU7.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-UWVKETYW.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-YXC4HBTR.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-CESD3CQR.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-KR6E7UIR.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-26HTHXXM.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-2SHFSHNB.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-2SHFSHNB.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-2SHFSHNB.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(un.push({name:"tar",load:async()=>(await import("./chunks/tar-26DH77YN.js")).tarCommand}),un.push({name:"yq",load:async()=>(await import("./chunks/yq-B7E6UX7Y.js")).yqCommand}),un.push({name:"xan",load:async()=>(await import("./chunks/xan-LUEGYXLV.js")).xanCommand}),un.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-XXXHFJGP.js")).sqlite3Command}));var Dr=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Dr.push({name:"python3",load:async()=>(await import("./chunks/python3-4Q7M5CDT.js")).python3Command}),Dr.push({name:"python",load:async()=>(await import("./chunks/python3-4Q7M5CDT.js")).pythonCommand}));var Ir=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ir.push({name:"js-exec",load:async()=>(await import("./chunks/js-exec-J4DLDAWY.js")).jsExecCommand}),Ir.push({name:"node",load:async()=>(await import("./chunks/js-exec-J4DLDAWY.js")).nodeStubCommand}));var wa=[{name:"curl",load:async()=>(await import("./chunks/curl-DEHFBW27.js")).curlCommand}],ga=new Map;function _r(e){return{name:e.name,async execute(t,n){let r=ga.get(e.name);if(r||(r=await Ce.runTrustedAsync(()=>e.load()),ga.set(e.name,r)),n.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:s}=await import("./chunks/flag-coverage-6LWPOTGE.js");s(n.coverage,e.name,t)}return r.execute(t,n)}}}function qf(){return un.map(e=>e.name)}function Gf(){return wa.map(e=>e.name)}function Ea(e){return(e?un.filter(n=>e.includes(n.name)):un).map(_r)}function ba(){return wa.map(_r)}function Zf(){return Dr.map(e=>e.name)}function Sa(){return Dr.map(_r)}function Hf(){return Ir.map(e=>e.name)}function Aa(){return Ir.map(_r)}var va=new WeakMap,ka=new WeakSet;function Tr(e){let t=va.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),va.set(e,t),ka.add(t)),t}function Pa(e){return ka.has(e)}var xa={maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},Qf={...xa,maxSourceBytes:8*1024*1024,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10*1024*1024,maxArrayElements:1e5,maxHeredocSize:10*1024*1024,maxBraceExpansionResults:1e4,maxOutputSize:10*1024*1024,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:64*1024*1024,maxInputBytes:32*1024*1024,maxFileSystemBytes:128*1024*1024,maxDatabaseBytes:64*1024*1024,maxDatabaseResultBytes:16*1024*1024,maxArchiveBytes:128*1024*1024,maxArchiveCompressedBytes:64*1024*1024,maxArchiveEntryBytes:64*1024*1024,maxArchiveEntries:1e5,maxWorkerMessageBytes:16*1024*1024,maxExecutionTimeMs:3e4};function Lr(e,t="normal"){if(t!=="normal"&&t!=="hardened")throw new RangeError('executionLimitProfile must be "normal" or "hardened"');let n=t==="hardened"?Qf:xa;if(!e)return{...n};let r={maxSourceBytes:e.maxSourceBytes??n.maxSourceBytes,maxExecDepth:e.maxExecDepth??n.maxExecDepth,maxCallDepth:e.maxCallDepth??n.maxCallDepth,maxCommandCount:e.maxCommandCount??n.maxCommandCount,maxLoopIterations:e.maxLoopIterations??n.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??n.maxAwkIterations,maxSedIterations:e.maxSedIterations??n.maxSedIterations,maxJqIterations:e.maxJqIterations??n.maxJqIterations,maxQueryTokens:e.maxQueryTokens??n.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??n.maxQueryDepth,maxQueryElements:e.maxQueryElements??n.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??n.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??n.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??n.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??n.maxCsvRows,maxCsvCells:e.maxCsvCells??n.maxCsvCells,maxWorkUnits:e.maxWorkUnits??n.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??n.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??n.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??n.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??n.maxLiveBytes,maxInputBytes:e.maxInputBytes??n.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??n.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??n.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??n.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??n.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??n.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??n.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??n.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??n.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??n.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??n.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??n.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??n.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??n.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??n.maxGlobOperations,maxStringLength:e.maxStringLength??n.maxStringLength,maxArrayElements:e.maxArrayElements??n.maxArrayElements,maxHeredocSize:e.maxHeredocSize??n.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??n.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??n.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??n.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??n.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??n.maxSourceDepth};for(let s of Object.keys(r)){let i=r[s];if(i!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(i)||i<0))throw new RangeError(`${s} must be a non-negative safe integer or positive Infinity`)}return r}function Kf(e){let{executionLimits:t,executionLimitProfile:n,fs:r,stdin:s=Xs,...i}=e;return{fs:r,fsIdentity:i.fsIdentity??Tr(r),cwd:"/",env:new Map,stdin:s,limits:Lr(t,n),...i}}function $a(e){return"load"in e&&typeof e.load=="function"}function Xf(e,t,n={}){return{name:e,trusted:n.trusted!==!1,execute:t}}function Ca(e){let t=null,n=null;return{name:e.name,trusted:e.trusted!==!1,async execute(r,s){if(!t){let o=n;o||(o=e.load().then(a=>(t=a,a)),n=o);try{t=await o}catch(a){throw n===o&&(n=null),a}}let i=t;if(!i)throw new Error(`Failed to load command: ${e.name}`);return i.execute(r,s)}}}var Na=Object.freeze(Object.create(null)),Mr=class{limits;signal;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(t,n=void 0){this.limits=t,this.signal=n}fail(t){throw this.poisoned??=t,this.poisoned}poisonAfterAbort(t){this.poisoned??=t}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw new Error("execution budget is already closed");this.throwIfAborted()}chargeCommand(){return this.consume("commands",1,"execution")}consumeWork(t=1,n="execution"){return this.consume("work",t,n)}consumeLimited(t,n,r,s=t){this.assertUsable();let i=this.countersByKind.get(t)??0;return(!Number.isSafeInteger(n)||n<0||!Number.isSafeInteger(r)||r<0||n>r-i)&&this.fail(new x(`${s}: ${t} work limit exceeded (${r})`,"iterations")),n>this.limits.maxWorkUnits-this.workUnits&&this.fail(new x(`${s}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,"iterations")),this.countersByKind.set(t,i+n),this.workUnits+=n,i+n}consumeInput(t,n="execution"){return this.assertUsable(),(!Number.isSafeInteger(t)||t<0||t>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new x(`${n}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,"string_length")),this.inputBytes+=t,this.inputBytes}consume(t,n=1,r=t){this.assertUsable();let s=this.countersByKind.get(t)??0,i=t==="commands"?this.commandCount:this.workUnits,o=t==="commands"?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(n)||n<0||n>o-i)&&this.fail(new x(t==="commands"?`too many commands executed (>${o}), increase executionLimits.maxCommandCount`:`${r}: ${t} work limit exceeded (${o})`,t==="commands"?"commands":"iterations"));let a=i+n;return t==="commands"?this.commandCount=a:this.workUnits=a,this.countersByKind.set(t,s+n),a}reserveBytes(t,n,r){this.assertUsable();let s=typeof t=="string"?t:"live",i=typeof t=="string"?n:t,o=typeof t=="string"?r??s:n??"execution";(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new x(`${o}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,"string_length")),this.liveBytes+=i,this.bytesByKind.set(s,(this.bytesByKind.get(s)??0)+i);let a=!1;return{release:()=>{if(a)return;a=!0,this.liveBytes-=i;let l=(this.bytesByKind.get(s)??i)-i;l<=0?this.bytesByKind.delete(s):this.bytesByKind.set(s,l)}}}appendOutput(t,n,r="execution",s=0,i="text"){this.assertUsable();let o=i==="bytes"?n.length:B(n);(!Number.isSafeInteger(s)||s<0||s>o)&&this.fail(new x(`${r}: invalid ${t} accounting`,"output_size"));let a=o-s;return a>this.limits.maxOutputSize-this.outputBytes&&this.fail(new x(`${r}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,"output_size")),this.outputBytes+=a,o}accountResult(t,n="execution",r=Number.POSITIVE_INFINITY){let s=t.internalOutputAccounting,i=Math.min(s?.stdout??0,r),o=Math.min(s?.stderr??0,Math.max(0,r-i)),a=this.appendOutput("stdout",t.stdout,n,i,t.stdoutKind==="bytes"||t.stdoutEncoding==="binary"?"bytes":"text"),l=this.appendOutput("stderr",t.stderr,n,o);return Object.isExtensible(t)?(t.internalOutputAccounting={stdout:a,stderr:l},t):a===0&&l===0?t:{...t,internalOutputAccounting:{stdout:a,stderr:l}}}relinquishOutput(t,n,r){this.assertUsable(),r!==Na&&this.fail(new x(`${n}: unauthorized output accounting release`,"output_size")),(!Number.isSafeInteger(t)||t<0||t>this.outputBytes)&&this.fail(new x(`${n}: invalid output accounting release`,"output_size")),this.outputBytes-=t}enterDepth(t,n=this.limits.maxCallDepth,r){this.assertUsable();let s=typeof n=="number"?n:this.limits.maxCallDepth,i=typeof n=="string"?n:r??t,o=this.depthByKind.get(t)??0;o>=s&&this.fail(new x(`${i}: maximum depth (${s}) exceeded`,"recursion")),this.depthByKind.set(t,o+1);let a=!1;return{release:()=>{if(a)return;a=!0;let l=(this.depthByKind.get(t)??1)-1;l<=0?this.depthByKind.delete(t):this.depthByKind.set(t,l)}}}throwIfAborted(t="execution"){this.signal?.aborted&&this.fail(new ze("",`bash: ${t} aborted
|
|
2
|
+
import{a as Rt,b as Ot,c as it}from"./chunks/chunk-WNH3HOQA.js";import{a as Nr}from"./chunks/chunk-BRJERIF4.js";import{c as ei,e as ya}from"./chunks/chunk-KIGPB52X.js";import{a as $r,b as Cr,c as Yn,d as Jn}from"./chunks/chunk-WXPNKIIH.js";import{a as Vt}from"./chunks/chunk-J2OBOJ64.js";import{a as Js}from"./chunks/chunk-L2UW7DWF.js";import{a as Wt,b as Xe,c as nr}from"./chunks/chunk-DLL7UR66.js";import{a as tr,b as ma}from"./chunks/chunk-BKUWXPEM.js";import{a as ge}from"./chunks/chunk-KVG5FR5F.js";import{a as _t,b as Ce}from"./chunks/chunk-ZBUZKIPX.js";import"./chunks/chunk-6D3WD6YU.js";import{c as Ft,d as Pn}from"./chunks/chunk-AH7VTVWU.js";import"./chunks/chunk-STHBFACM.js";import{a as W,b as Ct,c as z,d as xn,e as Bt,f as Nt,g as $n}from"./chunks/chunk-YUSFCOM7.js";import{a as kn,b as He,c as Qe,d as Te,e as We,f as Ve,g as G,h as ce,i as Ke,j as Lt,k as Rr,l as x,m as ze,n as Mt,o as Or,p as st}from"./chunks/chunk-EFORKKSH.js";import{a as B,b as er,c as cn,d as Vf,e as Tt,f as Xs,g as vn,h as zf,i as xt,j as Ys,k as Uf,l as jf}from"./chunks/chunk-GN6CQ3J4.js";import{a as wt}from"./chunks/chunk-FOCWZZDE.js";import{a as $t}from"./chunks/chunk-W5DWRFSU.js";import{a as Ks}from"./chunks/chunk-NCUTH6QL.js";var un=[{name:"echo",load:async()=>(await import("./chunks/echo-PLLZYM2L.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-33KGN4MZ.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-V42QCPHL.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-R5CQLZQM.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-WDDKK2P3.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-WZKAT6M5.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-W4DF6Z4T.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-JQ4GDKDD.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-FKTQRFYJ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-XSJA2FNL.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-VYDFOFNO.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-APOXUPXW.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-76BPYV5F.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-IY6QKK2P.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-CFENJILH.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-BDNMS4FR.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-RUR7HE5O.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-6KILP5AL.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-5UPEO42U.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-5UPEO42U.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-5UPEO42U.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-UQE6KUBP.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-JW2JDLSI.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-NPLZQ3K7.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-PV2NEQHF.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-OVOW532K.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-DTWKU2MC.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-RWPUW5FY.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-LLZ3ZQR2.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-3I4MDKIF.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-EPOS3MFH.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-RFXH2GNX.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-QJBPHRFJ.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-2BPPGGSM.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-YD5BWFH4.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-WTD7Q2EF.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-2SD6EP72.js")).split},{name:"column",load:async()=>(await import("./chunks/column-LKMDIDCH.js")).column},{name:"join",load:async()=>(await import("./chunks/join-KQ4Z5OD4.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-OOWSWHRQ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-PM3TD7V4.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-SJZQ5W65.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-Z2ZMOOW2.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-7OOL2MH6.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-PR3M44X6.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-VUUMB47B.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-VUUMB47B.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-T5TO5GWK.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-T5TO5GWK.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-3N762S3K.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-L7TJHOJT.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-QUBPEGGU.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-QUBPEGGU.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-KPIUNI6K.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-HIEWVHJ2.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-HIEWVHJ2.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-X2P7Q64K.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-2BAITDZF.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-CSARC7WF.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-FN2DXAEE.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-PPRBTSVR.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-C6WDYPLV.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-NERE2JJ2.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-5R2GKXC6.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-UMT2OHZ7.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-JEDX55KS.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BLPZJ6MP.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-VJZ4PHQ4.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-VEGKTTSF.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-GGVR4YGL.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-QDDMBDU7.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-UWVKETYW.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-YXC4HBTR.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-CESD3CQR.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-KR6E7UIR.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-BI6XJPXY.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-ZINVK3M6.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-ZINVK3M6.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-ZINVK3M6.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(un.push({name:"tar",load:async()=>(await import("./chunks/tar-6365WH6H.js")).tarCommand}),un.push({name:"yq",load:async()=>(await import("./chunks/yq-MI27NZ2U.js")).yqCommand}),un.push({name:"xan",load:async()=>(await import("./chunks/xan-HUOXKUQA.js")).xanCommand}),un.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-UVVRYDAL.js")).sqlite3Command}));var Dr=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Dr.push({name:"python3",load:async()=>(await import("./chunks/python3-F5S5TYGS.js")).python3Command}),Dr.push({name:"python",load:async()=>(await import("./chunks/python3-F5S5TYGS.js")).pythonCommand}));var Ir=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ir.push({name:"js-exec",load:async()=>(await import("./chunks/js-exec-XKF2B7C3.js")).jsExecCommand}),Ir.push({name:"node",load:async()=>(await import("./chunks/js-exec-XKF2B7C3.js")).nodeStubCommand}));var wa=[{name:"curl",load:async()=>(await import("./chunks/curl-DEHFBW27.js")).curlCommand}],ga=new Map;function _r(e){return{name:e.name,async execute(t,n){let r=ga.get(e.name);if(r||(r=await Ce.runTrustedAsync(()=>e.load()),ga.set(e.name,r)),n.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:s}=await import("./chunks/flag-coverage-I6UJUKQ4.js");s(n.coverage,e.name,t)}return r.execute(t,n)}}}function qf(){return un.map(e=>e.name)}function Gf(){return wa.map(e=>e.name)}function Ea(e){return(e?un.filter(n=>e.includes(n.name)):un).map(_r)}function ba(){return wa.map(_r)}function Zf(){return Dr.map(e=>e.name)}function Sa(){return Dr.map(_r)}function Hf(){return Ir.map(e=>e.name)}function Aa(){return Ir.map(_r)}var va=new WeakMap,ka=new WeakSet;function Tr(e){let t=va.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),va.set(e,t),ka.add(t)),t}function Pa(e){return ka.has(e)}var xa={maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},Qf={...xa,maxSourceBytes:8*1024*1024,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10*1024*1024,maxArrayElements:1e5,maxHeredocSize:10*1024*1024,maxBraceExpansionResults:1e4,maxOutputSize:10*1024*1024,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:64*1024*1024,maxInputBytes:32*1024*1024,maxFileSystemBytes:128*1024*1024,maxDatabaseBytes:64*1024*1024,maxDatabaseResultBytes:16*1024*1024,maxArchiveBytes:128*1024*1024,maxArchiveCompressedBytes:64*1024*1024,maxArchiveEntryBytes:64*1024*1024,maxArchiveEntries:1e5,maxWorkerMessageBytes:16*1024*1024,maxExecutionTimeMs:3e4};function Lr(e,t="normal"){if(t!=="normal"&&t!=="hardened")throw new RangeError('executionLimitProfile must be "normal" or "hardened"');let n=t==="hardened"?Qf:xa;if(!e)return{...n};let r={maxSourceBytes:e.maxSourceBytes??n.maxSourceBytes,maxExecDepth:e.maxExecDepth??n.maxExecDepth,maxCallDepth:e.maxCallDepth??n.maxCallDepth,maxCommandCount:e.maxCommandCount??n.maxCommandCount,maxLoopIterations:e.maxLoopIterations??n.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??n.maxAwkIterations,maxSedIterations:e.maxSedIterations??n.maxSedIterations,maxJqIterations:e.maxJqIterations??n.maxJqIterations,maxQueryTokens:e.maxQueryTokens??n.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??n.maxQueryDepth,maxQueryElements:e.maxQueryElements??n.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??n.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??n.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??n.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??n.maxCsvRows,maxCsvCells:e.maxCsvCells??n.maxCsvCells,maxWorkUnits:e.maxWorkUnits??n.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??n.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??n.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??n.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??n.maxLiveBytes,maxInputBytes:e.maxInputBytes??n.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??n.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??n.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??n.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??n.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??n.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??n.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??n.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??n.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??n.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??n.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??n.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??n.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??n.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??n.maxGlobOperations,maxStringLength:e.maxStringLength??n.maxStringLength,maxArrayElements:e.maxArrayElements??n.maxArrayElements,maxHeredocSize:e.maxHeredocSize??n.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??n.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??n.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??n.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??n.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??n.maxSourceDepth};for(let s of Object.keys(r)){let i=r[s];if(i!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(i)||i<0))throw new RangeError(`${s} must be a non-negative safe integer or positive Infinity`)}return r}function Kf(e){let{executionLimits:t,executionLimitProfile:n,fs:r,stdin:s=Xs,...i}=e;return{fs:r,fsIdentity:i.fsIdentity??Tr(r),cwd:"/",env:new Map,stdin:s,limits:Lr(t,n),...i}}function $a(e){return"load"in e&&typeof e.load=="function"}function Xf(e,t,n={}){return{name:e,trusted:n.trusted!==!1,execute:t}}function Ca(e){let t=null,n=null;return{name:e.name,trusted:e.trusted!==!1,async execute(r,s){if(!t){let o=n;o||(o=e.load().then(a=>(t=a,a)),n=o);try{t=await o}catch(a){throw n===o&&(n=null),a}}let i=t;if(!i)throw new Error(`Failed to load command: ${e.name}`);return i.execute(r,s)}}}var Na=Object.freeze(Object.create(null)),Mr=class{limits;signal;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(t,n=void 0){this.limits=t,this.signal=n}fail(t){throw this.poisoned??=t,this.poisoned}poisonAfterAbort(t){this.poisoned??=t}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw new Error("execution budget is already closed");this.throwIfAborted()}chargeCommand(){return this.consume("commands",1,"execution")}consumeWork(t=1,n="execution"){return this.consume("work",t,n)}consumeLimited(t,n,r,s=t){this.assertUsable();let i=this.countersByKind.get(t)??0;return(!Number.isSafeInteger(n)||n<0||!Number.isSafeInteger(r)||r<0||n>r-i)&&this.fail(new x(`${s}: ${t} work limit exceeded (${r})`,"iterations")),n>this.limits.maxWorkUnits-this.workUnits&&this.fail(new x(`${s}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,"iterations")),this.countersByKind.set(t,i+n),this.workUnits+=n,i+n}consumeInput(t,n="execution"){return this.assertUsable(),(!Number.isSafeInteger(t)||t<0||t>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new x(`${n}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,"string_length")),this.inputBytes+=t,this.inputBytes}consume(t,n=1,r=t){this.assertUsable();let s=this.countersByKind.get(t)??0,i=t==="commands"?this.commandCount:this.workUnits,o=t==="commands"?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(n)||n<0||n>o-i)&&this.fail(new x(t==="commands"?`too many commands executed (>${o}), increase executionLimits.maxCommandCount`:`${r}: ${t} work limit exceeded (${o})`,t==="commands"?"commands":"iterations"));let a=i+n;return t==="commands"?this.commandCount=a:this.workUnits=a,this.countersByKind.set(t,s+n),a}reserveBytes(t,n,r){this.assertUsable();let s=typeof t=="string"?t:"live",i=typeof t=="string"?n:t,o=typeof t=="string"?r??s:n??"execution";(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new x(`${o}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,"string_length")),this.liveBytes+=i,this.bytesByKind.set(s,(this.bytesByKind.get(s)??0)+i);let a=!1;return{release:()=>{if(a)return;a=!0,this.liveBytes-=i;let l=(this.bytesByKind.get(s)??i)-i;l<=0?this.bytesByKind.delete(s):this.bytesByKind.set(s,l)}}}appendOutput(t,n,r="execution",s=0,i="text"){this.assertUsable();let o=i==="bytes"?n.length:B(n);(!Number.isSafeInteger(s)||s<0||s>o)&&this.fail(new x(`${r}: invalid ${t} accounting`,"output_size"));let a=o-s;return a>this.limits.maxOutputSize-this.outputBytes&&this.fail(new x(`${r}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,"output_size")),this.outputBytes+=a,o}accountResult(t,n="execution",r=Number.POSITIVE_INFINITY){let s=t.internalOutputAccounting,i=Math.min(s?.stdout??0,r),o=Math.min(s?.stderr??0,Math.max(0,r-i)),a=this.appendOutput("stdout",t.stdout,n,i,t.stdoutKind==="bytes"||t.stdoutEncoding==="binary"?"bytes":"text"),l=this.appendOutput("stderr",t.stderr,n,o);return Object.isExtensible(t)?(t.internalOutputAccounting={stdout:a,stderr:l},t):a===0&&l===0?t:{...t,internalOutputAccounting:{stdout:a,stderr:l}}}relinquishOutput(t,n,r){this.assertUsable(),r!==Na&&this.fail(new x(`${n}: unauthorized output accounting release`,"output_size")),(!Number.isSafeInteger(t)||t<0||t>this.outputBytes)&&this.fail(new x(`${n}: invalid output accounting release`,"output_size")),this.outputBytes-=t}enterDepth(t,n=this.limits.maxCallDepth,r){this.assertUsable();let s=typeof n=="number"?n:this.limits.maxCallDepth,i=typeof n=="string"?n:r??t,o=this.depthByKind.get(t)??0;o>=s&&this.fail(new x(`${i}: maximum depth (${s}) exceeded`,"recursion")),this.depthByKind.set(t,o+1);let a=!1;return{release:()=>{if(a)return;a=!0;let l=(this.depthByKind.get(t)??1)-1;l<=0?this.depthByKind.delete(t):this.depthByKind.set(t,l)}}}throwIfAborted(t="execution"){this.signal?.aborted&&this.fail(new ze("",`bash: ${t} aborted
|
|
3
3
|
`)),Date.now()-this.startedAt>this.limits.maxExecutionTimeMs&&this.fail(new ze("",`bash: ${t} exceeded execution deadline (${this.limits.maxExecutionTimeMs}ms)
|
|
4
4
|
`))}remainingTimeMs(){return Math.max(0,this.limits.maxExecutionTimeMs-(Date.now()-this.startedAt))}registerCleanup(t){this.assertUsable(),this.cleanupCallbacks.push(t);let n=!0;return()=>{if(!n)return;n=!1;let r=this.cleanupCallbacks.indexOf(t);r>=0&&this.cleanupCallbacks.splice(r,1)}}async close(){if(this.closed)return;this.closed=!0;let t=[],n=Date.now()+this.limits.maxExtensionCleanupTimeMs;for(let r=this.cleanupCallbacks.length-1;r>=0;r--)try{let s=n-Date.now();if(s<=0){t.push(new Error("execution cleanup grace period exceeded"));break}let i,o=await Promise.race([Promise.resolve().then(this.cleanupCallbacks[r]).then(()=>({ok:!0}),a=>({ok:!1,error:a})),new Promise(a=>{i=Yn(()=>a({ok:!1,error:new Error("execution cleanup grace period exceeded")}),s)})]);if(Jn(i),!o.ok&&(t.push(o.error),Date.now()>=n))break}catch(s){t.push(s)}if(this.cleanupCallbacks.length=0,this.depthByKind.clear(),this.bytesByKind.clear(),this.liveBytes=0,t.length>0)throw new AggregateError(t,"execution cleanup failed")}assertExecDepth(t){this.assertUsable(),t>this.limits.maxExecDepth&&this.fail(new x(`maximum nested execution depth (${this.limits.maxExecDepth}) exceeded`,"recursion"))}};function Ra(e){let t=Object.create(null);return Object.defineProperties(t,{remainingLiveBytes:{enumerable:!0,get:()=>e.remainingLiveBytes},consumeWork:{enumerable:!0,value:e.consumeWork.bind(e)},consumeLimited:{enumerable:!0,value:e.consumeLimited.bind(e)},consumeInput:{enumerable:!0,value:e.consumeInput.bind(e)},reserveBytes:{enumerable:!0,value:e.reserveBytes.bind(e)},enterDepth:{enumerable:!0,value:e.enterDepth.bind(e)},throwIfAborted:{enumerable:!0,value:e.throwIfAborted.bind(e)},remainingTimeMs:{enumerable:!0,value:e.remainingTimeMs.bind(e)},registerCleanup:{enumerable:!0,value:e.registerCleanup.bind(e)}}),Object.freeze(t)}function Oa(e,t,n="pipeline"){e.relinquishOutput(t,n,Na)}var fn=new TextEncoder;function Yf(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}var ft=class{data=new Map;entryIdentities=new WeakMap;nextEntryIdentity=1;maxTotalBytes;retainedBytes=0;contentReferences=new WeakMap;materializedContent(t){return t?.type==="file"&&"content"in t?t.content:null}storedByteLength(t){return t===null?0:t instanceof Uint8Array?t.byteLength:B(t)}wouldReleaseBytes(t){let n=this.materializedContent(t);return n===null?0:n instanceof Uint8Array?this.contentReferences.get(n)===1?n.byteLength:0:this.storedByteLength(n)}assertCanAllocate(t,n){let r=this.wouldReleaseBytes(this.data.get(t));if(!Number.isSafeInteger(n)||n<0||n>this.maxTotalBytes-this.retainedBytes+r)throw new Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`)}setEntry(t,n){let r=this.data.get(t),s=this.materializedContent(r),i=this.materializedContent(n);if(s===i){this.data.set(t,n);return}let o=this.wouldReleaseBytes(r),a=i instanceof Uint8Array?this.contentReferences.has(i)?0:i.byteLength:this.storedByteLength(i);if(a>this.maxTotalBytes-this.retainedBytes+o)throw new Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`);if(s instanceof Uint8Array){let l=this.contentReferences.get(s)??0;l<=1?this.contentReferences.delete(s):this.contentReferences.set(s,l-1)}i instanceof Uint8Array&&this.contentReferences.set(i,(this.contentReferences.get(i)??0)+1),this.retainedBytes+=a-o,this.data.set(t,n)}deleteEntry(t){let n=this.data.get(t);if(!n)return!1;let r=this.materializedContent(n),s=this.wouldReleaseBytes(n);if(r instanceof Uint8Array){let i=this.contentReferences.get(r)??0;i<=1?this.contentReferences.delete(r):this.contentReferences.set(r,i-1)}return this.retainedBytes-=s,this.data.delete(t)}contentByteLength(t,n){if(t instanceof Uint8Array)return t.byteLength;if(n==="hex")return Math.floor(t.length/2);if(n==="base64"){let r=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.max(0,Math.floor(t.length*3/4)-r)}return n==="binary"||n==="latin1"?t.length:B(t)}identityFor(t){let n=this.entryIdentities.get(t);return n||(n=`memfs:${this.nextEntryIdentity++}`,this.entryIdentities.set(t,n)),n}constructor(t,n={}){if(this.maxTotalBytes=n.maxTotalBytes??1024*1024*1024,!Number.isSafeInteger(this.maxTotalBytes)||this.maxTotalBytes<0)throw new Error("InMemoryFs: invalid maxTotalBytes");if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[r,s]of Object.entries(t))typeof s=="function"?this.writeFileLazy(r,s):Yf(s)?this.writeFileSync(r,s.content,void 0,{mode:s.mode,mtime:s.mtime}):this.writeFileSync(r,s)}ensureParentDirs(t){let n=xn(t);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,n,r,s){z(t,"write");let i=W(t);this.ensureParentDirs(i);let o=it(r);this.assertCanAllocate(i,this.contentByteLength(n,o));let a=Rt(n,o);this.setEntry(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}writeFileLazy(t,n,r){z(t,"write");let s=W(t);this.ensureParentDirs(s),this.setEntry(s,{type:"file",lazy:n,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,n){let r=await n.lazy(),s=typeof r=="string"?fn.encode(r):r,i={type:"file",content:s,mode:n.mode,mtime:n.mtime};return this.assertCanAllocate(t,s.byteLength),this.setEntry(t,i),i}async readFile(t,n){let r=await this.readFileBuffer(t),s=it(n);return Ot(r,s)}async readFileBytes(t){let n=await this.readFileBuffer(t);return Ot(n,"binary")}async readFileBuffer(t){z(t,"open");let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if("lazy"in r){let s=await this.materializeLazy(n,r);return s.content instanceof Uint8Array?s.content:fn.encode(s.content)}return r.content instanceof Uint8Array?r.content:fn.encode(r.content)}async writeFile(t,n,r){this.writeFileSync(t,n,r)}async appendFile(t,n,r){z(t,"append");let s=W(t),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=it(r),a=this.contentByteLength(n,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(s,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:fn.encode("content"in l?l.content:"");this.assertCanAllocate(s,c.byteLength+a);let u=Rt(n,o),f=new Uint8Array(c.length+u.length);f.set(c),f.set(u,c.length),this.setEntry(s,{type:"file",content:f,mode:l.mode,mtime:new Date})}else this.writeFileSync(t,n,r)}async exists(t){if(t.includes("\0"))return!1;try{let n=this.resolvePathWithSymlinks(t);return this.data.has(n)}catch{return!1}}async stat(t){z(t,"stat");let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=fn.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date,identity:this.identityFor(r)}}async lstat(t){z(t,"lstat");let n=this.resolveIntermediateSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=fn.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date,identity:this.identityFor(r)}}resolveIntermediateSymlinks(t){let n=W(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(s),s=$n(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let n=W(t);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(s),s=$n(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return s}async mkdir(t,n){this.mkdirSync(t,n)}mkdirSync(t,n){z(t,"mkdir");let r=W(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let s=xn(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){z(t,"scandir");let n=W(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);s.add(n),n=$n(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,n){z(t,"rm");let r=W(t),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=Nt(r,o);await this.rm(a,n)}}}this.deleteEntry(r)}async cp(t,n,r){z(t,"cp"),z(n,"cp");let s=W(t),i=W(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")if(this.ensureParentDirs(i),"content"in o){let a=o.content instanceof Uint8Array?o.content.byteLength:fn.encode(o.content).byteLength;this.assertCanAllocate(i,a);let l=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.setEntry(i,{...o,content:l})}else this.setEntry(i,{...o});else if(o.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);if(Ct(s,i))throw new Error(`EINVAL: cannot copy '${t}' into itself, '${n}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=Nt(s,l),u=Nt(i,l);await this.cp(c,u,r)}}}async mv(t,n){z(t,"mv"),z(n,"mv");let r=W(t),s=W(n);if(r===s)return;let i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, mv '${t}'`);if(i.type==="directory"&&Ct(r,s))throw new Error(`EINVAL: cannot move '${t}' into itself, '${n}'`);if(i.type==="directory"){await this.mkdir(s,{recursive:!0});let o=await this.readdir(r);for(let a of o)await this.mv(Nt(r,a),Nt(s,a));this.deleteEntry(r);return}this.ensureParentDirs(s),this.setEntry(s,i),this.deleteEntry(r)}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,n){return Bt(t,n)}async chmod(t,n){z(t,"chmod");let r=W(t),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);s.mode=n}async symlink(t,n){z(n,"symlink");let r=W(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,n){z(t,"link"),z(n,"link");let r=W(t),s=W(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(s);let a={type:"file",content:o.content,mode:o.mode,mtime:o.mtime};this.entryIdentities.set(a,this.identityFor(o)),this.setEntry(s,a)}async readlink(t){z(t,"readlink");let n=W(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){z(t,"realpath");let n=this.resolvePathWithSymlinks(t);if(!this.data.has(n))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return n}async utimes(t,n,r){z(t,"utimes");let s=W(t),i=this.resolvePathWithSymlinks(s),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};var Da="5.1.0(1)-release",Ia="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function ni(e){let{pid:t,ppid:n,uid:r,gid:s}=e;return`Name: bash
|
|
5
5
|
State: R (running)
|
|
@@ -39,6 +39,11 @@ import * as nodeAsyncHooks from "node:async_hooks";
|
|
|
39
39
|
import * as nodeModule from "node:module";
|
|
40
40
|
|
|
41
41
|
// src/security/blocked-globals.ts
|
|
42
|
+
var blockedGlobalViolationTypes;
|
|
43
|
+
function getBlockedGlobalViolationTypes() {
|
|
44
|
+
if (!blockedGlobalViolationTypes) getBlockedGlobals();
|
|
45
|
+
return blockedGlobalViolationTypes;
|
|
46
|
+
}
|
|
42
47
|
function getBlockedGlobals() {
|
|
43
48
|
const globals = [
|
|
44
49
|
// Direct code execution vectors
|
|
@@ -98,6 +103,7 @@ function getBlockedGlobals() {
|
|
|
98
103
|
"NODE_DEBUG",
|
|
99
104
|
"NODE_DEBUG_NATIVE",
|
|
100
105
|
"NODE_COMPILE_CACHE",
|
|
106
|
+
"NODE_ENV",
|
|
101
107
|
"WATCH_REPORT_DEPENDENCIES",
|
|
102
108
|
// Dependencies
|
|
103
109
|
"FORCE_COLOR",
|
|
@@ -511,13 +517,49 @@ function getBlockedGlobals() {
|
|
|
511
517
|
}
|
|
512
518
|
} catch {
|
|
513
519
|
}
|
|
514
|
-
|
|
520
|
+
const availableGlobals = globals.filter((g) => {
|
|
515
521
|
try {
|
|
516
522
|
return g.target[g.prop] !== void 0;
|
|
517
523
|
} catch {
|
|
518
524
|
return false;
|
|
519
525
|
}
|
|
520
526
|
});
|
|
527
|
+
blockedGlobalViolationTypes ??= new Set(
|
|
528
|
+
availableGlobals.map(({ violationType }) => violationType)
|
|
529
|
+
);
|
|
530
|
+
return availableGlobals;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// src/security/safe-timestamp.ts
|
|
534
|
+
var performanceTimeOrigin = performance.timeOrigin;
|
|
535
|
+
var performanceNow = performance.now.bind(performance);
|
|
536
|
+
function getSafeTimestamp() {
|
|
537
|
+
return Math.floor(performanceTimeOrigin + performanceNow());
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// src/security/violation-error-message.ts
|
|
541
|
+
var NON_EXCLUDABLE_VIOLATION_TYPES = /* @__PURE__ */ new Set([
|
|
542
|
+
"function_constructor",
|
|
543
|
+
"async_function_constructor",
|
|
544
|
+
"generator_function_constructor",
|
|
545
|
+
"async_generator_function_constructor"
|
|
546
|
+
]);
|
|
547
|
+
function assertExcludableViolationTypes(violationTypes) {
|
|
548
|
+
const nonExcludable = violationTypes?.find(
|
|
549
|
+
(type) => NON_EXCLUDABLE_VIOLATION_TYPES.has(type)
|
|
550
|
+
);
|
|
551
|
+
if (nonExcludable) {
|
|
552
|
+
throw new RangeError(
|
|
553
|
+
`defenseInDepth.excludeViolationTypes cannot disable the non-excludable "${nonExcludable}" protection`
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
var DEFENSE_IN_DEPTH_NOTICE = "\n\nThis is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com";
|
|
558
|
+
function formatViolationErrorMessage(message, violationType, canExclude) {
|
|
559
|
+
const exclusionHint = canExclude && !NON_EXCLUDABLE_VIOLATION_TYPES.has(violationType) ? `
|
|
560
|
+
|
|
561
|
+
If this access is required by trusted host-runtime code, add "${violationType}" to defenseInDepth.excludeViolationTypes.` : "";
|
|
562
|
+
return message + DEFENSE_IN_DEPTH_NOTICE + exclusionHint;
|
|
521
563
|
}
|
|
522
564
|
|
|
523
565
|
// src/security/defense-in-depth-box.ts
|
|
@@ -536,10 +578,23 @@ if (!IS_BROWSER) {
|
|
|
536
578
|
var executionContext = !IS_BROWSER && AsyncLocalStorageClass ? new AsyncLocalStorageClass() : null;
|
|
537
579
|
|
|
538
580
|
// src/security/worker-defense-in-depth.ts
|
|
539
|
-
var
|
|
581
|
+
var WORKER_SPECIAL_EXCLUDABLE_VIOLATION_TYPES = /* @__PURE__ */ new Set([
|
|
582
|
+
"error_prepare_stack_trace",
|
|
583
|
+
"module_load",
|
|
584
|
+
"module_resolve_filename",
|
|
585
|
+
"process_main_module",
|
|
586
|
+
"process_exec_path",
|
|
587
|
+
"process_connected"
|
|
588
|
+
]);
|
|
540
589
|
var WorkerSecurityViolationError = class extends Error {
|
|
541
590
|
constructor(message, violation) {
|
|
542
|
-
super(
|
|
591
|
+
super(
|
|
592
|
+
formatViolationErrorMessage(
|
|
593
|
+
message,
|
|
594
|
+
violation.type,
|
|
595
|
+
WORKER_SPECIAL_EXCLUDABLE_VIOLATION_TYPES.has(violation.type) || getBlockedGlobalViolationTypes().has(violation.type)
|
|
596
|
+
)
|
|
597
|
+
);
|
|
543
598
|
this.violation = violation;
|
|
544
599
|
this.name = "WorkerSecurityViolationError";
|
|
545
600
|
}
|
|
@@ -598,6 +653,7 @@ var WorkerDefenseInDepth = class {
|
|
|
598
653
|
* @param config - Configuration for the defense layer
|
|
599
654
|
*/
|
|
600
655
|
constructor(config) {
|
|
656
|
+
assertExcludableViolationTypes(config.excludeViolationTypes);
|
|
601
657
|
this.originalProxy = Proxy;
|
|
602
658
|
this.config = config;
|
|
603
659
|
this.executionId = generateExecutionId();
|
|
@@ -681,7 +737,7 @@ var WorkerDefenseInDepth = class {
|
|
|
681
737
|
*/
|
|
682
738
|
recordViolation(type, path, message) {
|
|
683
739
|
const violation = {
|
|
684
|
-
timestamp:
|
|
740
|
+
timestamp: getSafeTimestamp(),
|
|
685
741
|
type,
|
|
686
742
|
message,
|
|
687
743
|
path,
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import*as E from"node:async_hooks";import*as I from"node:module";function P(){let l=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables",allowedKeys:new Set(["NODE_V8_COVERAGE","NODE_DEBUG","NODE_DEBUG_NATIVE","NODE_COMPILE_CACHE","WATCH_REPORT_DEPENDENCIES","FORCE_COLOR","DEBUG","UNDICI_NO_FG","JEST_WORKER_ID","__MINIMATCH_TESTING_PLATFORM__","LOG_TOKENS","LOG_STREAM"])},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"getBuiltinModule",target:process,violationType:"process_get_builtin_module",strategy:"throw",reason:"process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"},{prop:"exit",target:process,violationType:"process_exit",strategy:"throw",reason:"process.exit could terminate the interpreter"},{prop:"abort",target:process,violationType:"process_exit",strategy:"throw",reason:"process.abort could crash the interpreter"},{prop:"kill",target:process,violationType:"process_kill",strategy:"throw",reason:"process.kill could signal other processes"},{prop:"setuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setuid could escalate privileges"},{prop:"setgid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgid could escalate privileges"},{prop:"seteuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.seteuid could escalate effective user privileges"},{prop:"setegid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setegid could escalate effective group privileges"},{prop:"initgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.initgroups could modify supplementary group IDs"},{prop:"setgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgroups could modify supplementary group IDs"},{prop:"umask",target:process,violationType:"process_umask",strategy:"throw",reason:"process.umask could modify file creation permissions"},{prop:"argv",target:process,violationType:"process_argv",strategy:"throw",reason:"process.argv may contain secrets in CLI arguments"},{prop:"cwd",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.cwd could disclose real host working directory path"},{prop:"chdir",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.chdir could confuse the interpreter's CWD tracking"},{prop:"report",target:process,violationType:"process_report",strategy:"throw",reason:"process.report could disclose full environment, host paths, and system info"},{prop:"loadEnvFile",target:process,violationType:"process_env",strategy:"throw",reason:"process.loadEnvFile could load env files bypassing env proxy"},{prop:"setUncaughtExceptionCaptureCallback",target:process,violationType:"process_exception_handler",strategy:"throw",reason:"setUncaughtExceptionCaptureCallback could intercept security errors"},...["on","once","addListener","prependListener","prependOnceListener"].map(e=>({prop:e,target:process,violationType:"process_exception_handler",strategy:"throw",reason:"process-global listeners can outlive the sandbox and lose its security context"})),{prop:"send",target:process,violationType:"process_send",strategy:"throw",reason:"process.send could communicate with parent process in IPC contexts"},{prop:"channel",target:process,violationType:"process_channel",strategy:"throw",reason:"process.channel could access IPC channel to parent process"},{prop:"cpuUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.cpuUsage could enable timing side-channel attacks"},{prop:"memoryUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.memoryUsage could enable timing side-channel attacks"},{prop:"hrtime",target:process,violationType:"process_timing",strategy:"throw",reason:"process.hrtime could enable timing side-channel attacks"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"},{prop:"performance",target:globalThis,violationType:"performance_timing",strategy:"throw",reason:"performance.now() provides sub-millisecond timing for side-channel attacks"},{prop:"stdout",target:process,violationType:"process_stdout",strategy:"throw",reason:"process.stdout could bypass interpreter output to write to host stdout"},{prop:"stderr",target:process,violationType:"process_stderr",strategy:"throw",reason:"process.stderr could bypass interpreter output to write to host stderr"},{prop:"__defineGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineGetter__ allows prototype pollution via getter injection"},{prop:"__defineSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineSetter__ allows prototype pollution via setter injection"},{prop:"__lookupGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupGetter__ enables introspection for prototype pollution attacks"},{prop:"__lookupSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupSetter__ enables introspection for prototype pollution attacks"},{prop:"JSON",target:globalThis,violationType:"json_mutation",strategy:"freeze",reason:"Freeze JSON to prevent mutation of parsing/serialization"},{prop:"Math",target:globalThis,violationType:"math_mutation",strategy:"freeze",reason:"Freeze Math to prevent mutation of math utilities"}];try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&l.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&l.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let e=Object.getPrototypeOf(async function*(){}).constructor;e&&e!==Function&&e!==Object.getPrototypeOf(async()=>{}).constructor&&l.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return l.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}})}var f=typeof __BROWSER__<"u"&&__BROWSER__;function _(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,l=>{let e=Math.random()*16|0;return(l==="x"?e:e&3|8).toString(16)})}var v=null,m=null,O=null;if(!f)try{v=E.AsyncLocalStorage,m=I,O=m.Module??m.default??null}catch{}var C=`
|
|
4
|
-
|
|
5
|
-
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,d=class extends Error{violation;constructor(e,t){super(e+C),this.violation=t,this.name="SecurityViolationError"}},p=!f&&v?new v:null,B=1e3;function M(l,e,...t){return p.run(l,()=>e(...t))}var A={enabled:!0,auditMode:!1,processLifetimeIntrinsicHardening:!1};function k(){return!f&&typeof m?.registerHooks=="function"}function T(l){let e=typeof l=="boolean"?{enabled:l}:l??{};if(e.enabled!==void 0&&e.enabled!==!0&&e.enabled!==!1&&e.enabled!=="auto")throw new RangeError('defenseInDepth.enabled must be true, false, or "auto"');let t={...A,...e},n=t.enabled==="auto"?"auto":t.enabled?"enabled":"disabled",s={...t,enabled:n!=="disabled",requested:n};return s.excludeViolationTypes&&(s.excludeViolationTypes=[...new Set(s.excludeViolationTypes)].sort()),s}function F(l,e){if(l.enabled!==e.enabled||l.auditMode!==e.auditMode||l.processLifetimeIntrinsicHardening!==e.processLifetimeIntrinsicHardening||l.onViolation!==e.onViolation)return!1;let t=l.excludeViolationTypes??[],n=e.excludeViolationTypes??[];return t.length===n.length&&t.every((s,o)=>s===n[o])}var D=class l{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];temporaryIntrinsicDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(e){let t=T(e);if(!l.instance)l.instance=new l(t);else{let n=l.instance.config;if(!F(t,n))throw new Error("DefenseInDepthBox config conflict: all resolved defense options, including exclusions and the violation callback, must match across Bash instances. Call DefenseInDepthBox.resetInstance() between incompatible configurations.")}return l.instance}static resetInstance(){l.instance&&(l.instance.forceDeactivate(),l.instance=null),l.trustedExecutionDepth.clear()}static isInSandboxedContext(){return p?p?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(p)return p?.getStore()?.executionId}static enterTrustedScope(e){let t=l.trustedExecutionDepth.get(e)??0;l.trustedExecutionDepth.set(e,t+1)}static leaveTrustedScope(e){let t=l.trustedExecutionDepth.get(e);if(t){if(t===1){l.trustedExecutionDepth.delete(e);return}l.trustedExecutionDepth.set(e,t-1)}}static isTrustedScopeActive(e){return e?(l.trustedExecutionDepth.get(e)??0)>0:!1}static isTrustedContext(e){return!e||e.forceUntrusted?!1:e.trusted===!0||l.isTrustedScopeActive(e.executionId)}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}static bindCurrentContext(e){if(!p)return e;let t=p.getStore(),n=t?.sandboxActive===!0?t.executionId:void 0;if(!n)return e;let o=l.instance?.getCachedContext(n)??{sandboxActive:!0,executionId:n},r=t?.forceUntrusted?{...o,forceUntrusted:!0}:o;return((...i)=>{let c=l.instance;if(!(c&&!c.isExecutionIdActive(n)&&(c.recordViolation("bound_callback_after_deactivate","bound callback","Bound callback blocked after originating execution was deactivated"),!c.config.auditMode)))return M(r,e,...i)})}isEnabled(){return this.getStatus().state==="enabled"}getStatus(){let e=k();return this.config.requested==="disabled"?{requested:"disabled",state:"disabled",level:"none",contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort"}:!p||f?{requested:this.config.requested,state:"unsupported",level:"none",contextualDynamicImportProtection:!1,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort",reason:"context-aware ESM loader hooks (node:module.registerHooks) are unavailable"}:{requested:this.config.requested,state:"enabled",level:this.config.auditMode?"none":e?"full":"best-effort",contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort",reason:this.config.auditMode?"audit mode records violations but does not block them":e?void 0:"best-effort protection; context-aware ESM loader hooks are unavailable"}}updateConfig(e){if(this.refCount>0)throw new Error("DefenseInDepthBox configuration cannot change while protection is active");this.config=T({...this.config,...e})}activate(){if(!f&&this.config.enabled&&!p)throw new Error("DefenseInDepthBox: enabled protection requires node:async_hooks and node:module");if(f||!this.config.enabled){let n=_(),s=!1;return{run:o=>s?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):o(),deactivate:()=>{s=!0},executionId:n}}if(this.refCount++,this.refCount===1){try{this.applyPatches()}catch(n){throw this.restorePatches(),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0,n}this.activationTime=Date.now()}let e=_(),t=!1;return{run:n=>t?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):(this.activeExecutionIds.add(e),p.run({sandboxActive:!0,executionId:e},n)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(e){if(!p)return e();let t=p.getStore();if(!t)return e();let{executionId:n}=t;return p.run({...t,trusted:!0,forceUntrusted:!1},()=>{l.enterTrustedScope(n);try{let s=e();return typeof s=="object"&&s!==null&&"finally"in s&&typeof s.finally=="function"?s.finally(()=>{l.leaveTrustedScope(n)}):(l.leaveTrustedScope(n),s)}catch(s){throw l.leaveTrustedScope(n),s}})}static async runTrustedAsync(e){if(!p)return e();let t=p.getStore();if(!t)return e();let{executionId:n}=t;return p.run({...t,trusted:!0,forceUntrusted:!1},async()=>{l.enterTrustedScope(n);try{return await e()}finally{l.leaveTrustedScope(n)}})}static async runUntrustedAsync(e){if(!p)return e();let t=p.getStore();return t?p.run({...t,trusted:!1,forceUntrusted:!0},e):e()}shouldBlock(){if(f||this.config.auditMode||!p)return!1;let e=p?.getStore();return!(e?.sandboxActive!==!0||l.isTrustedContext(e))}shouldAudit(){if(!this.config.auditMode||!p)return!1;let e=p.getStore();return e?.sandboxActive===!0&&!l.isTrustedContext(e)}recordViolation(e,t,n){let s={timestamp:Date.now(),type:e,message:n,path:t,stack:new Error().stack,executionId:p?.getStore()?.executionId};if(this.violations.length<B&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(o){console.debug("[DefenseInDepthBox] onViolation callback threw:",o instanceof Error?o.message:o)}return s}createBlockingProxy(e,t,n){let s=this;return new Proxy(e,{apply(o,r,i){if(s.shouldBlock()){let c=`${t} is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} called (audit mode)`),Reflect.apply(o,r,i)},construct(o,r,i){if(s.shouldBlock()){let c=`${t} constructor is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} constructor called (audit mode)`),Reflect.construct(o,r,i)}})}createBlockingObjectProxy(e,t,n,s){let o=this;return new Proxy(e,{get(r,i,c){if(o.shouldBlock()){if(s&&typeof i=="string"&&s.has(i))return Reflect.get(r,i,c);let a=`${t}.${String(i)}`,u=`${a} is blocked during script execution`,h=o.recordViolation(n,a,u);throw new d(u,h)}if(o.shouldAudit()){let a=`${t}.${String(i)}`;o.recordViolation(n,a,`${a} accessed (audit mode)`)}return Reflect.get(r,i,c)},set(r,i,c,a){if(o.shouldBlock()){let u=`${t}.${String(i)}`,h=`${u} modification is blocked during script execution`,y=o.recordViolation(n,u,h);throw new d(h,y)}return t==="process.env"&&i==="DEBUG"?Reflect.set(r,i,c):Reflect.set(r,i,c,a)},ownKeys(r){if(o.shouldBlock()){let i=`${t} enumeration is blocked during script execution`,c=o.recordViolation(n,t,i);throw new d(i,c)}return Reflect.ownKeys(r)},getOwnPropertyDescriptor(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} descriptor access is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.getOwnPropertyDescriptor(r,i)},has(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} existence check is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.has(r,i)},deleteProperty(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} deletion is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.deleteProperty(r,i)},setPrototypeOf(r,i){if(o.shouldBlock()){let c=`${t} setPrototypeOf is blocked during script execution`,a=o.recordViolation(n,t,c);throw new d(c,a)}return Reflect.setPrototypeOf(r,i)},defineProperty(r,i,c){if(o.shouldBlock()){let a=`${t}.${String(i)}`,u=`${a} defineProperty is blocked during script execution`,h=o.recordViolation(n,a,u);throw new d(u,h)}return Reflect.defineProperty(r,i,c)}})}createReadonlyObjectProxy(e,t,n){let s=this,o=r=>{let i=`${t} ${r} is blocked during script execution`,c=s.recordViolation(n,t,i);throw new d(i,c)};return new Proxy(e,{set(r,i,c,a){return s.shouldBlock()&&o("modification"),Reflect.set(r,i,c,a)},defineProperty(r,i,c){return s.shouldBlock()&&o("defineProperty"),Reflect.defineProperty(r,i,c)},deleteProperty(r,i){return s.shouldBlock()&&o("deletion"),Reflect.deleteProperty(r,i)},setPrototypeOf(r,i){return s.shouldBlock()&&o("setPrototypeOf"),Reflect.setPrototypeOf(r,i)},preventExtensions(r){return s.shouldBlock()&&o("preventExtensions"),Reflect.preventExtensions(r)}})}applyPatches(){this.patchFailures=[];let e=P(),t=new Set(["process_send","process_channel","process_stdout","process_stderr"]),n=[];for(let r of e)if(!t.has(r.violationType)){if(r.strategy==="freeze"){n.push(r);continue}this.applyPatch(r)}this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),k()&&this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.protectProxyRevocable();let s=["Function.prototype.constructor","Module._load","Module._resolveFilename"],o=this.patchFailures.filter(r=>s.includes(r));if(o.length>0)throw this.restorePatches(),new Error(`DefenseInDepthBox: critical patches failed: ${o.join(", ")}`);this.config.processLifetimeIntrinsicHardening||this.protectReversibleIntrinsics(n);for(let r of n)this.applyPatch(r,this.config.processLifetimeIntrinsicHardening===!0);this.config.processLifetimeIntrinsicHardening&&this.lockWellKnownSymbols()}protectReversibleIntrinsics(e){let t=new Set,n=(r,i)=>{let c=Object.getOwnPropertyDescriptor(r,i);!c||!("value"in c)||c.writable!==!0||c.configurable!==!0||(this.temporaryIntrinsicDescriptors.push({target:r,prop:i,descriptor:c}),Object.defineProperty(r,i,{...c,writable:!1}))};for(let{target:r,prop:i}of e){let c=r[i];if(!(typeof c!="object"||c===null)){t.add(c);for(let a of Reflect.ownKeys(c))n(c,a)}}let s=[];for(let r of[Array,Map,Set,RegExp,Promise])s.push([r,Symbol.species]);for(let r of[Array.prototype,String.prototype,Map.prototype,Set.prototype])s.push([r,Symbol.iterator]);s.push([Symbol.prototype,Symbol.toPrimitive],[Date.prototype,Symbol.toPrimitive],[Function.prototype,Symbol.hasInstance],[Array.prototype,Symbol.unscopables]);for(let r of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])s.push([RegExp.prototype,r]);for(let r of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])s.push([r,Symbol.toStringTag]);for(let[r,i]of s)t.add(r),n(r,i);let o=(r,i,c)=>{let a=Object.getOwnPropertyDescriptor(r,i);if(!a||!("value"in a)||typeof a.value!="function"||a.configurable!==!0)return;let u=a.value,h=this,y=function(...b){let g=b[0];if(h.shouldBlock()&&typeof g=="object"&&g!==null&&t.has(g)){let x=`${c}.${i}`,w=`${x} is blocked for protected intrinsics during script execution`,S=h.recordViolation("prototype_mutation",x,w);throw new d(w,S)}return Reflect.apply(u,this,b)};this.temporaryIntrinsicDescriptors.push({target:r,prop:i,descriptor:a}),Object.defineProperty(r,i,{...a,value:y,writable:!1})};for(let r of["assign","defineProperties","defineProperty","freeze","preventExtensions","seal","setPrototypeOf"])o(Object,r,"Object");for(let r of["defineProperty","deleteProperty","preventExtensions","set","setPrototypeOf"])o(Reflect,r,"Reflect")}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(e){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(e){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(e){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:t});let n=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(s){if(e.shouldBlock()){let o="Error.prepareStackTrace modification is blocked during script execution",r=e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",o);throw new d(o,r)}e.shouldAudit()&&e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),n=s},configurable:!0})}catch(t){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",t instanceof Error?t.message:t)}}protectPromiseThen(){let e=this;try{let o=function(...r){return p.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation("promise_then_after_deactivate","Promise.then","Promise.then callback is blocked after defense deactivation"),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,r);if(this.kind==="fulfilled")return r[0];throw r[0]}return Reflect.apply(this.cb,void 0,r)})};var t=o;let n=Object.getOwnPropertyDescriptor(Promise.prototype,"then");this.originalDescriptors.push({target:Promise.prototype,prop:"then",descriptor:n});let s=n?.value;if(typeof s!="function")return;Object.defineProperty(Promise.prototype,"then",{value:function(i,c){if(!p)return Reflect.apply(s,this,[i,c]);let a=p.getStore(),u=a?.sandboxActive===!0&&a.trusted!==!0?a.executionId:void 0;if(!u)return Reflect.apply(s,this,[i,c]);let h=e.getCachedContext(u),y=a?.forceUntrusted?{...h,forceUntrusted:!0}:h,b=(g,x)=>typeof g!="function"?g:o.bind({box:e,executionId:u,captured:y,cb:g,kind:x});return Reflect.apply(s,this,[b(i,"fulfilled"),b(c,"rejected")])},writable:!0,configurable:!0})}catch(n){this.patchFailures.push("Promise.prototype.then"),console.debug("[DefenseInDepthBox] Could not protect Promise.prototype.then:",n instanceof Error?n.message:n)}}patchPrototypeConstructor(e,t,n){let s=this;try{let o=Object.getOwnPropertyDescriptor(e,"constructor");this.originalDescriptors.push({target:e,prop:"constructor",descriptor:o});let r=o?.value;Object.defineProperty(e,"constructor",{get(){if(s.shouldBlock()){let i=`${t} access is blocked during script execution`,c=s.recordViolation(n,t,i);throw new d(i,c)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} accessed (audit mode)`),r},set(i){if(s.shouldBlock()){let c=`${t} modification is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}Object.defineProperty(this,"constructor",{value:i,writable:!0,configurable:!0})},configurable:!0})}catch(o){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,o instanceof Error?o.message:o)}}protectProcessMainModule(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:t});let n=t?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let s="process.mainModule access is blocked during script execution",o=e.recordViolation("process_main_module","process.mainModule",s);throw new d(s,o)}return e.shouldAudit()&&e.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),n},set(s){if(e.shouldBlock()){let o="process.mainModule modification is blocked during script execution",r=e.recordViolation("process_main_module","process.mainModule",o);throw new d(o,r)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",t instanceof Error?t.message:t)}}protectProcessExecPath(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:t});let n=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let s="process.execPath access is blocked during script execution",o=e.recordViolation("process_exec_path","process.execPath",s);throw new d(s,o)}return e.shouldAudit()&&e.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),n},set(s){if(e.shouldBlock()){let o="process.execPath modification is blocked during script execution",r=e.recordViolation("process_exec_path","process.execPath",o);throw new d(o,r)}Object.defineProperty(process,"execPath",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",t instanceof Error?t.message:t)}}lockWellKnownSymbols(){let e=(t,n)=>{try{let s=Object.getOwnPropertyDescriptor(t,n);if(s?.configurable){if("value"in s){Object.defineProperty(t,n,{...s,configurable:!1,writable:!1});return}Object.defineProperty(t,n,{...s,configurable:!1})}}catch{}};for(let t of[Array,Map,Set,RegExp,Promise])e(t,Symbol.species);for(let t of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(t,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let t of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,t);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let t of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(t,Symbol.toStringTag)}protectProxyRevocable(){let e=this;try{let t=Proxy.revocable;if(typeof t!="function")return;let n=Object.getOwnPropertyDescriptor(Proxy,"revocable");this.originalDescriptors.push({target:Proxy,prop:"revocable",descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(o,r){if(e.shouldBlock()){let i="Proxy.revocable is blocked during script execution",c=e.recordViolation("proxy","Proxy.revocable",i);throw new d(i,c)}return e.shouldAudit()&&e.recordViolation("proxy","Proxy.revocable","Proxy.revocable called (audit mode)"),t(o,r)},writable:!1,configurable:!0})}catch(t){this.patchFailures.push("Proxy.revocable"),console.debug("[DefenseInDepthBox] Could not protect Proxy.revocable:",t instanceof Error?t.message:t)}}protectDynamicImport(){if(!(f||l.importHooksRegistered))try{let e=m;if(!e)throw new Error("node:module is unavailable");let t=new Set;for(let o of e.builtinModules??[]){let r=o.startsWith("node:")?o.slice(5):o;t.add(r);let i=r.indexOf("/");i>0&&t.add(r.slice(0,i))}let n=o=>{if(o.startsWith("./")||o.startsWith("../")||o.startsWith("/")||o.startsWith("file:")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("http:")||o.startsWith("https:"))return!1;let r=o.startsWith("node:")?o.slice(5):o;if(!r)return!1;if(typeof e.isBuiltin=="function"&&e.isBuiltin(r)||t.has(r))return!0;let i=r.indexOf("/");return i>0&&t.has(r.slice(0,i))},s=o=>{let r=p?.getStore();return o.config.auditMode===!0&&r?.sandboxActive===!0&&!l.isTrustedContext(r)};if(typeof e.registerHooks=="function"){e.registerHooks({resolve(o,r,i){let c=l.instance;if(!c)return i(o,r);if((o.startsWith("data:")||o.startsWith("blob:"))&&c.shouldBlock()){let a=`import(${o.startsWith("data:")?"data:":"blob:"})`,u=`dynamic import of ${o.startsWith("data:")?"data:":"blob:"} URLs is blocked by defense-in-depth`,h=c.recordViolation("dynamic_import_builtin",a,u);throw new d(u,h)}if(n(o)){let a=`import(${o})`,u=`dynamic import of Node.js builtin '${o}' is blocked during script execution`;if(c.shouldBlock()){let h=c.recordViolation("dynamic_import_builtin",a,u);throw new d(u,h)}s(c)&&c.recordViolation("dynamic_import_builtin",a,`dynamic import of Node.js builtin '${o}' called (audit mode)`)}return i(o,r)}}),l.importHooksRegistered=!0;return}throw new Error("context-aware ESM loader hooks (node:module.registerHooks) are unavailable")}catch(e){throw new Error(`DefenseInDepthBox: could not register dynamic-import hooks: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}protectModuleLoad(){this.protectModuleMethod("_load","module_load")}protectModuleResolveFilename(){this.protectModuleMethod("_resolveFilename","module_resolve_filename")}protectModuleMethod(e,t){if(f)return;let n=`Module.${e}`;try{let s=O,o=s?.[e];if(!s||typeof o!="function")throw new Error("node:module Module class or method is unavailable");let r=Object.getOwnPropertyDescriptor(s,e);if(!r)throw new Error("method has no own property descriptor");if(r.configurable===!1&&r.writable===!1)throw new Error("method is non-configurable and non-writable");let i=this.createBlockingProxy(o,n,t);this.originalDescriptors.push({target:s,prop:e,descriptor:r}),Object.defineProperty(s,e,{...r,value:i});let c=Object.getOwnPropertyDescriptor(s,e);if(s[e]!==i||c?.value!==i)throw new Error("installed patch failed verification")}catch{this.patchFailures.push(n)}}applyPatch(e,t=!1){let{target:n,prop:s,violationType:o,strategy:r}=e;try{let i=n[s];if(i===void 0)return;let c=Object.getOwnPropertyDescriptor(n,s);if(this.originalDescriptors.push({target:n,prop:s,descriptor:c}),r==="freeze"){if(typeof i=="object"&&i!==null){t&&Object.freeze(i);let a=this.getPathForTarget(n,s),u=this.createReadonlyObjectProxy(i,a,o);Object.defineProperty(n,s,{...c,value:u})}}else{let a=this.getPathForTarget(n,s),u=typeof i=="function"?this.createBlockingProxy(i,a,o):this.createBlockingObjectProxy(i,a,o,e.allowedKeys);Object.defineProperty(n,s,{value:u,writable:!0,configurable:!0})}}catch(i){let c=this.getPathForTarget(n,s);this.patchFailures.push(c),console.debug(`[DefenseInDepthBox] Could not patch ${c}:`,i instanceof Error?i.message:i)}}restorePatches(){for(let e=this.temporaryIntrinsicDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:s}=this.temporaryIntrinsicDescriptors[e];try{Object.defineProperty(t,n,s)}catch(o){console.debug(`[DefenseInDepthBox] Could not restore temporary intrinsic ${String(n)}:`,o instanceof Error?o.message:o)}}this.temporaryIntrinsicDescriptors=[];for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(t,n,s):delete t[n]}catch(o){let r=this.getPathForTarget(t,n);console.debug(`[DefenseInDepthBox] Could not restore ${r}:`,o instanceof Error?o.message:o)}}this.originalDescriptors=[]}};export{d as a,D as b};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import*as E from"node:async_hooks";import*as I from"node:module";function P(){let l=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables",allowedKeys:new Set(["NODE_V8_COVERAGE","NODE_DEBUG","NODE_DEBUG_NATIVE","NODE_COMPILE_CACHE","WATCH_REPORT_DEPENDENCIES","FORCE_COLOR","DEBUG","UNDICI_NO_FG","JEST_WORKER_ID","__MINIMATCH_TESTING_PLATFORM__","LOG_TOKENS","LOG_STREAM"])},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"getBuiltinModule",target:process,violationType:"process_get_builtin_module",strategy:"throw",reason:"process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"},{prop:"exit",target:process,violationType:"process_exit",strategy:"throw",reason:"process.exit could terminate the interpreter"},{prop:"abort",target:process,violationType:"process_exit",strategy:"throw",reason:"process.abort could crash the interpreter"},{prop:"kill",target:process,violationType:"process_kill",strategy:"throw",reason:"process.kill could signal other processes"},{prop:"setuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setuid could escalate privileges"},{prop:"setgid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgid could escalate privileges"},{prop:"seteuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.seteuid could escalate effective user privileges"},{prop:"setegid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setegid could escalate effective group privileges"},{prop:"initgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.initgroups could modify supplementary group IDs"},{prop:"setgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgroups could modify supplementary group IDs"},{prop:"umask",target:process,violationType:"process_umask",strategy:"throw",reason:"process.umask could modify file creation permissions"},{prop:"argv",target:process,violationType:"process_argv",strategy:"throw",reason:"process.argv may contain secrets in CLI arguments"},{prop:"cwd",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.cwd could disclose real host working directory path"},{prop:"chdir",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.chdir could confuse the interpreter's CWD tracking"},{prop:"report",target:process,violationType:"process_report",strategy:"throw",reason:"process.report could disclose full environment, host paths, and system info"},{prop:"loadEnvFile",target:process,violationType:"process_env",strategy:"throw",reason:"process.loadEnvFile could load env files bypassing env proxy"},{prop:"setUncaughtExceptionCaptureCallback",target:process,violationType:"process_exception_handler",strategy:"throw",reason:"setUncaughtExceptionCaptureCallback could intercept security errors"},...["on","once","addListener","prependListener","prependOnceListener"].map(e=>({prop:e,target:process,violationType:"process_exception_handler",strategy:"throw",reason:"process-global listeners can outlive the sandbox and lose its security context"})),{prop:"send",target:process,violationType:"process_send",strategy:"throw",reason:"process.send could communicate with parent process in IPC contexts"},{prop:"channel",target:process,violationType:"process_channel",strategy:"throw",reason:"process.channel could access IPC channel to parent process"},{prop:"cpuUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.cpuUsage could enable timing side-channel attacks"},{prop:"memoryUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.memoryUsage could enable timing side-channel attacks"},{prop:"hrtime",target:process,violationType:"process_timing",strategy:"throw",reason:"process.hrtime could enable timing side-channel attacks"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"},{prop:"performance",target:globalThis,violationType:"performance_timing",strategy:"throw",reason:"performance.now() provides sub-millisecond timing for side-channel attacks"},{prop:"stdout",target:process,violationType:"process_stdout",strategy:"throw",reason:"process.stdout could bypass interpreter output to write to host stdout"},{prop:"stderr",target:process,violationType:"process_stderr",strategy:"throw",reason:"process.stderr could bypass interpreter output to write to host stderr"},{prop:"__defineGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineGetter__ allows prototype pollution via getter injection"},{prop:"__defineSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineSetter__ allows prototype pollution via setter injection"},{prop:"__lookupGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupGetter__ enables introspection for prototype pollution attacks"},{prop:"__lookupSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupSetter__ enables introspection for prototype pollution attacks"},{prop:"JSON",target:globalThis,violationType:"json_mutation",strategy:"freeze",reason:"Freeze JSON to prevent mutation of parsing/serialization"},{prop:"Math",target:globalThis,violationType:"math_mutation",strategy:"freeze",reason:"Freeze Math to prevent mutation of math utilities"}];try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&l.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&l.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let e=Object.getPrototypeOf(async function*(){}).constructor;e&&e!==Function&&e!==Object.getPrototypeOf(async()=>{}).constructor&&l.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return l.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}})}var f=typeof __BROWSER__<"u"&&__BROWSER__;function _(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,l=>{let e=Math.random()*16|0;return(l==="x"?e:e&3|8).toString(16)})}var v=null,m=null,O=null;if(!f)try{v=E.AsyncLocalStorage,m=I,O=m.Module??m.default??null}catch{}var C=`
|
|
4
|
-
|
|
5
|
-
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,d=class extends Error{violation;constructor(e,t){super(e+C),this.violation=t,this.name="SecurityViolationError"}},p=!f&&v?new v:null,B=1e3;function M(l,e,...t){return p.run(l,()=>e(...t))}var A={enabled:!0,auditMode:!1,processLifetimeIntrinsicHardening:!1};function k(){return!f&&typeof m?.registerHooks=="function"}function T(l){let e=typeof l=="boolean"?{enabled:l}:l??{};if(e.enabled!==void 0&&e.enabled!==!0&&e.enabled!==!1&&e.enabled!=="auto")throw new RangeError('defenseInDepth.enabled must be true, false, or "auto"');let t={...A,...e},n=t.enabled==="auto"?"auto":t.enabled?"enabled":"disabled",s={...t,enabled:n!=="disabled",requested:n};return s.excludeViolationTypes&&(s.excludeViolationTypes=[...new Set(s.excludeViolationTypes)].sort()),s}function F(l,e){if(l.enabled!==e.enabled||l.auditMode!==e.auditMode||l.processLifetimeIntrinsicHardening!==e.processLifetimeIntrinsicHardening||l.onViolation!==e.onViolation)return!1;let t=l.excludeViolationTypes??[],n=e.excludeViolationTypes??[];return t.length===n.length&&t.every((s,o)=>s===n[o])}var D=class l{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];temporaryIntrinsicDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(e){let t=T(e);if(!l.instance)l.instance=new l(t);else{let n=l.instance.config;if(!F(t,n))throw new Error("DefenseInDepthBox config conflict: all resolved defense options, including exclusions and the violation callback, must match across Bash instances. Call DefenseInDepthBox.resetInstance() between incompatible configurations.")}return l.instance}static resetInstance(){l.instance&&(l.instance.forceDeactivate(),l.instance=null),l.trustedExecutionDepth.clear()}static isInSandboxedContext(){return p?p?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(p)return p?.getStore()?.executionId}static enterTrustedScope(e){let t=l.trustedExecutionDepth.get(e)??0;l.trustedExecutionDepth.set(e,t+1)}static leaveTrustedScope(e){let t=l.trustedExecutionDepth.get(e);if(t){if(t===1){l.trustedExecutionDepth.delete(e);return}l.trustedExecutionDepth.set(e,t-1)}}static isTrustedScopeActive(e){return e?(l.trustedExecutionDepth.get(e)??0)>0:!1}static isTrustedContext(e){return!e||e.forceUntrusted?!1:e.trusted===!0||l.isTrustedScopeActive(e.executionId)}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}static bindCurrentContext(e){if(!p)return e;let t=p.getStore(),n=t?.sandboxActive===!0?t.executionId:void 0;if(!n)return e;let o=l.instance?.getCachedContext(n)??{sandboxActive:!0,executionId:n},r=t?.forceUntrusted?{...o,forceUntrusted:!0}:o;return((...i)=>{let c=l.instance;if(!(c&&!c.isExecutionIdActive(n)&&(c.recordViolation("bound_callback_after_deactivate","bound callback","Bound callback blocked after originating execution was deactivated"),!c.config.auditMode)))return M(r,e,...i)})}isEnabled(){return this.getStatus().state==="enabled"}getStatus(){let e=k();return this.config.requested==="disabled"?{requested:"disabled",state:"disabled",level:"none",contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort"}:!p||f?{requested:this.config.requested,state:"unsupported",level:"none",contextualDynamicImportProtection:!1,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort",reason:"context-aware ESM loader hooks (node:module.registerHooks) are unavailable"}:{requested:this.config.requested,state:"enabled",level:this.config.auditMode?"none":e?"full":"best-effort",contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort",reason:this.config.auditMode?"audit mode records violations but does not block them":e?void 0:"best-effort protection; context-aware ESM loader hooks are unavailable"}}updateConfig(e){if(this.refCount>0)throw new Error("DefenseInDepthBox configuration cannot change while protection is active");this.config=T({...this.config,...e})}activate(){if(!f&&this.config.enabled&&!p)throw new Error("DefenseInDepthBox: enabled protection requires node:async_hooks and node:module");if(f||!this.config.enabled){let n=_(),s=!1;return{run:o=>s?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):o(),deactivate:()=>{s=!0},executionId:n}}if(this.refCount++,this.refCount===1){try{this.applyPatches()}catch(n){throw this.restorePatches(),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0,n}this.activationTime=Date.now()}let e=_(),t=!1;return{run:n=>t?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):(this.activeExecutionIds.add(e),p.run({sandboxActive:!0,executionId:e},n)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(e){if(!p)return e();let t=p.getStore();if(!t)return e();let{executionId:n}=t;return p.run({...t,trusted:!0,forceUntrusted:!1},()=>{l.enterTrustedScope(n);try{let s=e();return typeof s=="object"&&s!==null&&"finally"in s&&typeof s.finally=="function"?s.finally(()=>{l.leaveTrustedScope(n)}):(l.leaveTrustedScope(n),s)}catch(s){throw l.leaveTrustedScope(n),s}})}static async runTrustedAsync(e){if(!p)return e();let t=p.getStore();if(!t)return e();let{executionId:n}=t;return p.run({...t,trusted:!0,forceUntrusted:!1},async()=>{l.enterTrustedScope(n);try{return await e()}finally{l.leaveTrustedScope(n)}})}static async runUntrustedAsync(e){if(!p)return e();let t=p.getStore();return t?p.run({...t,trusted:!1,forceUntrusted:!0},e):e()}shouldBlock(){if(f||this.config.auditMode||!p)return!1;let e=p?.getStore();return!(e?.sandboxActive!==!0||l.isTrustedContext(e))}shouldAudit(){if(!this.config.auditMode||!p)return!1;let e=p.getStore();return e?.sandboxActive===!0&&!l.isTrustedContext(e)}recordViolation(e,t,n){let s={timestamp:Date.now(),type:e,message:n,path:t,stack:new Error().stack,executionId:p?.getStore()?.executionId};if(this.violations.length<B&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(o){console.debug("[DefenseInDepthBox] onViolation callback threw:",o instanceof Error?o.message:o)}return s}createBlockingProxy(e,t,n){let s=this;return new Proxy(e,{apply(o,r,i){if(s.shouldBlock()){let c=`${t} is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} called (audit mode)`),Reflect.apply(o,r,i)},construct(o,r,i){if(s.shouldBlock()){let c=`${t} constructor is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} constructor called (audit mode)`),Reflect.construct(o,r,i)}})}createBlockingObjectProxy(e,t,n,s){let o=this;return new Proxy(e,{get(r,i,c){if(o.shouldBlock()){if(s&&typeof i=="string"&&s.has(i))return Reflect.get(r,i,c);let a=`${t}.${String(i)}`,u=`${a} is blocked during script execution`,h=o.recordViolation(n,a,u);throw new d(u,h)}if(o.shouldAudit()){let a=`${t}.${String(i)}`;o.recordViolation(n,a,`${a} accessed (audit mode)`)}return Reflect.get(r,i,c)},set(r,i,c,a){if(o.shouldBlock()){let u=`${t}.${String(i)}`,h=`${u} modification is blocked during script execution`,y=o.recordViolation(n,u,h);throw new d(h,y)}return t==="process.env"&&i==="DEBUG"?Reflect.set(r,i,c):Reflect.set(r,i,c,a)},ownKeys(r){if(o.shouldBlock()){let i=`${t} enumeration is blocked during script execution`,c=o.recordViolation(n,t,i);throw new d(i,c)}return Reflect.ownKeys(r)},getOwnPropertyDescriptor(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} descriptor access is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.getOwnPropertyDescriptor(r,i)},has(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} existence check is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.has(r,i)},deleteProperty(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} deletion is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.deleteProperty(r,i)},setPrototypeOf(r,i){if(o.shouldBlock()){let c=`${t} setPrototypeOf is blocked during script execution`,a=o.recordViolation(n,t,c);throw new d(c,a)}return Reflect.setPrototypeOf(r,i)},defineProperty(r,i,c){if(o.shouldBlock()){let a=`${t}.${String(i)}`,u=`${a} defineProperty is blocked during script execution`,h=o.recordViolation(n,a,u);throw new d(u,h)}return Reflect.defineProperty(r,i,c)}})}createReadonlyObjectProxy(e,t,n){let s=this,o=r=>{let i=`${t} ${r} is blocked during script execution`,c=s.recordViolation(n,t,i);throw new d(i,c)};return new Proxy(e,{set(r,i,c,a){return s.shouldBlock()&&o("modification"),Reflect.set(r,i,c,a)},defineProperty(r,i,c){return s.shouldBlock()&&o("defineProperty"),Reflect.defineProperty(r,i,c)},deleteProperty(r,i){return s.shouldBlock()&&o("deletion"),Reflect.deleteProperty(r,i)},setPrototypeOf(r,i){return s.shouldBlock()&&o("setPrototypeOf"),Reflect.setPrototypeOf(r,i)},preventExtensions(r){return s.shouldBlock()&&o("preventExtensions"),Reflect.preventExtensions(r)}})}applyPatches(){this.patchFailures=[];let e=P(),t=new Set(["process_send","process_channel","process_stdout","process_stderr"]),n=[];for(let r of e)if(!t.has(r.violationType)){if(r.strategy==="freeze"){n.push(r);continue}this.applyPatch(r)}this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),k()&&this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.protectProxyRevocable();let s=["Function.prototype.constructor","Module._load","Module._resolveFilename"],o=this.patchFailures.filter(r=>s.includes(r));if(o.length>0)throw this.restorePatches(),new Error(`DefenseInDepthBox: critical patches failed: ${o.join(", ")}`);this.config.processLifetimeIntrinsicHardening||this.protectReversibleIntrinsics(n);for(let r of n)this.applyPatch(r,this.config.processLifetimeIntrinsicHardening===!0);this.config.processLifetimeIntrinsicHardening&&this.lockWellKnownSymbols()}protectReversibleIntrinsics(e){let t=new Set,n=(r,i)=>{let c=Object.getOwnPropertyDescriptor(r,i);!c||!("value"in c)||c.writable!==!0||c.configurable!==!0||(this.temporaryIntrinsicDescriptors.push({target:r,prop:i,descriptor:c}),Object.defineProperty(r,i,{...c,writable:!1}))};for(let{target:r,prop:i}of e){let c=r[i];if(!(typeof c!="object"||c===null)){t.add(c);for(let a of Reflect.ownKeys(c))n(c,a)}}let s=[];for(let r of[Array,Map,Set,RegExp,Promise])s.push([r,Symbol.species]);for(let r of[Array.prototype,String.prototype,Map.prototype,Set.prototype])s.push([r,Symbol.iterator]);s.push([Symbol.prototype,Symbol.toPrimitive],[Date.prototype,Symbol.toPrimitive],[Function.prototype,Symbol.hasInstance],[Array.prototype,Symbol.unscopables]);for(let r of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])s.push([RegExp.prototype,r]);for(let r of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])s.push([r,Symbol.toStringTag]);for(let[r,i]of s)t.add(r),n(r,i);let o=(r,i,c)=>{let a=Object.getOwnPropertyDescriptor(r,i);if(!a||!("value"in a)||typeof a.value!="function"||a.configurable!==!0)return;let u=a.value,h=this,y=function(...b){let g=b[0];if(h.shouldBlock()&&typeof g=="object"&&g!==null&&t.has(g)){let x=`${c}.${i}`,w=`${x} is blocked for protected intrinsics during script execution`,S=h.recordViolation("prototype_mutation",x,w);throw new d(w,S)}return Reflect.apply(u,this,b)};this.temporaryIntrinsicDescriptors.push({target:r,prop:i,descriptor:a}),Object.defineProperty(r,i,{...a,value:y,writable:!1})};for(let r of["assign","defineProperties","defineProperty","freeze","preventExtensions","seal","setPrototypeOf"])o(Object,r,"Object");for(let r of["defineProperty","deleteProperty","preventExtensions","set","setPrototypeOf"])o(Reflect,r,"Reflect")}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(e){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(e){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(e){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:t});let n=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(s){if(e.shouldBlock()){let o="Error.prepareStackTrace modification is blocked during script execution",r=e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",o);throw new d(o,r)}e.shouldAudit()&&e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),n=s},configurable:!0})}catch(t){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",t instanceof Error?t.message:t)}}protectPromiseThen(){let e=this;try{let o=function(...r){return p.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation("promise_then_after_deactivate","Promise.then","Promise.then callback is blocked after defense deactivation"),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,r);if(this.kind==="fulfilled")return r[0];throw r[0]}return Reflect.apply(this.cb,void 0,r)})};var t=o;let n=Object.getOwnPropertyDescriptor(Promise.prototype,"then");this.originalDescriptors.push({target:Promise.prototype,prop:"then",descriptor:n});let s=n?.value;if(typeof s!="function")return;Object.defineProperty(Promise.prototype,"then",{value:function(i,c){if(!p)return Reflect.apply(s,this,[i,c]);let a=p.getStore(),u=a?.sandboxActive===!0&&a.trusted!==!0?a.executionId:void 0;if(!u)return Reflect.apply(s,this,[i,c]);let h=e.getCachedContext(u),y=a?.forceUntrusted?{...h,forceUntrusted:!0}:h,b=(g,x)=>typeof g!="function"?g:o.bind({box:e,executionId:u,captured:y,cb:g,kind:x});return Reflect.apply(s,this,[b(i,"fulfilled"),b(c,"rejected")])},writable:!0,configurable:!0})}catch(n){this.patchFailures.push("Promise.prototype.then"),console.debug("[DefenseInDepthBox] Could not protect Promise.prototype.then:",n instanceof Error?n.message:n)}}patchPrototypeConstructor(e,t,n){let s=this;try{let o=Object.getOwnPropertyDescriptor(e,"constructor");this.originalDescriptors.push({target:e,prop:"constructor",descriptor:o});let r=o?.value;Object.defineProperty(e,"constructor",{get(){if(s.shouldBlock()){let i=`${t} access is blocked during script execution`,c=s.recordViolation(n,t,i);throw new d(i,c)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} accessed (audit mode)`),r},set(i){if(s.shouldBlock()){let c=`${t} modification is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}Object.defineProperty(this,"constructor",{value:i,writable:!0,configurable:!0})},configurable:!0})}catch(o){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,o instanceof Error?o.message:o)}}protectProcessMainModule(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:t});let n=t?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let s="process.mainModule access is blocked during script execution",o=e.recordViolation("process_main_module","process.mainModule",s);throw new d(s,o)}return e.shouldAudit()&&e.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),n},set(s){if(e.shouldBlock()){let o="process.mainModule modification is blocked during script execution",r=e.recordViolation("process_main_module","process.mainModule",o);throw new d(o,r)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",t instanceof Error?t.message:t)}}protectProcessExecPath(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:t});let n=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let s="process.execPath access is blocked during script execution",o=e.recordViolation("process_exec_path","process.execPath",s);throw new d(s,o)}return e.shouldAudit()&&e.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),n},set(s){if(e.shouldBlock()){let o="process.execPath modification is blocked during script execution",r=e.recordViolation("process_exec_path","process.execPath",o);throw new d(o,r)}Object.defineProperty(process,"execPath",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",t instanceof Error?t.message:t)}}lockWellKnownSymbols(){let e=(t,n)=>{try{let s=Object.getOwnPropertyDescriptor(t,n);if(s?.configurable){if("value"in s){Object.defineProperty(t,n,{...s,configurable:!1,writable:!1});return}Object.defineProperty(t,n,{...s,configurable:!1})}}catch{}};for(let t of[Array,Map,Set,RegExp,Promise])e(t,Symbol.species);for(let t of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(t,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let t of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,t);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let t of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(t,Symbol.toStringTag)}protectProxyRevocable(){let e=this;try{let t=Proxy.revocable;if(typeof t!="function")return;let n=Object.getOwnPropertyDescriptor(Proxy,"revocable");this.originalDescriptors.push({target:Proxy,prop:"revocable",descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(o,r){if(e.shouldBlock()){let i="Proxy.revocable is blocked during script execution",c=e.recordViolation("proxy","Proxy.revocable",i);throw new d(i,c)}return e.shouldAudit()&&e.recordViolation("proxy","Proxy.revocable","Proxy.revocable called (audit mode)"),t(o,r)},writable:!1,configurable:!0})}catch(t){this.patchFailures.push("Proxy.revocable"),console.debug("[DefenseInDepthBox] Could not protect Proxy.revocable:",t instanceof Error?t.message:t)}}protectDynamicImport(){if(!(f||l.importHooksRegistered))try{let e=m;if(!e)throw new Error("node:module is unavailable");let t=new Set;for(let o of e.builtinModules??[]){let r=o.startsWith("node:")?o.slice(5):o;t.add(r);let i=r.indexOf("/");i>0&&t.add(r.slice(0,i))}let n=o=>{if(o.startsWith("./")||o.startsWith("../")||o.startsWith("/")||o.startsWith("file:")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("http:")||o.startsWith("https:"))return!1;let r=o.startsWith("node:")?o.slice(5):o;if(!r)return!1;if(typeof e.isBuiltin=="function"&&e.isBuiltin(r)||t.has(r))return!0;let i=r.indexOf("/");return i>0&&t.has(r.slice(0,i))},s=o=>{let r=p?.getStore();return o.config.auditMode===!0&&r?.sandboxActive===!0&&!l.isTrustedContext(r)};if(typeof e.registerHooks=="function"){e.registerHooks({resolve(o,r,i){let c=l.instance;if(!c)return i(o,r);if((o.startsWith("data:")||o.startsWith("blob:"))&&c.shouldBlock()){let a=`import(${o.startsWith("data:")?"data:":"blob:"})`,u=`dynamic import of ${o.startsWith("data:")?"data:":"blob:"} URLs is blocked by defense-in-depth`,h=c.recordViolation("dynamic_import_builtin",a,u);throw new d(u,h)}if(n(o)){let a=`import(${o})`,u=`dynamic import of Node.js builtin '${o}' is blocked during script execution`;if(c.shouldBlock()){let h=c.recordViolation("dynamic_import_builtin",a,u);throw new d(u,h)}s(c)&&c.recordViolation("dynamic_import_builtin",a,`dynamic import of Node.js builtin '${o}' called (audit mode)`)}return i(o,r)}}),l.importHooksRegistered=!0;return}throw new Error("context-aware ESM loader hooks (node:module.registerHooks) are unavailable")}catch(e){throw new Error(`DefenseInDepthBox: could not register dynamic-import hooks: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}protectModuleLoad(){this.protectModuleMethod("_load","module_load")}protectModuleResolveFilename(){this.protectModuleMethod("_resolveFilename","module_resolve_filename")}protectModuleMethod(e,t){if(f)return;let n=`Module.${e}`;try{let s=O,o=s?.[e];if(!s||typeof o!="function")throw new Error("node:module Module class or method is unavailable");let r=Object.getOwnPropertyDescriptor(s,e);if(!r)throw new Error("method has no own property descriptor");if(r.configurable===!1&&r.writable===!1)throw new Error("method is non-configurable and non-writable");let i=this.createBlockingProxy(o,n,t);this.originalDescriptors.push({target:s,prop:e,descriptor:r}),Object.defineProperty(s,e,{...r,value:i});let c=Object.getOwnPropertyDescriptor(s,e);if(s[e]!==i||c?.value!==i)throw new Error("installed patch failed verification")}catch{this.patchFailures.push(n)}}applyPatch(e,t=!1){let{target:n,prop:s,violationType:o,strategy:r}=e;try{let i=n[s];if(i===void 0)return;let c=Object.getOwnPropertyDescriptor(n,s);if(this.originalDescriptors.push({target:n,prop:s,descriptor:c}),r==="freeze"){if(typeof i=="object"&&i!==null){t&&Object.freeze(i);let a=this.getPathForTarget(n,s),u=this.createReadonlyObjectProxy(i,a,o);Object.defineProperty(n,s,{...c,value:u})}}else{let a=this.getPathForTarget(n,s),u=typeof i=="function"?this.createBlockingProxy(i,a,o):this.createBlockingObjectProxy(i,a,o,e.allowedKeys);Object.defineProperty(n,s,{value:u,writable:!0,configurable:!0})}}catch(i){let c=this.getPathForTarget(n,s);this.patchFailures.push(c),console.debug(`[DefenseInDepthBox] Could not patch ${c}:`,i instanceof Error?i.message:i)}}restorePatches(){for(let e=this.temporaryIntrinsicDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:s}=this.temporaryIntrinsicDescriptors[e];try{Object.defineProperty(t,n,s)}catch(o){console.debug(`[DefenseInDepthBox] Could not restore temporary intrinsic ${String(n)}:`,o instanceof Error?o.message:o)}}this.temporaryIntrinsicDescriptors=[];for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(t,n,s):delete t[n]}catch(o){let r=this.getPathForTarget(t,n);console.debug(`[DefenseInDepthBox] Could not restore ${r}:`,o instanceof Error?o.message:o)}}this.originalDescriptors=[]}};export{d as a,D as b};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import*as E from"node:async_hooks";import*as I from"node:module";function P(){let l=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables",allowedKeys:new Set(["NODE_V8_COVERAGE","NODE_DEBUG","NODE_DEBUG_NATIVE","NODE_COMPILE_CACHE","WATCH_REPORT_DEPENDENCIES","FORCE_COLOR","DEBUG","UNDICI_NO_FG","JEST_WORKER_ID","__MINIMATCH_TESTING_PLATFORM__","LOG_TOKENS","LOG_STREAM"])},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"getBuiltinModule",target:process,violationType:"process_get_builtin_module",strategy:"throw",reason:"process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"},{prop:"exit",target:process,violationType:"process_exit",strategy:"throw",reason:"process.exit could terminate the interpreter"},{prop:"abort",target:process,violationType:"process_exit",strategy:"throw",reason:"process.abort could crash the interpreter"},{prop:"kill",target:process,violationType:"process_kill",strategy:"throw",reason:"process.kill could signal other processes"},{prop:"setuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setuid could escalate privileges"},{prop:"setgid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgid could escalate privileges"},{prop:"seteuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.seteuid could escalate effective user privileges"},{prop:"setegid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setegid could escalate effective group privileges"},{prop:"initgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.initgroups could modify supplementary group IDs"},{prop:"setgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgroups could modify supplementary group IDs"},{prop:"umask",target:process,violationType:"process_umask",strategy:"throw",reason:"process.umask could modify file creation permissions"},{prop:"argv",target:process,violationType:"process_argv",strategy:"throw",reason:"process.argv may contain secrets in CLI arguments"},{prop:"cwd",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.cwd could disclose real host working directory path"},{prop:"chdir",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.chdir could confuse the interpreter's CWD tracking"},{prop:"report",target:process,violationType:"process_report",strategy:"throw",reason:"process.report could disclose full environment, host paths, and system info"},{prop:"loadEnvFile",target:process,violationType:"process_env",strategy:"throw",reason:"process.loadEnvFile could load env files bypassing env proxy"},{prop:"setUncaughtExceptionCaptureCallback",target:process,violationType:"process_exception_handler",strategy:"throw",reason:"setUncaughtExceptionCaptureCallback could intercept security errors"},...["on","once","addListener","prependListener","prependOnceListener"].map(e=>({prop:e,target:process,violationType:"process_exception_handler",strategy:"throw",reason:"process-global listeners can outlive the sandbox and lose its security context"})),{prop:"send",target:process,violationType:"process_send",strategy:"throw",reason:"process.send could communicate with parent process in IPC contexts"},{prop:"channel",target:process,violationType:"process_channel",strategy:"throw",reason:"process.channel could access IPC channel to parent process"},{prop:"cpuUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.cpuUsage could enable timing side-channel attacks"},{prop:"memoryUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.memoryUsage could enable timing side-channel attacks"},{prop:"hrtime",target:process,violationType:"process_timing",strategy:"throw",reason:"process.hrtime could enable timing side-channel attacks"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"},{prop:"performance",target:globalThis,violationType:"performance_timing",strategy:"throw",reason:"performance.now() provides sub-millisecond timing for side-channel attacks"},{prop:"stdout",target:process,violationType:"process_stdout",strategy:"throw",reason:"process.stdout could bypass interpreter output to write to host stdout"},{prop:"stderr",target:process,violationType:"process_stderr",strategy:"throw",reason:"process.stderr could bypass interpreter output to write to host stderr"},{prop:"__defineGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineGetter__ allows prototype pollution via getter injection"},{prop:"__defineSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineSetter__ allows prototype pollution via setter injection"},{prop:"__lookupGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupGetter__ enables introspection for prototype pollution attacks"},{prop:"__lookupSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupSetter__ enables introspection for prototype pollution attacks"},{prop:"JSON",target:globalThis,violationType:"json_mutation",strategy:"freeze",reason:"Freeze JSON to prevent mutation of parsing/serialization"},{prop:"Math",target:globalThis,violationType:"math_mutation",strategy:"freeze",reason:"Freeze Math to prevent mutation of math utilities"}];try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&l.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&l.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let e=Object.getPrototypeOf(async function*(){}).constructor;e&&e!==Function&&e!==Object.getPrototypeOf(async()=>{}).constructor&&l.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return l.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}})}var f=typeof __BROWSER__<"u"&&__BROWSER__;function _(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,l=>{let e=Math.random()*16|0;return(l==="x"?e:e&3|8).toString(16)})}var v=null,m=null,O=null;if(!f)try{v=E.AsyncLocalStorage,m=I,O=m.Module??m.default??null}catch{}var C=`
|
|
3
|
-
|
|
4
|
-
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,d=class extends Error{violation;constructor(e,t){super(e+C),this.violation=t,this.name="SecurityViolationError"}},p=!f&&v?new v:null,B=1e3;function M(l,e,...t){return p.run(l,()=>e(...t))}var A={enabled:!0,auditMode:!1,processLifetimeIntrinsicHardening:!1};function k(){return!f&&typeof m?.registerHooks=="function"}function T(l){let e=typeof l=="boolean"?{enabled:l}:l??{};if(e.enabled!==void 0&&e.enabled!==!0&&e.enabled!==!1&&e.enabled!=="auto")throw new RangeError('defenseInDepth.enabled must be true, false, or "auto"');let t={...A,...e},n=t.enabled==="auto"?"auto":t.enabled?"enabled":"disabled",s={...t,enabled:n!=="disabled",requested:n};return s.excludeViolationTypes&&(s.excludeViolationTypes=[...new Set(s.excludeViolationTypes)].sort()),s}function F(l,e){if(l.enabled!==e.enabled||l.auditMode!==e.auditMode||l.processLifetimeIntrinsicHardening!==e.processLifetimeIntrinsicHardening||l.onViolation!==e.onViolation)return!1;let t=l.excludeViolationTypes??[],n=e.excludeViolationTypes??[];return t.length===n.length&&t.every((s,o)=>s===n[o])}var D=class l{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];temporaryIntrinsicDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(e){let t=T(e);if(!l.instance)l.instance=new l(t);else{let n=l.instance.config;if(!F(t,n))throw new Error("DefenseInDepthBox config conflict: all resolved defense options, including exclusions and the violation callback, must match across Bash instances. Call DefenseInDepthBox.resetInstance() between incompatible configurations.")}return l.instance}static resetInstance(){l.instance&&(l.instance.forceDeactivate(),l.instance=null),l.trustedExecutionDepth.clear()}static isInSandboxedContext(){return p?p?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(p)return p?.getStore()?.executionId}static enterTrustedScope(e){let t=l.trustedExecutionDepth.get(e)??0;l.trustedExecutionDepth.set(e,t+1)}static leaveTrustedScope(e){let t=l.trustedExecutionDepth.get(e);if(t){if(t===1){l.trustedExecutionDepth.delete(e);return}l.trustedExecutionDepth.set(e,t-1)}}static isTrustedScopeActive(e){return e?(l.trustedExecutionDepth.get(e)??0)>0:!1}static isTrustedContext(e){return!e||e.forceUntrusted?!1:e.trusted===!0||l.isTrustedScopeActive(e.executionId)}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}static bindCurrentContext(e){if(!p)return e;let t=p.getStore(),n=t?.sandboxActive===!0?t.executionId:void 0;if(!n)return e;let o=l.instance?.getCachedContext(n)??{sandboxActive:!0,executionId:n},r=t?.forceUntrusted?{...o,forceUntrusted:!0}:o;return((...i)=>{let c=l.instance;if(!(c&&!c.isExecutionIdActive(n)&&(c.recordViolation("bound_callback_after_deactivate","bound callback","Bound callback blocked after originating execution was deactivated"),!c.config.auditMode)))return M(r,e,...i)})}isEnabled(){return this.getStatus().state==="enabled"}getStatus(){let e=k();return this.config.requested==="disabled"?{requested:"disabled",state:"disabled",level:"none",contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort"}:!p||f?{requested:this.config.requested,state:"unsupported",level:"none",contextualDynamicImportProtection:!1,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort",reason:"context-aware ESM loader hooks (node:module.registerHooks) are unavailable"}:{requested:this.config.requested,state:"enabled",level:this.config.auditMode?"none":e?"full":"best-effort",contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort",reason:this.config.auditMode?"audit mode records violations but does not block them":e?void 0:"best-effort protection; context-aware ESM loader hooks are unavailable"}}updateConfig(e){if(this.refCount>0)throw new Error("DefenseInDepthBox configuration cannot change while protection is active");this.config=T({...this.config,...e})}activate(){if(!f&&this.config.enabled&&!p)throw new Error("DefenseInDepthBox: enabled protection requires node:async_hooks and node:module");if(f||!this.config.enabled){let n=_(),s=!1;return{run:o=>s?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):o(),deactivate:()=>{s=!0},executionId:n}}if(this.refCount++,this.refCount===1){try{this.applyPatches()}catch(n){throw this.restorePatches(),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0,n}this.activationTime=Date.now()}let e=_(),t=!1;return{run:n=>t?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):(this.activeExecutionIds.add(e),p.run({sandboxActive:!0,executionId:e},n)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(e){if(!p)return e();let t=p.getStore();if(!t)return e();let{executionId:n}=t;return p.run({...t,trusted:!0,forceUntrusted:!1},()=>{l.enterTrustedScope(n);try{let s=e();return typeof s=="object"&&s!==null&&"finally"in s&&typeof s.finally=="function"?s.finally(()=>{l.leaveTrustedScope(n)}):(l.leaveTrustedScope(n),s)}catch(s){throw l.leaveTrustedScope(n),s}})}static async runTrustedAsync(e){if(!p)return e();let t=p.getStore();if(!t)return e();let{executionId:n}=t;return p.run({...t,trusted:!0,forceUntrusted:!1},async()=>{l.enterTrustedScope(n);try{return await e()}finally{l.leaveTrustedScope(n)}})}static async runUntrustedAsync(e){if(!p)return e();let t=p.getStore();return t?p.run({...t,trusted:!1,forceUntrusted:!0},e):e()}shouldBlock(){if(f||this.config.auditMode||!p)return!1;let e=p?.getStore();return!(e?.sandboxActive!==!0||l.isTrustedContext(e))}shouldAudit(){if(!this.config.auditMode||!p)return!1;let e=p.getStore();return e?.sandboxActive===!0&&!l.isTrustedContext(e)}recordViolation(e,t,n){let s={timestamp:Date.now(),type:e,message:n,path:t,stack:new Error().stack,executionId:p?.getStore()?.executionId};if(this.violations.length<B&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(o){console.debug("[DefenseInDepthBox] onViolation callback threw:",o instanceof Error?o.message:o)}return s}createBlockingProxy(e,t,n){let s=this;return new Proxy(e,{apply(o,r,i){if(s.shouldBlock()){let c=`${t} is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} called (audit mode)`),Reflect.apply(o,r,i)},construct(o,r,i){if(s.shouldBlock()){let c=`${t} constructor is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} constructor called (audit mode)`),Reflect.construct(o,r,i)}})}createBlockingObjectProxy(e,t,n,s){let o=this;return new Proxy(e,{get(r,i,c){if(o.shouldBlock()){if(s&&typeof i=="string"&&s.has(i))return Reflect.get(r,i,c);let a=`${t}.${String(i)}`,u=`${a} is blocked during script execution`,h=o.recordViolation(n,a,u);throw new d(u,h)}if(o.shouldAudit()){let a=`${t}.${String(i)}`;o.recordViolation(n,a,`${a} accessed (audit mode)`)}return Reflect.get(r,i,c)},set(r,i,c,a){if(o.shouldBlock()){let u=`${t}.${String(i)}`,h=`${u} modification is blocked during script execution`,y=o.recordViolation(n,u,h);throw new d(h,y)}return t==="process.env"&&i==="DEBUG"?Reflect.set(r,i,c):Reflect.set(r,i,c,a)},ownKeys(r){if(o.shouldBlock()){let i=`${t} enumeration is blocked during script execution`,c=o.recordViolation(n,t,i);throw new d(i,c)}return Reflect.ownKeys(r)},getOwnPropertyDescriptor(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} descriptor access is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.getOwnPropertyDescriptor(r,i)},has(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} existence check is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.has(r,i)},deleteProperty(r,i){if(o.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} deletion is blocked during script execution`,u=o.recordViolation(n,c,a);throw new d(a,u)}return Reflect.deleteProperty(r,i)},setPrototypeOf(r,i){if(o.shouldBlock()){let c=`${t} setPrototypeOf is blocked during script execution`,a=o.recordViolation(n,t,c);throw new d(c,a)}return Reflect.setPrototypeOf(r,i)},defineProperty(r,i,c){if(o.shouldBlock()){let a=`${t}.${String(i)}`,u=`${a} defineProperty is blocked during script execution`,h=o.recordViolation(n,a,u);throw new d(u,h)}return Reflect.defineProperty(r,i,c)}})}createReadonlyObjectProxy(e,t,n){let s=this,o=r=>{let i=`${t} ${r} is blocked during script execution`,c=s.recordViolation(n,t,i);throw new d(i,c)};return new Proxy(e,{set(r,i,c,a){return s.shouldBlock()&&o("modification"),Reflect.set(r,i,c,a)},defineProperty(r,i,c){return s.shouldBlock()&&o("defineProperty"),Reflect.defineProperty(r,i,c)},deleteProperty(r,i){return s.shouldBlock()&&o("deletion"),Reflect.deleteProperty(r,i)},setPrototypeOf(r,i){return s.shouldBlock()&&o("setPrototypeOf"),Reflect.setPrototypeOf(r,i)},preventExtensions(r){return s.shouldBlock()&&o("preventExtensions"),Reflect.preventExtensions(r)}})}applyPatches(){this.patchFailures=[];let e=P(),t=new Set(["process_send","process_channel","process_stdout","process_stderr"]),n=[];for(let r of e)if(!t.has(r.violationType)){if(r.strategy==="freeze"){n.push(r);continue}this.applyPatch(r)}this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),k()&&this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.protectProxyRevocable();let s=["Function.prototype.constructor","Module._load","Module._resolveFilename"],o=this.patchFailures.filter(r=>s.includes(r));if(o.length>0)throw this.restorePatches(),new Error(`DefenseInDepthBox: critical patches failed: ${o.join(", ")}`);this.config.processLifetimeIntrinsicHardening||this.protectReversibleIntrinsics(n);for(let r of n)this.applyPatch(r,this.config.processLifetimeIntrinsicHardening===!0);this.config.processLifetimeIntrinsicHardening&&this.lockWellKnownSymbols()}protectReversibleIntrinsics(e){let t=new Set,n=(r,i)=>{let c=Object.getOwnPropertyDescriptor(r,i);!c||!("value"in c)||c.writable!==!0||c.configurable!==!0||(this.temporaryIntrinsicDescriptors.push({target:r,prop:i,descriptor:c}),Object.defineProperty(r,i,{...c,writable:!1}))};for(let{target:r,prop:i}of e){let c=r[i];if(!(typeof c!="object"||c===null)){t.add(c);for(let a of Reflect.ownKeys(c))n(c,a)}}let s=[];for(let r of[Array,Map,Set,RegExp,Promise])s.push([r,Symbol.species]);for(let r of[Array.prototype,String.prototype,Map.prototype,Set.prototype])s.push([r,Symbol.iterator]);s.push([Symbol.prototype,Symbol.toPrimitive],[Date.prototype,Symbol.toPrimitive],[Function.prototype,Symbol.hasInstance],[Array.prototype,Symbol.unscopables]);for(let r of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])s.push([RegExp.prototype,r]);for(let r of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])s.push([r,Symbol.toStringTag]);for(let[r,i]of s)t.add(r),n(r,i);let o=(r,i,c)=>{let a=Object.getOwnPropertyDescriptor(r,i);if(!a||!("value"in a)||typeof a.value!="function"||a.configurable!==!0)return;let u=a.value,h=this,y=function(...b){let g=b[0];if(h.shouldBlock()&&typeof g=="object"&&g!==null&&t.has(g)){let x=`${c}.${i}`,w=`${x} is blocked for protected intrinsics during script execution`,S=h.recordViolation("prototype_mutation",x,w);throw new d(w,S)}return Reflect.apply(u,this,b)};this.temporaryIntrinsicDescriptors.push({target:r,prop:i,descriptor:a}),Object.defineProperty(r,i,{...a,value:y,writable:!1})};for(let r of["assign","defineProperties","defineProperty","freeze","preventExtensions","seal","setPrototypeOf"])o(Object,r,"Object");for(let r of["defineProperty","deleteProperty","preventExtensions","set","setPrototypeOf"])o(Reflect,r,"Reflect")}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(e){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(e){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(e){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:t});let n=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(s){if(e.shouldBlock()){let o="Error.prepareStackTrace modification is blocked during script execution",r=e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",o);throw new d(o,r)}e.shouldAudit()&&e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),n=s},configurable:!0})}catch(t){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",t instanceof Error?t.message:t)}}protectPromiseThen(){let e=this;try{let o=function(...r){return p.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation("promise_then_after_deactivate","Promise.then","Promise.then callback is blocked after defense deactivation"),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,r);if(this.kind==="fulfilled")return r[0];throw r[0]}return Reflect.apply(this.cb,void 0,r)})};var t=o;let n=Object.getOwnPropertyDescriptor(Promise.prototype,"then");this.originalDescriptors.push({target:Promise.prototype,prop:"then",descriptor:n});let s=n?.value;if(typeof s!="function")return;Object.defineProperty(Promise.prototype,"then",{value:function(i,c){if(!p)return Reflect.apply(s,this,[i,c]);let a=p.getStore(),u=a?.sandboxActive===!0&&a.trusted!==!0?a.executionId:void 0;if(!u)return Reflect.apply(s,this,[i,c]);let h=e.getCachedContext(u),y=a?.forceUntrusted?{...h,forceUntrusted:!0}:h,b=(g,x)=>typeof g!="function"?g:o.bind({box:e,executionId:u,captured:y,cb:g,kind:x});return Reflect.apply(s,this,[b(i,"fulfilled"),b(c,"rejected")])},writable:!0,configurable:!0})}catch(n){this.patchFailures.push("Promise.prototype.then"),console.debug("[DefenseInDepthBox] Could not protect Promise.prototype.then:",n instanceof Error?n.message:n)}}patchPrototypeConstructor(e,t,n){let s=this;try{let o=Object.getOwnPropertyDescriptor(e,"constructor");this.originalDescriptors.push({target:e,prop:"constructor",descriptor:o});let r=o?.value;Object.defineProperty(e,"constructor",{get(){if(s.shouldBlock()){let i=`${t} access is blocked during script execution`,c=s.recordViolation(n,t,i);throw new d(i,c)}return s.shouldAudit()&&s.recordViolation(n,t,`${t} accessed (audit mode)`),r},set(i){if(s.shouldBlock()){let c=`${t} modification is blocked during script execution`,a=s.recordViolation(n,t,c);throw new d(c,a)}Object.defineProperty(this,"constructor",{value:i,writable:!0,configurable:!0})},configurable:!0})}catch(o){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,o instanceof Error?o.message:o)}}protectProcessMainModule(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:t});let n=t?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let s="process.mainModule access is blocked during script execution",o=e.recordViolation("process_main_module","process.mainModule",s);throw new d(s,o)}return e.shouldAudit()&&e.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),n},set(s){if(e.shouldBlock()){let o="process.mainModule modification is blocked during script execution",r=e.recordViolation("process_main_module","process.mainModule",o);throw new d(o,r)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",t instanceof Error?t.message:t)}}protectProcessExecPath(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:t});let n=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let s="process.execPath access is blocked during script execution",o=e.recordViolation("process_exec_path","process.execPath",s);throw new d(s,o)}return e.shouldAudit()&&e.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),n},set(s){if(e.shouldBlock()){let o="process.execPath modification is blocked during script execution",r=e.recordViolation("process_exec_path","process.execPath",o);throw new d(o,r)}Object.defineProperty(process,"execPath",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",t instanceof Error?t.message:t)}}lockWellKnownSymbols(){let e=(t,n)=>{try{let s=Object.getOwnPropertyDescriptor(t,n);if(s?.configurable){if("value"in s){Object.defineProperty(t,n,{...s,configurable:!1,writable:!1});return}Object.defineProperty(t,n,{...s,configurable:!1})}}catch{}};for(let t of[Array,Map,Set,RegExp,Promise])e(t,Symbol.species);for(let t of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(t,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let t of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,t);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let t of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(t,Symbol.toStringTag)}protectProxyRevocable(){let e=this;try{let t=Proxy.revocable;if(typeof t!="function")return;let n=Object.getOwnPropertyDescriptor(Proxy,"revocable");this.originalDescriptors.push({target:Proxy,prop:"revocable",descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(o,r){if(e.shouldBlock()){let i="Proxy.revocable is blocked during script execution",c=e.recordViolation("proxy","Proxy.revocable",i);throw new d(i,c)}return e.shouldAudit()&&e.recordViolation("proxy","Proxy.revocable","Proxy.revocable called (audit mode)"),t(o,r)},writable:!1,configurable:!0})}catch(t){this.patchFailures.push("Proxy.revocable"),console.debug("[DefenseInDepthBox] Could not protect Proxy.revocable:",t instanceof Error?t.message:t)}}protectDynamicImport(){if(!(f||l.importHooksRegistered))try{let e=m;if(!e)throw new Error("node:module is unavailable");let t=new Set;for(let o of e.builtinModules??[]){let r=o.startsWith("node:")?o.slice(5):o;t.add(r);let i=r.indexOf("/");i>0&&t.add(r.slice(0,i))}let n=o=>{if(o.startsWith("./")||o.startsWith("../")||o.startsWith("/")||o.startsWith("file:")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("http:")||o.startsWith("https:"))return!1;let r=o.startsWith("node:")?o.slice(5):o;if(!r)return!1;if(typeof e.isBuiltin=="function"&&e.isBuiltin(r)||t.has(r))return!0;let i=r.indexOf("/");return i>0&&t.has(r.slice(0,i))},s=o=>{let r=p?.getStore();return o.config.auditMode===!0&&r?.sandboxActive===!0&&!l.isTrustedContext(r)};if(typeof e.registerHooks=="function"){e.registerHooks({resolve(o,r,i){let c=l.instance;if(!c)return i(o,r);if((o.startsWith("data:")||o.startsWith("blob:"))&&c.shouldBlock()){let a=`import(${o.startsWith("data:")?"data:":"blob:"})`,u=`dynamic import of ${o.startsWith("data:")?"data:":"blob:"} URLs is blocked by defense-in-depth`,h=c.recordViolation("dynamic_import_builtin",a,u);throw new d(u,h)}if(n(o)){let a=`import(${o})`,u=`dynamic import of Node.js builtin '${o}' is blocked during script execution`;if(c.shouldBlock()){let h=c.recordViolation("dynamic_import_builtin",a,u);throw new d(u,h)}s(c)&&c.recordViolation("dynamic_import_builtin",a,`dynamic import of Node.js builtin '${o}' called (audit mode)`)}return i(o,r)}}),l.importHooksRegistered=!0;return}throw new Error("context-aware ESM loader hooks (node:module.registerHooks) are unavailable")}catch(e){throw new Error(`DefenseInDepthBox: could not register dynamic-import hooks: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}protectModuleLoad(){this.protectModuleMethod("_load","module_load")}protectModuleResolveFilename(){this.protectModuleMethod("_resolveFilename","module_resolve_filename")}protectModuleMethod(e,t){if(f)return;let n=`Module.${e}`;try{let s=O,o=s?.[e];if(!s||typeof o!="function")throw new Error("node:module Module class or method is unavailable");let r=Object.getOwnPropertyDescriptor(s,e);if(!r)throw new Error("method has no own property descriptor");if(r.configurable===!1&&r.writable===!1)throw new Error("method is non-configurable and non-writable");let i=this.createBlockingProxy(o,n,t);this.originalDescriptors.push({target:s,prop:e,descriptor:r}),Object.defineProperty(s,e,{...r,value:i});let c=Object.getOwnPropertyDescriptor(s,e);if(s[e]!==i||c?.value!==i)throw new Error("installed patch failed verification")}catch{this.patchFailures.push(n)}}applyPatch(e,t=!1){let{target:n,prop:s,violationType:o,strategy:r}=e;try{let i=n[s];if(i===void 0)return;let c=Object.getOwnPropertyDescriptor(n,s);if(this.originalDescriptors.push({target:n,prop:s,descriptor:c}),r==="freeze"){if(typeof i=="object"&&i!==null){t&&Object.freeze(i);let a=this.getPathForTarget(n,s),u=this.createReadonlyObjectProxy(i,a,o);Object.defineProperty(n,s,{...c,value:u})}}else{let a=this.getPathForTarget(n,s),u=typeof i=="function"?this.createBlockingProxy(i,a,o):this.createBlockingObjectProxy(i,a,o,e.allowedKeys);Object.defineProperty(n,s,{value:u,writable:!0,configurable:!0})}}catch(i){let c=this.getPathForTarget(n,s);this.patchFailures.push(c),console.debug(`[DefenseInDepthBox] Could not patch ${c}:`,i instanceof Error?i.message:i)}}restorePatches(){for(let e=this.temporaryIntrinsicDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:s}=this.temporaryIntrinsicDescriptors[e];try{Object.defineProperty(t,n,s)}catch(o){console.debug(`[DefenseInDepthBox] Could not restore temporary intrinsic ${String(n)}:`,o instanceof Error?o.message:o)}}this.temporaryIntrinsicDescriptors=[];for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(t,n,s):delete t[n]}catch(o){let r=this.getPathForTarget(t,n);console.debug(`[DefenseInDepthBox] Could not restore ${r}:`,o instanceof Error?o.message:o)}}this.originalDescriptors=[]}};export{d as a,D as b};
|