reeval 0.13.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/THIRD_PARTY_NOTICES.md +190 -190
- package/assets/gateway-models.mjs +74 -0
- package/dist/{adapter-IKKo4sZj.js → adapter-CbqbMR7y.js} +55 -14
- package/dist/adapter-CbqbMR7y.js.map +1 -0
- package/dist/{agent-ClE-g9VL.js → agent-Zgn-kiqq.js} +105 -35
- package/dist/agent-Zgn-kiqq.js.map +1 -0
- package/dist/{analysis-B0nOfAzA.js → analysis-C2-aEbr7.js} +4 -4
- package/dist/{analysis-B0nOfAzA.js.map → analysis-C2-aEbr7.js.map} +1 -1
- package/dist/app-files-ChbvRx3P.js +11 -0
- package/dist/app-files-ChbvRx3P.js.map +1 -0
- package/dist/{assemble-BO93VAk1.js → assemble-SKQGW_QF.js} +213 -136
- package/dist/assemble-SKQGW_QF.js.map +1 -0
- package/dist/assemble-XBWuK3Ed.js +1 -0
- package/dist/{attempt-jI0OWxlz.js → attempt-Ba2QerOK.js} +10 -10
- package/dist/{attempt-jI0OWxlz.js.map → attempt-Ba2QerOK.js.map} +1 -1
- package/dist/attempt-host-BOp8JklD.js +295 -0
- package/dist/attempt-host-BOp8JklD.js.map +1 -0
- package/dist/{capture-dn2hjSLj.js → capture-BM_3100g.js} +600 -53
- package/dist/capture-BM_3100g.js.map +1 -0
- package/dist/capture-DSK8O5bA.js +1 -0
- package/dist/{cli-BCE1xlm4.js → cli-PdYrcoKM.js} +177 -249
- package/dist/cli-PdYrcoKM.js.map +1 -0
- package/dist/{cli-spec-BXIBUlaK.js → cli-spec-D0qyrPZi.js} +9 -21
- package/dist/cli-spec-D0qyrPZi.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/{assert-EUIoRdIt.js → client-Ct6s6OnF.js} +106 -3
- package/dist/client-Ct6s6OnF.js.map +1 -0
- package/dist/{command-CANun0m0.js → command-4pJYVCT4.js} +34 -21
- package/dist/command-4pJYVCT4.js.map +1 -0
- package/dist/{validate-DWjkshl1.js → command-9xm5ImqI.js} +420 -60
- package/dist/command-9xm5ImqI.js.map +1 -0
- package/dist/{command-D_kEnYcX.js → command-BqBxLgTc.js} +33 -31
- package/dist/command-BqBxLgTc.js.map +1 -0
- package/dist/{command-Bh3yhN_b.js → command-DbSMcxZL.js} +35 -15
- package/dist/command-DbSMcxZL.js.map +1 -0
- package/dist/{commands-7tH3EsVu.js → commands-BU6YJCz9.js} +183 -71
- package/dist/commands-BU6YJCz9.js.map +1 -0
- package/dist/{commands-BKGzBMgb.js → commands-Bi2SEQtr.js} +1 -1
- package/dist/config-k6m7XbAz.js +3777 -0
- package/dist/config-k6m7XbAz.js.map +1 -0
- package/dist/{contrasts-B4nOhn0Z.js → contrasts-DLZF4dGF.js} +3 -2
- package/dist/contrasts-DLZF4dGF.js.map +1 -0
- package/dist/cost-C5RBTTJr.js +1 -0
- package/dist/cost-ChPa8-Fp.js +359 -0
- package/dist/cost-ChPa8-Fp.js.map +1 -0
- package/dist/db-CpsifVln.js +1530 -0
- package/dist/db-CpsifVln.js.map +1 -0
- package/dist/db-DkD-F-X-.js +2 -0
- package/dist/{debug-D24NOQH1.js → debug-BhizgAsU.js} +2 -1
- package/dist/{debug-D24NOQH1.js.map → debug-BhizgAsU.js.map} +1 -1
- package/dist/debug-DeM5pswK.js +1 -0
- package/dist/{dist-Dp_AJgYN.js → dist-CYrBwyHA.js} +2 -2
- package/dist/{dist-Dp_AJgYN.js.map → dist-CYrBwyHA.js.map} +1 -1
- package/dist/{docker-DuHcQidD.js → docker-51WvhN_X.js} +5 -4
- package/dist/docker-51WvhN_X.js.map +1 -0
- package/dist/{docker-CQxucRPe.js → docker-B4-rx4dA.js} +48 -14
- package/dist/docker-B4-rx4dA.js.map +1 -0
- package/dist/{docker-Dac6Zalz.js → docker-YFj4H1Cr.js} +1 -1
- package/dist/{doctor-De_QlOTM.js → doctor-BuQnfz4e.js} +390 -53
- package/dist/doctor-BuQnfz4e.js.map +1 -0
- package/dist/{env-BQqj93gu.js → env-CARj5Axq.js} +6 -3
- package/dist/env-CARj5Axq.js.map +1 -0
- package/dist/{environment-B4IuURK1.js → environment-BOFgzFDg.js} +117 -297
- package/dist/environment-BOFgzFDg.js.map +1 -0
- package/dist/{errors-r025B0Zb.js → errors-UjcLWelF.js} +2 -2
- package/dist/{errors-r025B0Zb.js.map → errors-UjcLWelF.js.map} +1 -1
- package/dist/eval-source-Dje3rERU.js +145 -0
- package/dist/eval-source-Dje3rERU.js.map +1 -0
- package/dist/{evaluate-Djk1YPFL.js → evaluate-BPP9s3s6.js} +406 -130
- package/dist/evaluate-BPP9s3s6.js.map +1 -0
- package/dist/evaluate-dqXccn4k.d.ts +44 -0
- package/dist/{files-CN1QfenC.js → files-Bi461Be2.js} +202 -91
- package/dist/files-Bi461Be2.js.map +1 -0
- package/dist/files-C2h2Cw4F.js +1 -0
- package/dist/files-Clipx4OW.js +37 -0
- package/dist/files-Clipx4OW.js.map +1 -0
- package/dist/files-DmUrRmmL.js +1 -0
- package/dist/{files-D27nUk0K.js → files-H24pz0hL.js} +20 -9
- package/dist/files-H24pz0hL.js.map +1 -0
- package/dist/gateway.d.ts +30 -0
- package/dist/gateway.js +39 -0
- package/dist/gateway.js.map +1 -0
- package/dist/{git-rPfl7AD1.js → git-CsVZkNNL.js} +3 -3
- package/dist/{git-rPfl7AD1.js.map → git-CsVZkNNL.js.map} +1 -1
- package/dist/harness-3NVyTSGK.js +392 -0
- package/dist/harness-3NVyTSGK.js.map +1 -0
- package/dist/harness.d.ts +33 -21
- package/dist/harness.js +1 -1
- package/dist/{images-m784ueGK.js → images-4mwhNkvh.js} +8 -8
- package/dist/{images-m784ueGK.js.map → images-4mwhNkvh.js.map} +1 -1
- package/dist/index.d.ts +34 -35
- package/dist/index.js +5 -6
- package/dist/init-BDEOopK7.js +1 -0
- package/dist/{init-hiTkiM4L.js → init-cOk3D44b.js} +12 -15
- package/dist/init-cOk3D44b.js.map +1 -0
- package/dist/{invocations-D_ePcwyL.js → invocations-DW-lTk2f.js} +10 -6
- package/dist/invocations-DW-lTk2f.js.map +1 -0
- package/dist/judge-CKdgEXN7.js +575 -0
- package/dist/judge-CKdgEXN7.js.map +1 -0
- package/dist/judge.d.ts +8 -9
- package/dist/judge.js +7 -9
- package/dist/judge.js.map +1 -1
- package/dist/{live-DYd2QEyR.js → live-XJQ6nqK4.js} +2 -2
- package/dist/{live-DYd2QEyR.js.map → live-XJQ6nqK4.js.map} +1 -1
- package/dist/{matchers-Ddmc2z7H.js → matchers-DT2TaGix.js} +2 -2
- package/dist/{matchers-Ddmc2z7H.js.map → matchers-DT2TaGix.js.map} +1 -1
- package/dist/{model-DpkclE4r.js → model-Bq3G0OG1.js} +52 -45
- package/dist/model-Bq3G0OG1.js.map +1 -0
- package/dist/{model-UgHDMhI1.js → model-CTnyvh7H.js} +345 -382
- package/dist/model-CTnyvh7H.js.map +1 -0
- package/dist/model-D-SWrLZG.js +1 -0
- package/dist/model-g3XnzUv0.js +1 -0
- package/dist/model-vRiUycWh.js +77 -0
- package/dist/model-vRiUycWh.js.map +1 -0
- package/dist/{node-CGZYh4Fj.js → node-BVbbnFtv.js} +80 -51
- package/dist/node-BVbbnFtv.js.map +1 -0
- package/dist/opencode-providers-Bz0l7OZI.js +3276 -0
- package/dist/opencode-providers-Bz0l7OZI.js.map +1 -0
- package/dist/openrouter-models-CWRwLX-G.js +34 -0
- package/dist/openrouter-models-CWRwLX-G.js.map +1 -0
- package/dist/{pairs-DP6XOJby.js → pairs-puYi-zj2.js} +17 -9
- package/dist/pairs-puYi-zj2.js.map +1 -0
- package/dist/patch-CquGAGX5.js +76 -0
- package/dist/patch-CquGAGX5.js.map +1 -0
- package/dist/{patch-uMq9rCl_.js → patch-DKJiC5Sq.js} +5 -7
- package/dist/patch-DKJiC5Sq.js.map +1 -0
- package/dist/{plan-CZYgXnZh.js → plan-DdWkM6SW.js} +118 -46
- package/dist/plan-DdWkM6SW.js.map +1 -0
- package/dist/{plugins-P-uh54VF.js → plugins-D-CP6mMd.js} +254 -18
- package/dist/plugins-D-CP6mMd.js.map +1 -0
- package/dist/{preflight-D3HvKeAx.js → preflight-9ixuXzsx.js} +3 -3
- package/dist/{preflight-D3HvKeAx.js.map → preflight-9ixuXzsx.js.map} +1 -1
- package/dist/{preflight-BQlPTHVu.js → preflight-DTiVv0gY.js} +1 -1
- package/dist/{prepare-Dx7dOnJB.js → prepare-BfyikQit.js} +8 -8
- package/dist/{prepare-Dx7dOnJB.js.map → prepare-BfyikQit.js.map} +1 -1
- package/dist/{prepare-DCwM2KKD.js → prepare-tmBBf4W8.js} +2 -2
- package/dist/prices-QaS-kjSQ.js +253 -0
- package/dist/prices-QaS-kjSQ.js.map +1 -0
- package/dist/{provenance-C_-8y-x3.js → provenance-BizwUn3h.js} +4 -4
- package/dist/{provenance-C_-8y-x3.js.map → provenance-BizwUn3h.js.map} +1 -1
- package/dist/{providers-CF5UEaP8.js → providers-B6b9Tnyi.js} +5 -5
- package/dist/{providers-CF5UEaP8.js.map → providers-B6b9Tnyi.js.map} +1 -1
- package/dist/{providers-CTBYvMxu.js → providers-DkOupEBl.js} +1 -1
- package/dist/query-Clm2mNSm.js +1 -0
- package/dist/{query-DXthKmq0.js → query-DyM-VExS.js} +3 -3
- package/dist/{query-DXthKmq0.js.map → query-DyM-VExS.js.map} +1 -1
- package/dist/questions-BRhU8MzB.js +861 -0
- package/dist/questions-BRhU8MzB.js.map +1 -0
- package/dist/{record-kk9M1hj-.js → record-DZBCjuwm.js} +6 -6
- package/dist/{record-kk9M1hj-.js.map → record-DZBCjuwm.js.map} +1 -1
- package/dist/redact-DVIaahLv.js +658 -0
- package/dist/redact-DVIaahLv.js.map +1 -0
- package/dist/remarks-BwJ8pcTQ.js +1 -0
- package/dist/remarks-C7i2LMRb.js +596 -0
- package/dist/remarks-C7i2LMRb.js.map +1 -0
- package/dist/{header-BVzbRnNv.js → remarks-D_3qhBWU.js} +34 -9
- package/dist/remarks-D_3qhBWU.js.map +1 -0
- package/dist/{remarks-1521zwfW.js → remarks-dA8LyoPc.js} +12 -6
- package/dist/remarks-dA8LyoPc.js.map +1 -0
- package/dist/remote-DFIzcx_6.js +273 -0
- package/dist/remote-DFIzcx_6.js.map +1 -0
- package/dist/resolve--rQZ8u6Z.js +1 -0
- package/dist/{resolve-DzdWcIL6.js → resolve-DWSJpKHX.js} +48 -33
- package/dist/resolve-DWSJpKHX.js.map +1 -0
- package/dist/{results-D-naai_Q.js → results-BC3pcG_Z.js} +15 -30
- package/dist/results-BC3pcG_Z.js.map +1 -0
- package/dist/{resume-8-nnW8iO.js → resume-j-rcIryi.js} +47 -17
- package/dist/resume-j-rcIryi.js.map +1 -0
- package/dist/{root-DNuLhaA5.js → root-Dlff-zp8.js} +4 -4
- package/dist/{root-DNuLhaA5.js.map → root-Dlff-zp8.js.map} +1 -1
- package/dist/{runtime-PX_oXiCS.js → runtime-d56Gg3J5.js} +42 -13
- package/dist/runtime-d56Gg3J5.js.map +1 -0
- package/dist/{sandbox-YLbk9mO7.js → sandbox-Cmln11gU.js} +2 -2
- package/dist/{sandbox-YLbk9mO7.js.map → sandbox-Cmln11gU.js.map} +1 -1
- package/dist/sandbox.d.ts +2 -1
- package/dist/sandbox.js +1 -1
- package/dist/{server-De8oH3bt.js → server-BOoH10J8.js} +69 -52
- package/dist/server-BOoH10J8.js.map +1 -0
- package/dist/server-DpuVAbrO.js +1 -0
- package/dist/{shared-CA61BuPJ.js → shared-B_lvGqWz.js} +20 -12
- package/dist/shared-B_lvGqWz.js.map +1 -0
- package/dist/shared-CHvO7eLi.d.ts +1 -0
- package/dist/source-BFd6f0-R.js +1 -0
- package/dist/{source-C686eZpY.js → source-wD04-rRG.js} +15 -10
- package/dist/source-wD04-rRG.js.map +1 -0
- package/dist/{src-CzQrAcF8.js → src-1lpTocbd.js} +152 -75
- package/dist/src-1lpTocbd.js.map +1 -0
- package/dist/{src-DrJSnoMR.js → src-6_zz7oJs.js} +1 -1
- package/dist/{src-cbCb-MPy.js → src-8yTF251P.js} +68 -22
- package/dist/{src-cbCb-MPy.js.map → src-8yTF251P.js.map} +1 -1
- package/dist/{src-Xj_BZKbq.js → src-BO8AYqJ5.js} +45 -18
- package/dist/src-BO8AYqJ5.js.map +1 -0
- package/dist/{src-DeY52Gyf.js → src-BYDOXw_Y.js} +26 -10
- package/dist/{src-DeY52Gyf.js.map → src-BYDOXw_Y.js.map} +1 -1
- package/dist/src-BYPMM1x7.js +2 -0
- package/dist/src-Bp4aN3rA.js +2 -0
- package/dist/src-C7upnZSd.js +2 -0
- package/dist/{src-CIpKL45U.js → src-D91Hd6hT.js} +566 -1070
- package/dist/src-D91Hd6hT.js.map +1 -0
- package/dist/src-DH-9IO7f.js +1 -0
- package/dist/{src-djNNYIdP.js → src-DSZyg0Uq.js} +178 -29
- package/dist/src-DSZyg0Uq.js.map +1 -0
- package/dist/{src-DIL0jST0.js → src-DgHuStEi.js} +159 -31
- package/dist/src-DgHuStEi.js.map +1 -0
- package/dist/src-HSxBazcg.js +3 -0
- package/dist/src-LD1BAJFa.js +2 -0
- package/dist/src-dlX-Lmxg.js +2 -0
- package/dist/{src-C7W6kg81.js → src-gn7YlnRg.js} +64 -17
- package/dist/{src-C7W6kg81.js.map → src-gn7YlnRg.js.map} +1 -1
- package/dist/src-kYeaJJrl.js +2 -0
- package/dist/state-B5PLm5qY.js +1 -0
- package/dist/{state-C0i_ujQZ.js → state-DrJ687ut.js} +18 -18
- package/dist/{state-C0i_ujQZ.js.map → state-DrJ687ut.js.map} +1 -1
- package/dist/stats-hfpuYsAM.js +315 -0
- package/dist/stats-hfpuYsAM.js.map +1 -0
- package/dist/suite-22Kt9Grx.js +2 -0
- package/dist/{suite-DmuF_ApO.js → suite-Co8cwelb.js} +92 -42
- package/dist/suite-Co8cwelb.js.map +1 -0
- package/dist/{summary-BFMHMTz2.js → summary-DLFHVoux.js} +131 -280
- package/dist/summary-DLFHVoux.js.map +1 -0
- package/dist/testing.d.ts +449 -2
- package/dist/testing.js +16 -3
- package/dist/testing.js.map +1 -0
- package/dist/{text-CrVy5ioL.js → text-DTigcA64.js} +9 -5
- package/dist/text-DTigcA64.js.map +1 -0
- package/dist/{transcript-BTxJpW4R.js → transcript-DxPaWHTZ.js} +12 -4
- package/dist/transcript-DxPaWHTZ.js.map +1 -0
- package/dist/types-C5vI3g1C.js.map +1 -1
- package/dist/{types-B-9b1MDV.d.ts → types-coMWHaU2.d.ts} +493 -745
- package/dist/{usage-CleNKkly.js → usage-BNY1ABrU.js} +3 -3
- package/dist/{usage-CleNKkly.js.map → usage-BNY1ABrU.js.map} +1 -1
- package/dist/vertex-Bv7vhMgs.js +1 -0
- package/dist/vertex-C7PI-WPc.d.ts +3 -0
- package/dist/vertex-DypYjx71.js +456 -0
- package/dist/vertex-DypYjx71.js.map +1 -0
- package/dist/view/index.d.ts +505 -43
- package/dist/view/index.js +10 -9
- package/dist/{views-Dk8MCQKr.js → views-BFO1BLKu.js} +14 -13
- package/dist/views-BFO1BLKu.js.map +1 -0
- package/dist/views-BOf8qEL8.js +2 -0
- package/dist/{worker-entry-CqrzGPF4.js → worker-entry-CJtdsKBP.js} +21 -14
- package/dist/worker-entry-CJtdsKBP.js.map +1 -0
- package/dist/{workspace-CLeOybkr.js → workspace-BRxjfa8N.js} +5 -5
- package/dist/{workspace-CLeOybkr.js.map → workspace-BRxjfa8N.js.map} +1 -1
- package/dist/workspace-DDHzkMjm.js +1 -0
- package/docker/seccomp-default.json +1 -0
- package/package.json +10 -2
- package/skills/eval-rubric/SKILL.md +43 -103
- package/dist/adapter-IKKo4sZj.js.map +0 -1
- package/dist/agent-ClE-g9VL.js.map +0 -1
- package/dist/assemble-BO93VAk1.js.map +0 -1
- package/dist/assemble-VQxyoDxK.js +0 -1
- package/dist/assert-EUIoRdIt.js.map +0 -1
- package/dist/capture-dn2hjSLj.js.map +0 -1
- package/dist/capture-nIJ-7kUE.js +0 -1
- package/dist/cli-BCE1xlm4.js.map +0 -1
- package/dist/cli-spec-BXIBUlaK.js.map +0 -1
- package/dist/client-fcwgwOAD.js +0 -106
- package/dist/client-fcwgwOAD.js.map +0 -1
- package/dist/command-Bh3yhN_b.js.map +0 -1
- package/dist/command-C6vwmjS7.js +0 -91
- package/dist/command-C6vwmjS7.js.map +0 -1
- package/dist/command-CANun0m0.js.map +0 -1
- package/dist/command-CBaHukyl.js +0 -335
- package/dist/command-CBaHukyl.js.map +0 -1
- package/dist/command-D_kEnYcX.js.map +0 -1
- package/dist/commands-7tH3EsVu.js.map +0 -1
- package/dist/config-D7TFvUpL.js +0 -759
- package/dist/config-D7TFvUpL.js.map +0 -1
- package/dist/contrasts-B4nOhn0Z.js.map +0 -1
- package/dist/db-DJUuFoWQ.js +0 -602
- package/dist/db-DJUuFoWQ.js.map +0 -1
- package/dist/db-W9EFlXnn.js +0 -2
- package/dist/debug-D7bEv_UV.js +0 -1
- package/dist/docker-CQxucRPe.js.map +0 -1
- package/dist/docker-DuHcQidD.js.map +0 -1
- package/dist/doctor-De_QlOTM.js.map +0 -1
- package/dist/egress-DEAvq8Fl.js +0 -1258
- package/dist/egress-DEAvq8Fl.js.map +0 -1
- package/dist/env-BQqj93gu.js.map +0 -1
- package/dist/environment-B4IuURK1.js.map +0 -1
- package/dist/evaluate-C9-ritA5.d.ts +0 -92
- package/dist/evaluate-Djk1YPFL.js.map +0 -1
- package/dist/facts-Cfx1H70y.js +0 -898
- package/dist/facts-Cfx1H70y.js.map +0 -1
- package/dist/files-Bs6H3HiG.js +0 -65
- package/dist/files-Bs6H3HiG.js.map +0 -1
- package/dist/files-CN1QfenC.js.map +0 -1
- package/dist/files-CtjEXWXm.js +0 -1
- package/dist/files-D27nUk0K.js.map +0 -1
- package/dist/files-D3gJa91B.js +0 -1
- package/dist/generate-BnrvBAzF.js +0 -1646
- package/dist/generate-BnrvBAzF.js.map +0 -1
- package/dist/harness-1OkumOAm.js +0 -323
- package/dist/harness-1OkumOAm.js.map +0 -1
- package/dist/header-BVzbRnNv.js.map +0 -1
- package/dist/init-hiTkiM4L.js.map +0 -1
- package/dist/init-kMkTgTZc.js +0 -1
- package/dist/insights-B2Xmhz9o.js +0 -64
- package/dist/insights-B2Xmhz9o.js.map +0 -1
- package/dist/invocations-D_ePcwyL.js.map +0 -1
- package/dist/judge-CEDIfRiU.js +0 -186
- package/dist/judge-CEDIfRiU.js.map +0 -1
- package/dist/model-B8H3gL69.js +0 -1
- package/dist/model-CTiuzkWw.js +0 -46
- package/dist/model-CTiuzkWw.js.map +0 -1
- package/dist/model-DcIbmggK.js +0 -1
- package/dist/model-DpkclE4r.js.map +0 -1
- package/dist/model-UgHDMhI1.js.map +0 -1
- package/dist/node-CGZYh4Fj.js.map +0 -1
- package/dist/opencode-providers-snfeWd6Z.js +0 -3305
- package/dist/opencode-providers-snfeWd6Z.js.map +0 -1
- package/dist/options-CyAyLjgJ.js +0 -1129
- package/dist/options-CyAyLjgJ.js.map +0 -1
- package/dist/pairs-DP6XOJby.js.map +0 -1
- package/dist/patch-uMq9rCl_.js.map +0 -1
- package/dist/plan-CZYgXnZh.js.map +0 -1
- package/dist/plugins-P-uh54VF.js.map +0 -1
- package/dist/query-D_1ARx5q.js +0 -1
- package/dist/questions-KENpWnfV.js +0 -523
- package/dist/questions-KENpWnfV.js.map +0 -1
- package/dist/redact-CRGdfV2s.js +0 -240
- package/dist/redact-CRGdfV2s.js.map +0 -1
- package/dist/remarks-1521zwfW.js.map +0 -1
- package/dist/remarks-BhAV1H4V.js +0 -1
- package/dist/remarks-Ml6bcSdV.js +0 -278
- package/dist/remarks-Ml6bcSdV.js.map +0 -1
- package/dist/remote-Dkeghk8k.js +0 -378
- package/dist/remote-Dkeghk8k.js.map +0 -1
- package/dist/resolve-CMmhACr6.js +0 -1
- package/dist/resolve-DzdWcIL6.js.map +0 -1
- package/dist/results-D-naai_Q.js.map +0 -1
- package/dist/resume-8-nnW8iO.js.map +0 -1
- package/dist/rules-CcV3zLDR.js +0 -318
- package/dist/rules-CcV3zLDR.js.map +0 -1
- package/dist/run-Bel7Vde4.js +0 -88
- package/dist/run-Bel7Vde4.js.map +0 -1
- package/dist/runtime-PX_oXiCS.js.map +0 -1
- package/dist/server-C-ysqkLv.js +0 -1
- package/dist/server-De8oH3bt.js.map +0 -1
- package/dist/shared-CA61BuPJ.js.map +0 -1
- package/dist/source-C686eZpY.js.map +0 -1
- package/dist/source-DjgypUHW.js +0 -1
- package/dist/src-3mP821Pt.js +0 -2
- package/dist/src-B3KCLZVk.js +0 -3
- package/dist/src-BAyg6CtQ.js +0 -2
- package/dist/src-BezgGX4X.js +0 -2
- package/dist/src-CIpKL45U.js.map +0 -1
- package/dist/src-ChBhk06Q.js +0 -2
- package/dist/src-CoqZYspK.js +0 -2
- package/dist/src-CzQrAcF8.js.map +0 -1
- package/dist/src-D9fSTxlc.js +0 -1
- package/dist/src-DIL0jST0.js.map +0 -1
- package/dist/src-Xj_BZKbq.js.map +0 -1
- package/dist/src-dhSTRN50.js +0 -2
- package/dist/src-djNNYIdP.js.map +0 -1
- package/dist/state-BGWGAwdo.js +0 -1
- package/dist/state-CeR6oz0k.js +0 -66
- package/dist/state-CeR6oz0k.js.map +0 -1
- package/dist/studio-app/assets/index-Bb_cid9k.js +0 -58
- package/dist/studio-app/assets/index-CwQN3f_h.css +0 -2
- package/dist/studio-app/favicon.svg +0 -1
- package/dist/studio-app/index.html +0 -15
- package/dist/suite-DmuF_ApO.js.map +0 -1
- package/dist/suite-mn9g4veR.js +0 -2
- package/dist/summary-BFMHMTz2.js.map +0 -1
- package/dist/text-CrVy5ioL.js.map +0 -1
- package/dist/transcript-BTxJpW4R.js.map +0 -1
- package/dist/usage-BDo2q_yu.js +0 -1
- package/dist/validate-DWjkshl1.js.map +0 -1
- package/dist/views-DE2A1jEX.js +0 -2
- package/dist/views-Dk8MCQKr.js.map +0 -1
- package/dist/worker-entry-CqrzGPF4.js.map +0 -1
- package/dist/workspace-B1eGO46M.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as ownFileURL } from "./root-
|
|
1
|
+
import { u as ownFileURL } from "./root-Dlff-zp8.js";
|
|
2
2
|
import { existsSync, lstatSync, readFileSync, readdirSync, readlinkSync, renameSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { basename, dirname, join, posix, relative, win32 } from "node:path";
|
|
@@ -8,6 +8,7 @@ import { fileURLToPath } from "node:url";
|
|
|
8
8
|
import { execFileSync, spawn } from "node:child_process";
|
|
9
9
|
import { createHarnessSandboxTemplate } from "@ai-sdk/harness/agent";
|
|
10
10
|
import { isUtf8 } from "node:buffer";
|
|
11
|
+
import dockerignore from "@balena/dockerignore";
|
|
11
12
|
import { Duplex, Readable, Transform } from "node:stream";
|
|
12
13
|
import http from "node:http";
|
|
13
14
|
import http2 from "node:http2";
|
|
@@ -15,937 +16,13 @@ import https from "node:https";
|
|
|
15
16
|
import tls from "node:tls";
|
|
16
17
|
import zlib from "node:zlib";
|
|
17
18
|
import { lookup } from "node:dns/promises";
|
|
18
|
-
//#region ../sandbox-docker/src/seccomp-profile.ts
|
|
19
|
-
const DOCKER_SECCOMP_PROFILE = {
|
|
20
|
-
defaultAction: "SCMP_ACT_ERRNO",
|
|
21
|
-
defaultErrnoRet: 1,
|
|
22
|
-
archMap: [
|
|
23
|
-
{
|
|
24
|
-
architecture: "SCMP_ARCH_X86_64",
|
|
25
|
-
subArchitectures: ["SCMP_ARCH_X86", "SCMP_ARCH_X32"]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
architecture: "SCMP_ARCH_AARCH64",
|
|
29
|
-
subArchitectures: ["SCMP_ARCH_ARM"]
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
architecture: "SCMP_ARCH_MIPS64",
|
|
33
|
-
subArchitectures: ["SCMP_ARCH_MIPS", "SCMP_ARCH_MIPS64N32"]
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
architecture: "SCMP_ARCH_MIPS64N32",
|
|
37
|
-
subArchitectures: ["SCMP_ARCH_MIPS", "SCMP_ARCH_MIPS64"]
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
architecture: "SCMP_ARCH_MIPSEL64",
|
|
41
|
-
subArchitectures: ["SCMP_ARCH_MIPSEL", "SCMP_ARCH_MIPSEL64N32"]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
architecture: "SCMP_ARCH_MIPSEL64N32",
|
|
45
|
-
subArchitectures: ["SCMP_ARCH_MIPSEL", "SCMP_ARCH_MIPSEL64"]
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
architecture: "SCMP_ARCH_S390X",
|
|
49
|
-
subArchitectures: ["SCMP_ARCH_S390"]
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
architecture: "SCMP_ARCH_RISCV64",
|
|
53
|
-
subArchitectures: null
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
architecture: "SCMP_ARCH_LOONGARCH64",
|
|
57
|
-
subArchitectures: null
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
syscalls: [
|
|
61
|
-
{
|
|
62
|
-
names: [
|
|
63
|
-
"accept",
|
|
64
|
-
"accept4",
|
|
65
|
-
"access",
|
|
66
|
-
"adjtimex",
|
|
67
|
-
"alarm",
|
|
68
|
-
"bind",
|
|
69
|
-
"brk",
|
|
70
|
-
"cachestat",
|
|
71
|
-
"capget",
|
|
72
|
-
"capset",
|
|
73
|
-
"chdir",
|
|
74
|
-
"chmod",
|
|
75
|
-
"chown",
|
|
76
|
-
"chown32",
|
|
77
|
-
"clock_adjtime",
|
|
78
|
-
"clock_adjtime64",
|
|
79
|
-
"clock_getres",
|
|
80
|
-
"clock_getres_time64",
|
|
81
|
-
"clock_gettime",
|
|
82
|
-
"clock_gettime64",
|
|
83
|
-
"clock_nanosleep",
|
|
84
|
-
"clock_nanosleep_time64",
|
|
85
|
-
"close",
|
|
86
|
-
"close_range",
|
|
87
|
-
"connect",
|
|
88
|
-
"copy_file_range",
|
|
89
|
-
"creat",
|
|
90
|
-
"dup",
|
|
91
|
-
"dup2",
|
|
92
|
-
"dup3",
|
|
93
|
-
"epoll_create",
|
|
94
|
-
"epoll_create1",
|
|
95
|
-
"epoll_ctl",
|
|
96
|
-
"epoll_ctl_old",
|
|
97
|
-
"epoll_pwait",
|
|
98
|
-
"epoll_pwait2",
|
|
99
|
-
"epoll_wait",
|
|
100
|
-
"epoll_wait_old",
|
|
101
|
-
"eventfd",
|
|
102
|
-
"eventfd2",
|
|
103
|
-
"execve",
|
|
104
|
-
"execveat",
|
|
105
|
-
"exit",
|
|
106
|
-
"exit_group",
|
|
107
|
-
"faccessat",
|
|
108
|
-
"faccessat2",
|
|
109
|
-
"fadvise64",
|
|
110
|
-
"fadvise64_64",
|
|
111
|
-
"fallocate",
|
|
112
|
-
"fanotify_mark",
|
|
113
|
-
"fchdir",
|
|
114
|
-
"fchmod",
|
|
115
|
-
"fchmodat",
|
|
116
|
-
"fchmodat2",
|
|
117
|
-
"fchown",
|
|
118
|
-
"fchown32",
|
|
119
|
-
"fchownat",
|
|
120
|
-
"fcntl",
|
|
121
|
-
"fcntl64",
|
|
122
|
-
"fdatasync",
|
|
123
|
-
"fgetxattr",
|
|
124
|
-
"flistxattr",
|
|
125
|
-
"flock",
|
|
126
|
-
"fork",
|
|
127
|
-
"fremovexattr",
|
|
128
|
-
"fsetxattr",
|
|
129
|
-
"fstat",
|
|
130
|
-
"fstat64",
|
|
131
|
-
"fstatat64",
|
|
132
|
-
"fstatfs",
|
|
133
|
-
"fstatfs64",
|
|
134
|
-
"fsync",
|
|
135
|
-
"ftruncate",
|
|
136
|
-
"ftruncate64",
|
|
137
|
-
"futex",
|
|
138
|
-
"futex_requeue",
|
|
139
|
-
"futex_time64",
|
|
140
|
-
"futex_wait",
|
|
141
|
-
"futex_waitv",
|
|
142
|
-
"futex_wake",
|
|
143
|
-
"futimesat",
|
|
144
|
-
"getcpu",
|
|
145
|
-
"getcwd",
|
|
146
|
-
"getdents",
|
|
147
|
-
"getdents64",
|
|
148
|
-
"getegid",
|
|
149
|
-
"getegid32",
|
|
150
|
-
"geteuid",
|
|
151
|
-
"geteuid32",
|
|
152
|
-
"getgid",
|
|
153
|
-
"getgid32",
|
|
154
|
-
"getgroups",
|
|
155
|
-
"getgroups32",
|
|
156
|
-
"getitimer",
|
|
157
|
-
"getpeername",
|
|
158
|
-
"getpgid",
|
|
159
|
-
"getpgrp",
|
|
160
|
-
"getpid",
|
|
161
|
-
"getppid",
|
|
162
|
-
"getpriority",
|
|
163
|
-
"getrandom",
|
|
164
|
-
"getresgid",
|
|
165
|
-
"getresgid32",
|
|
166
|
-
"getresuid",
|
|
167
|
-
"getresuid32",
|
|
168
|
-
"getrlimit",
|
|
169
|
-
"get_robust_list",
|
|
170
|
-
"getrusage",
|
|
171
|
-
"getsid",
|
|
172
|
-
"getsockname",
|
|
173
|
-
"getsockopt",
|
|
174
|
-
"get_thread_area",
|
|
175
|
-
"gettid",
|
|
176
|
-
"gettimeofday",
|
|
177
|
-
"getuid",
|
|
178
|
-
"getuid32",
|
|
179
|
-
"getxattr",
|
|
180
|
-
"getxattrat",
|
|
181
|
-
"inotify_add_watch",
|
|
182
|
-
"inotify_init",
|
|
183
|
-
"inotify_init1",
|
|
184
|
-
"inotify_rm_watch",
|
|
185
|
-
"io_cancel",
|
|
186
|
-
"ioctl",
|
|
187
|
-
"io_destroy",
|
|
188
|
-
"io_getevents",
|
|
189
|
-
"io_pgetevents",
|
|
190
|
-
"io_pgetevents_time64",
|
|
191
|
-
"ioprio_get",
|
|
192
|
-
"ioprio_set",
|
|
193
|
-
"io_setup",
|
|
194
|
-
"io_submit",
|
|
195
|
-
"ipc",
|
|
196
|
-
"kill",
|
|
197
|
-
"landlock_add_rule",
|
|
198
|
-
"landlock_create_ruleset",
|
|
199
|
-
"landlock_restrict_self",
|
|
200
|
-
"lchown",
|
|
201
|
-
"lchown32",
|
|
202
|
-
"lgetxattr",
|
|
203
|
-
"link",
|
|
204
|
-
"linkat",
|
|
205
|
-
"listen",
|
|
206
|
-
"listmount",
|
|
207
|
-
"listxattr",
|
|
208
|
-
"listxattrat",
|
|
209
|
-
"llistxattr",
|
|
210
|
-
"_llseek",
|
|
211
|
-
"lremovexattr",
|
|
212
|
-
"lseek",
|
|
213
|
-
"lsetxattr",
|
|
214
|
-
"lstat",
|
|
215
|
-
"lstat64",
|
|
216
|
-
"madvise",
|
|
217
|
-
"map_shadow_stack",
|
|
218
|
-
"membarrier",
|
|
219
|
-
"memfd_create",
|
|
220
|
-
"memfd_secret",
|
|
221
|
-
"mincore",
|
|
222
|
-
"mkdir",
|
|
223
|
-
"mkdirat",
|
|
224
|
-
"mknod",
|
|
225
|
-
"mknodat",
|
|
226
|
-
"mlock",
|
|
227
|
-
"mlock2",
|
|
228
|
-
"mlockall",
|
|
229
|
-
"mmap",
|
|
230
|
-
"mmap2",
|
|
231
|
-
"mprotect",
|
|
232
|
-
"mq_getsetattr",
|
|
233
|
-
"mq_notify",
|
|
234
|
-
"mq_open",
|
|
235
|
-
"mq_timedreceive",
|
|
236
|
-
"mq_timedreceive_time64",
|
|
237
|
-
"mq_timedsend",
|
|
238
|
-
"mq_timedsend_time64",
|
|
239
|
-
"mq_unlink",
|
|
240
|
-
"mremap",
|
|
241
|
-
"mseal",
|
|
242
|
-
"msgctl",
|
|
243
|
-
"msgget",
|
|
244
|
-
"msgrcv",
|
|
245
|
-
"msgsnd",
|
|
246
|
-
"msync",
|
|
247
|
-
"munlock",
|
|
248
|
-
"munlockall",
|
|
249
|
-
"munmap",
|
|
250
|
-
"name_to_handle_at",
|
|
251
|
-
"nanosleep",
|
|
252
|
-
"newfstatat",
|
|
253
|
-
"_newselect",
|
|
254
|
-
"open",
|
|
255
|
-
"openat",
|
|
256
|
-
"openat2",
|
|
257
|
-
"pause",
|
|
258
|
-
"pidfd_open",
|
|
259
|
-
"pidfd_send_signal",
|
|
260
|
-
"pipe",
|
|
261
|
-
"pipe2",
|
|
262
|
-
"pkey_alloc",
|
|
263
|
-
"pkey_free",
|
|
264
|
-
"pkey_mprotect",
|
|
265
|
-
"poll",
|
|
266
|
-
"ppoll",
|
|
267
|
-
"ppoll_time64",
|
|
268
|
-
"prctl",
|
|
269
|
-
"pread64",
|
|
270
|
-
"preadv",
|
|
271
|
-
"preadv2",
|
|
272
|
-
"prlimit64",
|
|
273
|
-
"process_mrelease",
|
|
274
|
-
"pselect6",
|
|
275
|
-
"pselect6_time64",
|
|
276
|
-
"pwrite64",
|
|
277
|
-
"pwritev",
|
|
278
|
-
"pwritev2",
|
|
279
|
-
"read",
|
|
280
|
-
"readahead",
|
|
281
|
-
"readlink",
|
|
282
|
-
"readlinkat",
|
|
283
|
-
"readv",
|
|
284
|
-
"recv",
|
|
285
|
-
"recvfrom",
|
|
286
|
-
"recvmmsg",
|
|
287
|
-
"recvmmsg_time64",
|
|
288
|
-
"recvmsg",
|
|
289
|
-
"remap_file_pages",
|
|
290
|
-
"removexattr",
|
|
291
|
-
"removexattrat",
|
|
292
|
-
"rename",
|
|
293
|
-
"renameat",
|
|
294
|
-
"renameat2",
|
|
295
|
-
"restart_syscall",
|
|
296
|
-
"riscv_hwprobe",
|
|
297
|
-
"rmdir",
|
|
298
|
-
"rseq",
|
|
299
|
-
"rt_sigaction",
|
|
300
|
-
"rt_sigpending",
|
|
301
|
-
"rt_sigprocmask",
|
|
302
|
-
"rt_sigqueueinfo",
|
|
303
|
-
"rt_sigreturn",
|
|
304
|
-
"rt_sigsuspend",
|
|
305
|
-
"rt_sigtimedwait",
|
|
306
|
-
"rt_sigtimedwait_time64",
|
|
307
|
-
"rt_tgsigqueueinfo",
|
|
308
|
-
"sched_getaffinity",
|
|
309
|
-
"sched_getattr",
|
|
310
|
-
"sched_getparam",
|
|
311
|
-
"sched_get_priority_max",
|
|
312
|
-
"sched_get_priority_min",
|
|
313
|
-
"sched_getscheduler",
|
|
314
|
-
"sched_rr_get_interval",
|
|
315
|
-
"sched_rr_get_interval_time64",
|
|
316
|
-
"sched_setaffinity",
|
|
317
|
-
"sched_setattr",
|
|
318
|
-
"sched_setparam",
|
|
319
|
-
"sched_setscheduler",
|
|
320
|
-
"sched_yield",
|
|
321
|
-
"seccomp",
|
|
322
|
-
"select",
|
|
323
|
-
"semctl",
|
|
324
|
-
"semget",
|
|
325
|
-
"semop",
|
|
326
|
-
"semtimedop",
|
|
327
|
-
"semtimedop_time64",
|
|
328
|
-
"send",
|
|
329
|
-
"sendfile",
|
|
330
|
-
"sendfile64",
|
|
331
|
-
"sendmmsg",
|
|
332
|
-
"sendmsg",
|
|
333
|
-
"sendto",
|
|
334
|
-
"setfsgid",
|
|
335
|
-
"setfsgid32",
|
|
336
|
-
"setfsuid",
|
|
337
|
-
"setfsuid32",
|
|
338
|
-
"setgid",
|
|
339
|
-
"setgid32",
|
|
340
|
-
"setgroups",
|
|
341
|
-
"setgroups32",
|
|
342
|
-
"setitimer",
|
|
343
|
-
"setpgid",
|
|
344
|
-
"setpriority",
|
|
345
|
-
"setregid",
|
|
346
|
-
"setregid32",
|
|
347
|
-
"setresgid",
|
|
348
|
-
"setresgid32",
|
|
349
|
-
"setresuid",
|
|
350
|
-
"setresuid32",
|
|
351
|
-
"setreuid",
|
|
352
|
-
"setreuid32",
|
|
353
|
-
"setrlimit",
|
|
354
|
-
"set_robust_list",
|
|
355
|
-
"setsid",
|
|
356
|
-
"setsockopt",
|
|
357
|
-
"set_thread_area",
|
|
358
|
-
"set_tid_address",
|
|
359
|
-
"setuid",
|
|
360
|
-
"setuid32",
|
|
361
|
-
"setxattr",
|
|
362
|
-
"setxattrat",
|
|
363
|
-
"shmat",
|
|
364
|
-
"shmctl",
|
|
365
|
-
"shmdt",
|
|
366
|
-
"shmget",
|
|
367
|
-
"shutdown",
|
|
368
|
-
"sigaltstack",
|
|
369
|
-
"signalfd",
|
|
370
|
-
"signalfd4",
|
|
371
|
-
"sigprocmask",
|
|
372
|
-
"sigreturn",
|
|
373
|
-
"socketcall",
|
|
374
|
-
"socketpair",
|
|
375
|
-
"splice",
|
|
376
|
-
"stat",
|
|
377
|
-
"stat64",
|
|
378
|
-
"statfs",
|
|
379
|
-
"statfs64",
|
|
380
|
-
"statmount",
|
|
381
|
-
"statx",
|
|
382
|
-
"symlink",
|
|
383
|
-
"symlinkat",
|
|
384
|
-
"sync",
|
|
385
|
-
"sync_file_range",
|
|
386
|
-
"syncfs",
|
|
387
|
-
"sysinfo",
|
|
388
|
-
"tee",
|
|
389
|
-
"tgkill",
|
|
390
|
-
"time",
|
|
391
|
-
"timer_create",
|
|
392
|
-
"timer_delete",
|
|
393
|
-
"timer_getoverrun",
|
|
394
|
-
"timer_gettime",
|
|
395
|
-
"timer_gettime64",
|
|
396
|
-
"timer_settime",
|
|
397
|
-
"timer_settime64",
|
|
398
|
-
"timerfd_create",
|
|
399
|
-
"timerfd_gettime",
|
|
400
|
-
"timerfd_gettime64",
|
|
401
|
-
"timerfd_settime",
|
|
402
|
-
"timerfd_settime64",
|
|
403
|
-
"times",
|
|
404
|
-
"tkill",
|
|
405
|
-
"truncate",
|
|
406
|
-
"truncate64",
|
|
407
|
-
"ugetrlimit",
|
|
408
|
-
"umask",
|
|
409
|
-
"uname",
|
|
410
|
-
"unlink",
|
|
411
|
-
"unlinkat",
|
|
412
|
-
"uretprobe",
|
|
413
|
-
"utime",
|
|
414
|
-
"utimensat",
|
|
415
|
-
"utimensat_time64",
|
|
416
|
-
"utimes",
|
|
417
|
-
"vfork",
|
|
418
|
-
"vmsplice",
|
|
419
|
-
"wait4",
|
|
420
|
-
"waitid",
|
|
421
|
-
"waitpid",
|
|
422
|
-
"write",
|
|
423
|
-
"writev"
|
|
424
|
-
],
|
|
425
|
-
action: "SCMP_ACT_ALLOW"
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
names: [
|
|
429
|
-
"process_vm_readv",
|
|
430
|
-
"process_vm_writev",
|
|
431
|
-
"ptrace"
|
|
432
|
-
],
|
|
433
|
-
action: "SCMP_ACT_ALLOW",
|
|
434
|
-
includes: { minKernel: "4.8" }
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
names: ["socket"],
|
|
438
|
-
action: "SCMP_ACT_ALLOW",
|
|
439
|
-
args: [{
|
|
440
|
-
index: 0,
|
|
441
|
-
value: 3,
|
|
442
|
-
op: "SCMP_CMP_LT"
|
|
443
|
-
}]
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
names: ["socket"],
|
|
447
|
-
action: "SCMP_ACT_ALLOW",
|
|
448
|
-
args: [{
|
|
449
|
-
index: 0,
|
|
450
|
-
value: 7,
|
|
451
|
-
op: "SCMP_CMP_EQ"
|
|
452
|
-
}]
|
|
453
|
-
},
|
|
454
|
-
{
|
|
455
|
-
names: ["socket"],
|
|
456
|
-
action: "SCMP_ACT_ALLOW",
|
|
457
|
-
args: [{
|
|
458
|
-
index: 0,
|
|
459
|
-
value: 8,
|
|
460
|
-
op: "SCMP_CMP_EQ"
|
|
461
|
-
}]
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
names: ["socket"],
|
|
465
|
-
action: "SCMP_ACT_ALLOW",
|
|
466
|
-
args: [{
|
|
467
|
-
index: 0,
|
|
468
|
-
value: 9,
|
|
469
|
-
op: "SCMP_CMP_EQ"
|
|
470
|
-
}]
|
|
471
|
-
},
|
|
472
|
-
{
|
|
473
|
-
names: ["socket"],
|
|
474
|
-
action: "SCMP_ACT_ALLOW",
|
|
475
|
-
args: [{
|
|
476
|
-
index: 0,
|
|
477
|
-
value: 10,
|
|
478
|
-
op: "SCMP_CMP_EQ"
|
|
479
|
-
}]
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
names: ["socket"],
|
|
483
|
-
action: "SCMP_ACT_ALLOW",
|
|
484
|
-
args: [{
|
|
485
|
-
index: 0,
|
|
486
|
-
value: 13,
|
|
487
|
-
op: "SCMP_CMP_EQ"
|
|
488
|
-
}]
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
names: ["socket"],
|
|
492
|
-
action: "SCMP_ACT_ALLOW",
|
|
493
|
-
args: [{
|
|
494
|
-
index: 0,
|
|
495
|
-
value: 14,
|
|
496
|
-
op: "SCMP_CMP_EQ"
|
|
497
|
-
}]
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
names: ["socket"],
|
|
501
|
-
action: "SCMP_ACT_ALLOW",
|
|
502
|
-
args: [{
|
|
503
|
-
index: 0,
|
|
504
|
-
value: 15,
|
|
505
|
-
op: "SCMP_CMP_EQ"
|
|
506
|
-
}]
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
names: ["socket"],
|
|
510
|
-
action: "SCMP_ACT_ALLOW",
|
|
511
|
-
args: [{
|
|
512
|
-
index: 0,
|
|
513
|
-
value: 16,
|
|
514
|
-
op: "SCMP_CMP_EQ"
|
|
515
|
-
}]
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
names: ["socket"],
|
|
519
|
-
action: "SCMP_ACT_ALLOW",
|
|
520
|
-
args: [{
|
|
521
|
-
index: 0,
|
|
522
|
-
value: 17,
|
|
523
|
-
op: "SCMP_CMP_EQ"
|
|
524
|
-
}]
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
names: ["socket"],
|
|
528
|
-
action: "SCMP_ACT_ALLOW",
|
|
529
|
-
args: [{
|
|
530
|
-
index: 0,
|
|
531
|
-
value: 18,
|
|
532
|
-
op: "SCMP_CMP_EQ"
|
|
533
|
-
}]
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
names: ["socket"],
|
|
537
|
-
action: "SCMP_ACT_ALLOW",
|
|
538
|
-
args: [{
|
|
539
|
-
index: 0,
|
|
540
|
-
value: 21,
|
|
541
|
-
op: "SCMP_CMP_EQ"
|
|
542
|
-
}]
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
names: ["socket"],
|
|
546
|
-
action: "SCMP_ACT_ALLOW",
|
|
547
|
-
args: [{
|
|
548
|
-
index: 0,
|
|
549
|
-
value: 22,
|
|
550
|
-
op: "SCMP_CMP_EQ"
|
|
551
|
-
}]
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
names: ["socket"],
|
|
555
|
-
action: "SCMP_ACT_ALLOW",
|
|
556
|
-
args: [{
|
|
557
|
-
index: 0,
|
|
558
|
-
value: 24,
|
|
559
|
-
op: "SCMP_CMP_EQ"
|
|
560
|
-
}]
|
|
561
|
-
},
|
|
562
|
-
{
|
|
563
|
-
names: ["socket"],
|
|
564
|
-
action: "SCMP_ACT_ALLOW",
|
|
565
|
-
args: [{
|
|
566
|
-
index: 0,
|
|
567
|
-
value: 26,
|
|
568
|
-
op: "SCMP_CMP_EQ"
|
|
569
|
-
}]
|
|
570
|
-
},
|
|
571
|
-
{
|
|
572
|
-
names: ["socket"],
|
|
573
|
-
action: "SCMP_ACT_ALLOW",
|
|
574
|
-
args: [{
|
|
575
|
-
index: 0,
|
|
576
|
-
value: 27,
|
|
577
|
-
op: "SCMP_CMP_EQ"
|
|
578
|
-
}]
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
names: ["socket"],
|
|
582
|
-
action: "SCMP_ACT_ALLOW",
|
|
583
|
-
args: [{
|
|
584
|
-
index: 0,
|
|
585
|
-
value: 28,
|
|
586
|
-
op: "SCMP_CMP_EQ"
|
|
587
|
-
}]
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
names: ["socket"],
|
|
591
|
-
action: "SCMP_ACT_ALLOW",
|
|
592
|
-
args: [{
|
|
593
|
-
index: 0,
|
|
594
|
-
value: 29,
|
|
595
|
-
op: "SCMP_CMP_EQ"
|
|
596
|
-
}]
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
names: ["socket"],
|
|
600
|
-
action: "SCMP_ACT_ALLOW",
|
|
601
|
-
args: [{
|
|
602
|
-
index: 0,
|
|
603
|
-
value: 30,
|
|
604
|
-
op: "SCMP_CMP_EQ"
|
|
605
|
-
}]
|
|
606
|
-
},
|
|
607
|
-
{
|
|
608
|
-
names: ["socket"],
|
|
609
|
-
action: "SCMP_ACT_ALLOW",
|
|
610
|
-
args: [{
|
|
611
|
-
index: 0,
|
|
612
|
-
value: 31,
|
|
613
|
-
op: "SCMP_CMP_EQ"
|
|
614
|
-
}]
|
|
615
|
-
},
|
|
616
|
-
{
|
|
617
|
-
names: ["socket"],
|
|
618
|
-
action: "SCMP_ACT_ALLOW",
|
|
619
|
-
args: [{
|
|
620
|
-
index: 0,
|
|
621
|
-
value: 32,
|
|
622
|
-
op: "SCMP_CMP_EQ"
|
|
623
|
-
}]
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
names: ["socket"],
|
|
627
|
-
action: "SCMP_ACT_ALLOW",
|
|
628
|
-
args: [{
|
|
629
|
-
index: 0,
|
|
630
|
-
value: 33,
|
|
631
|
-
op: "SCMP_CMP_EQ"
|
|
632
|
-
}]
|
|
633
|
-
},
|
|
634
|
-
{
|
|
635
|
-
names: ["socket"],
|
|
636
|
-
action: "SCMP_ACT_ALLOW",
|
|
637
|
-
args: [{
|
|
638
|
-
index: 0,
|
|
639
|
-
value: 35,
|
|
640
|
-
op: "SCMP_CMP_EQ"
|
|
641
|
-
}]
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
names: ["socket"],
|
|
645
|
-
action: "SCMP_ACT_ALLOW",
|
|
646
|
-
args: [{
|
|
647
|
-
index: 0,
|
|
648
|
-
value: 36,
|
|
649
|
-
op: "SCMP_CMP_EQ"
|
|
650
|
-
}]
|
|
651
|
-
},
|
|
652
|
-
{
|
|
653
|
-
names: ["socket"],
|
|
654
|
-
action: "SCMP_ACT_ALLOW",
|
|
655
|
-
args: [{
|
|
656
|
-
index: 0,
|
|
657
|
-
value: 39,
|
|
658
|
-
op: "SCMP_CMP_EQ"
|
|
659
|
-
}]
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
names: ["socket"],
|
|
663
|
-
action: "SCMP_ACT_ALLOW",
|
|
664
|
-
args: [{
|
|
665
|
-
index: 0,
|
|
666
|
-
value: 41,
|
|
667
|
-
op: "SCMP_CMP_EQ"
|
|
668
|
-
}]
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
names: ["socket"],
|
|
672
|
-
action: "SCMP_ACT_ALLOW",
|
|
673
|
-
args: [{
|
|
674
|
-
index: 0,
|
|
675
|
-
value: 42,
|
|
676
|
-
op: "SCMP_CMP_EQ"
|
|
677
|
-
}]
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
names: ["socket"],
|
|
681
|
-
action: "SCMP_ACT_ALLOW",
|
|
682
|
-
args: [{
|
|
683
|
-
index: 0,
|
|
684
|
-
value: 43,
|
|
685
|
-
op: "SCMP_CMP_EQ"
|
|
686
|
-
}]
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
names: ["socket"],
|
|
690
|
-
action: "SCMP_ACT_ALLOW",
|
|
691
|
-
args: [{
|
|
692
|
-
index: 0,
|
|
693
|
-
value: 44,
|
|
694
|
-
op: "SCMP_CMP_EQ"
|
|
695
|
-
}]
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
names: ["socket"],
|
|
699
|
-
action: "SCMP_ACT_ALLOW",
|
|
700
|
-
args: [{
|
|
701
|
-
index: 0,
|
|
702
|
-
value: 45,
|
|
703
|
-
op: "SCMP_CMP_EQ"
|
|
704
|
-
}]
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
names: ["personality"],
|
|
708
|
-
action: "SCMP_ACT_ALLOW",
|
|
709
|
-
args: [{
|
|
710
|
-
index: 0,
|
|
711
|
-
value: 0,
|
|
712
|
-
op: "SCMP_CMP_EQ"
|
|
713
|
-
}]
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
names: ["personality"],
|
|
717
|
-
action: "SCMP_ACT_ALLOW",
|
|
718
|
-
args: [{
|
|
719
|
-
index: 0,
|
|
720
|
-
value: 8,
|
|
721
|
-
op: "SCMP_CMP_EQ"
|
|
722
|
-
}]
|
|
723
|
-
},
|
|
724
|
-
{
|
|
725
|
-
names: ["personality"],
|
|
726
|
-
action: "SCMP_ACT_ALLOW",
|
|
727
|
-
args: [{
|
|
728
|
-
index: 0,
|
|
729
|
-
value: 131072,
|
|
730
|
-
op: "SCMP_CMP_EQ"
|
|
731
|
-
}]
|
|
732
|
-
},
|
|
733
|
-
{
|
|
734
|
-
names: ["personality"],
|
|
735
|
-
action: "SCMP_ACT_ALLOW",
|
|
736
|
-
args: [{
|
|
737
|
-
index: 0,
|
|
738
|
-
value: 131080,
|
|
739
|
-
op: "SCMP_CMP_EQ"
|
|
740
|
-
}]
|
|
741
|
-
},
|
|
742
|
-
{
|
|
743
|
-
names: ["personality"],
|
|
744
|
-
action: "SCMP_ACT_ALLOW",
|
|
745
|
-
args: [{
|
|
746
|
-
index: 0,
|
|
747
|
-
value: 4294967295,
|
|
748
|
-
op: "SCMP_CMP_EQ"
|
|
749
|
-
}]
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
names: ["sync_file_range2", "swapcontext"],
|
|
753
|
-
action: "SCMP_ACT_ALLOW",
|
|
754
|
-
includes: { arches: ["ppc64le"] }
|
|
755
|
-
},
|
|
756
|
-
{
|
|
757
|
-
names: [
|
|
758
|
-
"arm_fadvise64_64",
|
|
759
|
-
"arm_sync_file_range",
|
|
760
|
-
"sync_file_range2",
|
|
761
|
-
"breakpoint",
|
|
762
|
-
"cacheflush",
|
|
763
|
-
"set_tls"
|
|
764
|
-
],
|
|
765
|
-
action: "SCMP_ACT_ALLOW",
|
|
766
|
-
includes: { arches: ["arm", "arm64"] }
|
|
767
|
-
},
|
|
768
|
-
{
|
|
769
|
-
names: ["arch_prctl"],
|
|
770
|
-
action: "SCMP_ACT_ALLOW",
|
|
771
|
-
includes: { arches: ["amd64", "x32"] }
|
|
772
|
-
},
|
|
773
|
-
{
|
|
774
|
-
names: ["modify_ldt"],
|
|
775
|
-
action: "SCMP_ACT_ALLOW",
|
|
776
|
-
includes: { arches: [
|
|
777
|
-
"amd64",
|
|
778
|
-
"x32",
|
|
779
|
-
"x86"
|
|
780
|
-
] }
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
names: [
|
|
784
|
-
"s390_pci_mmio_read",
|
|
785
|
-
"s390_pci_mmio_write",
|
|
786
|
-
"s390_runtime_instr"
|
|
787
|
-
],
|
|
788
|
-
action: "SCMP_ACT_ALLOW",
|
|
789
|
-
includes: { arches: ["s390", "s390x"] }
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
names: ["riscv_flush_icache"],
|
|
793
|
-
action: "SCMP_ACT_ALLOW",
|
|
794
|
-
includes: { arches: ["riscv64"] }
|
|
795
|
-
},
|
|
796
|
-
{
|
|
797
|
-
names: ["open_by_handle_at"],
|
|
798
|
-
action: "SCMP_ACT_ALLOW",
|
|
799
|
-
includes: { caps: ["CAP_DAC_READ_SEARCH"] }
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
names: [
|
|
803
|
-
"bpf",
|
|
804
|
-
"clone",
|
|
805
|
-
"clone3",
|
|
806
|
-
"fanotify_init",
|
|
807
|
-
"fsconfig",
|
|
808
|
-
"fsmount",
|
|
809
|
-
"fsopen",
|
|
810
|
-
"fspick",
|
|
811
|
-
"lookup_dcookie",
|
|
812
|
-
"lsm_get_self_attr",
|
|
813
|
-
"lsm_list_modules",
|
|
814
|
-
"lsm_set_self_attr",
|
|
815
|
-
"mount",
|
|
816
|
-
"mount_setattr",
|
|
817
|
-
"move_mount",
|
|
818
|
-
"open_tree",
|
|
819
|
-
"perf_event_open",
|
|
820
|
-
"quotactl",
|
|
821
|
-
"quotactl_fd",
|
|
822
|
-
"setdomainname",
|
|
823
|
-
"sethostname",
|
|
824
|
-
"setns",
|
|
825
|
-
"syslog",
|
|
826
|
-
"umount",
|
|
827
|
-
"umount2",
|
|
828
|
-
"unshare"
|
|
829
|
-
],
|
|
830
|
-
action: "SCMP_ACT_ALLOW",
|
|
831
|
-
includes: { caps: ["CAP_SYS_ADMIN"] }
|
|
832
|
-
},
|
|
833
|
-
{
|
|
834
|
-
names: ["clone"],
|
|
835
|
-
action: "SCMP_ACT_ALLOW",
|
|
836
|
-
args: [{
|
|
837
|
-
index: 0,
|
|
838
|
-
value: 2114060288,
|
|
839
|
-
op: "SCMP_CMP_MASKED_EQ"
|
|
840
|
-
}],
|
|
841
|
-
excludes: {
|
|
842
|
-
caps: ["CAP_SYS_ADMIN"],
|
|
843
|
-
arches: ["s390", "s390x"]
|
|
844
|
-
}
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
names: ["clone"],
|
|
848
|
-
action: "SCMP_ACT_ALLOW",
|
|
849
|
-
args: [{
|
|
850
|
-
index: 1,
|
|
851
|
-
value: 2114060288,
|
|
852
|
-
op: "SCMP_CMP_MASKED_EQ"
|
|
853
|
-
}],
|
|
854
|
-
comment: "s390 parameter ordering for clone is different",
|
|
855
|
-
includes: { arches: ["s390", "s390x"] },
|
|
856
|
-
excludes: { caps: ["CAP_SYS_ADMIN"] }
|
|
857
|
-
},
|
|
858
|
-
{
|
|
859
|
-
names: ["clone3"],
|
|
860
|
-
action: "SCMP_ACT_ERRNO",
|
|
861
|
-
errnoRet: 38,
|
|
862
|
-
excludes: { caps: ["CAP_SYS_ADMIN"] }
|
|
863
|
-
},
|
|
864
|
-
{
|
|
865
|
-
names: ["reboot"],
|
|
866
|
-
action: "SCMP_ACT_ALLOW",
|
|
867
|
-
includes: { caps: ["CAP_SYS_BOOT"] }
|
|
868
|
-
},
|
|
869
|
-
{
|
|
870
|
-
names: ["chroot"],
|
|
871
|
-
action: "SCMP_ACT_ALLOW",
|
|
872
|
-
includes: { caps: ["CAP_SYS_CHROOT"] }
|
|
873
|
-
},
|
|
874
|
-
{
|
|
875
|
-
names: [
|
|
876
|
-
"delete_module",
|
|
877
|
-
"init_module",
|
|
878
|
-
"finit_module"
|
|
879
|
-
],
|
|
880
|
-
action: "SCMP_ACT_ALLOW",
|
|
881
|
-
includes: { caps: ["CAP_SYS_MODULE"] }
|
|
882
|
-
},
|
|
883
|
-
{
|
|
884
|
-
names: ["acct"],
|
|
885
|
-
action: "SCMP_ACT_ALLOW",
|
|
886
|
-
includes: { caps: ["CAP_SYS_PACCT"] }
|
|
887
|
-
},
|
|
888
|
-
{
|
|
889
|
-
names: [
|
|
890
|
-
"kcmp",
|
|
891
|
-
"pidfd_getfd",
|
|
892
|
-
"process_madvise",
|
|
893
|
-
"process_vm_readv",
|
|
894
|
-
"process_vm_writev",
|
|
895
|
-
"ptrace"
|
|
896
|
-
],
|
|
897
|
-
action: "SCMP_ACT_ALLOW",
|
|
898
|
-
includes: { caps: ["CAP_SYS_PTRACE"] }
|
|
899
|
-
},
|
|
900
|
-
{
|
|
901
|
-
names: ["iopl", "ioperm"],
|
|
902
|
-
action: "SCMP_ACT_ALLOW",
|
|
903
|
-
includes: { caps: ["CAP_SYS_RAWIO"] }
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
names: [
|
|
907
|
-
"settimeofday",
|
|
908
|
-
"stime",
|
|
909
|
-
"clock_settime",
|
|
910
|
-
"clock_settime64"
|
|
911
|
-
],
|
|
912
|
-
action: "SCMP_ACT_ALLOW",
|
|
913
|
-
includes: { caps: ["CAP_SYS_TIME"] }
|
|
914
|
-
},
|
|
915
|
-
{
|
|
916
|
-
names: ["vhangup"],
|
|
917
|
-
action: "SCMP_ACT_ALLOW",
|
|
918
|
-
includes: { caps: ["CAP_SYS_TTY_CONFIG"] }
|
|
919
|
-
},
|
|
920
|
-
{
|
|
921
|
-
names: [
|
|
922
|
-
"get_mempolicy",
|
|
923
|
-
"mbind",
|
|
924
|
-
"set_mempolicy",
|
|
925
|
-
"set_mempolicy_home_node"
|
|
926
|
-
],
|
|
927
|
-
action: "SCMP_ACT_ALLOW",
|
|
928
|
-
includes: { caps: ["CAP_SYS_NICE"] }
|
|
929
|
-
},
|
|
930
|
-
{
|
|
931
|
-
names: ["syslog"],
|
|
932
|
-
action: "SCMP_ACT_ALLOW",
|
|
933
|
-
includes: { caps: ["CAP_SYSLOG"] }
|
|
934
|
-
},
|
|
935
|
-
{
|
|
936
|
-
names: ["bpf"],
|
|
937
|
-
action: "SCMP_ACT_ALLOW",
|
|
938
|
-
includes: { caps: ["CAP_BPF"] }
|
|
939
|
-
},
|
|
940
|
-
{
|
|
941
|
-
names: ["perf_event_open"],
|
|
942
|
-
action: "SCMP_ACT_ALLOW",
|
|
943
|
-
includes: { caps: ["CAP_PERFMON"] }
|
|
944
|
-
}
|
|
945
|
-
]
|
|
946
|
-
};
|
|
947
|
-
//#endregion
|
|
948
19
|
//#region ../sandbox-docker/src/engine.ts
|
|
20
|
+
/**
|
|
21
|
+
* Docker's default seccomp profile, copied unmodified from moby/profiles (Apache-2.0),
|
|
22
|
+
* seccomp/default.json at 6fe7deb1b9fb7c0397a4593480d7d22b9ee8caef. Podman gets it on every
|
|
23
|
+
* container, so a sandbox there refuses the same syscalls (unshare, mount, keyctl…) as on Docker.
|
|
24
|
+
*/
|
|
25
|
+
const DOCKER_SECCOMP_PROFILE = ownFileURL("docker/seccomp-default.json");
|
|
949
26
|
let seccompFile;
|
|
950
27
|
/**
|
|
951
28
|
* Docker's default seccomp profile as a file Podman can read, written once per content under the
|
|
@@ -953,7 +30,7 @@ let seccompFile;
|
|
|
953
30
|
*/
|
|
954
31
|
function dockerSeccompFile() {
|
|
955
32
|
if (seccompFile && existsSync(seccompFile)) return seccompFile;
|
|
956
|
-
const json =
|
|
33
|
+
const json = readFileSync(DOCKER_SECCOMP_PROFILE, "utf8");
|
|
957
34
|
const hash = createHash("sha256").update(json).digest("hex").slice(0, 16);
|
|
958
35
|
const path = join(tmpdir(), `reeval-seccomp-${hash}.json`);
|
|
959
36
|
if (!existsSync(path)) {
|
|
@@ -1296,11 +373,29 @@ const MAX_STREAM = 4096;
|
|
|
1296
373
|
/** Most of each argument a trace keeps, e.g. the gateway's forwarder script. */
|
|
1297
374
|
const MAX_ARG = 300;
|
|
1298
375
|
let listener;
|
|
1299
|
-
|
|
1300
|
-
|
|
376
|
+
const asIs = (text) => text;
|
|
377
|
+
let mask = asIs;
|
|
378
|
+
/**
|
|
379
|
+
* Calls `fn` for every docker command this process runs, or stops with `undefined`. `redact`
|
|
380
|
+
* masks each argument, stream and error before it's clipped, so a value the clip would cut
|
|
381
|
+
* through is masked whole.
|
|
382
|
+
*/
|
|
383
|
+
function onDockerCommand(fn, redact = asIs) {
|
|
1301
384
|
listener = fn;
|
|
385
|
+
mask = redact;
|
|
1302
386
|
}
|
|
1303
|
-
|
|
387
|
+
/**
|
|
388
|
+
* How far past the clip `redact` reads, so a value that starts before the clip and is shorter
|
|
389
|
+
* than this is masked whole, without masking all of a large output.
|
|
390
|
+
*/
|
|
391
|
+
const MASK_SPAN = 16384;
|
|
392
|
+
const clip = (raw, max) => {
|
|
393
|
+
const read = raw.slice(0, max + MASK_SPAN);
|
|
394
|
+
const text = mask(read);
|
|
395
|
+
const unread = raw.length - read.length;
|
|
396
|
+
if (text.length <= max && !unread) return text;
|
|
397
|
+
return `${text.slice(0, max)}… (${Math.max(0, text.length - max) + unread} more)`;
|
|
398
|
+
};
|
|
1304
399
|
/** Text as is (clipped), or a byte count for binary output such as a file read with `cat`. */
|
|
1305
400
|
function streamPreview(data) {
|
|
1306
401
|
if (typeof data === "string") return clip(data, MAX_STREAM);
|
|
@@ -1322,7 +417,7 @@ function traceDocker(args, startedAt, result, bin = "docker") {
|
|
|
1322
417
|
exitCode: null,
|
|
1323
418
|
stdout: "",
|
|
1324
419
|
stderr: "",
|
|
1325
|
-
error
|
|
420
|
+
error: mask(error)
|
|
1326
421
|
});
|
|
1327
422
|
return;
|
|
1328
423
|
}
|
|
@@ -1602,6 +697,98 @@ async function imageInfo(image, engine) {
|
|
|
1602
697
|
};
|
|
1603
698
|
}
|
|
1604
699
|
//#endregion
|
|
700
|
+
//#region ../sandbox-docker/src/dockerignore.ts
|
|
701
|
+
const ignore = dockerignore.default;
|
|
702
|
+
/**
|
|
703
|
+
* A pattern `@balena/dockerignore` may match differently from BuildKit: escapes, character
|
|
704
|
+
* classes and the regexp characters it doesn't escape, a `**` joined to other characters, and the
|
|
705
|
+
* whitespace Go and JavaScript trim differently. One over 1024 characters is risky too, since
|
|
706
|
+
* JavaScript refuses a regexp that long that Go accepts, and so is one with more than four `*`
|
|
707
|
+
* runs, whose JavaScript regexp can backtrack for minutes where Go's runs in linear time.
|
|
708
|
+
*/
|
|
709
|
+
const RISKY = /[\\[\]^+(){}|\u0085\uFEFF]|[^/]\*\*|\*\*[^/]/;
|
|
710
|
+
const MAX_STARS = 4;
|
|
711
|
+
/**
|
|
712
|
+
* Names `@balena/dockerignore` may match differently: `?` matches one UTF-16 unit there and one
|
|
713
|
+
* code point in BuildKit, and `.` doesn't match a line terminator there but does in Go.
|
|
714
|
+
*/
|
|
715
|
+
const ODD_NAME = /[\n\r\u2028\u2029\u{10000}-\u{10FFFF}]/u;
|
|
716
|
+
const clean = (pattern) => posix.normalize(pattern).replace(/^\/+/, "").replace(/\/+$/, "");
|
|
717
|
+
/**
|
|
718
|
+
* `.dockerignore` lines as Docker reads them: a BOM is dropped, a line starting `#` is a comment,
|
|
719
|
+
* and `!` re-includes. A path is left out when a rule excludes it and no `!` rule matches it or a
|
|
720
|
+
* directory it's in: BuildKit then excludes it whatever order the rules are in, so this never
|
|
721
|
+
* leaves out a file `docker build` sends, though it keeps some it doesn't. A risky exclusion is
|
|
722
|
+
* dropped, and a risky `!` rule keeps everything, as does one `@balena/dockerignore` would read
|
|
723
|
+
* as a comment or a pattern that cleans to a leading `!` (`!!a`, `/ !a`), which the two read
|
|
724
|
+
* differently.
|
|
725
|
+
*/
|
|
726
|
+
function parseRules(text) {
|
|
727
|
+
const excludes = [];
|
|
728
|
+
const reincludes = [];
|
|
729
|
+
for (const line of text.replace(/^\uFEFF/, "").split(/\r?\n/)) {
|
|
730
|
+
if (line.startsWith("#")) continue;
|
|
731
|
+
let pattern = line.trim();
|
|
732
|
+
const negate = pattern.startsWith("!");
|
|
733
|
+
if (negate) pattern = pattern.slice(1).trim();
|
|
734
|
+
if (!pattern) continue;
|
|
735
|
+
const cleaned = clean(pattern);
|
|
736
|
+
const risky = RISKY.test(pattern) || pattern.length > 1024 || (pattern.match(/\*+/g)?.length ?? 0) > MAX_STARS || [".", ""].includes(cleaned);
|
|
737
|
+
if (cleaned.trim().startsWith("!") || negate && pattern.startsWith("#") || negate && risky) return {
|
|
738
|
+
left: () => false,
|
|
739
|
+
literal: null
|
|
740
|
+
};
|
|
741
|
+
if (!negate) {
|
|
742
|
+
if (!risky) excludes.push(line);
|
|
743
|
+
} else reincludes.push(pattern);
|
|
744
|
+
}
|
|
745
|
+
const exclude = ignore({ ignorecase: false }).add(excludes);
|
|
746
|
+
const reinclude = ignore({ ignorecase: false }).add(reincludes);
|
|
747
|
+
return {
|
|
748
|
+
left: (path) => !ODD_NAME.test(path) && exclude.ignores(path) && !reinclude.ignores(path),
|
|
749
|
+
literal: reincludes.some((p) => /[*?]/.test(p)) ? null : reincludes.map(clean)
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
/** Whether reeval leaves `path` out of a hash under these `.dockerignore` rules. */
|
|
753
|
+
function dockerignoreMatcher(text) {
|
|
754
|
+
return parseRules(text).left;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Files in the build context that reeval hashes, sorted, relative to `context`: every file
|
|
758
|
+
* `docker build` sends (and some it doesn't), plus the Dockerfile and `.dockerignore`. A
|
|
759
|
+
* Dockerfile read from stdin (`dockerfile` null) has no `<Dockerfile>.dockerignore` of its own.
|
|
760
|
+
* A left-out directory is skipped only when every `!` rule is a literal path outside it. Docker
|
|
761
|
+
* doesn't apply an ignore file that's a symlink or not a file, so then every file is hashed; nor
|
|
762
|
+
* can it send what's in a directory it can't read.
|
|
763
|
+
*/
|
|
764
|
+
function contextFiles(context, dockerfile) {
|
|
765
|
+
const own = [...dockerfile ? [`${dockerfile}.dockerignore`] : [], join(context, ".dockerignore")].map((path) => ({
|
|
766
|
+
path,
|
|
767
|
+
stat: lstatSync(path, { throwIfNoEntry: false })
|
|
768
|
+
})).find(({ stat }) => stat);
|
|
769
|
+
const { left, literal } = parseRules(own?.stat?.isFile() ? readFileSync(own.path, "utf8") : "");
|
|
770
|
+
const always = [...dockerfile ? [relative(context, dockerfile)] : [], ".dockerignore"].map((path) => path.split("\\").join("/"));
|
|
771
|
+
const reach = [...always, ...literal ?? []];
|
|
772
|
+
const files = [];
|
|
773
|
+
const walk = (rel) => {
|
|
774
|
+
let entries;
|
|
775
|
+
try {
|
|
776
|
+
entries = readdirSync(join(context, rel), { withFileTypes: true });
|
|
777
|
+
} catch (error) {
|
|
778
|
+
if (rel && ["EACCES", "EPERM"].includes(error.code ?? "")) return;
|
|
779
|
+
throw error;
|
|
780
|
+
}
|
|
781
|
+
for (const entry of entries) {
|
|
782
|
+
const path = rel ? `${rel}/${entry.name}` : entry.name;
|
|
783
|
+
if (entry.isDirectory()) {
|
|
784
|
+
if (!(left(path) && literal && !reach.some((p) => p.startsWith(`${path}/`)))) walk(path);
|
|
785
|
+
} else if (!left(path) || always.includes(path)) files.push(path);
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
walk("");
|
|
789
|
+
return files.sort();
|
|
790
|
+
}
|
|
791
|
+
//#endregion
|
|
1605
792
|
//#region ../sandbox-docker/src/image.ts
|
|
1606
793
|
/**
|
|
1607
794
|
* The harness adapters an image can bake. Each pin must match the exact dependency (or
|
|
@@ -1621,15 +808,15 @@ const HARNESS_PACKAGES = {
|
|
|
1621
808
|
},
|
|
1622
809
|
antigravity: {
|
|
1623
810
|
name: "@reeval/harness-antigravity",
|
|
1624
|
-
version: "0.1.
|
|
811
|
+
version: "0.1.12"
|
|
1625
812
|
},
|
|
1626
813
|
opencode: {
|
|
1627
814
|
name: "@reeval/harness-opencode",
|
|
1628
|
-
version: "0.2.
|
|
815
|
+
version: "0.2.10"
|
|
1629
816
|
},
|
|
1630
817
|
goose: {
|
|
1631
818
|
name: "@reeval/harness-goose",
|
|
1632
|
-
version: "0.1.
|
|
819
|
+
version: "0.1.6"
|
|
1633
820
|
},
|
|
1634
821
|
pi: {
|
|
1635
822
|
name: "@reeval/harness-pi",
|
|
@@ -1637,15 +824,15 @@ const HARNESS_PACKAGES = {
|
|
|
1637
824
|
},
|
|
1638
825
|
codex: {
|
|
1639
826
|
name: "@reeval/harness-codex",
|
|
1640
|
-
version: "0.1.
|
|
827
|
+
version: "0.1.9"
|
|
1641
828
|
},
|
|
1642
829
|
fx: {
|
|
1643
830
|
name: "@reeval/harness-fx",
|
|
1644
|
-
version: "0.1.
|
|
831
|
+
version: "0.1.3"
|
|
1645
832
|
},
|
|
1646
833
|
"grok-build": {
|
|
1647
834
|
name: "@reeval/harness-grok-build",
|
|
1648
|
-
version: "0.1.
|
|
835
|
+
version: "0.1.6"
|
|
1649
836
|
}
|
|
1650
837
|
};
|
|
1651
838
|
/** Every harness with an image, in {@link HARNESS_PACKAGES} order. */
|
|
@@ -2066,6 +1253,56 @@ function forwarderMain(io, makeMux, linkStreams, proxyPort) {
|
|
|
2066
1253
|
/** The `node -e` script that runs {@link forwarderMain} in the container. */
|
|
2067
1254
|
const forwarderScript = (proxyPort) => `(${forwarderMain.toString()})({ net: require('node:net'), Duplex: require('node:stream').Duplex, input: process.stdin, output: process.stdout, error: (m) => process.stderr.write(m + '\\n'), exit: (c) => process.exit(c) }, ${createMux.toString()}, ${link.toString()}, ${proxyPort})`;
|
|
2068
1255
|
//#endregion
|
|
1256
|
+
//#region ../sandbox-docker/src/egress/effort.ts
|
|
1257
|
+
/** The paths read, in order; `*` is any key of an object (a gateway's provider name). */
|
|
1258
|
+
const PATHS = [
|
|
1259
|
+
"generationConfig.thinkingConfig.thinkingLevel",
|
|
1260
|
+
"generationConfig.thinkingConfig.thinkingBudget",
|
|
1261
|
+
"providerOptions.*.thinkingConfig.thinkingLevel",
|
|
1262
|
+
"providerOptions.*.thinkingConfig.thinkingBudget",
|
|
1263
|
+
"providerOptions.*.reasoningEffort",
|
|
1264
|
+
"reasoning_effort",
|
|
1265
|
+
"reasoning.effort",
|
|
1266
|
+
"reasoning.max_tokens",
|
|
1267
|
+
"reasoning.enabled",
|
|
1268
|
+
"output_config.effort",
|
|
1269
|
+
"thinking.type",
|
|
1270
|
+
"thinking.budget_tokens"
|
|
1271
|
+
];
|
|
1272
|
+
function walk(value, keys, at, out) {
|
|
1273
|
+
if (keys.length === 0) {
|
|
1274
|
+
if ([
|
|
1275
|
+
"string",
|
|
1276
|
+
"number",
|
|
1277
|
+
"boolean"
|
|
1278
|
+
].includes(typeof value)) out.push({
|
|
1279
|
+
path: at.join("."),
|
|
1280
|
+
value: String(value)
|
|
1281
|
+
});
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
1285
|
+
const [key, ...rest] = keys;
|
|
1286
|
+
const record = value;
|
|
1287
|
+
for (const name of key === "*" ? Object.keys(record).sort() : [key]) if (Object.hasOwn(record, name)) walk(record[name], rest, [...at, name], out);
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Every reasoning setting in a JSON request body, as `<path>=<value>` joined by spaces
|
|
1291
|
+
* (`reasoning_effort=high`, `providerOptions.google.thinkingConfig.thinkingLevel=low`), or
|
|
1292
|
+
* undefined when it carries none or isn't JSON.
|
|
1293
|
+
*/
|
|
1294
|
+
function requestedEffort(body) {
|
|
1295
|
+
let parsed;
|
|
1296
|
+
try {
|
|
1297
|
+
parsed = JSON.parse(body);
|
|
1298
|
+
} catch {
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
const found = [];
|
|
1302
|
+
for (const path of PATHS) walk(parsed, path.split("."), [], found);
|
|
1303
|
+
return found.length ? found.map((f) => `${f.path}=${f.value}`).join(" ") : void 0;
|
|
1304
|
+
}
|
|
1305
|
+
//#endregion
|
|
2069
1306
|
//#region ../sandbox-docker/src/egress/policy.ts
|
|
2070
1307
|
/** The Docker sandbox enforces every policy through its egress gateway, and records what passes. */
|
|
2071
1308
|
const DOCKER_EGRESS = {
|
|
@@ -2126,7 +1363,7 @@ const inList = (list, address) => {
|
|
|
2126
1363
|
const v = isIP(address);
|
|
2127
1364
|
return v !== 0 && list.check(address, v === 6 ? "ipv6" : "ipv4");
|
|
2128
1365
|
};
|
|
2129
|
-
const
|
|
1366
|
+
const normalize$1 = (host) => host.toLowerCase().replace(/\.$/, "").replace(/^\[|\]$/g, "");
|
|
2130
1367
|
/**
|
|
2131
1368
|
* Private, carrier-grade NAT and unique-local ranges: a name matched only by a `*.` pattern
|
|
2132
1369
|
* mustn't resolve into them, or anyone who can add a DNS record under the pattern's domain
|
|
@@ -2173,8 +1410,8 @@ function embeddedIPv4(address) {
|
|
|
2173
1410
|
const reaches = (address) => isIP(address) === 6 && inList(NAT64, address) ? [address, embeddedIPv4(address)] : [address];
|
|
2174
1411
|
/** How `host` matches: listed as it is, only by a `*.` pattern (never an IP address), or not. */
|
|
2175
1412
|
function hostMatch(patterns, host) {
|
|
2176
|
-
const h =
|
|
2177
|
-
const ps = patterns.map(
|
|
1413
|
+
const h = normalize$1(host);
|
|
1414
|
+
const ps = patterns.map(normalize$1);
|
|
2178
1415
|
if (ps.includes(h)) return "exact";
|
|
2179
1416
|
if (isIP(h) || /(?:^|\.)\d+$/.test(h)) return void 0;
|
|
2180
1417
|
return ps.some((p) => p.startsWith("*.") && h.endsWith(p.slice(1))) ? "wildcard" : void 0;
|
|
@@ -2196,7 +1433,7 @@ function createPolicyCheck(policy, options = {}) {
|
|
|
2196
1433
|
const allowedCidrs = blockList(custom?.allowedCIDRs);
|
|
2197
1434
|
const deniedCidrs = blockList(custom?.deniedCIDRs);
|
|
2198
1435
|
return async (rawHost) => {
|
|
2199
|
-
const host =
|
|
1436
|
+
const host = normalize$1(rawHost);
|
|
2200
1437
|
if (policy.mode === "deny-all") return {
|
|
2201
1438
|
allowed: false,
|
|
2202
1439
|
status: 403,
|
|
@@ -2270,7 +1507,7 @@ function createPolicyCheck(policy, options = {}) {
|
|
|
2270
1507
|
}
|
|
2271
1508
|
//#endregion
|
|
2272
1509
|
//#region ../sandbox-docker/src/egress/rules.ts
|
|
2273
|
-
const
|
|
1510
|
+
const normalizeHost = (host) => host.toLowerCase().replace(/\.$/, "");
|
|
2274
1511
|
function matchPart(matcher, value, ignoreCase = false) {
|
|
2275
1512
|
const v = ignoreCase ? value.toLowerCase() : value;
|
|
2276
1513
|
if ("exact" in matcher) return v === (ignoreCase ? matcher.exact.toLowerCase() : matcher.exact);
|
|
@@ -2284,7 +1521,7 @@ function matchPairs(matchers, pairs, ignoreKeyCase) {
|
|
|
2284
1521
|
const headerPairs = (headers) => Object.entries(headers).flatMap(([k, v]) => v === void 0 ? [] : (Array.isArray(v) ? v : [v]).map((x) => [k, x]));
|
|
2285
1522
|
function matches(rule, request) {
|
|
2286
1523
|
const { match } = rule;
|
|
2287
|
-
if (
|
|
1524
|
+
if (normalizeHost(match.host) !== normalizeHost(request.host)) return false;
|
|
2288
1525
|
const url = new URL(request.path, "https://placeholder.invalid");
|
|
2289
1526
|
if (match.path && !matchPart(match.path, url.pathname)) return false;
|
|
2290
1527
|
if (match.method && !match.method.some((m) => m.toUpperCase() === request.method.toUpperCase())) return false;
|
|
@@ -2297,13 +1534,18 @@ const onEndpoint = (endpoints, request) => endpoints.some((match) => matches({
|
|
|
2297
1534
|
transform: { headers: {} }
|
|
2298
1535
|
}, request));
|
|
2299
1536
|
/** Whether the gateway must decrypt connections to `host`: some rule could apply there. */
|
|
2300
|
-
const decrypts = (rules, host) => rules.some((r) =>
|
|
1537
|
+
const decrypts = (rules, host) => rules.some((r) => normalizeHost(r.match.host) === normalizeHost(host));
|
|
2301
1538
|
/** What a credential the sandbox never sent comes back as. */
|
|
2302
1539
|
const REDACTED = "reeval_redacted_credential";
|
|
2303
1540
|
/** Shorter values aren't credentials, and scrubbing them would mangle ordinary text. */
|
|
2304
1541
|
const MIN_CREDENTIAL = 16;
|
|
2305
1542
|
const schemeAndToken = (value) => /^([A-Za-z][\w-]*) +(\S+)$/.exec(value);
|
|
2306
1543
|
/**
|
|
1544
|
+
* Whether a rule for `host` sets a credential: a header value long enough to be one, whether it
|
|
1545
|
+
* replaces a placeholder the sandbox sent or adds a bearer the sandbox never had.
|
|
1546
|
+
*/
|
|
1547
|
+
const setsCredential = (rules, host) => rules.some((r) => normalizeHost(r.match.host) === normalizeHost(host) && Object.values(r.transform.headers).some((v) => v.length >= MIN_CREDENTIAL));
|
|
1548
|
+
/**
|
|
2307
1549
|
* The values credential rules for `host` set (rules keyed on a header the sandbox sends, such as
|
|
2308
1550
|
* a placeholder key), each paired with what the sandbox sent in its place, for scrubbing from
|
|
2309
1551
|
* responses. A value with a scheme (`Bearer <key>`) is paired as a whole and by its token too.
|
|
@@ -2315,7 +1557,7 @@ function credentialValues(rules, host) {
|
|
|
2315
1557
|
};
|
|
2316
1558
|
for (const rule of rules) {
|
|
2317
1559
|
const keyed = rule.match.headers ?? [];
|
|
2318
|
-
if (!keyed.length ||
|
|
1560
|
+
if (!keyed.length || normalizeHost(rule.match.host) !== normalizeHost(host)) continue;
|
|
2319
1561
|
for (const [name, value] of Object.entries(rule.transform.headers)) {
|
|
2320
1562
|
const sent = keyed.find((m) => m.key && "exact" in m.key && m.key.exact.toLowerCase() === name.toLowerCase())?.value;
|
|
2321
1563
|
const shown = sent && "exact" in sent ? sent.exact : REDACTED;
|
|
@@ -2530,7 +1772,7 @@ function tokenPlaceholder(token) {
|
|
|
2530
1772
|
* The exchange response with each token field replaced by a placeholder, and a substitution per
|
|
2531
1773
|
* token. A token already seen keeps its placeholder. Throws when the body isn't a JSON object.
|
|
2532
1774
|
*/
|
|
2533
|
-
function
|
|
1775
|
+
function tokenizeResponse(derived, body, known) {
|
|
2534
1776
|
const parsed = JSON.parse(body);
|
|
2535
1777
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("the response is not a JSON object");
|
|
2536
1778
|
const out = { ...parsed };
|
|
@@ -2577,12 +1819,28 @@ function frame(first, payload) {
|
|
|
2577
1819
|
}
|
|
2578
1820
|
return Buffer.concat([head, payload]);
|
|
2579
1821
|
}
|
|
1822
|
+
/** A control frame may carry at most this many payload bytes. */
|
|
1823
|
+
const MAX_CONTROL = 125;
|
|
1824
|
+
/**
|
|
1825
|
+
* A control frame's payload scrubbed and kept within 125 bytes, since a placeholder can be
|
|
1826
|
+
* longer than its value. A close frame keeps its 2-byte status code and its reason is cut at a
|
|
1827
|
+
* UTF-8 character boundary; a ping or pong payload is cut at 125 bytes.
|
|
1828
|
+
*/
|
|
1829
|
+
function scrubControl(opcode, payload, pairs) {
|
|
1830
|
+
if (opcode !== 8) return replaceAll(payload, pairs).subarray(0, MAX_CONTROL);
|
|
1831
|
+
if (payload.length < 2) return payload;
|
|
1832
|
+
const reason = replaceAll(payload.subarray(2), pairs);
|
|
1833
|
+
let end = Math.min(reason.length, 123);
|
|
1834
|
+
if (end < reason.length) while (end > 0 && ((reason[end] ?? 0) & 192) === 128) end--;
|
|
1835
|
+
return Buffer.concat([payload.subarray(0, 2), reason.subarray(0, end)]);
|
|
1836
|
+
}
|
|
2580
1837
|
/**
|
|
2581
1838
|
* Server-to-client WebSocket frames with every real value put back as its placeholder. Each data
|
|
2582
1839
|
* message is gathered whole, so a value split across its frames is still found, and sent on as
|
|
2583
|
-
* one frame; control
|
|
2584
|
-
* compressed frame (the upgrade request goes up without
|
|
2585
|
-
* one), or a message over 16 MiB, errors the stream
|
|
1840
|
+
* one frame; each control frame is scrubbed alone (`scrubControl`) and sent on at once, even
|
|
1841
|
+
* between a message's frames. A compressed frame (the upgrade request goes up without
|
|
1842
|
+
* extensions, so a server shouldn't send one), or a message over 16 MiB, errors the stream
|
|
1843
|
+
* rather than pass unread.
|
|
2586
1844
|
*/
|
|
2587
1845
|
function webSocketScrubber(subs) {
|
|
2588
1846
|
const pairs = subs.map((s) => [s.value, s.placeholder]);
|
|
@@ -2617,7 +1875,7 @@ function webSocketScrubber(subs) {
|
|
|
2617
1875
|
const opcode = first & 15;
|
|
2618
1876
|
if (first & 112) return done(/* @__PURE__ */ new Error("a compressed or extended WebSocket frame, which can't be scrubbed"));
|
|
2619
1877
|
if (opcode >= 8) {
|
|
2620
|
-
out.push(frame(first, payload));
|
|
1878
|
+
out.push(frame(first, scrubControl(opcode, payload, pairs)));
|
|
2621
1879
|
continue;
|
|
2622
1880
|
}
|
|
2623
1881
|
if (opcode === 0 ? !message : message) return done(/* @__PURE__ */ new Error("WebSocket frames out of order"));
|
|
@@ -2639,6 +1897,10 @@ function webSocketScrubber(subs) {
|
|
|
2639
1897
|
}
|
|
2640
1898
|
//#endregion
|
|
2641
1899
|
//#region ../sandbox-docker/src/egress/proxy.ts
|
|
1900
|
+
/** A TLS record's first byte when it carries a handshake, as a ClientHello does. */
|
|
1901
|
+
const TLS_HANDSHAKE = 22;
|
|
1902
|
+
/** How long a decrypted CONNECT waits for its client's first byte: Node's TLS handshake timeout. */
|
|
1903
|
+
const FIRST_BYTE_TIMEOUT_MS = 12e4;
|
|
2642
1904
|
const HOP_BY_HOP = /* @__PURE__ */ new Set([
|
|
2643
1905
|
"connection",
|
|
2644
1906
|
"keep-alive",
|
|
@@ -2661,6 +1923,8 @@ function parseAuthority(authority, defaultPort) {
|
|
|
2661
1923
|
port: Number(m?.[2] ?? defaultPort)
|
|
2662
1924
|
};
|
|
2663
1925
|
}
|
|
1926
|
+
/** Whether a parsed port names a TCP port; `net.connect` and `tls.connect` throw above 65535. */
|
|
1927
|
+
const isPort = (port) => Number.isInteger(port) && port >= 1 && port <= 65535;
|
|
2664
1928
|
/** `host` or `host:port` for a Host header or URL, IPv6 in brackets. */
|
|
2665
1929
|
const authorityOf = (host, port) => {
|
|
2666
1930
|
const name = net.isIPv6(host) ? `[${host}]` : host;
|
|
@@ -2688,6 +1952,7 @@ const isText = (type) => !type.trim() || /^\s*(text\/|application\/(json|xml|jav
|
|
|
2688
1952
|
const plainHeaders = (headers) => Object.fromEntries(Object.entries(headers).flatMap(([k, v]) => v === void 0 ? [] : [[k, Array.isArray(v) ? v.map(String) : String(v)]]));
|
|
2689
1953
|
function createEgressProxy(options) {
|
|
2690
1954
|
const log = options.log ?? (() => {});
|
|
1955
|
+
const firstByteTimeout = options.firstByteTimeout ?? FIRST_BYTE_TIMEOUT_MS;
|
|
2691
1956
|
const emit = (event) => {
|
|
2692
1957
|
try {
|
|
2693
1958
|
options.onEvent?.(event);
|
|
@@ -2700,6 +1965,8 @@ function createEgressProxy(options) {
|
|
|
2700
1965
|
const allSubs = () => tokens.length ? [...subs, ...tokens] : subs;
|
|
2701
1966
|
const derived = options.derivedTokens ?? [];
|
|
2702
1967
|
const tokenHosts = derived.flatMap((d) => [d.endpoint.host, ...d.hosts]);
|
|
1968
|
+
const locals = options.localResponses ?? [];
|
|
1969
|
+
const localHosts = locals.map((l) => l.match.host);
|
|
2703
1970
|
let policyCheck = createPolicyCheck(options.policy, options);
|
|
2704
1971
|
const check = async (host) => {
|
|
2705
1972
|
const verdict = await policyCheck(host);
|
|
@@ -2848,6 +2115,10 @@ function createEgressProxy(options) {
|
|
|
2848
2115
|
const front = http.createServer();
|
|
2849
2116
|
front.on("connect", (req, socket, head) => {
|
|
2850
2117
|
const { host, port } = parseAuthority(req.url ?? "", 443);
|
|
2118
|
+
if (!isPort(port)) {
|
|
2119
|
+
log(`reeval:egress CONNECT ${req.url} refused (invalid port)`);
|
|
2120
|
+
return reply(socket, 400, `reeval egress gateway: invalid port ${port} in CONNECT ${req.url}`);
|
|
2121
|
+
}
|
|
2851
2122
|
const startedAt = Date.now();
|
|
2852
2123
|
const tunnel = {
|
|
2853
2124
|
type: "request",
|
|
@@ -2881,11 +2152,21 @@ function createEgressProxy(options) {
|
|
|
2881
2152
|
port,
|
|
2882
2153
|
address: verdict.address
|
|
2883
2154
|
};
|
|
2884
|
-
if (decrypts(rules, host) || substitutes(allSubs(), host) || hostAllowed(tokenHosts, host)) {
|
|
2155
|
+
if (decrypts(rules, host) || substitutes(allSubs(), host) || hostAllowed(tokenHosts, host) || hostAllowed(localHosts, host)) {
|
|
2885
2156
|
log(`reeval:egress CONNECT ${host}:${port} decrypt`);
|
|
2886
2157
|
socket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
|
|
2887
2158
|
if (head.length) socket.unshift(head);
|
|
2888
|
-
return decrypt(socket, target)
|
|
2159
|
+
return firstByte(socket, (byte) => byte === TLS_HANDSHAKE ? decrypt(socket, target) : plainInTunnel(socket, target), (reason) => {
|
|
2160
|
+
log(`reeval:egress CONNECT ${host}:${port} closed (${reason})`);
|
|
2161
|
+
emit({
|
|
2162
|
+
...tunnel,
|
|
2163
|
+
allowed: true,
|
|
2164
|
+
reason,
|
|
2165
|
+
sent: 0,
|
|
2166
|
+
received: 0,
|
|
2167
|
+
ms: Date.now() - startedAt
|
|
2168
|
+
});
|
|
2169
|
+
});
|
|
2889
2170
|
}
|
|
2890
2171
|
log(`reeval:egress CONNECT ${host}:${port} tunnel`);
|
|
2891
2172
|
let status = 200;
|
|
@@ -2934,6 +2215,10 @@ function createEgressProxy(options) {
|
|
|
2934
2215
|
if (url.protocol !== "http:" && url.protocol !== "https:") return res.writeHead(400).end(`reeval egress gateway: expected an http:// or https:// URL, not ${url.protocol}\n`);
|
|
2935
2216
|
const secure = url.protocol === "https:";
|
|
2936
2217
|
const { host, port } = parseAuthority(url.host, secure ? 443 : 80);
|
|
2218
|
+
if (!isPort(port)) {
|
|
2219
|
+
log(`reeval:egress ${req.method} ${url.protocol}//${url.host} refused (invalid port)`);
|
|
2220
|
+
return res.writeHead(400).end(`reeval egress gateway: invalid port ${port} in ${url.origin}\n`);
|
|
2221
|
+
}
|
|
2937
2222
|
const shown = secure ? `https://${host}` : `http://${host}:${port}`;
|
|
2938
2223
|
const done = requestEvent(res, {
|
|
2939
2224
|
method: req.method ?? "GET",
|
|
@@ -2943,6 +2228,7 @@ function createEgressProxy(options) {
|
|
|
2943
2228
|
via: secure ? "decrypted" : "http",
|
|
2944
2229
|
requestHeaders: plainHeaders(req.headers)
|
|
2945
2230
|
});
|
|
2231
|
+
const path = url.pathname + url.search;
|
|
2946
2232
|
check(host).then((verdict) => {
|
|
2947
2233
|
if (!verdict.allowed) {
|
|
2948
2234
|
log(`reeval:egress ${req.method} ${shown} denied (${verdict.reason})`);
|
|
@@ -2951,41 +2237,224 @@ function createEgressProxy(options) {
|
|
|
2951
2237
|
return res.writeHead(verdict.status).end(`blocked by the reeval egress policy: ${verdict.reason}\n`);
|
|
2952
2238
|
}
|
|
2953
2239
|
contact(req.socket, host, port);
|
|
2240
|
+
const target = {
|
|
2241
|
+
host,
|
|
2242
|
+
port,
|
|
2243
|
+
address: verdict.address
|
|
2244
|
+
};
|
|
2954
2245
|
if (secure) {
|
|
2955
2246
|
const headers = {
|
|
2956
2247
|
...req.headers,
|
|
2957
2248
|
host: url.host
|
|
2958
2249
|
};
|
|
2959
|
-
onDecrypted(
|
|
2960
|
-
host,
|
|
2961
|
-
port,
|
|
2962
|
-
address: verdict.address
|
|
2963
|
-
}, req, res, url.pathname + url.search, headers, done);
|
|
2250
|
+
onDecrypted(target, req, res, path, headers, done);
|
|
2964
2251
|
return;
|
|
2965
2252
|
}
|
|
2966
|
-
|
|
2967
|
-
const upstream = http.request({
|
|
2968
|
-
host: verdict.address,
|
|
2969
|
-
port,
|
|
2970
|
-
method: req.method,
|
|
2971
|
-
path: url.pathname + url.search,
|
|
2972
|
-
headers: {
|
|
2973
|
-
...endToEnd(req.headers),
|
|
2974
|
-
host: url.host
|
|
2975
|
-
}
|
|
2976
|
-
});
|
|
2977
|
-
forwardHttp1(req.pipe(counter(done.sent)), res, upstream, {
|
|
2978
|
-
own: [],
|
|
2979
|
-
creds: [],
|
|
2980
|
-
url: `${shown}${url.pathname}`,
|
|
2981
|
-
t: done
|
|
2982
|
-
});
|
|
2253
|
+
onPlain(target, req, res, path, url.host, done);
|
|
2983
2254
|
});
|
|
2984
2255
|
});
|
|
2985
2256
|
front.on("upgrade", (_req, socket) => {
|
|
2986
2257
|
reply(socket, 501, "reeval egress gateway: use CONNECT for websockets");
|
|
2987
2258
|
});
|
|
2988
2259
|
/**
|
|
2260
|
+
* Sends a plain-HTTP request upstream as the sandbox sent it: never given credentials or
|
|
2261
|
+
* substitutions, so a placeholder sent over plain HTTP goes out as the placeholder.
|
|
2262
|
+
*/
|
|
2263
|
+
function onPlain(target, req, res, path, host, done) {
|
|
2264
|
+
const url = `http://${target.host}:${target.port}${pathOnly(path)}`;
|
|
2265
|
+
log(`reeval:egress ${req.method} ${url}`);
|
|
2266
|
+
const upstream = http.request({
|
|
2267
|
+
host: target.address,
|
|
2268
|
+
port: target.port,
|
|
2269
|
+
method: req.method,
|
|
2270
|
+
path,
|
|
2271
|
+
headers: {
|
|
2272
|
+
...endToEnd(req.headers),
|
|
2273
|
+
host
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
forwardHttp1(req.pipe(counter(done.sent)), res, upstream, {
|
|
2277
|
+
own: [],
|
|
2278
|
+
creds: [],
|
|
2279
|
+
url,
|
|
2280
|
+
t: done
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
/**
|
|
2284
|
+
* Calls `then` with the connection's first byte once it arrives, left unread for the next
|
|
2285
|
+
* reader, or `idle` with why there's none: the client closed it first, or it waited
|
|
2286
|
+
* `firstByteTimeout` and closed it.
|
|
2287
|
+
*/
|
|
2288
|
+
function firstByte(socket, then, idle) {
|
|
2289
|
+
const timer = setTimeout(() => {
|
|
2290
|
+
stop();
|
|
2291
|
+
socket.destroy();
|
|
2292
|
+
idle(`the client sent nothing within ${firstByteTimeout / 1e3}s`);
|
|
2293
|
+
}, firstByteTimeout);
|
|
2294
|
+
const onReadable = () => {
|
|
2295
|
+
const chunk = socket.read();
|
|
2296
|
+
if (!chunk?.length) return;
|
|
2297
|
+
stop();
|
|
2298
|
+
socket.unshift(chunk);
|
|
2299
|
+
then(chunk[0]);
|
|
2300
|
+
};
|
|
2301
|
+
const onClose = () => {
|
|
2302
|
+
stop();
|
|
2303
|
+
idle("the client closed the connection without sending anything");
|
|
2304
|
+
};
|
|
2305
|
+
const stop = () => {
|
|
2306
|
+
clearTimeout(timer);
|
|
2307
|
+
socket.off("readable", onReadable);
|
|
2308
|
+
socket.off("close", onClose);
|
|
2309
|
+
};
|
|
2310
|
+
socket.on("readable", onReadable);
|
|
2311
|
+
socket.once("close", onClose);
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* The path a request in a plain tunnel asks for, or why it's refused: its Host or absolute-form
|
|
2315
|
+
* URL names a host other than the CONNECT target, which a server sharing the target's address
|
|
2316
|
+
* could route it to.
|
|
2317
|
+
*/
|
|
2318
|
+
function inTunnel(target, req) {
|
|
2319
|
+
const asked = req.url ?? "/";
|
|
2320
|
+
const absolute = asked.startsWith("/") ? void 0 : URL.parse(asked);
|
|
2321
|
+
const path = absolute ? absolute.pathname + absolute.search : asked;
|
|
2322
|
+
for (const named of [absolute?.host, req.headers.host]) {
|
|
2323
|
+
if (!named) continue;
|
|
2324
|
+
const host = parseAuthority(named, target.port).host;
|
|
2325
|
+
if (host === target.host) continue;
|
|
2326
|
+
const shown = `http://${authorityOf(target.host, target.port)}${pathOnly(path)}`;
|
|
2327
|
+
log(`reeval:egress ${req.method} ${shown} refused (Host ${host})`);
|
|
2328
|
+
return {
|
|
2329
|
+
path,
|
|
2330
|
+
refused: `reeval egress gateway: the request names ${host}, but the connection is to ${target.host}; send it on a connection to ${host}.`
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
return { path };
|
|
2334
|
+
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Serves a CONNECT to a decrypted host whose client speaks plain HTTP/1.1 in the tunnel, as a
|
|
2337
|
+
* Node client sends an `http://` request through a proxy: each request goes upstream as an
|
|
2338
|
+
* absolute-form `http://` one does, with no credentials or substitutions.
|
|
2339
|
+
*/
|
|
2340
|
+
function plainInTunnel(socket, target) {
|
|
2341
|
+
const authority = authorityOf(target.host, target.port);
|
|
2342
|
+
const refuse = (s, reason) => {
|
|
2343
|
+
emit({
|
|
2344
|
+
type: "request",
|
|
2345
|
+
method: "CONNECT",
|
|
2346
|
+
url: authority,
|
|
2347
|
+
host: target.host,
|
|
2348
|
+
port: target.port,
|
|
2349
|
+
via: "http",
|
|
2350
|
+
allowed: false,
|
|
2351
|
+
status: 400,
|
|
2352
|
+
reason,
|
|
2353
|
+
sent: 0,
|
|
2354
|
+
received: 0,
|
|
2355
|
+
substituted: [],
|
|
2356
|
+
credentials: [],
|
|
2357
|
+
ms: 0
|
|
2358
|
+
});
|
|
2359
|
+
reply(s, 400, reason);
|
|
2360
|
+
};
|
|
2361
|
+
const server = http.createServer((req, res) => {
|
|
2362
|
+
const { path, refused } = inTunnel(target, req);
|
|
2363
|
+
const done = requestEvent(res, {
|
|
2364
|
+
method: req.method ?? "GET",
|
|
2365
|
+
url: `http://${authority}${pathOnly(path)}`,
|
|
2366
|
+
host: target.host,
|
|
2367
|
+
port: target.port,
|
|
2368
|
+
via: "http",
|
|
2369
|
+
requestHeaders: plainHeaders(req.headers)
|
|
2370
|
+
});
|
|
2371
|
+
if (refused) {
|
|
2372
|
+
done.refuse(refused);
|
|
2373
|
+
req.resume();
|
|
2374
|
+
return res.writeHead(421, { "content-type": "text/plain" }).end(`${refused}\n`);
|
|
2375
|
+
}
|
|
2376
|
+
onPlain(target, req, res, path, req.headers.host ?? authority, done);
|
|
2377
|
+
});
|
|
2378
|
+
server.on("upgrade", (req, s, head) => onPlainUpgrade(target, req, track(s), head));
|
|
2379
|
+
server.on("connect", (req, s) => {
|
|
2380
|
+
log(`reeval:egress CONNECT ${authority} refused (CONNECT ${req.url} inside it)`);
|
|
2381
|
+
refuse(s, `reeval egress gateway: CONNECT ${req.url} came inside the tunnel to ${authority}; send it to the gateway on a connection of its own.`);
|
|
2382
|
+
});
|
|
2383
|
+
server.on("clientError", (error, s) => {
|
|
2384
|
+
if (!error.code?.startsWith("HPE_") || error.code === "HPE_INVALID_EOF_STATE") return s.destroy();
|
|
2385
|
+
log(`reeval:egress CONNECT ${authority} refused (neither TLS nor HTTP/1.1)`);
|
|
2386
|
+
refuse(s, `reeval egress gateway: the connection to ${authority} carries neither a TLS handshake nor an HTTP/1.1 request. reeval reads every connection to a host with a brokered secret.`);
|
|
2387
|
+
});
|
|
2388
|
+
server.emit("connection", socket);
|
|
2389
|
+
}
|
|
2390
|
+
/** A plain-HTTP upgrade (a `ws://` WebSocket) in a tunnel, passed upstream as it is. */
|
|
2391
|
+
function onPlainUpgrade(target, req, socket, head) {
|
|
2392
|
+
const method = req.method ?? "GET";
|
|
2393
|
+
const startedAt = Date.now();
|
|
2394
|
+
const authority = authorityOf(target.host, target.port);
|
|
2395
|
+
const { path, refused } = inTunnel(target, req);
|
|
2396
|
+
const upgraded = (fields) => emit({
|
|
2397
|
+
type: "request",
|
|
2398
|
+
method,
|
|
2399
|
+
url: `http://${authority}${pathOnly(path)}`,
|
|
2400
|
+
host: target.host,
|
|
2401
|
+
port: target.port,
|
|
2402
|
+
via: "http",
|
|
2403
|
+
allowed: true,
|
|
2404
|
+
sent: 0,
|
|
2405
|
+
received: 0,
|
|
2406
|
+
substituted: [],
|
|
2407
|
+
credentials: [],
|
|
2408
|
+
requestHeaders: plainHeaders(req.headers),
|
|
2409
|
+
...fields,
|
|
2410
|
+
ms: Date.now() - startedAt
|
|
2411
|
+
});
|
|
2412
|
+
if (refused) {
|
|
2413
|
+
upgraded({
|
|
2414
|
+
allowed: false,
|
|
2415
|
+
status: 421,
|
|
2416
|
+
reason: refused
|
|
2417
|
+
});
|
|
2418
|
+
return reply(socket, 421, refused);
|
|
2419
|
+
}
|
|
2420
|
+
log(`reeval:egress ${method} http://${authority}${pathOnly(path)} (upgrade)`);
|
|
2421
|
+
const upstream = http.request({
|
|
2422
|
+
host: target.address,
|
|
2423
|
+
port: target.port,
|
|
2424
|
+
method,
|
|
2425
|
+
path,
|
|
2426
|
+
headers: {
|
|
2427
|
+
...endToEnd(req.headers, ["upgrade", "connection"]),
|
|
2428
|
+
host: req.headers.host ?? authority
|
|
2429
|
+
}
|
|
2430
|
+
});
|
|
2431
|
+
upstream.once("upgrade", (up, upSocket, upHead) => {
|
|
2432
|
+
upgraded({
|
|
2433
|
+
status: up.statusCode,
|
|
2434
|
+
responseHeaders: plainHeaders(up.headers)
|
|
2435
|
+
});
|
|
2436
|
+
const lines = [`HTTP/1.1 ${up.statusCode} ${up.statusMessage}`];
|
|
2437
|
+
for (let i = 0; i < up.rawHeaders.length; i += 2) lines.push(`${up.rawHeaders[i]}: ${up.rawHeaders[i + 1] ?? ""}`);
|
|
2438
|
+
socket.write(`${lines.join("\r\n")}\r\n\r\n`);
|
|
2439
|
+
if (head.length) upSocket.write(head);
|
|
2440
|
+
if (upHead.length) socket.write(upHead);
|
|
2441
|
+
link(socket, track(upSocket));
|
|
2442
|
+
});
|
|
2443
|
+
upstream.once("response", (up) => {
|
|
2444
|
+
upgraded({ status: up.statusCode });
|
|
2445
|
+
reply(socket, up.statusCode ?? 502, `upstream refused the upgrade (${up.statusCode})`);
|
|
2446
|
+
up.resume();
|
|
2447
|
+
});
|
|
2448
|
+
upstream.once("error", (error) => {
|
|
2449
|
+
upgraded({
|
|
2450
|
+
status: 502,
|
|
2451
|
+
reason: error.message
|
|
2452
|
+
});
|
|
2453
|
+
reply(socket, 502, `reeval egress gateway: ${error.message}`);
|
|
2454
|
+
});
|
|
2455
|
+
upstream.end();
|
|
2456
|
+
}
|
|
2457
|
+
/**
|
|
2989
2458
|
* Terminates TLS with a certificate for the CONNECT host. One server per connection, since the
|
|
2990
2459
|
* host comes from CONNECT; it serves HTTP/2 and HTTP/1.1 (with upgrades) by ALPN.
|
|
2991
2460
|
*/
|
|
@@ -3107,9 +2576,11 @@ function createEgressProxy(options) {
|
|
|
3107
2576
|
* The request body as sent upstream: through the substituter when a secret there opts in to
|
|
3108
2577
|
* bodies, unless the body is encoded (gzip and the like), which is sent as is and fails closed.
|
|
3109
2578
|
*/
|
|
3110
|
-
function requestBody(req, headers, own, t) {
|
|
3111
|
-
const
|
|
3112
|
-
|
|
2579
|
+
function requestBody(req, headers, own, t, readsEffort = false) {
|
|
2580
|
+
const encoded = String(headers["content-encoding"] ?? "identity") !== "identity";
|
|
2581
|
+
const sent = t ? req.pipe(counter(t.sent)) : req;
|
|
2582
|
+
const counted = readsEffort && t && !encoded ? sent.pipe(effortReader(t)) : sent;
|
|
2583
|
+
if (encoded || !own.some((s) => s.in.includes("body"))) return counted;
|
|
3113
2584
|
delete headers["content-length"];
|
|
3114
2585
|
return counted.pipe(bodySubstituter(own));
|
|
3115
2586
|
}
|
|
@@ -3184,30 +2655,81 @@ function createEgressProxy(options) {
|
|
|
3184
2655
|
* echoes the request's instructions and tools before it.
|
|
3185
2656
|
*/
|
|
3186
2657
|
const MODEL_WINDOW = 524288;
|
|
2658
|
+
const PROVIDER = /"provider"\s*:\s*"([^"\\]{1,200})"/;
|
|
3187
2659
|
/**
|
|
3188
|
-
*
|
|
3189
|
-
* `
|
|
3190
|
-
|
|
2660
|
+
* The provider of the endpoint a gateway's routing metadata marks `"selected": true`
|
|
2661
|
+
* (OpenRouter's `openrouter_metadata.endpoints.available`, which lists the others too).
|
|
2662
|
+
*/
|
|
2663
|
+
const selectedProvider = (text) => {
|
|
2664
|
+
const endpoint = /\{[^{}]*"selected"\s*:\s*true[^{}]*\}/.exec(text);
|
|
2665
|
+
return endpoint ? PROVIDER.exec(endpoint[0])?.[1] : void 0;
|
|
2666
|
+
};
|
|
2667
|
+
/**
|
|
2668
|
+
* Records the first `"model"` or `"modelId"` value in the response body and the `"effort"` of the
|
|
2669
|
+
* `"reasoning"` object after it, within {@link MODEL_WINDOW}; the provider of a selected endpoint
|
|
2670
|
+
* there or in the body's {@link TAIL}, else the first `"provider"` string in the window; and the
|
|
2671
|
+
* last `"cost"` number in the whole body, reading alongside its flow. Inside a JSON string the
|
|
2672
|
+
* quotes are escaped, so text that merely mentions them doesn't match.
|
|
3191
2673
|
*/
|
|
3192
2674
|
function readModel(up, t) {
|
|
3193
2675
|
let seen = "";
|
|
2676
|
+
let tail = "";
|
|
2677
|
+
let model = null;
|
|
2678
|
+
let effort = null;
|
|
2679
|
+
let provider;
|
|
2680
|
+
let selected;
|
|
3194
2681
|
const onData = (chunk) => {
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
2682
|
+
const text = chunk.toString("utf8");
|
|
2683
|
+
if (seen.length <= MODEL_WINDOW && !(effort && selected)) {
|
|
2684
|
+
seen += text;
|
|
2685
|
+
model ??= /"model(?:Id)?"\s*:\s*"([^"\\]{1,200})"/.exec(seen);
|
|
2686
|
+
effort ??= model ? /"reasoning"\s*:\s*\{[^{}]*?"effort"\s*:\s*"(\w{1,40})"/.exec(seen.slice(model.index)) : null;
|
|
2687
|
+
provider ??= PROVIDER.exec(seen)?.[1];
|
|
2688
|
+
selected ??= selectedProvider(seen);
|
|
2689
|
+
if (model) t.set({ responseModel: model[1] });
|
|
2690
|
+
if (effort) t.set({ responseEffort: effort[1] });
|
|
2691
|
+
}
|
|
2692
|
+
tail = (tail + text).slice(-16384);
|
|
2693
|
+
selected ??= selectedProvider(tail);
|
|
2694
|
+
const served = selected ?? provider;
|
|
2695
|
+
if (served) t.set({ responseProvider: served });
|
|
2696
|
+
const cost = [...tail.matchAll(/"cost"\s*:\s*(\d+(?:\.\d+)?(?:[eE][-+]?\d+)?)/g)].at(-1);
|
|
2697
|
+
if (cost) t.set({ responseCost: Number(cost[1]) });
|
|
3201
2698
|
};
|
|
3202
2699
|
up.on("data", onData);
|
|
3203
2700
|
}
|
|
2701
|
+
/** Most of a request body the gateway reads for its reasoning settings: a long session's. */
|
|
2702
|
+
const EFFORT_LIMIT = 16777216;
|
|
2703
|
+
/**
|
|
2704
|
+
* The body passed on as it flows, recording the reasoning settings its JSON carries once it
|
|
2705
|
+
* ends. A transform, not a `data` listener: that would start the body flowing before the
|
|
2706
|
+
* upstream request is there to take it.
|
|
2707
|
+
*/
|
|
2708
|
+
function effortReader(t) {
|
|
2709
|
+
const chunks = [];
|
|
2710
|
+
let size = 0;
|
|
2711
|
+
return new Transform({
|
|
2712
|
+
transform(chunk, _encoding, done) {
|
|
2713
|
+
size += chunk.length;
|
|
2714
|
+
if (size <= EFFORT_LIMIT) chunks.push(chunk);
|
|
2715
|
+
done(null, chunk);
|
|
2716
|
+
},
|
|
2717
|
+
flush(done) {
|
|
2718
|
+
if (size <= EFFORT_LIMIT) {
|
|
2719
|
+
const effort = requestedEffort(Buffer.concat(chunks).toString("utf8"));
|
|
2720
|
+
if (effort) t.set({ requestEffort: effort });
|
|
2721
|
+
}
|
|
2722
|
+
done();
|
|
2723
|
+
}
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
3204
2726
|
/** Most an exchange's response may be; it's a few hundred bytes of JSON. */
|
|
3205
2727
|
const EXCHANGE_LIMIT = 1 << 20;
|
|
3206
2728
|
/**
|
|
3207
2729
|
* A token exchange's response, read whole, with each token replaced by a placeholder. A success
|
|
3208
2730
|
* that can't be read (compressed, too big, not JSON) is a 502: the real tokens never go through.
|
|
3209
2731
|
*/
|
|
3210
|
-
function
|
|
2732
|
+
function tokenized(exchange, url, status, headers, up, res, own, creds, t) {
|
|
3211
2733
|
const chunks = [];
|
|
3212
2734
|
let size = 0;
|
|
3213
2735
|
const refuse = (why) => {
|
|
@@ -3237,12 +2759,12 @@ function createEgressProxy(options) {
|
|
|
3237
2759
|
if (size > EXCHANGE_LIMIT) return refuse(`the response is over ${EXCHANGE_LIMIT} bytes`);
|
|
3238
2760
|
let result;
|
|
3239
2761
|
try {
|
|
3240
|
-
result =
|
|
2762
|
+
result = tokenizeResponse(exchange, body.toString("utf8"), tokens);
|
|
3241
2763
|
} catch (error) {
|
|
3242
2764
|
return refuse(error.message);
|
|
3243
2765
|
}
|
|
3244
2766
|
tokens = [...tokens, ...result.added];
|
|
3245
|
-
log(`reeval:egress ${url}
|
|
2767
|
+
log(`reeval:egress ${url} tokenized ${result.fields.join(", ") || "nothing"} (${exchange.name})`);
|
|
3246
2768
|
const text = Buffer.from(result.body);
|
|
3247
2769
|
delete out["content-encoding"];
|
|
3248
2770
|
res.writeHead(status, {
|
|
@@ -3272,9 +2794,28 @@ function createEgressProxy(options) {
|
|
|
3272
2794
|
req.resume();
|
|
3273
2795
|
return res.writeHead(refused.status, { "content-type": "text/plain" }).end(`${refused.reason}\n`);
|
|
3274
2796
|
}
|
|
2797
|
+
const local = locals.find((l) => onEndpoint([l.match], {
|
|
2798
|
+
host: target.host,
|
|
2799
|
+
method,
|
|
2800
|
+
path: asked,
|
|
2801
|
+
headers: {}
|
|
2802
|
+
}));
|
|
2803
|
+
if (local) {
|
|
2804
|
+
log(`reeval:egress ${method} ${url} answered by the gateway (${local.status})`);
|
|
2805
|
+
req.resume();
|
|
2806
|
+
const out = {
|
|
2807
|
+
"content-type": "application/json",
|
|
2808
|
+
...local.headers
|
|
2809
|
+
};
|
|
2810
|
+
t.set({
|
|
2811
|
+
status: local.status,
|
|
2812
|
+
responseHeaders: out
|
|
2813
|
+
});
|
|
2814
|
+
return res.writeHead(local.status, out).end(local.body);
|
|
2815
|
+
}
|
|
3275
2816
|
delete headers.upgrade;
|
|
3276
2817
|
delete headers.connection;
|
|
3277
|
-
const body = requestBody(req, headers, own, t);
|
|
2818
|
+
const body = requestBody(req, headers, own, t, !!readsModel || setsCredential(rules, target.host) || substitutes(allSubs(), target.host) || hostAllowed(tokenHosts, target.host));
|
|
3278
2819
|
const authority = authorityOf(target.host, target.port);
|
|
3279
2820
|
const session = req.httpVersionMajor === 2 ? await upstreamSession(target) : null;
|
|
3280
2821
|
if (!session) return forwardHttp1(body, res, https.request({
|
|
@@ -3312,7 +2853,7 @@ function createEgressProxy(options) {
|
|
|
3312
2853
|
const creds = credentialScrubs(target.host);
|
|
3313
2854
|
stream.once("response", (h) => {
|
|
3314
2855
|
const status = Number(h[":status"]);
|
|
3315
|
-
if (exchange) return
|
|
2856
|
+
if (exchange) return tokenized(exchange, url, status, h, stream, res, own, creds, t);
|
|
3316
2857
|
if (!respond(status, h, stream, res, own, creds, url, t, readsModel)) return;
|
|
3317
2858
|
stream.once("trailers", (trailers) => res.addTrailers(scrubbedHeaders(trailers, [...own, ...creds])));
|
|
3318
2859
|
});
|
|
@@ -3339,7 +2880,7 @@ function createEgressProxy(options) {
|
|
|
3339
2880
|
const { own, creds, url, exchange, t } = to;
|
|
3340
2881
|
upstream.once("response", (up) => {
|
|
3341
2882
|
const status = up.statusCode ?? 502;
|
|
3342
|
-
if (exchange) return
|
|
2883
|
+
if (exchange) return tokenized(exchange, url, status, up.headers, up, res, own, creds, t);
|
|
3343
2884
|
if (!respond(status, up.headers, up, res, own, creds, url, t, to.readsModel)) return;
|
|
3344
2885
|
up.once("end", () => {
|
|
3345
2886
|
if (Object.keys(up.trailers).length) res.addTrailers(scrubbedHeaders(up.trailers, [...own, ...creds]));
|
|
@@ -3517,7 +3058,7 @@ const installCa = (containerId, cert, signal, engine) => docker([
|
|
|
3517
3058
|
engine
|
|
3518
3059
|
});
|
|
3519
3060
|
/**
|
|
3520
|
-
* Starts the egress gateway for one container: a forwarder inside it,
|
|
3061
|
+
* Starts the egress gateway for one container: a forwarder inside it, tunneled over one
|
|
3521
3062
|
* `docker exec -i`, and the proxy in this process, which holds the real credentials.
|
|
3522
3063
|
*/
|
|
3523
3064
|
async function startGateway(containerId, options, signal, engine) {
|
|
@@ -3774,6 +3315,15 @@ async function confinementArgs(options) {
|
|
|
3774
3315
|
}
|
|
3775
3316
|
/** Runtime `npm i -g` goes to the sandbox user's own prefix, whose `bin` the images put on PATH. */
|
|
3776
3317
|
const userEnv = (options) => options.root ? {} : { NPM_CONFIG_PREFIX: `${SANDBOX_HOME}/.local` };
|
|
3318
|
+
/** The gateway didn't start for a detached container, which then has no way out: `reason` says why. */
|
|
3319
|
+
var EgressUnavailableError = class extends Error {
|
|
3320
|
+
reason;
|
|
3321
|
+
constructor(reason) {
|
|
3322
|
+
super(`Can't enforce the egress policy: ${reason}`);
|
|
3323
|
+
this.name = "EgressUnavailableError";
|
|
3324
|
+
this.reason = reason;
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3777
3327
|
/** Root's PATH in a privileged exec: none of the sandbox user's own `bin` directories. */
|
|
3778
3328
|
const SYSTEM_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
3779
3329
|
/** Set on every exec, so a kill can find the command's whole process tree in the container. */
|
|
@@ -3916,12 +3466,13 @@ async function createDockerSession(options) {
|
|
|
3916
3466
|
}
|
|
3917
3467
|
const egressOptions = options.egress === true ? {} : options.egress || void 0;
|
|
3918
3468
|
let egress;
|
|
3469
|
+
const direct = (policy) => !!egressOptions?.direct && !isRestricted(policy);
|
|
3919
3470
|
let detached = [];
|
|
3920
3471
|
const attach = async (policy) => {
|
|
3921
|
-
if (
|
|
3472
|
+
if (!direct(policy) && detached.length === 0) {
|
|
3922
3473
|
detached = await networksOf(id, engine);
|
|
3923
3474
|
const mode = detached.length === 0 ? await networkMode(id, engine) : "none";
|
|
3924
|
-
if (detached.length === 0 && mode !== "none") throw new Error(`the container's network is ${mode}, which ${spec.name} can't detach it from, so
|
|
3475
|
+
if (detached.length === 0 && mode !== "none") throw new Error(`the container's network is ${mode}, which ${spec.name} can't detach it from, so traffic around the gateway would still have a route out`);
|
|
3925
3476
|
for (const n of detached) await dockerOk([
|
|
3926
3477
|
"network",
|
|
3927
3478
|
"disconnect",
|
|
@@ -3929,7 +3480,7 @@ async function createDockerSession(options) {
|
|
|
3929
3480
|
n,
|
|
3930
3481
|
id
|
|
3931
3482
|
], { engine });
|
|
3932
|
-
} else if (
|
|
3483
|
+
} else if (direct(policy) && detached.length > 0) {
|
|
3933
3484
|
for (const n of detached) await dockerOk([
|
|
3934
3485
|
"network",
|
|
3935
3486
|
"connect",
|
|
@@ -3940,7 +3491,7 @@ async function createDockerSession(options) {
|
|
|
3940
3491
|
}
|
|
3941
3492
|
};
|
|
3942
3493
|
if (egressOptions) {
|
|
3943
|
-
const { policy = { mode: "allow-all" }, ...rest } = egressOptions;
|
|
3494
|
+
const { policy = { mode: "allow-all" }, direct: _, ...rest } = egressOptions;
|
|
3944
3495
|
try {
|
|
3945
3496
|
await attach(policy);
|
|
3946
3497
|
gateway = await startGateway(id, {
|
|
@@ -3949,10 +3500,10 @@ async function createDockerSession(options) {
|
|
|
3949
3500
|
}, signal, engine);
|
|
3950
3501
|
egress = { active: true };
|
|
3951
3502
|
} catch (error) {
|
|
3952
|
-
if (signal?.aborted ||
|
|
3503
|
+
if (signal?.aborted || !direct(policy)) {
|
|
3953
3504
|
await remove();
|
|
3954
3505
|
if (signal?.aborted) throw signal.reason;
|
|
3955
|
-
throw new
|
|
3506
|
+
throw new EgressUnavailableError(error.message);
|
|
3956
3507
|
}
|
|
3957
3508
|
egress = {
|
|
3958
3509
|
active: false,
|
|
@@ -4273,22 +3824,22 @@ const BOOTSTRAPS = {
|
|
|
4273
3824
|
name: "Cursor",
|
|
4274
3825
|
cli: "@cursor/sdk",
|
|
4275
3826
|
version: `node -p "'@cursor/sdk ' + require(process.env.HOME + '/.ai-sdk-harness/.harness-bootstrap/cursor-sdk/node_modules/@cursor/sdk/package.json').version"`,
|
|
4276
|
-
adapter: async () => (await import("./src-
|
|
3827
|
+
adapter: async () => (await import("./src-6_zz7oJs.js")).createCursorSdk()
|
|
4277
3828
|
},
|
|
4278
3829
|
"claude-code": {
|
|
4279
3830
|
name: "Claude Code",
|
|
4280
3831
|
cli: "claude",
|
|
4281
|
-
adapter: async () => (await import("./dist-
|
|
3832
|
+
adapter: async () => (await import("./dist-CYrBwyHA.js")).createClaudeCode()
|
|
4282
3833
|
},
|
|
4283
3834
|
antigravity: {
|
|
4284
3835
|
name: "Antigravity",
|
|
4285
3836
|
cli: "agy",
|
|
4286
|
-
adapter: async () => (await import("./src-
|
|
3837
|
+
adapter: async () => (await import("./src-C7upnZSd.js")).createAntigravity()
|
|
4287
3838
|
},
|
|
4288
3839
|
opencode: {
|
|
4289
3840
|
name: "OpenCode",
|
|
4290
3841
|
cli: "opencode",
|
|
4291
|
-
adapter: async () => (await import("./src-
|
|
3842
|
+
adapter: async () => (await import("./src-HSxBazcg.js")).createOpenCode({
|
|
4292
3843
|
auth: { GOOGLE_GENERATIVE_AI_API_KEY: "unused" },
|
|
4293
3844
|
model: "google/unused"
|
|
4294
3845
|
})
|
|
@@ -4296,7 +3847,7 @@ const BOOTSTRAPS = {
|
|
|
4296
3847
|
goose: {
|
|
4297
3848
|
name: "Goose",
|
|
4298
3849
|
cli: "goose",
|
|
4299
|
-
adapter: async () => (await import("./src-
|
|
3850
|
+
adapter: async () => (await import("./src-kYeaJJrl.js")).createGoose({
|
|
4300
3851
|
auth: { GOOGLE_API_KEY: "unused" },
|
|
4301
3852
|
model: "unused"
|
|
4302
3853
|
})
|
|
@@ -4304,17 +3855,17 @@ const BOOTSTRAPS = {
|
|
|
4304
3855
|
pi: {
|
|
4305
3856
|
name: "pi",
|
|
4306
3857
|
cli: "pi",
|
|
4307
|
-
adapter: async () => (await import("./src-
|
|
3858
|
+
adapter: async () => (await import("./src-Bp4aN3rA.js")).createPi({ auth: { GEMINI_API_KEY: "unused" } })
|
|
4308
3859
|
},
|
|
4309
3860
|
codex: {
|
|
4310
3861
|
name: "Codex",
|
|
4311
3862
|
cli: "codex",
|
|
4312
|
-
adapter: async () => (await import("./src-
|
|
3863
|
+
adapter: async () => (await import("./src-dlX-Lmxg.js")).createCodex({ auth: { OPENAI_API_KEY: "unused" } })
|
|
4313
3864
|
},
|
|
4314
3865
|
fx: {
|
|
4315
3866
|
name: "fx",
|
|
4316
3867
|
cli: "fx",
|
|
4317
|
-
adapter: async () => (await import("./src-
|
|
3868
|
+
adapter: async () => (await import("./src-LD1BAJFa.js")).createFx({
|
|
4318
3869
|
auth: { AI_GATEWAY_API_KEY: "unused" },
|
|
4319
3870
|
model: "unused/unused"
|
|
4320
3871
|
})
|
|
@@ -4322,7 +3873,7 @@ const BOOTSTRAPS = {
|
|
|
4322
3873
|
"grok-build": {
|
|
4323
3874
|
name: "Grok Build",
|
|
4324
3875
|
cli: "grok",
|
|
4325
|
-
adapter: async () => (await import("./src-
|
|
3876
|
+
adapter: async () => (await import("./src-BYPMM1x7.js")).createGrokBuild({
|
|
4326
3877
|
auth: { XAI_API_KEY: "unused" },
|
|
4327
3878
|
model: "unused"
|
|
4328
3879
|
})
|
|
@@ -4836,61 +4387,6 @@ async function buildPluginLayer(parent, b, options) {
|
|
|
4836
4387
|
}
|
|
4837
4388
|
/** The build arg a Dockerfile can start `FROM` to layer on reeval's sandbox image. */
|
|
4838
4389
|
const REEVAL_BASE_ARG = "REEVAL_BASE";
|
|
4839
|
-
/**
|
|
4840
|
-
* `.dockerignore` rules as Docker reads them: paths from the context root, `*`, `?` and `**`
|
|
4841
|
-
* globs, a pattern that matches a directory excludes what's in it, `!` re-includes, and the last
|
|
4842
|
-
* matching rule wins.
|
|
4843
|
-
*/
|
|
4844
|
-
function dockerignoreMatcher(text) {
|
|
4845
|
-
const rules = text.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => {
|
|
4846
|
-
const negate = line.startsWith("!");
|
|
4847
|
-
const body = (negate ? line.slice(1) : line).trim().replace(/^(?:\.?\/)+/, "").replace(/\/+$/, "");
|
|
4848
|
-
let re = "";
|
|
4849
|
-
for (let i = 0; i < body.length; i++) {
|
|
4850
|
-
const c = body[i];
|
|
4851
|
-
if (c === "*" && body[i + 1] === "*") {
|
|
4852
|
-
i++;
|
|
4853
|
-
if (body[i + 1] === "/") {
|
|
4854
|
-
i++;
|
|
4855
|
-
re += "(?:.*/)?";
|
|
4856
|
-
} else re += ".*";
|
|
4857
|
-
} else if (c === "*") re += "[^/]*";
|
|
4858
|
-
else if (c === "?") re += "[^/]";
|
|
4859
|
-
else re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
4860
|
-
}
|
|
4861
|
-
return {
|
|
4862
|
-
negate,
|
|
4863
|
-
re: new RegExp(`^${re}$`)
|
|
4864
|
-
};
|
|
4865
|
-
});
|
|
4866
|
-
return (path) => {
|
|
4867
|
-
const parts = path.split("/");
|
|
4868
|
-
const prefixes = parts.map((_, i) => parts.slice(0, i + 1).join("/"));
|
|
4869
|
-
let excluded = false;
|
|
4870
|
-
for (const rule of rules) if (prefixes.some((p) => rule.re.test(p))) excluded = !rule.negate;
|
|
4871
|
-
return excluded;
|
|
4872
|
-
};
|
|
4873
|
-
}
|
|
4874
|
-
/**
|
|
4875
|
-
* Files in the build context that `docker build` would send, sorted, relative to `context`. A
|
|
4876
|
-
* Dockerfile read from stdin (`dockerfile` null) has no `<Dockerfile>.dockerignore` of its own.
|
|
4877
|
-
*/
|
|
4878
|
-
function contextFiles(context, dockerfile) {
|
|
4879
|
-
const own = [...dockerfile ? [`${dockerfile}.dockerignore`] : [], join(context, ".dockerignore")].find(existsSync);
|
|
4880
|
-
const ignored = dockerignoreMatcher(own ? readFileSync(own, "utf8") : "");
|
|
4881
|
-
const always = /* @__PURE__ */ new Set([...dockerfile ? [relative(context, dockerfile)] : [], ".dockerignore"]);
|
|
4882
|
-
const files = [];
|
|
4883
|
-
const walk = (rel) => {
|
|
4884
|
-
for (const entry of readdirSync(join(context, rel), { withFileTypes: true })) {
|
|
4885
|
-
const path = rel ? `${rel}/${entry.name}` : entry.name;
|
|
4886
|
-
if (ignored(path) && !always.has(path)) continue;
|
|
4887
|
-
if (entry.isDirectory()) walk(path);
|
|
4888
|
-
else files.push(path);
|
|
4889
|
-
}
|
|
4890
|
-
};
|
|
4891
|
-
walk("");
|
|
4892
|
-
return files.sort();
|
|
4893
|
-
}
|
|
4894
4390
|
/** Whether the Dockerfile starts from reeval's sandbox image, which then has to exist first. */
|
|
4895
4391
|
const usesReevalBase = (dockerfile) => new RegExp(`\\$\\{?${REEVAL_BASE_ARG}\\b`).test(readFileSync(dockerfile, "utf8"));
|
|
4896
4392
|
/**
|
|
@@ -4965,6 +4461,6 @@ async function buildDockerfile(dockerfile, options) {
|
|
|
4965
4461
|
*/
|
|
4966
4462
|
const MCP_TIMER = fileURLToPath(ownFileURL("bin/mcp-timer.cjs"));
|
|
4967
4463
|
//#endregion
|
|
4968
|
-
export {
|
|
4464
|
+
export { contextFiles as $, applyTransformations as A, BRIDGE_PORT as B, PRIVILEGED_CAPABILITIES as C, normalizeImageId as Ct, CA_PATH as D, dockerSandboxProvider as E, PACKAGE_HOSTS as F, SANDBOX_ROOT as G, HARNESS_PACKAGES as H, defaultAllowedHosts as I, WORKSPACE_DIR as J, SANDBOX_STATE as K, hostAllowed as L, onEndpoint as M, DOCKER_EGRESS as N, PROXY_PORT as O, HARNESS_HOSTS as P, isBakedHarness as Q, BAKED_HARNESSES as R, EgressUnavailableError as S, engineSpec as St, createDockerSession as T, LABEL as U, DEFAULT_IMAGE as V, SANDBOX_HOME as W, harnessLabel as X, adapterVersion as Y, imageFor as Z, pruneImages as _, isTransient as _t, buildDockerfile as a, dockerState as at, usesReevalBase as b, ENGINES as bt, buildPluginLayer as c, isRegistryDigest as ct, harnessImageFor as d, run as dt, dockerignoreMatcher as et, installLayerTag as f, shellQuote as ft, pluginLayerTag as g, failureCause as gt, pluginBuildKey as h, causeLine as ht, REEVAL_BASE_ARG as i, dockerOk as it, matches as j, placeholder as k, contextHash as l, removeContainerDetached as lt, pluginBuildDir as m, RETRY_DELAYS as mt, DOCKER_CONTEXT as n, dockerAvailable as nt, buildImage as o, imageInfo as ot, installScript as p, ImageBuildError as pt, SANDBOX_USER as q, PLUGIN_BUILDS_DIR as r, dockerCapacity as rt, buildInstallLayer as s, imageTags as st, MCP_TIMER as t, docker as tt, dockerfileTag as u, onDockerCommand as ut, resolveFrom as v, parseBuildOutput as vt, ROOT_CAPABILITIES as w, DEFAULT_LIMITS as x, dockerSeccompFile as xt, sourceTreeHash as y, retryTransient as yt, BASE_IMAGE as z };
|
|
4969
4465
|
|
|
4970
|
-
//# sourceMappingURL=src-
|
|
4466
|
+
//# sourceMappingURL=src-D91Hd6hT.js.map
|