just-bash 3.4.0 → 3.4.2

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.
Files changed (222) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/bin/chunks/{awk2-DZN2ZRSE.js → awk2-C4A37H5N.js} +1 -1
  3. package/dist/bin/{shell/chunks/base64-TP4NUOEB.js → chunks/base64-FLJ4YPHB.js} +1 -1
  4. package/dist/bin/chunks/{cat-A3REFE6L.js → cat-2J5MA5PY.js} +1 -1
  5. package/dist/bin/{shell/chunks/chmod-PHPDPTZD.js → chunks/chmod-ZM5WLMZI.js} +1 -1
  6. package/dist/bin/chunks/{chunk-ODPB5AH7.js → chunk-2HFDEZUY.js} +1 -1
  7. package/dist/bin/chunks/{chunk-DX5LO7JF.js → chunk-2INNLNI5.js} +1 -1
  8. package/dist/bin/chunks/{chunk-57BWX3A3.js → chunk-2ND6MMXN.js} +1 -1
  9. package/dist/bin/chunks/{chunk-QUWWWM4E.js → chunk-2ORJ5HTY.js} +1 -1
  10. package/dist/bin/chunks/{chunk-SOKKZSUV.js → chunk-3SCW7PD5.js} +1 -1
  11. package/dist/bin/chunks/{chunk-TKBTWIXO.js → chunk-42AMF6EE.js} +1 -1
  12. package/dist/bin/{shell/chunks/chunk-NFYXRUSI.js → chunks/chunk-44MQ5AXA.js} +1 -1
  13. package/dist/bin/chunks/{chunk-GE5ERIO2.js → chunk-4APSDE57.js} +1 -1
  14. package/dist/bin/chunks/{chunk-ODCVIRIN.js → chunk-74TZ7ZF7.js} +1 -1
  15. package/dist/bin/chunks/{chunk-OD2SHTFL.js → chunk-7WBCA2BB.js} +1 -1
  16. package/dist/bin/{shell/chunks/chunk-MOCKUJD6.js → chunks/chunk-APV27ZZW.js} +1 -1
  17. package/dist/bin/{shell/chunks/chunk-YB3A42T5.js → chunks/chunk-BCQSUELK.js} +1 -1
  18. package/dist/bin/chunks/{chunk-FC5CC5UP.js → chunk-BJRT4VKD.js} +1 -1
  19. package/dist/bin/chunks/{chunk-6WNZWDBA.js → chunk-BOYPCOSV.js} +1 -1
  20. package/dist/bin/chunks/{chunk-KHS7PCAP.js → chunk-BZWGVRFA.js} +2 -2
  21. package/dist/bin/chunks/{chunk-BPMGKB5E.js → chunk-EXGPMLIE.js} +1 -1
  22. package/dist/bin/{shell/chunks/chunk-MLJZPRDV.js → chunks/chunk-FB44CW33.js} +1 -1
  23. package/dist/bin/chunks/{chunk-35BSNGJK.js → chunk-GRP7L2EL.js} +1 -1
  24. package/dist/bin/{shell/chunks/chunk-3DCUOX7D.js → chunks/chunk-GTULZ3ZD.js} +1 -1
  25. package/dist/bin/{shell/chunks/chunk-O5R7J45W.js → chunks/chunk-HL7NFZVQ.js} +1 -1
  26. package/dist/bin/chunks/chunk-HWI42GQO.js +7 -0
  27. package/dist/bin/{shell/chunks/chunk-TY77F4UM.js → chunks/chunk-ISOWCECJ.js} +1 -1
  28. package/dist/bin/chunks/{chunk-TIYIKCEZ.js → chunk-JQM3DKCH.js} +1 -1
  29. package/dist/bin/{shell/chunks/chunk-NWBQ75GZ.js → chunks/chunk-MF3GVFLC.js} +1 -1
  30. package/dist/bin/chunks/{chunk-6KTOOQK6.js → chunk-MHAGHCSO.js} +1 -1
  31. package/dist/bin/{shell/chunks/chunk-62NF3462.js → chunks/chunk-MNSMZU47.js} +1 -1
  32. package/dist/bin/chunks/{chunk-GGPUS2B4.js → chunk-MRPJL3ZK.js} +1 -1
  33. package/dist/bin/{shell/chunks/chunk-IHS3YLRI.js → chunks/chunk-MYEPQX6Y.js} +1 -1
  34. package/dist/bin/chunks/{chunk-EJIZDPMG.js → chunk-PPVF2N6C.js} +1 -1
  35. package/dist/bin/{shell/chunks/chunk-7NMBLWZ5.js → chunks/chunk-QFTZKD5O.js} +1 -1
  36. package/dist/bin/chunks/{chunk-YABXNPH6.js → chunk-TIHFGNPS.js} +1 -1
  37. package/dist/bin/chunks/{chunk-YBTJPT3R.js → chunk-UHNV55NF.js} +1 -1
  38. package/dist/bin/{shell/chunks/chunk-XG7YUZ3R.js → chunks/chunk-UNKX6YM6.js} +1 -1
  39. package/dist/bin/{shell/chunks/chunk-BXDEO6VY.js → chunks/chunk-VKTV45AP.js} +1 -1
  40. package/dist/bin/{shell/chunks/expr-FAB3XEIB.js → chunks/expr-TDF3B6QJ.js} +1 -1
  41. package/dist/bin/{shell/chunks/file-ZHL2YACR.js → chunks/file-AJGG7RYT.js} +1 -1
  42. package/dist/bin/chunks/{flag-coverage-SPPGTKG3.js → flag-coverage-DOLZIUQ7.js} +1 -1
  43. package/dist/bin/{shell/chunks/grep-FBVRTH4M.js → chunks/grep-WUZMZDGY.js} +1 -1
  44. package/dist/bin/chunks/{gzip-AWQGRTSF.js → gzip-JA7JQBUS.js} +1 -1
  45. package/dist/bin/chunks/{head-A7CPWX7R.js → head-YGKW3HS4.js} +1 -1
  46. package/dist/bin/{shell/chunks/html-to-markdown-EMODJ24M.js → chunks/html-to-markdown-ZWL7LZIP.js} +1 -1
  47. package/dist/bin/chunks/{jq-DXL4NMI5.js → jq-5MI4V3G5.js} +1 -1
  48. package/dist/bin/chunks/{js-exec-BFLXGNPQ.js → js-exec-DJQLXWCS.js} +1 -1
  49. package/dist/bin/chunks/js-exec-worker.js +60 -4
  50. package/dist/bin/{shell/chunks/od-ZPR6FUOW.js → chunks/od-YCY27MMO.js} +1 -1
  51. package/dist/bin/{shell/chunks/paste-RQKXCKQO.js → chunks/paste-ACKOG3XS.js} +1 -1
  52. package/dist/bin/{shell/chunks/python3-WKVKCO33.js → chunks/python3-JCJHSX4Z.js} +1 -1
  53. package/dist/bin/chunks/{rg-34TWIR7N.js → rg-A3E7YM2A.js} +1 -1
  54. package/dist/bin/{shell/chunks/sed-SW74NKGU.js → chunks/sed-KJWKB22J.js} +1 -1
  55. package/dist/bin/chunks/{sleep-J2AVORMB.js → sleep-DVFE2GSF.js} +1 -1
  56. package/dist/bin/chunks/{split-EDDYGW4A.js → split-XMXBXL5Q.js} +1 -1
  57. package/dist/bin/chunks/{sqlite3-AZ27WWV7.js → sqlite3-DNH2VLVN.js} +1 -1
  58. package/dist/bin/chunks/sqlite3-worker.js +60 -4
  59. package/dist/bin/{shell/chunks/stat-XNGV2W6W.js → chunks/stat-5PUSTPTK.js} +1 -1
  60. package/dist/bin/chunks/{tail-H2WOZSEI.js → tail-4MB7HHIZ.js} +1 -1
  61. package/dist/bin/chunks/{tar-MZP7QXR4.js → tar-FRDUJZDN.js} +1 -1
  62. package/dist/bin/{shell/chunks/timeout-GH6S72QX.js → chunks/timeout-YGFHQJKX.js} +1 -1
  63. package/dist/bin/chunks/{tr-RVCBERJ4.js → tr-Z6N34HZM.js} +1 -1
  64. package/dist/bin/chunks/worker.js +60 -4
  65. package/dist/bin/chunks/{xan-BSNJF6SH.js → xan-VSF6ZQGZ.js} +1 -1
  66. package/dist/bin/chunks/{xan-view-H3LNQ72O.js → xan-view-UEFBHYVN.js} +1 -1
  67. package/dist/bin/chunks/{yq-GNMXK6OP.js → yq-K5N5JD4N.js} +1 -1
  68. package/dist/bin/just-bash.js +1 -1
  69. package/dist/bin/shell/chunks/{awk2-DZN2ZRSE.js → awk2-C4A37H5N.js} +1 -1
  70. package/dist/bin/{chunks/base64-TP4NUOEB.js → shell/chunks/base64-FLJ4YPHB.js} +1 -1
  71. package/dist/bin/shell/chunks/{cat-A3REFE6L.js → cat-2J5MA5PY.js} +1 -1
  72. package/dist/bin/{chunks/chmod-PHPDPTZD.js → shell/chunks/chmod-ZM5WLMZI.js} +1 -1
  73. package/dist/bin/shell/chunks/{chunk-ODPB5AH7.js → chunk-2HFDEZUY.js} +1 -1
  74. package/dist/bin/shell/chunks/{chunk-DX5LO7JF.js → chunk-2INNLNI5.js} +1 -1
  75. package/dist/bin/shell/chunks/{chunk-57BWX3A3.js → chunk-2ND6MMXN.js} +1 -1
  76. package/dist/bin/shell/chunks/{chunk-QUWWWM4E.js → chunk-2ORJ5HTY.js} +1 -1
  77. package/dist/bin/shell/chunks/{chunk-SOKKZSUV.js → chunk-3SCW7PD5.js} +1 -1
  78. package/dist/bin/shell/chunks/{chunk-TKBTWIXO.js → chunk-42AMF6EE.js} +1 -1
  79. package/dist/bin/{chunks/chunk-NFYXRUSI.js → shell/chunks/chunk-44MQ5AXA.js} +1 -1
  80. package/dist/bin/shell/chunks/{chunk-GE5ERIO2.js → chunk-4APSDE57.js} +1 -1
  81. package/dist/bin/shell/chunks/{chunk-ODCVIRIN.js → chunk-74TZ7ZF7.js} +1 -1
  82. package/dist/bin/shell/chunks/{chunk-OD2SHTFL.js → chunk-7WBCA2BB.js} +1 -1
  83. package/dist/bin/{chunks/chunk-MOCKUJD6.js → shell/chunks/chunk-APV27ZZW.js} +1 -1
  84. package/dist/bin/{chunks/chunk-YB3A42T5.js → shell/chunks/chunk-BCQSUELK.js} +1 -1
  85. package/dist/bin/shell/chunks/{chunk-FC5CC5UP.js → chunk-BJRT4VKD.js} +1 -1
  86. package/dist/bin/shell/chunks/{chunk-6WNZWDBA.js → chunk-BOYPCOSV.js} +1 -1
  87. package/dist/bin/shell/chunks/{chunk-KHS7PCAP.js → chunk-BZWGVRFA.js} +2 -2
  88. package/dist/bin/shell/chunks/{chunk-BPMGKB5E.js → chunk-EXGPMLIE.js} +1 -1
  89. package/dist/bin/{chunks/chunk-MLJZPRDV.js → shell/chunks/chunk-FB44CW33.js} +1 -1
  90. package/dist/bin/shell/chunks/{chunk-35BSNGJK.js → chunk-GRP7L2EL.js} +1 -1
  91. package/dist/bin/{chunks/chunk-3DCUOX7D.js → shell/chunks/chunk-GTULZ3ZD.js} +1 -1
  92. package/dist/bin/{chunks/chunk-O5R7J45W.js → shell/chunks/chunk-HL7NFZVQ.js} +1 -1
  93. package/dist/bin/shell/chunks/chunk-HWI42GQO.js +7 -0
  94. package/dist/bin/{chunks/chunk-TY77F4UM.js → shell/chunks/chunk-ISOWCECJ.js} +1 -1
  95. package/dist/bin/shell/chunks/{chunk-TIYIKCEZ.js → chunk-JQM3DKCH.js} +1 -1
  96. package/dist/bin/{chunks/chunk-NWBQ75GZ.js → shell/chunks/chunk-MF3GVFLC.js} +1 -1
  97. package/dist/bin/shell/chunks/{chunk-6KTOOQK6.js → chunk-MHAGHCSO.js} +1 -1
  98. package/dist/bin/{chunks/chunk-62NF3462.js → shell/chunks/chunk-MNSMZU47.js} +1 -1
  99. package/dist/bin/shell/chunks/{chunk-GGPUS2B4.js → chunk-MRPJL3ZK.js} +1 -1
  100. package/dist/bin/{chunks/chunk-IHS3YLRI.js → shell/chunks/chunk-MYEPQX6Y.js} +1 -1
  101. package/dist/bin/shell/chunks/{chunk-EJIZDPMG.js → chunk-PPVF2N6C.js} +1 -1
  102. package/dist/bin/{chunks/chunk-7NMBLWZ5.js → shell/chunks/chunk-QFTZKD5O.js} +1 -1
  103. package/dist/bin/shell/chunks/{chunk-YABXNPH6.js → chunk-TIHFGNPS.js} +1 -1
  104. package/dist/bin/shell/chunks/{chunk-YBTJPT3R.js → chunk-UHNV55NF.js} +1 -1
  105. package/dist/bin/{chunks/chunk-XG7YUZ3R.js → shell/chunks/chunk-UNKX6YM6.js} +1 -1
  106. package/dist/bin/{chunks/chunk-BXDEO6VY.js → shell/chunks/chunk-VKTV45AP.js} +1 -1
  107. package/dist/bin/{chunks/expr-FAB3XEIB.js → shell/chunks/expr-TDF3B6QJ.js} +1 -1
  108. package/dist/bin/{chunks/file-ZHL2YACR.js → shell/chunks/file-AJGG7RYT.js} +1 -1
  109. package/dist/bin/shell/chunks/{flag-coverage-SPPGTKG3.js → flag-coverage-DOLZIUQ7.js} +1 -1
  110. package/dist/bin/{chunks/grep-FBVRTH4M.js → shell/chunks/grep-WUZMZDGY.js} +1 -1
  111. package/dist/bin/shell/chunks/{gzip-AWQGRTSF.js → gzip-JA7JQBUS.js} +1 -1
  112. package/dist/bin/shell/chunks/{head-A7CPWX7R.js → head-YGKW3HS4.js} +1 -1
  113. package/dist/bin/{chunks/html-to-markdown-EMODJ24M.js → shell/chunks/html-to-markdown-ZWL7LZIP.js} +1 -1
  114. package/dist/bin/shell/chunks/{jq-DXL4NMI5.js → jq-5MI4V3G5.js} +1 -1
  115. package/dist/bin/shell/chunks/{js-exec-BFLXGNPQ.js → js-exec-DJQLXWCS.js} +1 -1
  116. package/dist/bin/{chunks/od-ZPR6FUOW.js → shell/chunks/od-YCY27MMO.js} +1 -1
  117. package/dist/bin/{chunks/paste-RQKXCKQO.js → shell/chunks/paste-ACKOG3XS.js} +1 -1
  118. package/dist/bin/{chunks/python3-WKVKCO33.js → shell/chunks/python3-JCJHSX4Z.js} +1 -1
  119. package/dist/bin/shell/chunks/{rg-34TWIR7N.js → rg-A3E7YM2A.js} +1 -1
  120. package/dist/bin/{chunks/sed-SW74NKGU.js → shell/chunks/sed-KJWKB22J.js} +1 -1
  121. package/dist/bin/shell/chunks/{sleep-J2AVORMB.js → sleep-DVFE2GSF.js} +1 -1
  122. package/dist/bin/shell/chunks/{split-EDDYGW4A.js → split-XMXBXL5Q.js} +1 -1
  123. package/dist/bin/shell/chunks/{sqlite3-AZ27WWV7.js → sqlite3-DNH2VLVN.js} +1 -1
  124. package/dist/bin/{chunks/stat-XNGV2W6W.js → shell/chunks/stat-5PUSTPTK.js} +1 -1
  125. package/dist/bin/shell/chunks/{tail-H2WOZSEI.js → tail-4MB7HHIZ.js} +1 -1
  126. package/dist/bin/shell/chunks/{tar-MZP7QXR4.js → tar-FRDUJZDN.js} +1 -1
  127. package/dist/bin/{chunks/timeout-GH6S72QX.js → shell/chunks/timeout-YGFHQJKX.js} +1 -1
  128. package/dist/bin/shell/chunks/{tr-RVCBERJ4.js → tr-Z6N34HZM.js} +1 -1
  129. package/dist/bin/shell/chunks/{xan-BSNJF6SH.js → xan-VSF6ZQGZ.js} +1 -1
  130. package/dist/bin/shell/chunks/{xan-view-H3LNQ72O.js → xan-view-UEFBHYVN.js} +1 -1
  131. package/dist/bin/shell/chunks/{yq-GNMXK6OP.js → yq-K5N5JD4N.js} +1 -1
  132. package/dist/bin/shell/shell.js +1 -1
  133. package/dist/bundle/browser.js +446 -444
  134. package/dist/bundle/chunks/{awk2-IDCJYLV2.js → awk2-NPLZQ3K7.js} +1 -1
  135. package/dist/bundle/chunks/{base64-3XQZ3ADB.js → base64-2BAITDZF.js} +1 -1
  136. package/dist/bundle/chunks/{cat-XWS72C47.js → cat-33KGN4MZ.js} +1 -1
  137. package/dist/bundle/chunks/{chmod-6FVWFWKL.js → chmod-APOXUPXW.js} +1 -1
  138. package/dist/bundle/chunks/{chunk-JQL34RLH.js → chunk-3CBCABOZ.js} +1 -1
  139. package/dist/bundle/chunks/{chunk-EZFSCUSP.js → chunk-5ELNHAAJ.js} +1 -1
  140. package/dist/bundle/chunks/{chunk-M7DIEMEN.js → chunk-6DTD75TR.js} +1 -1
  141. package/dist/bundle/chunks/{chunk-5GI2HJYO.js → chunk-6KK46B7Q.js} +1 -1
  142. package/dist/bundle/chunks/{chunk-264HW33U.js → chunk-7IFSXTCJ.js} +1 -1
  143. package/dist/bundle/chunks/{chunk-4MPKG4PJ.js → chunk-A3D7NRT6.js} +1 -1
  144. package/dist/bundle/chunks/{chunk-EVJMYTCY.js → chunk-ALOFNPKY.js} +2 -2
  145. package/dist/bundle/chunks/{chunk-QKQP2SCP.js → chunk-BKUWXPEM.js} +1 -1
  146. package/dist/bundle/chunks/{chunk-W4IV5QW4.js → chunk-CFBEDNHJ.js} +1 -1
  147. package/dist/bundle/chunks/{chunk-CVMQI27W.js → chunk-DMWNBCXJ.js} +1 -1
  148. package/dist/bundle/chunks/{chunk-VQCA62JK.js → chunk-FNEG7DFQ.js} +1 -1
  149. package/dist/bundle/chunks/{chunk-ENMIHC6G.js → chunk-GVKYQN5J.js} +1 -1
  150. package/dist/bundle/chunks/{chunk-QNXJ5FEA.js → chunk-ICQYTW7W.js} +1 -1
  151. package/dist/bundle/chunks/{chunk-4X2R47I5.js → chunk-JA6EY7US.js} +1 -1
  152. package/dist/bundle/chunks/{chunk-XJWBSZIU.js → chunk-MHY57JTL.js} +1 -1
  153. package/dist/bundle/chunks/{chunk-XZZSXYTK.js → chunk-N3A4JVFJ.js} +1 -1
  154. package/dist/bundle/chunks/{chunk-HZYCWAEC.js → chunk-N3FZSEG7.js} +1 -1
  155. package/dist/bundle/chunks/{chunk-MP3NNO6W.js → chunk-Q6JV5CBB.js} +1 -1
  156. package/dist/bundle/chunks/{chunk-2TLWENMK.js → chunk-QE275OWT.js} +1 -1
  157. package/dist/bundle/chunks/{chunk-GP3D65AC.js → chunk-QPZVR6ZN.js} +1 -1
  158. package/dist/bundle/chunks/{chunk-CA7HMEGG.js → chunk-SI5VPVOA.js} +1 -1
  159. package/dist/bundle/chunks/{chunk-LDCENVG4.js → chunk-TVJ6JVK4.js} +1 -1
  160. package/dist/bundle/chunks/{chunk-UGU4ZDZA.js → chunk-UL6YJ7FT.js} +1 -1
  161. package/dist/bundle/chunks/{chunk-CYCUGNN7.js → chunk-USNDURQI.js} +1 -1
  162. package/dist/bundle/chunks/{chunk-VPJHPG6G.js → chunk-UXHSH7BM.js} +1 -1
  163. package/dist/bundle/chunks/{chunk-6D2ZCRTO.js → chunk-V2SOLEQN.js} +1 -1
  164. package/dist/bundle/chunks/{chunk-QXYDKHGI.js → chunk-WXPNKIIH.js} +1 -1
  165. package/dist/bundle/chunks/{chunk-XW6UBSKO.js → chunk-X3TZEFQG.js} +1 -1
  166. package/dist/bundle/chunks/{chunk-73DVPW3C.js → chunk-XMMV24SP.js} +1 -1
  167. package/dist/bundle/chunks/{chunk-FFNWVPYL.js → chunk-XPDOK3XY.js} +1 -1
  168. package/dist/bundle/chunks/{chunk-MMSRUX6V.js → chunk-XV2V56NQ.js} +1 -1
  169. package/dist/bundle/chunks/{chunk-XOBSBDA5.js → chunk-YDR2IWKO.js} +1 -1
  170. package/dist/bundle/chunks/{chunk-KESUKNUF.js → chunk-YJKHREBZ.js} +1 -1
  171. package/dist/bundle/chunks/chunk-ZBUZKIPX.js +6 -0
  172. package/dist/bundle/chunks/{expr-VKQHAJNO.js → expr-UMT2OHZ7.js} +1 -1
  173. package/dist/bundle/chunks/{file-WGI2QYXG.js → file-VEGKTTSF.js} +1 -1
  174. package/dist/bundle/chunks/{flag-coverage-6LWPOTGE.js → flag-coverage-I6UJUKQ4.js} +1 -1
  175. package/dist/bundle/chunks/{grep-SAEHL7UZ.js → grep-5UPEO42U.js} +1 -1
  176. package/dist/bundle/chunks/{gzip-2SHFSHNB.js → gzip-ZINVK3M6.js} +1 -1
  177. package/dist/bundle/chunks/{head-RMKV5HCV.js → head-CFENJILH.js} +1 -1
  178. package/dist/bundle/chunks/{html-to-markdown-GEKF6U7Z.js → html-to-markdown-GGVR4YGL.js} +1 -1
  179. package/dist/bundle/chunks/{jq-MW2VEOCW.js → jq-X2P7Q64K.js} +1 -1
  180. package/dist/bundle/chunks/{js-exec-J4DLDAWY.js → js-exec-XKF2B7C3.js} +1 -1
  181. package/dist/bundle/chunks/js-exec-worker.js +60 -4
  182. package/dist/bundle/chunks/{od-26HTHXXM.js → od-BI6XJPXY.js} +1 -1
  183. package/dist/bundle/chunks/{paste-WIDT5N6N.js → paste-LLZ3ZQR2.js} +1 -1
  184. package/dist/bundle/chunks/{python3-4Q7M5CDT.js → python3-F5S5TYGS.js} +1 -1
  185. package/dist/bundle/chunks/{rg-IA4UE2UF.js → rg-UQE6KUBP.js} +1 -1
  186. package/dist/bundle/chunks/{sed-LSWWSQ6J.js → sed-JW2JDLSI.js} +1 -1
  187. package/dist/bundle/chunks/{sleep-YMKR4HFQ.js → sleep-PPRBTSVR.js} +1 -1
  188. package/dist/bundle/chunks/{split-EATPU6Q7.js → split-2SD6EP72.js} +1 -1
  189. package/dist/bundle/chunks/{sqlite3-XXXHFJGP.js → sqlite3-UVVRYDAL.js} +1 -1
  190. package/dist/bundle/chunks/sqlite3-worker.js +60 -4
  191. package/dist/bundle/chunks/{stat-AKB6X3TV.js → stat-6KILP5AL.js} +1 -1
  192. package/dist/bundle/chunks/{tail-OEM7DTYC.js → tail-BDNMS4FR.js} +1 -1
  193. package/dist/bundle/chunks/{tar-26DH77YN.js → tar-6365WH6H.js} +1 -1
  194. package/dist/bundle/chunks/{timeout-FOKHN3GQ.js → timeout-C6WDYPLV.js} +1 -1
  195. package/dist/bundle/chunks/{tr-VUNRKFC3.js → tr-3I4MDKIF.js} +1 -1
  196. package/dist/bundle/chunks/worker.js +60 -4
  197. package/dist/bundle/chunks/{xan-LUEGYXLV.js → xan-HUOXKUQA.js} +1 -1
  198. package/dist/bundle/chunks/{xan-view-MDMZTFFI.js → xan-view-RT2WKDOQ.js} +1 -1
  199. package/dist/bundle/chunks/{yq-B7E6UX7Y.js → yq-MI27NZ2U.js} +1 -1
  200. package/dist/bundle/index.cjs +874 -872
  201. package/dist/bundle/index.js +1 -1
  202. package/dist/commands/sqlite3/worker.js +60 -4
  203. package/dist/security/blocked-globals.d.ts +60 -0
  204. package/dist/security/defense-context.d.ts +13 -0
  205. package/dist/security/defense-in-depth-box.d.ts +354 -0
  206. package/dist/security/index.d.ts +33 -0
  207. package/dist/security/safe-timestamp.d.ts +1 -0
  208. package/dist/security/security-violation-logger.d.ts +99 -0
  209. package/dist/security/trusted-globals.d.ts +17 -0
  210. package/dist/security/types.d.ts +151 -0
  211. package/dist/security/violation-error-message.d.ts +3 -0
  212. package/dist/security/wasm-callback.d.ts +6 -0
  213. package/dist/security/worker-defense-in-depth.d.ts +228 -0
  214. package/dist/transform/pipeline.d.ts +8 -0
  215. package/dist/transform/plugins/command-collector.d.ts +15 -0
  216. package/dist/transform/plugins/tee-plugin.d.ts +40 -0
  217. package/dist/transform/serialize.d.ts +4 -0
  218. package/dist/transform/types.d.ts +18 -0
  219. package/package.json +4 -2
  220. package/dist/bin/chunks/chunk-SHAOH2UJ.js +0 -5
  221. package/dist/bin/shell/chunks/chunk-SHAOH2UJ.js +0 -5
  222. package/dist/bundle/chunks/chunk-RT7ROXPF.js +0 -4
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Worker Defense-in-Depth
3
+ *
4
+ * A simplified version of DefenseInDepthBox designed for use in Worker threads.
5
+ * Since workers have their own isolated V8 context, we don't need AsyncLocalStorage
6
+ * to track execution context - the entire worker IS the sandboxed context.
7
+ *
8
+ * Key differences from DefenseInDepthBox:
9
+ * - No AsyncLocalStorage (always blocks, no context tracking needed)
10
+ * - Single activation model (apply patches once at worker startup)
11
+ * - Violations reported via callback (typically postMessage to parent)
12
+ *
13
+ * Usage in a worker:
14
+ * ```typescript
15
+ * import { parentPort } from 'node:worker_threads';
16
+ * import { WorkerDefenseInDepth } from '../security/worker-defense-in-depth.js';
17
+ *
18
+ * // Apply patches at worker startup
19
+ * const defense = new WorkerDefenseInDepth({
20
+ * onViolation: (v) => parentPort?.postMessage({ type: 'security-violation', violation: v }),
21
+ * });
22
+ *
23
+ * // All code in the worker is now protected
24
+ * // Attempting Function, eval, etc. will throw SecurityViolationError
25
+ * ```
26
+ *
27
+ * Constructor Protection:
28
+ * Function.prototype.constructor returns a proxy that allows property reads
29
+ * (e.g., `.constructor.name` for type introspection) but blocks invocation
30
+ * (e.g., `.constructor("code")` for dynamic code execution).
31
+ *
32
+ * IMPORTANT: This is a SECONDARY defense layer. It should never be relied upon
33
+ * as the primary security mechanism. The primary security comes from proper
34
+ * sandboxing, input validation, and architectural constraints.
35
+ *
36
+ * Dynamic import() mitigation (three layers):
37
+ * 1. Module._resolveFilename blocked — catches file-based specifiers
38
+ * 2. Main-thread ESM loader hooks block data:/blob: URLs (not in workers)
39
+ * 3. Filesystem restrictions — OverlayFs writes to memory only
40
+ *
41
+ * Note: ESM loader hooks are registered by DefenseInDepthBox in the main
42
+ * thread. Workers inherit the hooks automatically. Worker-level registration
43
+ * is not needed (and would require require('node:module') which is blocked).
44
+ */
45
+ import type { DefenseInDepthConfig, SecurityViolation } from "./types.js";
46
+ /**
47
+ * Error thrown when a security violation is detected.
48
+ */
49
+ export declare class WorkerSecurityViolationError extends Error {
50
+ readonly violation: SecurityViolation;
51
+ constructor(message: string, violation: SecurityViolation);
52
+ }
53
+ /**
54
+ * Statistics about the worker defense layer.
55
+ */
56
+ export interface WorkerDefenseStats {
57
+ /** Total number of violations detected */
58
+ violationsBlocked: number;
59
+ /** List of all violations detected (capped to prevent memory issues) */
60
+ violations: SecurityViolation[];
61
+ /** Whether patches are currently active */
62
+ isActive: boolean;
63
+ }
64
+ /**
65
+ * Worker Defense-in-Depth
66
+ *
67
+ * Applies security patches to dangerous JavaScript globals in a worker context.
68
+ * Unlike DefenseInDepthBox, this is designed for workers where the entire
69
+ * execution context is sandboxed.
70
+ */
71
+ export declare class WorkerDefenseInDepth {
72
+ private config;
73
+ private isActivated;
74
+ private originalDescriptors;
75
+ private patchFailures;
76
+ private violations;
77
+ private executionId;
78
+ /**
79
+ * Original Proxy constructor, captured before patching.
80
+ * This is captured at instance creation time to ensure we get the unpatched version.
81
+ */
82
+ private originalProxy;
83
+ /**
84
+ * Recursion guard to prevent infinite loops when proxy traps trigger
85
+ * code that accesses the same proxied object (e.g., process.env).
86
+ */
87
+ private inTrap;
88
+ /**
89
+ * Create and activate the worker defense layer.
90
+ *
91
+ * @param config - Configuration for the defense layer
92
+ */
93
+ constructor(config: DefenseInDepthConfig);
94
+ /**
95
+ * Get statistics about the defense layer.
96
+ */
97
+ getStats(): WorkerDefenseStats;
98
+ /**
99
+ * Clear stored violations. Useful for testing.
100
+ */
101
+ clearViolations(): void;
102
+ /**
103
+ * Get the execution ID for this worker.
104
+ */
105
+ getExecutionId(): string;
106
+ /**
107
+ * Deactivate the defense layer and restore original globals.
108
+ * Typically only needed for testing.
109
+ */
110
+ deactivate(): void;
111
+ /**
112
+ * Activate the defense layer by applying patches.
113
+ */
114
+ private activate;
115
+ /**
116
+ * Get a human-readable path for a target object and property.
117
+ */
118
+ private getPathForTarget;
119
+ /**
120
+ * Record a violation and invoke the callback.
121
+ * In worker context, blocking always happens (no audit mode context check).
122
+ */
123
+ private recordViolation;
124
+ /**
125
+ * Create a blocking proxy for a function.
126
+ * In worker context, always blocks (no context check needed).
127
+ */
128
+ private createBlockingProxy;
129
+ /**
130
+ * Create a blocking proxy for an object (blocks all property access).
131
+ */
132
+ private createBlockingObjectProxy;
133
+ private createReadonlyObjectProxy;
134
+ /**
135
+ * Apply security patches to dangerous globals.
136
+ */
137
+ private applyPatches;
138
+ /**
139
+ * Lock well-known Symbol properties on built-in constructors/prototypes.
140
+ */
141
+ private lockWellKnownSymbols;
142
+ /**
143
+ * Block Proxy.revocable to prevent bypassing Proxy constructor blocking.
144
+ *
145
+ * Proxy.revocable internally uses the real Proxy constructor, so it bypasses
146
+ * our blocking proxy on globalThis.Proxy. We replace it with a wrapper that
147
+ * always blocks in worker context.
148
+ */
149
+ private protectProxyRevocable;
150
+ /**
151
+ * Protect against .constructor.constructor escape vector.
152
+ * @param excludeTypes - Set of violation types to skip
153
+ */
154
+ private protectConstructorChain;
155
+ /**
156
+ * Protect Error.prepareStackTrace from being set.
157
+ */
158
+ private protectErrorPrepareStackTrace;
159
+ /**
160
+ * Patch a prototype's constructor property.
161
+ *
162
+ * Returns a proxy that allows reading properties (like .name) but blocks
163
+ * calling the constructor as a function (which would allow code execution).
164
+ */
165
+ private patchPrototypeConstructor;
166
+ /**
167
+ * Protect process.mainModule from being accessed or set.
168
+ *
169
+ * The attack vector is:
170
+ * ```
171
+ * process.mainModule.require('child_process').execSync('whoami')
172
+ * process.mainModule.constructor._load('vm')
173
+ * ```
174
+ *
175
+ * process.mainModule may be undefined in ESM contexts but could exist in
176
+ * CommonJS workers. We block both reading and setting.
177
+ */
178
+ private protectProcessMainModule;
179
+ /**
180
+ * Protect process.execPath from being read or set in worker context.
181
+ *
182
+ * process.execPath is a string primitive (not an object), so it cannot be
183
+ * proxied via the normal blocked globals mechanism. We use Object.defineProperty
184
+ * with getter/setter (same pattern as protectProcessMainModule).
185
+ */
186
+ private protectProcessExecPath;
187
+ /**
188
+ * Protect process.connected from being read or set in worker context.
189
+ *
190
+ * process.connected is a boolean primitive (not an object), so it cannot be
191
+ * proxied via the normal blocked globals mechanism. We use Object.defineProperty
192
+ * with getter/setter (same pattern as protectProcessExecPath).
193
+ *
194
+ * Only protects if process.connected exists (IPC contexts).
195
+ */
196
+ private protectProcessConnected;
197
+ /**
198
+ * Protect Module._load from being called.
199
+ *
200
+ * The attack vector is:
201
+ * ```
202
+ * module.constructor._load('child_process')
203
+ * require.main.constructor._load('vm')
204
+ * ```
205
+ *
206
+ * We access the Module class and replace _load with a blocking proxy.
207
+ */
208
+ private protectModuleLoad;
209
+ /**
210
+ * Protect Module._resolveFilename from being called in worker context.
211
+ *
212
+ * Module._resolveFilename is called for both require() and import() resolution.
213
+ * Blocking it catches file-based import() specifiers.
214
+ *
215
+ * data: and blob: URLs are handled by ESM loader hooks registered
216
+ * in the main thread (DefenseInDepthBox.protectDynamicImport).
217
+ */
218
+ private protectModuleResolveFilename;
219
+ private protectModuleMethod;
220
+ /**
221
+ * Apply a single patch to a blocked global.
222
+ */
223
+ private applyPatch;
224
+ /**
225
+ * Restore all original values.
226
+ */
227
+ private restorePatches;
228
+ }
@@ -0,0 +1,8 @@
1
+ import type { BashTransformResult, TransformPlugin } from "./types.js";
2
+ export declare class BashTransformPipeline<TMetadata extends object = Record<string, never>> {
3
+ private readonly maxSourceBytes;
4
+ private plugins;
5
+ constructor(maxSourceBytes?: number);
6
+ use<M extends object>(plugin: TransformPlugin<M>): BashTransformPipeline<TMetadata & M>;
7
+ transform(script: string): BashTransformResult<TMetadata>;
8
+ }
@@ -0,0 +1,15 @@
1
+ import type { TransformContext, TransformPlugin, TransformResult } from "../types.js";
2
+ export interface CommandCollectorMetadata {
3
+ commands: string[];
4
+ }
5
+ export declare class CommandCollectorPlugin implements TransformPlugin<CommandCollectorMetadata> {
6
+ readonly name = "command-collector";
7
+ transform(context: TransformContext): TransformResult<CommandCollectorMetadata>;
8
+ private walkScript;
9
+ private walkStatement;
10
+ private walkPipeline;
11
+ private walkCommand;
12
+ private walkWordParts;
13
+ private walkParameterOp;
14
+ private extractName;
15
+ }
@@ -0,0 +1,40 @@
1
+ import type { TransformContext, TransformPlugin, TransformResult } from "../types.js";
2
+ export interface TeePluginOptions {
3
+ outputDir: string;
4
+ targetCommandPattern?: {
5
+ test(input: string): boolean;
6
+ };
7
+ timestamp?: Date;
8
+ }
9
+ export interface TeeFileInfo {
10
+ commandIndex: number;
11
+ commandName: string;
12
+ /** The full command string (name + arguments) before tee wrapping */
13
+ command: string;
14
+ stdoutFile: string;
15
+ }
16
+ export interface TeePluginMetadata {
17
+ teeFiles: TeeFileInfo[];
18
+ }
19
+ export declare class TeePlugin implements TransformPlugin<TeePluginMetadata> {
20
+ readonly name = "tee";
21
+ private options;
22
+ private counter;
23
+ constructor(options: TeePluginOptions);
24
+ transform(context: TransformContext): TransformResult<TeePluginMetadata>;
25
+ private formatTimestamp;
26
+ private generateStdoutPath;
27
+ private encodeCommandName;
28
+ private transformScript;
29
+ private transformStatement;
30
+ private transformPipeline;
31
+ /**
32
+ * Restore PIPESTATUS and exit code without user-visible variables.
33
+ * Produces: `builtin __just_bash_tee_restore ${PIPESTATUS[i]} ...`
34
+ */
35
+ private makePipestatusRestore;
36
+ private shouldTarget;
37
+ private getCommandName;
38
+ private serializeCommand;
39
+ private makeTeeCommand;
40
+ }
@@ -0,0 +1,4 @@
1
+ import type { ScriptNode, WordNode } from "../ast/types.js";
2
+ export declare function serialize(node: ScriptNode): string;
3
+ export { serializeWord };
4
+ declare function serializeWord(node: WordNode): string;
@@ -0,0 +1,18 @@
1
+ import type { ScriptNode } from "../ast/types.js";
2
+ export interface TransformPlugin<TMetadata extends object = Record<string, unknown>> {
3
+ name: string;
4
+ transform(context: TransformContext): TransformResult<TMetadata>;
5
+ }
6
+ export interface TransformContext {
7
+ ast: ScriptNode;
8
+ metadata: Record<string, unknown>;
9
+ }
10
+ export interface TransformResult<TMetadata extends object = Record<string, unknown>> {
11
+ ast: ScriptNode;
12
+ metadata?: TMetadata;
13
+ }
14
+ export interface BashTransformResult<TMetadata extends object = Record<string, unknown>> {
15
+ script: string;
16
+ ast: ScriptNode;
17
+ metadata: TMetadata;
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-bash",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "A simulated bash environment with virtual filesystem",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,6 +46,8 @@
46
46
  "dist/network/**/*.d.ts",
47
47
  "dist/parser/*.d.ts",
48
48
  "dist/sandbox/*.d.ts",
49
+ "dist/security/*.d.ts",
50
+ "dist/transform/**/*.d.ts",
49
51
  "dist/utils/*.d.ts",
50
52
  "vendor/cpython-emscripten/",
51
53
  "README.md",
@@ -117,7 +119,7 @@
117
119
  "knip": "knip",
118
120
  "test": "vitest",
119
121
  "test:run": "vitest run --exclude src/security/fuzzing/ --exclude src/commands/python3/ --exclude src/commands/sqlite3/ --exclude src/commands/js-exec/ --exclude src/agent-examples/python-scripting.test.ts",
120
- "test:dist": "vitest run src/cli/just-bash.bundle.test.ts",
122
+ "test:dist": "vitest run src/cli/just-bash.bundle.test.ts src/package-contents.test.ts",
121
123
  "test:unit": "vitest run --config vitest.unit.config.ts",
122
124
  "test:wasm": "vitest run --config vitest.wasm.config.ts",
123
125
  "test:comparison": "vitest run --config vitest.comparison.config.ts",
@@ -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};