reeval 0.14.0 → 0.16.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 +15 -15
- package/THIRD_PARTY_NOTICES.md +69 -69
- package/assets/gateway-models.mjs +74 -0
- package/dist/{adapter-BloGVZ_a.js → adapter-CRKYPkRt.js} +37 -8
- package/dist/adapter-CRKYPkRt.js.map +1 -0
- package/dist/{agent-m-_t-IuW.js → agent-BgH4-kFc.js} +58 -16
- package/dist/agent-BgH4-kFc.js.map +1 -0
- package/dist/{app-files-C-jwhRDt.js → app-files-BMVBr079.js} +4 -4
- package/dist/app-files-BMVBr079.js.map +1 -0
- package/dist/{assemble-BDEpelpi.js → assemble-BVbI6NW-.js} +214 -128
- package/dist/assemble-BVbI6NW-.js.map +1 -0
- package/dist/assemble-SiHa4__F.js +1 -0
- package/dist/{attempt-jI0OWxlz.js → attempt-CpbZ9arV.js} +10 -10
- package/dist/{attempt-jI0OWxlz.js.map → attempt-CpbZ9arV.js.map} +1 -1
- package/dist/{match-Bz0nSdzN.js → attempt-host-CIxjs2Be.js} +104 -6
- package/dist/attempt-host-CIxjs2Be.js.map +1 -0
- package/dist/{capture-CVRwRTnb.js → capture-iQ6kYJV0.js} +2360 -1523
- package/dist/capture-iQ6kYJV0.js.map +1 -0
- package/dist/capture-px7Ey95_.js +1 -0
- package/dist/{cli-C_4gaJ50.js → cli-1YQU-66F.js} +153 -180
- package/dist/cli-1YQU-66F.js.map +1 -0
- package/dist/{cli-spec-CpnbATtI.js → cli-spec-CPWT1mAG.js} +10 -21
- package/dist/cli-spec-CPWT1mAG.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/{client-D5hNjpEx.js → client-DMmOkbRA.js} +14 -7
- package/dist/client-DMmOkbRA.js.map +1 -0
- package/dist/{command-BXLUfw4h.js → command-8_Cg5v6b.js} +35 -22
- package/dist/command-8_Cg5v6b.js.map +1 -0
- package/dist/{command-I1euLLio.js → command-BlYCAqu-.js} +7 -7
- package/dist/{command-I1euLLio.js.map → command-BlYCAqu-.js.map} +1 -1
- package/dist/{validate-BhwqrVsm.js → command-C-HeGlap.js} +388 -60
- package/dist/command-C-HeGlap.js.map +1 -0
- package/dist/{command-Bxdy62dW.js → command-Cr1zjRvl.js} +32 -31
- package/dist/command-Cr1zjRvl.js.map +1 -0
- package/dist/{commands-p1S4nw_H.js → commands-Bj9NbmsO.js} +1 -1
- package/dist/{commands-jzigbNFb.js → commands-BvTNZ2-b.js} +181 -73
- package/dist/commands-BvTNZ2-b.js.map +1 -0
- package/dist/{config-BrdHA9bJ.js → config-CneBZB84.js} +883 -433
- package/dist/config-CneBZB84.js.map +1 -0
- package/dist/{contrasts-DRxMQQTC.js → contrasts-lhFsekco.js} +3 -3
- package/dist/{contrasts-DRxMQQTC.js.map → contrasts-lhFsekco.js.map} +1 -1
- package/dist/cost-C5RBTTJr.js +1 -0
- package/dist/{cost-D4elx933.js → cost-ChPa8-Fp.js} +3 -3
- package/dist/cost-ChPa8-Fp.js.map +1 -0
- package/dist/db-BnXyamuj.js +2 -0
- package/dist/db-Cnh3jIv_.js +1530 -0
- package/dist/db-Cnh3jIv_.js.map +1 -0
- package/dist/debug-CAx3qcaP.js +1 -0
- package/dist/{debug-D24NOQH1.js → debug-CgG3T071.js} +5 -2
- package/dist/debug-CgG3T071.js.map +1 -0
- package/dist/{docker-BnRlTpZA.js → docker-BihzJwbV.js} +11 -6
- package/dist/docker-BihzJwbV.js.map +1 -0
- package/dist/{docker-D01slDF3.js → docker-Cqq03H72.js} +26 -8
- package/dist/docker-Cqq03H72.js.map +1 -0
- package/dist/{docker-DivfZl2u.js → docker-DCAtFMo9.js} +1 -1
- package/dist/{doctor-DQ2p0euG.js → doctor-Dl4vMeqt.js} +275 -37
- package/dist/doctor-Dl4vMeqt.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-CO0P0soF.js → environment-Cf5HMjib.js} +116 -297
- package/dist/environment-Cf5HMjib.js.map +1 -0
- package/dist/{errors-r025B0Zb.js → errors-CHebohjc.js} +10 -4
- package/dist/{errors-r025B0Zb.js.map → errors-CHebohjc.js.map} +1 -1
- package/dist/eval-source-CAE4y2Sr.js +146 -0
- package/dist/eval-source-CAE4y2Sr.js.map +1 -0
- package/dist/{evaluate-BUmsN7yG.js → evaluate-CUtgyr43.js} +682 -150
- package/dist/evaluate-CUtgyr43.js.map +1 -0
- package/dist/evaluate-D35T51AC.d.ts +45 -0
- package/dist/files-BEnUJW1e.js +1 -0
- package/dist/{files-B-CJeeEh.js → files-BRViE7m-.js} +200 -87
- package/dist/files-BRViE7m-.js.map +1 -0
- package/dist/{files-kUCrswI6.js → files-BSqA2sZE.js} +20 -9
- package/dist/files-BSqA2sZE.js.map +1 -0
- package/dist/files-C3tQtD26.js +1 -0
- package/dist/files-CNiJ_fZf.js +37 -0
- package/dist/files-CNiJ_fZf.js.map +1 -0
- package/dist/{files-Ca0d6Uq3.js → files-D1y8Pg4Z.js} +35 -7
- package/dist/files-D1y8Pg4Z.js.map +1 -0
- package/dist/files-Dts7EY3H.js +1 -0
- package/dist/{pairs-CHfZNRT6.js → gate-BC6SdQZs.js} +58 -4
- package/dist/gate-BC6SdQZs.js.map +1 -0
- package/dist/gateway.d.ts +22 -9
- package/dist/gateway.js +30 -8
- package/dist/gateway.js.map +1 -1
- package/dist/{git-Bk8DSwHy.js → git-UNxT_3z0.js} +3 -3
- package/dist/{git-Bk8DSwHy.js.map → git-UNxT_3z0.js.map} +1 -1
- package/dist/harness-3NVyTSGK.js +392 -0
- package/dist/harness-3NVyTSGK.js.map +1 -0
- package/dist/harness.d.ts +12 -8
- package/dist/harness.js +1 -1
- package/dist/{images-DzLeFjLx.js → images-8A_LzVfw.js} +8 -8
- package/dist/{images-DzLeFjLx.js.map → images-8A_LzVfw.js.map} +1 -1
- package/dist/index.d.ts +99 -11
- package/dist/index.js +5 -5
- package/dist/init-okoALIah.js +1 -0
- package/dist/{init-SRalM5xF.js → init-sFBgODhu.js} +10 -11
- package/dist/init-sFBgODhu.js.map +1 -0
- package/dist/{invocations-DzyKSJBa.js → invocations-C9ejlOYl.js} +10 -6
- package/dist/invocations-C9ejlOYl.js.map +1 -0
- package/dist/{judge-yLvjC5A3.js → judge-Bg4v4e_K.js} +236 -46
- package/dist/judge-Bg4v4e_K.js.map +1 -0
- package/dist/judge.d.ts +5 -7
- package/dist/judge.js +4 -8
- package/dist/judge.js.map +1 -1
- package/dist/{live-DYd2QEyR.js → live-DeMvnDD5.js} +3 -3
- package/dist/{live-DYd2QEyR.js.map → live-DeMvnDD5.js.map} +1 -1
- package/dist/{matchers-D4eUqx4j.js → matchers-BKPuaXlj.js} +14 -13
- package/dist/matchers-BKPuaXlj.js.map +1 -0
- package/dist/{model-1ZLr9Dcv.js → model-2rBZrdZA.js} +29 -36
- package/dist/model-2rBZrdZA.js.map +1 -0
- package/dist/{model-B45lDUV1.js → model-3MJtpho8.js} +22 -13
- package/dist/model-3MJtpho8.js.map +1 -0
- package/dist/{model-CgnOpss4.js → model-Bz7-j71_.js} +245 -68
- package/dist/model-Bz7-j71_.js.map +1 -0
- package/dist/model-DkPwypN4.js +1 -0
- package/dist/model-bREXVXwT.js +1 -0
- package/dist/{node-BSq5qHnQ.js → node-fP-H2uxn.js} +72 -50
- package/dist/node-fP-H2uxn.js.map +1 -0
- package/dist/{object-CLf2-tNq.js → object-BkXGPKWY.js} +3 -2
- package/dist/object-BkXGPKWY.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-Bo8PZ4Ew.js +34 -0
- package/dist/openrouter-models-Bo8PZ4Ew.js.map +1 -0
- package/dist/{patch-DWf-I_Q_.js → patch-6T9XAipm.js} +7 -9
- package/dist/patch-6T9XAipm.js.map +1 -0
- package/dist/patch-CquGAGX5.js +76 -0
- package/dist/patch-CquGAGX5.js.map +1 -0
- package/dist/{plan-BIwUzlB8.js → plan-Dw2BjafJ.js} +79 -35
- package/dist/plan-Dw2BjafJ.js.map +1 -0
- package/dist/{plugins-Dkp_H3pB.js → plugins-ngQEJBjJ.js} +274 -17
- package/dist/plugins-ngQEJBjJ.js.map +1 -0
- package/dist/{preflight-D9y-HvZQ.js → preflight-BYXkweNN.js} +1 -1
- package/dist/{preflight-DJCD_BDn.js → preflight-CDRpog9o.js} +3 -3
- package/dist/{preflight-DJCD_BDn.js.map → preflight-CDRpog9o.js.map} +1 -1
- package/dist/{prepare-BJG_pD54.js → prepare-B3btUlT6.js} +2 -2
- package/dist/{prepare-CIxCGG0M.js → prepare-PkARUGoF.js} +8 -8
- package/dist/{prepare-CIxCGG0M.js.map → prepare-PkARUGoF.js.map} +1 -1
- package/dist/{prices-BcLEXvdY.js → prices-QaS-kjSQ.js} +7 -4
- package/dist/prices-QaS-kjSQ.js.map +1 -0
- package/dist/{provenance-CfZpFpAh.js → provenance-7Hzg88f4.js} +4 -4
- package/dist/{provenance-CfZpFpAh.js.map → provenance-7Hzg88f4.js.map} +1 -1
- package/dist/{providers-D1Zxp2he.js → providers-DDNMbv1T.js} +1 -1
- package/dist/{providers-DFk_6W4K.js → providers-PKoJtGK0.js} +5 -5
- package/dist/{providers-DFk_6W4K.js.map → providers-PKoJtGK0.js.map} +1 -1
- package/dist/query-Bt6vLJ3m.js +1 -0
- package/dist/{query-CemclveB.js → query-nBXrgEwl.js} +3 -3
- package/dist/{query-CemclveB.js.map → query-nBXrgEwl.js.map} +1 -1
- package/dist/{questions-bAudIc04.js → questions-CkAwePPR.js} +110 -36
- package/dist/questions-CkAwePPR.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-Bp6AwPgb.js +1 -0
- package/dist/{rules-VhftPOOT.js → remarks-Bt0zwiQB.js} +330 -66
- package/dist/remarks-Bt0zwiQB.js.map +1 -0
- package/dist/{header-BLPP6aCU.js → remarks-IFFe_oty.js} +35 -9
- package/dist/remarks-IFFe_oty.js.map +1 -0
- package/dist/{remarks-mujJv1Ey.js → remarks-eBcrIZRu.js} +10 -5
- package/dist/remarks-eBcrIZRu.js.map +1 -0
- package/dist/{remote-CKcEKja4.js → remote-DfJYiP-R.js} +39 -99
- package/dist/remote-DfJYiP-R.js.map +1 -0
- package/dist/resolve-CT4XZIfV.js +1 -0
- package/dist/{resolve-CBoKzQMP.js → resolve-D_cLa4tW.js} +46 -30
- package/dist/resolve-D_cLa4tW.js.map +1 -0
- package/dist/results-DrKJuIQF.js +63 -0
- package/dist/results-DrKJuIQF.js.map +1 -0
- package/dist/{resume-B9SOSnK9.js → resume-BmIM52MJ.js} +47 -17
- package/dist/resume-BmIM52MJ.js.map +1 -0
- package/dist/{runtime-BgQRyCLl.js → runtime-CZVpkr04.js} +139 -48
- package/dist/runtime-CZVpkr04.js.map +1 -0
- package/dist/{sandbox-BOYZ0hlo.js → sandbox-Cmi6IQML.js} +2 -2
- package/dist/{sandbox-BOYZ0hlo.js.map → sandbox-Cmi6IQML.js.map} +1 -1
- package/dist/sandbox.d.ts +1 -1
- package/dist/sandbox.js +1 -1
- package/dist/server-CKJOnIB0.js +1 -0
- package/dist/{server-TGW4WyAz.js → server-DS8BGhGU.js} +75 -33
- package/dist/server-DS8BGhGU.js.map +1 -0
- package/dist/{shared-BDUzStad.js → shared-B_lvGqWz.js} +19 -11
- package/dist/shared-B_lvGqWz.js.map +1 -0
- package/dist/source-CgUqpumI.js +1 -0
- package/dist/source-DcXv4de-.js +59 -0
- package/dist/source-DcXv4de-.js.map +1 -0
- package/dist/{src-CHIwOy0o.js → src-1lpTocbd.js} +75 -30
- package/dist/{src-CHIwOy0o.js.map → src-1lpTocbd.js.map} +1 -1
- package/dist/{src-DjF_M8_f.js → src-8yTF251P.js} +30 -8
- package/dist/{src-DjF_M8_f.js.map → src-8yTF251P.js.map} +1 -1
- package/dist/{src-DjRI-IeE.js → src-A8HLtO0a.js} +135 -35
- package/dist/{src-DjRI-IeE.js.map → src-A8HLtO0a.js.map} +1 -1
- package/dist/{src-NSdQ9zI6.js → src-BO8AYqJ5.js} +17 -5
- package/dist/src-BO8AYqJ5.js.map +1 -0
- package/dist/src-BTqJbvj6.js +2 -0
- package/dist/{src-DmUgeTlE.js → src-BYDOXw_Y.js} +23 -7
- package/dist/{src-DmUgeTlE.js.map → src-BYDOXw_Y.js.map} +1 -1
- package/dist/src-BkiComGh.js +2 -0
- package/dist/src-BvgeZ4tS.js +2 -0
- package/dist/{src-8zoX_qrb.js → src-C0ySiej5.js} +572 -1067
- package/dist/src-C0ySiej5.js.map +1 -0
- package/dist/src-CgJrz5p0.js +3 -0
- package/dist/src-Cp-2Hdib.js +2 -0
- package/dist/{src-CyaDNG9r.js → src-DMo2eCOJ.js} +1 -1
- package/dist/{src-ChhtI6BP.js → src-DSZyg0Uq.js} +177 -28
- package/dist/src-DSZyg0Uq.js.map +1 -0
- package/dist/src-Dk2Na0b-.js +2 -0
- package/dist/src-OESRtvOi.js +2 -0
- package/dist/{src-DKPVX2Us.js → src-gn7YlnRg.js} +34 -5
- package/dist/{src-DKPVX2Us.js.map → src-gn7YlnRg.js.map} +1 -1
- package/dist/src-h5uDlk3m.js +1 -0
- package/dist/state-C97udoh3.js +1 -0
- package/dist/{state-B1t143wG.js → state-C_kdhp5v.js} +15 -15
- package/dist/{state-B1t143wG.js.map → state-C_kdhp5v.js.map} +1 -1
- package/dist/{stats-DSy5HfOv.js → stats-hfpuYsAM.js} +2 -2
- package/dist/{stats-DSy5HfOv.js.map → stats-hfpuYsAM.js.map} +1 -1
- package/dist/suite-ByT1lsdD.js +2 -0
- package/dist/{suite-WgT7m6Vs.js → suite-DieLXvCT.js} +61 -65
- package/dist/suite-DieLXvCT.js.map +1 -0
- package/dist/{summary-DIGEVr08.js → summary-CSzyBVsF.js} +113 -277
- package/dist/summary-CSzyBVsF.js.map +1 -0
- package/dist/tarball-CHcahyNK.js +258 -0
- package/dist/tarball-CHcahyNK.js.map +1 -0
- package/dist/testing.d.ts +426 -143
- package/dist/testing.js +12 -10
- package/dist/testing.js.map +1 -1
- package/dist/{text-CrVy5ioL.js → text-DTigcA64.js} +9 -5
- package/dist/text-DTigcA64.js.map +1 -0
- package/dist/{tool-target-D2mcYlSQ.js → tool-target-CKWkd6QI.js} +2 -2
- package/dist/{tool-target-D2mcYlSQ.js.map → tool-target-CKWkd6QI.js.map} +1 -1
- package/dist/{transcript-BTxJpW4R.js → transcript-BJrKfgRW.js} +13 -5
- package/dist/transcript-BJrKfgRW.js.map +1 -0
- package/dist/types-C5vI3g1C.js.map +1 -1
- package/dist/{types-DXBbP9Mk.d.ts → types-DVvW66ci.d.ts} +569 -895
- 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 +548 -121
- package/dist/view/index.js +9 -9
- package/dist/{views-sXpGE6a2.js → views-B9STsLB4.js} +9 -10
- package/dist/{views-sXpGE6a2.js.map → views-B9STsLB4.js.map} +1 -1
- package/dist/views-Ca-rTixp.js +2 -0
- package/dist/{worker-entry-Duo9oAeT.js → worker-entry-C5bLCv6s.js} +48 -20
- package/dist/worker-entry-C5bLCv6s.js.map +1 -0
- package/dist/workspace-8uHtBSve.js +1 -0
- package/dist/{workspace-CDI68wtX.js → workspace-CBuI9Uds.js} +5 -5
- package/dist/{workspace-CDI68wtX.js.map → workspace-CBuI9Uds.js.map} +1 -1
- package/docker/seccomp-default.json +1 -0
- package/package.json +5 -1
- package/skills/eval-rubric/SKILL.md +46 -104
- package/dist/adapter-BloGVZ_a.js.map +0 -1
- package/dist/agent-m-_t-IuW.js.map +0 -1
- package/dist/app-files-C-jwhRDt.js.map +0 -1
- package/dist/assemble-BDEpelpi.js.map +0 -1
- package/dist/assemble-C5bfncHU.js +0 -1
- package/dist/capture-CVRwRTnb.js.map +0 -1
- package/dist/capture-CherbjzB.js +0 -1
- package/dist/cli-C_4gaJ50.js.map +0 -1
- package/dist/cli-spec-CpnbATtI.js.map +0 -1
- package/dist/client-D5hNjpEx.js.map +0 -1
- package/dist/command-BWAuwQNk.js +0 -91
- package/dist/command-BWAuwQNk.js.map +0 -1
- package/dist/command-BXLUfw4h.js.map +0 -1
- package/dist/command-Be6BSE2L.js +0 -335
- package/dist/command-Be6BSE2L.js.map +0 -1
- package/dist/command-Bxdy62dW.js.map +0 -1
- package/dist/commands-jzigbNFb.js.map +0 -1
- package/dist/config-BrdHA9bJ.js.map +0 -1
- package/dist/cost-D4elx933.js.map +0 -1
- package/dist/cost-DmnAod9x.js +0 -1
- package/dist/db-CAfksinX.js +0 -2
- package/dist/db-DO0p7xgP.js +0 -619
- package/dist/db-DO0p7xgP.js.map +0 -1
- package/dist/debug-D24NOQH1.js.map +0 -1
- package/dist/debug-D7bEv_UV.js +0 -1
- package/dist/docker-BnRlTpZA.js.map +0 -1
- package/dist/docker-D01slDF3.js.map +0 -1
- package/dist/doctor-DQ2p0euG.js.map +0 -1
- package/dist/env-BQqj93gu.js.map +0 -1
- package/dist/environment-CO0P0soF.js.map +0 -1
- package/dist/evaluate-BUmsN7yG.js.map +0 -1
- package/dist/evaluate-C_sgRA-V.d.ts +0 -134
- package/dist/facts-DzOUTreB.js +0 -906
- package/dist/facts-DzOUTreB.js.map +0 -1
- package/dist/files-B-CJeeEh.js.map +0 -1
- package/dist/files-BAt0i00X.js +0 -1
- package/dist/files-Bp5j5BqI.js +0 -1
- package/dist/files-C2sjmXhk.js +0 -1
- package/dist/files-C_gQNVB-.js +0 -65
- package/dist/files-C_gQNVB-.js.map +0 -1
- package/dist/files-Ca0d6Uq3.js.map +0 -1
- package/dist/files-kUCrswI6.js.map +0 -1
- package/dist/generate-DZ7vp69F.js +0 -1647
- package/dist/generate-DZ7vp69F.js.map +0 -1
- package/dist/harness-COVXSwJ6.js +0 -354
- package/dist/harness-COVXSwJ6.js.map +0 -1
- package/dist/header-BLPP6aCU.js.map +0 -1
- package/dist/init-RgCQXZhb.js +0 -1
- package/dist/init-SRalM5xF.js.map +0 -1
- package/dist/insights-TyAvz9aV.js +0 -68
- package/dist/insights-TyAvz9aV.js.map +0 -1
- package/dist/invocations-DzyKSJBa.js.map +0 -1
- package/dist/judge-yLvjC5A3.js.map +0 -1
- package/dist/match-Bz0nSdzN.js.map +0 -1
- package/dist/matchers-D4eUqx4j.js.map +0 -1
- package/dist/model-1ZLr9Dcv.js.map +0 -1
- package/dist/model-B45lDUV1.js.map +0 -1
- package/dist/model-BTZq8HIZ.js +0 -1
- package/dist/model-CgnOpss4.js.map +0 -1
- package/dist/model-Ch8kX87u.js +0 -1
- package/dist/node-BSq5qHnQ.js.map +0 -1
- package/dist/object-CLf2-tNq.js.map +0 -1
- package/dist/opencode-providers-klkqgzvb.js +0 -3276
- package/dist/opencode-providers-klkqgzvb.js.map +0 -1
- package/dist/pairs-CHfZNRT6.js.map +0 -1
- package/dist/patch-DWf-I_Q_.js.map +0 -1
- package/dist/plan-BIwUzlB8.js.map +0 -1
- package/dist/plugins-Dkp_H3pB.js.map +0 -1
- package/dist/prices-BcLEXvdY.js.map +0 -1
- package/dist/query-Cvbwl804.js +0 -1
- package/dist/questions-bAudIc04.js.map +0 -1
- package/dist/redact-CRGdfV2s.js +0 -240
- package/dist/redact-CRGdfV2s.js.map +0 -1
- package/dist/remarks-CXwSnSjR.js +0 -278
- package/dist/remarks-CXwSnSjR.js.map +0 -1
- package/dist/remarks-CyAu2DiB.js +0 -1
- package/dist/remarks-mujJv1Ey.js.map +0 -1
- package/dist/remote-CKcEKja4.js.map +0 -1
- package/dist/resolve-B5-uqmJ6.js +0 -1
- package/dist/resolve-CBoKzQMP.js.map +0 -1
- package/dist/results-CMgZEANy.js +0 -78
- package/dist/results-CMgZEANy.js.map +0 -1
- package/dist/resume-B9SOSnK9.js.map +0 -1
- package/dist/rules-VhftPOOT.js.map +0 -1
- package/dist/run-CwIEK16q.js +0 -88
- package/dist/run-CwIEK16q.js.map +0 -1
- package/dist/runtime-BgQRyCLl.js.map +0 -1
- package/dist/server-CHRSgKRp.js +0 -1
- package/dist/server-TGW4WyAz.js.map +0 -1
- package/dist/shared-BDUzStad.js.map +0 -1
- package/dist/source-B1WvBIQt.js +0 -40
- package/dist/source-B1WvBIQt.js.map +0 -1
- package/dist/source-DAzztZwU.js +0 -1
- package/dist/src-1jHbFaGW.js +0 -1
- package/dist/src-8zoX_qrb.js.map +0 -1
- package/dist/src-C_9wgowC.js +0 -2
- package/dist/src-ChhtI6BP.js.map +0 -1
- package/dist/src-D005Cbqz.js +0 -2
- package/dist/src-DIfRbp5a.js +0 -3
- package/dist/src-Dg8121Xy.js +0 -2
- package/dist/src-ElBqEN-S.js +0 -2
- package/dist/src-NSdQ9zI6.js.map +0 -1
- package/dist/src-YHGaUrGE.js +0 -2
- package/dist/src-mJVxw1Jm.js +0 -2
- package/dist/state-vznMh2wl.js +0 -1
- package/dist/suite-BsWGHzlG.js +0 -2
- package/dist/suite-WgT7m6Vs.js.map +0 -1
- package/dist/summary-DIGEVr08.js.map +0 -1
- package/dist/text-CrVy5ioL.js.map +0 -1
- package/dist/transcript-BTxJpW4R.js.map +0 -1
- package/dist/usage-DF3_p5pE.js +0 -1
- package/dist/validate-BhwqrVsm.js.map +0 -1
- package/dist/views-BW_C5eVH.js +0 -2
- package/dist/worker-entry-Duo9oAeT.js.map +0 -1
- package/dist/workspace-QZCacP8A.js +0 -1
|
@@ -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,13 +373,37 @@ 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
|
-
|
|
1304
|
-
|
|
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
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* The first line of a command's output that a trace counts but never shows, such as an archive
|
|
401
|
+
* encoded as text, which masking can't read into.
|
|
402
|
+
*/
|
|
403
|
+
const OPAQUE_OUTPUT = "--opaque-output--";
|
|
404
|
+
/** Text as is (clipped), or a byte count for binary or opaque output such as a file read with `cat`. */
|
|
1305
405
|
function streamPreview(data) {
|
|
406
|
+
if ((typeof data === "string" ? data.slice(0, 17) : data.subarray(0, 17).toString("latin1")) === "--opaque-output--") return `<${data.length} bytes>`;
|
|
1306
407
|
if (typeof data === "string") return clip(data, MAX_STREAM);
|
|
1307
408
|
if (data.includes(0) || !isUtf8(data)) return `<${data.length} bytes>`;
|
|
1308
409
|
return clip(data.toString("utf8"), MAX_STREAM);
|
|
@@ -1322,7 +423,7 @@ function traceDocker(args, startedAt, result, bin = "docker") {
|
|
|
1322
423
|
exitCode: null,
|
|
1323
424
|
stdout: "",
|
|
1324
425
|
stderr: "",
|
|
1325
|
-
error
|
|
426
|
+
error: mask(error)
|
|
1326
427
|
});
|
|
1327
428
|
return;
|
|
1328
429
|
}
|
|
@@ -1602,6 +703,98 @@ async function imageInfo(image, engine) {
|
|
|
1602
703
|
};
|
|
1603
704
|
}
|
|
1604
705
|
//#endregion
|
|
706
|
+
//#region ../sandbox-docker/src/dockerignore.ts
|
|
707
|
+
const ignore = dockerignore.default;
|
|
708
|
+
/**
|
|
709
|
+
* A pattern `@balena/dockerignore` may match differently from BuildKit: escapes, character
|
|
710
|
+
* classes and the regexp characters it doesn't escape, a `**` joined to other characters, and the
|
|
711
|
+
* whitespace Go and JavaScript trim differently. One over 1024 characters is risky too, since
|
|
712
|
+
* JavaScript refuses a regexp that long that Go accepts, and so is one with more than four `*`
|
|
713
|
+
* runs, whose JavaScript regexp can backtrack for minutes where Go's runs in linear time.
|
|
714
|
+
*/
|
|
715
|
+
const RISKY = /[\\[\]^+(){}|\u0085\uFEFF]|[^/]\*\*|\*\*[^/]/;
|
|
716
|
+
const MAX_STARS = 4;
|
|
717
|
+
/**
|
|
718
|
+
* Names `@balena/dockerignore` may match differently: `?` matches one UTF-16 unit there and one
|
|
719
|
+
* code point in BuildKit, and `.` doesn't match a line terminator there but does in Go.
|
|
720
|
+
*/
|
|
721
|
+
const ODD_NAME = /[\n\r\u2028\u2029\u{10000}-\u{10FFFF}]/u;
|
|
722
|
+
const clean = (pattern) => posix.normalize(pattern).replace(/^\/+/, "").replace(/\/+$/, "");
|
|
723
|
+
/**
|
|
724
|
+
* `.dockerignore` lines as Docker reads them: a BOM is dropped, a line starting `#` is a comment,
|
|
725
|
+
* and `!` re-includes. A path is left out when a rule excludes it and no `!` rule matches it or a
|
|
726
|
+
* directory it's in: BuildKit then excludes it whatever order the rules are in, so this never
|
|
727
|
+
* leaves out a file `docker build` sends, though it keeps some it doesn't. A risky exclusion is
|
|
728
|
+
* dropped, and a risky `!` rule keeps everything, as does one `@balena/dockerignore` would read
|
|
729
|
+
* as a comment or a pattern that cleans to a leading `!` (`!!a`, `/ !a`), which the two read
|
|
730
|
+
* differently.
|
|
731
|
+
*/
|
|
732
|
+
function parseRules(text) {
|
|
733
|
+
const excludes = [];
|
|
734
|
+
const reincludes = [];
|
|
735
|
+
for (const line of text.replace(/^\uFEFF/, "").split(/\r?\n/)) {
|
|
736
|
+
if (line.startsWith("#")) continue;
|
|
737
|
+
let pattern = line.trim();
|
|
738
|
+
const negate = pattern.startsWith("!");
|
|
739
|
+
if (negate) pattern = pattern.slice(1).trim();
|
|
740
|
+
if (!pattern) continue;
|
|
741
|
+
const cleaned = clean(pattern);
|
|
742
|
+
const risky = RISKY.test(pattern) || pattern.length > 1024 || (pattern.match(/\*+/g)?.length ?? 0) > MAX_STARS || [".", ""].includes(cleaned);
|
|
743
|
+
if (cleaned.trim().startsWith("!") || negate && pattern.startsWith("#") || negate && risky) return {
|
|
744
|
+
left: () => false,
|
|
745
|
+
literal: null
|
|
746
|
+
};
|
|
747
|
+
if (!negate) {
|
|
748
|
+
if (!risky) excludes.push(line);
|
|
749
|
+
} else reincludes.push(pattern);
|
|
750
|
+
}
|
|
751
|
+
const exclude = ignore({ ignorecase: false }).add(excludes);
|
|
752
|
+
const reinclude = ignore({ ignorecase: false }).add(reincludes);
|
|
753
|
+
return {
|
|
754
|
+
left: (path) => !ODD_NAME.test(path) && exclude.ignores(path) && !reinclude.ignores(path),
|
|
755
|
+
literal: reincludes.some((p) => /[*?]/.test(p)) ? null : reincludes.map(clean)
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
/** Whether reeval leaves `path` out of a hash under these `.dockerignore` rules. */
|
|
759
|
+
function dockerignoreMatcher(text) {
|
|
760
|
+
return parseRules(text).left;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Files in the build context that reeval hashes, sorted, relative to `context`: every file
|
|
764
|
+
* `docker build` sends (and some it doesn't), plus the Dockerfile and `.dockerignore`. A
|
|
765
|
+
* Dockerfile read from stdin (`dockerfile` null) has no `<Dockerfile>.dockerignore` of its own.
|
|
766
|
+
* A left-out directory is skipped only when every `!` rule is a literal path outside it. Docker
|
|
767
|
+
* doesn't apply an ignore file that's a symlink or not a file, so then every file is hashed; nor
|
|
768
|
+
* can it send what's in a directory it can't read.
|
|
769
|
+
*/
|
|
770
|
+
function contextFiles(context, dockerfile) {
|
|
771
|
+
const own = [...dockerfile ? [`${dockerfile}.dockerignore`] : [], join(context, ".dockerignore")].map((path) => ({
|
|
772
|
+
path,
|
|
773
|
+
stat: lstatSync(path, { throwIfNoEntry: false })
|
|
774
|
+
})).find(({ stat }) => stat);
|
|
775
|
+
const { left, literal } = parseRules(own?.stat?.isFile() ? readFileSync(own.path, "utf8") : "");
|
|
776
|
+
const always = [...dockerfile ? [relative(context, dockerfile)] : [], ".dockerignore"].map((path) => path.split("\\").join("/"));
|
|
777
|
+
const reach = [...always, ...literal ?? []];
|
|
778
|
+
const files = [];
|
|
779
|
+
const walk = (rel) => {
|
|
780
|
+
let entries;
|
|
781
|
+
try {
|
|
782
|
+
entries = readdirSync(join(context, rel), { withFileTypes: true });
|
|
783
|
+
} catch (error) {
|
|
784
|
+
if (rel && ["EACCES", "EPERM"].includes(error.code ?? "")) return;
|
|
785
|
+
throw error;
|
|
786
|
+
}
|
|
787
|
+
for (const entry of entries) {
|
|
788
|
+
const path = rel ? `${rel}/${entry.name}` : entry.name;
|
|
789
|
+
if (entry.isDirectory()) {
|
|
790
|
+
if (!(left(path) && literal && !reach.some((p) => p.startsWith(`${path}/`)))) walk(path);
|
|
791
|
+
} else if (!left(path) || always.includes(path)) files.push(path);
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
walk("");
|
|
795
|
+
return files.sort();
|
|
796
|
+
}
|
|
797
|
+
//#endregion
|
|
1605
798
|
//#region ../sandbox-docker/src/image.ts
|
|
1606
799
|
/**
|
|
1607
800
|
* The harness adapters an image can bake. Each pin must match the exact dependency (or
|
|
@@ -1629,7 +822,7 @@ const HARNESS_PACKAGES = {
|
|
|
1629
822
|
},
|
|
1630
823
|
goose: {
|
|
1631
824
|
name: "@reeval/harness-goose",
|
|
1632
|
-
version: "0.1.
|
|
825
|
+
version: "0.1.6"
|
|
1633
826
|
},
|
|
1634
827
|
pi: {
|
|
1635
828
|
name: "@reeval/harness-pi",
|
|
@@ -1637,15 +830,15 @@ const HARNESS_PACKAGES = {
|
|
|
1637
830
|
},
|
|
1638
831
|
codex: {
|
|
1639
832
|
name: "@reeval/harness-codex",
|
|
1640
|
-
version: "0.1.
|
|
833
|
+
version: "0.1.9"
|
|
1641
834
|
},
|
|
1642
835
|
fx: {
|
|
1643
836
|
name: "@reeval/harness-fx",
|
|
1644
|
-
version: "0.1.
|
|
837
|
+
version: "0.1.3"
|
|
1645
838
|
},
|
|
1646
839
|
"grok-build": {
|
|
1647
840
|
name: "@reeval/harness-grok-build",
|
|
1648
|
-
version: "0.1.
|
|
841
|
+
version: "0.1.6"
|
|
1649
842
|
}
|
|
1650
843
|
};
|
|
1651
844
|
/** Every harness with an image, in {@link HARNESS_PACKAGES} order. */
|
|
@@ -2043,11 +1236,24 @@ function forwarderMain(io, makeMux, linkStreams, proxyPort) {
|
|
|
2043
1236
|
parity: 1,
|
|
2044
1237
|
send: (f) => io.output.write(f),
|
|
2045
1238
|
onOpen(stream, port) {
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
1239
|
+
const attempt = (hosts) => {
|
|
1240
|
+
const socket = io.net.connect({
|
|
1241
|
+
port,
|
|
1242
|
+
host: hosts[0],
|
|
1243
|
+
allowHalfOpen: true
|
|
1244
|
+
});
|
|
1245
|
+
const refused = (error) => {
|
|
1246
|
+
if (error.code === "ECONNREFUSED" && hosts.length > 1) attempt(hosts.slice(1));
|
|
1247
|
+
else stream.destroy();
|
|
1248
|
+
};
|
|
1249
|
+
socket.once("error", refused);
|
|
1250
|
+
socket.once("connect", () => {
|
|
1251
|
+
socket.off("error", refused);
|
|
1252
|
+
if (stream.destroyed) socket.destroy();
|
|
1253
|
+
else linkStreams(socket, stream);
|
|
1254
|
+
});
|
|
1255
|
+
};
|
|
1256
|
+
attempt(["127.0.0.1", "::1"]);
|
|
2051
1257
|
},
|
|
2052
1258
|
onError(message) {
|
|
2053
1259
|
io.error(`reeval egress forwarder: ${message}`);
|
|
@@ -2066,6 +1272,56 @@ function forwarderMain(io, makeMux, linkStreams, proxyPort) {
|
|
|
2066
1272
|
/** The `node -e` script that runs {@link forwarderMain} in the container. */
|
|
2067
1273
|
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
1274
|
//#endregion
|
|
1275
|
+
//#region ../sandbox-docker/src/egress/effort.ts
|
|
1276
|
+
/** The paths read, in order; `*` is any key of an object (a gateway's provider name). */
|
|
1277
|
+
const PATHS = [
|
|
1278
|
+
"generationConfig.thinkingConfig.thinkingLevel",
|
|
1279
|
+
"generationConfig.thinkingConfig.thinkingBudget",
|
|
1280
|
+
"providerOptions.*.thinkingConfig.thinkingLevel",
|
|
1281
|
+
"providerOptions.*.thinkingConfig.thinkingBudget",
|
|
1282
|
+
"providerOptions.*.reasoningEffort",
|
|
1283
|
+
"reasoning_effort",
|
|
1284
|
+
"reasoning.effort",
|
|
1285
|
+
"reasoning.max_tokens",
|
|
1286
|
+
"reasoning.enabled",
|
|
1287
|
+
"output_config.effort",
|
|
1288
|
+
"thinking.type",
|
|
1289
|
+
"thinking.budget_tokens"
|
|
1290
|
+
];
|
|
1291
|
+
function walk(value, keys, at, out) {
|
|
1292
|
+
if (keys.length === 0) {
|
|
1293
|
+
if ([
|
|
1294
|
+
"string",
|
|
1295
|
+
"number",
|
|
1296
|
+
"boolean"
|
|
1297
|
+
].includes(typeof value)) out.push({
|
|
1298
|
+
path: at.join("."),
|
|
1299
|
+
value: String(value)
|
|
1300
|
+
});
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
1304
|
+
const [key, ...rest] = keys;
|
|
1305
|
+
const record = value;
|
|
1306
|
+
for (const name of key === "*" ? Object.keys(record).sort() : [key]) if (Object.hasOwn(record, name)) walk(record[name], rest, [...at, name], out);
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Every reasoning setting in a JSON request body, as `<path>=<value>` joined by spaces
|
|
1310
|
+
* (`reasoning_effort=high`, `providerOptions.google.thinkingConfig.thinkingLevel=low`), or
|
|
1311
|
+
* undefined when it carries none or isn't JSON.
|
|
1312
|
+
*/
|
|
1313
|
+
function requestedEffort(body) {
|
|
1314
|
+
let parsed;
|
|
1315
|
+
try {
|
|
1316
|
+
parsed = JSON.parse(body);
|
|
1317
|
+
} catch {
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
const found = [];
|
|
1321
|
+
for (const path of PATHS) walk(parsed, path.split("."), [], found);
|
|
1322
|
+
return found.length ? found.map((f) => `${f.path}=${f.value}`).join(" ") : void 0;
|
|
1323
|
+
}
|
|
1324
|
+
//#endregion
|
|
2069
1325
|
//#region ../sandbox-docker/src/egress/policy.ts
|
|
2070
1326
|
/** The Docker sandbox enforces every policy through its egress gateway, and records what passes. */
|
|
2071
1327
|
const DOCKER_EGRESS = {
|
|
@@ -2126,7 +1382,7 @@ const inList = (list, address) => {
|
|
|
2126
1382
|
const v = isIP(address);
|
|
2127
1383
|
return v !== 0 && list.check(address, v === 6 ? "ipv6" : "ipv4");
|
|
2128
1384
|
};
|
|
2129
|
-
const
|
|
1385
|
+
const normalize$1 = (host) => host.toLowerCase().replace(/\.$/, "").replace(/^\[|\]$/g, "");
|
|
2130
1386
|
/**
|
|
2131
1387
|
* Private, carrier-grade NAT and unique-local ranges: a name matched only by a `*.` pattern
|
|
2132
1388
|
* mustn't resolve into them, or anyone who can add a DNS record under the pattern's domain
|
|
@@ -2173,8 +1429,8 @@ function embeddedIPv4(address) {
|
|
|
2173
1429
|
const reaches = (address) => isIP(address) === 6 && inList(NAT64, address) ? [address, embeddedIPv4(address)] : [address];
|
|
2174
1430
|
/** How `host` matches: listed as it is, only by a `*.` pattern (never an IP address), or not. */
|
|
2175
1431
|
function hostMatch(patterns, host) {
|
|
2176
|
-
const h =
|
|
2177
|
-
const ps = patterns.map(
|
|
1432
|
+
const h = normalize$1(host);
|
|
1433
|
+
const ps = patterns.map(normalize$1);
|
|
2178
1434
|
if (ps.includes(h)) return "exact";
|
|
2179
1435
|
if (isIP(h) || /(?:^|\.)\d+$/.test(h)) return void 0;
|
|
2180
1436
|
return ps.some((p) => p.startsWith("*.") && h.endsWith(p.slice(1))) ? "wildcard" : void 0;
|
|
@@ -2196,7 +1452,7 @@ function createPolicyCheck(policy, options = {}) {
|
|
|
2196
1452
|
const allowedCidrs = blockList(custom?.allowedCIDRs);
|
|
2197
1453
|
const deniedCidrs = blockList(custom?.deniedCIDRs);
|
|
2198
1454
|
return async (rawHost) => {
|
|
2199
|
-
const host =
|
|
1455
|
+
const host = normalize$1(rawHost);
|
|
2200
1456
|
if (policy.mode === "deny-all") return {
|
|
2201
1457
|
allowed: false,
|
|
2202
1458
|
status: 403,
|
|
@@ -2270,7 +1526,7 @@ function createPolicyCheck(policy, options = {}) {
|
|
|
2270
1526
|
}
|
|
2271
1527
|
//#endregion
|
|
2272
1528
|
//#region ../sandbox-docker/src/egress/rules.ts
|
|
2273
|
-
const
|
|
1529
|
+
const normalizeHost = (host) => host.toLowerCase().replace(/\.$/, "");
|
|
2274
1530
|
function matchPart(matcher, value, ignoreCase = false) {
|
|
2275
1531
|
const v = ignoreCase ? value.toLowerCase() : value;
|
|
2276
1532
|
if ("exact" in matcher) return v === (ignoreCase ? matcher.exact.toLowerCase() : matcher.exact);
|
|
@@ -2284,7 +1540,7 @@ function matchPairs(matchers, pairs, ignoreKeyCase) {
|
|
|
2284
1540
|
const headerPairs = (headers) => Object.entries(headers).flatMap(([k, v]) => v === void 0 ? [] : (Array.isArray(v) ? v : [v]).map((x) => [k, x]));
|
|
2285
1541
|
function matches(rule, request) {
|
|
2286
1542
|
const { match } = rule;
|
|
2287
|
-
if (
|
|
1543
|
+
if (normalizeHost(match.host) !== normalizeHost(request.host)) return false;
|
|
2288
1544
|
const url = new URL(request.path, "https://placeholder.invalid");
|
|
2289
1545
|
if (match.path && !matchPart(match.path, url.pathname)) return false;
|
|
2290
1546
|
if (match.method && !match.method.some((m) => m.toUpperCase() === request.method.toUpperCase())) return false;
|
|
@@ -2297,13 +1553,18 @@ const onEndpoint = (endpoints, request) => endpoints.some((match) => matches({
|
|
|
2297
1553
|
transform: { headers: {} }
|
|
2298
1554
|
}, request));
|
|
2299
1555
|
/** Whether the gateway must decrypt connections to `host`: some rule could apply there. */
|
|
2300
|
-
const decrypts = (rules, host) => rules.some((r) =>
|
|
1556
|
+
const decrypts = (rules, host) => rules.some((r) => normalizeHost(r.match.host) === normalizeHost(host));
|
|
2301
1557
|
/** What a credential the sandbox never sent comes back as. */
|
|
2302
1558
|
const REDACTED = "reeval_redacted_credential";
|
|
2303
1559
|
/** Shorter values aren't credentials, and scrubbing them would mangle ordinary text. */
|
|
2304
1560
|
const MIN_CREDENTIAL = 16;
|
|
2305
1561
|
const schemeAndToken = (value) => /^([A-Za-z][\w-]*) +(\S+)$/.exec(value);
|
|
2306
1562
|
/**
|
|
1563
|
+
* Whether a rule for `host` sets a credential: a header value long enough to be one, whether it
|
|
1564
|
+
* replaces a placeholder the sandbox sent or adds a bearer the sandbox never had.
|
|
1565
|
+
*/
|
|
1566
|
+
const setsCredential = (rules, host) => rules.some((r) => normalizeHost(r.match.host) === normalizeHost(host) && Object.values(r.transform.headers).some((v) => v.length >= MIN_CREDENTIAL));
|
|
1567
|
+
/**
|
|
2307
1568
|
* The values credential rules for `host` set (rules keyed on a header the sandbox sends, such as
|
|
2308
1569
|
* a placeholder key), each paired with what the sandbox sent in its place, for scrubbing from
|
|
2309
1570
|
* responses. A value with a scheme (`Bearer <key>`) is paired as a whole and by its token too.
|
|
@@ -2315,7 +1576,7 @@ function credentialValues(rules, host) {
|
|
|
2315
1576
|
};
|
|
2316
1577
|
for (const rule of rules) {
|
|
2317
1578
|
const keyed = rule.match.headers ?? [];
|
|
2318
|
-
if (!keyed.length ||
|
|
1579
|
+
if (!keyed.length || normalizeHost(rule.match.host) !== normalizeHost(host)) continue;
|
|
2319
1580
|
for (const [name, value] of Object.entries(rule.transform.headers)) {
|
|
2320
1581
|
const sent = keyed.find((m) => m.key && "exact" in m.key && m.key.exact.toLowerCase() === name.toLowerCase())?.value;
|
|
2321
1582
|
const shown = sent && "exact" in sent ? sent.exact : REDACTED;
|
|
@@ -2530,7 +1791,7 @@ function tokenPlaceholder(token) {
|
|
|
2530
1791
|
* The exchange response with each token field replaced by a placeholder, and a substitution per
|
|
2531
1792
|
* token. A token already seen keeps its placeholder. Throws when the body isn't a JSON object.
|
|
2532
1793
|
*/
|
|
2533
|
-
function
|
|
1794
|
+
function tokenizeResponse(derived, body, known) {
|
|
2534
1795
|
const parsed = JSON.parse(body);
|
|
2535
1796
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("the response is not a JSON object");
|
|
2536
1797
|
const out = { ...parsed };
|
|
@@ -2577,12 +1838,28 @@ function frame(first, payload) {
|
|
|
2577
1838
|
}
|
|
2578
1839
|
return Buffer.concat([head, payload]);
|
|
2579
1840
|
}
|
|
1841
|
+
/** A control frame may carry at most this many payload bytes. */
|
|
1842
|
+
const MAX_CONTROL = 125;
|
|
1843
|
+
/**
|
|
1844
|
+
* A control frame's payload scrubbed and kept within 125 bytes, since a placeholder can be
|
|
1845
|
+
* longer than its value. A close frame keeps its 2-byte status code and its reason is cut at a
|
|
1846
|
+
* UTF-8 character boundary; a ping or pong payload is cut at 125 bytes.
|
|
1847
|
+
*/
|
|
1848
|
+
function scrubControl(opcode, payload, pairs) {
|
|
1849
|
+
if (opcode !== 8) return replaceAll(payload, pairs).subarray(0, MAX_CONTROL);
|
|
1850
|
+
if (payload.length < 2) return payload;
|
|
1851
|
+
const reason = replaceAll(payload.subarray(2), pairs);
|
|
1852
|
+
let end = Math.min(reason.length, 123);
|
|
1853
|
+
if (end < reason.length) while (end > 0 && ((reason[end] ?? 0) & 192) === 128) end--;
|
|
1854
|
+
return Buffer.concat([payload.subarray(0, 2), reason.subarray(0, end)]);
|
|
1855
|
+
}
|
|
2580
1856
|
/**
|
|
2581
1857
|
* Server-to-client WebSocket frames with every real value put back as its placeholder. Each data
|
|
2582
1858
|
* 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
|
|
1859
|
+
* one frame; each control frame is scrubbed alone (`scrubControl`) and sent on at once, even
|
|
1860
|
+
* between a message's frames. A compressed frame (the upgrade request goes up without
|
|
1861
|
+
* extensions, so a server shouldn't send one), or a message over 16 MiB, errors the stream
|
|
1862
|
+
* rather than pass unread.
|
|
2586
1863
|
*/
|
|
2587
1864
|
function webSocketScrubber(subs) {
|
|
2588
1865
|
const pairs = subs.map((s) => [s.value, s.placeholder]);
|
|
@@ -2617,7 +1894,7 @@ function webSocketScrubber(subs) {
|
|
|
2617
1894
|
const opcode = first & 15;
|
|
2618
1895
|
if (first & 112) return done(/* @__PURE__ */ new Error("a compressed or extended WebSocket frame, which can't be scrubbed"));
|
|
2619
1896
|
if (opcode >= 8) {
|
|
2620
|
-
out.push(frame(first, payload));
|
|
1897
|
+
out.push(frame(first, scrubControl(opcode, payload, pairs)));
|
|
2621
1898
|
continue;
|
|
2622
1899
|
}
|
|
2623
1900
|
if (opcode === 0 ? !message : message) return done(/* @__PURE__ */ new Error("WebSocket frames out of order"));
|
|
@@ -2639,6 +1916,10 @@ function webSocketScrubber(subs) {
|
|
|
2639
1916
|
}
|
|
2640
1917
|
//#endregion
|
|
2641
1918
|
//#region ../sandbox-docker/src/egress/proxy.ts
|
|
1919
|
+
/** A TLS record's first byte when it carries a handshake, as a ClientHello does. */
|
|
1920
|
+
const TLS_HANDSHAKE = 22;
|
|
1921
|
+
/** How long a decrypted CONNECT waits for its client's first byte: Node's TLS handshake timeout. */
|
|
1922
|
+
const FIRST_BYTE_TIMEOUT_MS = 12e4;
|
|
2642
1923
|
const HOP_BY_HOP = /* @__PURE__ */ new Set([
|
|
2643
1924
|
"connection",
|
|
2644
1925
|
"keep-alive",
|
|
@@ -2661,6 +1942,8 @@ function parseAuthority(authority, defaultPort) {
|
|
|
2661
1942
|
port: Number(m?.[2] ?? defaultPort)
|
|
2662
1943
|
};
|
|
2663
1944
|
}
|
|
1945
|
+
/** Whether a parsed port names a TCP port; `net.connect` and `tls.connect` throw above 65535. */
|
|
1946
|
+
const isPort = (port) => Number.isInteger(port) && port >= 1 && port <= 65535;
|
|
2664
1947
|
/** `host` or `host:port` for a Host header or URL, IPv6 in brackets. */
|
|
2665
1948
|
const authorityOf = (host, port) => {
|
|
2666
1949
|
const name = net.isIPv6(host) ? `[${host}]` : host;
|
|
@@ -2688,6 +1971,7 @@ const isText = (type) => !type.trim() || /^\s*(text\/|application\/(json|xml|jav
|
|
|
2688
1971
|
const plainHeaders = (headers) => Object.fromEntries(Object.entries(headers).flatMap(([k, v]) => v === void 0 ? [] : [[k, Array.isArray(v) ? v.map(String) : String(v)]]));
|
|
2689
1972
|
function createEgressProxy(options) {
|
|
2690
1973
|
const log = options.log ?? (() => {});
|
|
1974
|
+
const firstByteTimeout = options.firstByteTimeout ?? FIRST_BYTE_TIMEOUT_MS;
|
|
2691
1975
|
const emit = (event) => {
|
|
2692
1976
|
try {
|
|
2693
1977
|
options.onEvent?.(event);
|
|
@@ -2700,6 +1984,8 @@ function createEgressProxy(options) {
|
|
|
2700
1984
|
const allSubs = () => tokens.length ? [...subs, ...tokens] : subs;
|
|
2701
1985
|
const derived = options.derivedTokens ?? [];
|
|
2702
1986
|
const tokenHosts = derived.flatMap((d) => [d.endpoint.host, ...d.hosts]);
|
|
1987
|
+
const locals = options.localResponses ?? [];
|
|
1988
|
+
const localHosts = locals.map((l) => l.match.host);
|
|
2703
1989
|
let policyCheck = createPolicyCheck(options.policy, options);
|
|
2704
1990
|
const check = async (host) => {
|
|
2705
1991
|
const verdict = await policyCheck(host);
|
|
@@ -2848,6 +2134,10 @@ function createEgressProxy(options) {
|
|
|
2848
2134
|
const front = http.createServer();
|
|
2849
2135
|
front.on("connect", (req, socket, head) => {
|
|
2850
2136
|
const { host, port } = parseAuthority(req.url ?? "", 443);
|
|
2137
|
+
if (!isPort(port)) {
|
|
2138
|
+
log(`reeval:egress CONNECT ${req.url} refused (invalid port)`);
|
|
2139
|
+
return reply(socket, 400, `reeval egress gateway: invalid port ${port} in CONNECT ${req.url}`);
|
|
2140
|
+
}
|
|
2851
2141
|
const startedAt = Date.now();
|
|
2852
2142
|
const tunnel = {
|
|
2853
2143
|
type: "request",
|
|
@@ -2881,11 +2171,21 @@ function createEgressProxy(options) {
|
|
|
2881
2171
|
port,
|
|
2882
2172
|
address: verdict.address
|
|
2883
2173
|
};
|
|
2884
|
-
if (decrypts(rules, host) || substitutes(allSubs(), host) || hostAllowed(tokenHosts, host)) {
|
|
2174
|
+
if (decrypts(rules, host) || substitutes(allSubs(), host) || hostAllowed(tokenHosts, host) || hostAllowed(localHosts, host)) {
|
|
2885
2175
|
log(`reeval:egress CONNECT ${host}:${port} decrypt`);
|
|
2886
2176
|
socket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
|
|
2887
2177
|
if (head.length) socket.unshift(head);
|
|
2888
|
-
return decrypt(socket, target)
|
|
2178
|
+
return firstByte(socket, (byte) => byte === TLS_HANDSHAKE ? decrypt(socket, target) : plainInTunnel(socket, target), (reason) => {
|
|
2179
|
+
log(`reeval:egress CONNECT ${host}:${port} closed (${reason})`);
|
|
2180
|
+
emit({
|
|
2181
|
+
...tunnel,
|
|
2182
|
+
allowed: true,
|
|
2183
|
+
reason,
|
|
2184
|
+
sent: 0,
|
|
2185
|
+
received: 0,
|
|
2186
|
+
ms: Date.now() - startedAt
|
|
2187
|
+
});
|
|
2188
|
+
});
|
|
2889
2189
|
}
|
|
2890
2190
|
log(`reeval:egress CONNECT ${host}:${port} tunnel`);
|
|
2891
2191
|
let status = 200;
|
|
@@ -2934,6 +2234,10 @@ function createEgressProxy(options) {
|
|
|
2934
2234
|
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
2235
|
const secure = url.protocol === "https:";
|
|
2936
2236
|
const { host, port } = parseAuthority(url.host, secure ? 443 : 80);
|
|
2237
|
+
if (!isPort(port)) {
|
|
2238
|
+
log(`reeval:egress ${req.method} ${url.protocol}//${url.host} refused (invalid port)`);
|
|
2239
|
+
return res.writeHead(400).end(`reeval egress gateway: invalid port ${port} in ${url.origin}\n`);
|
|
2240
|
+
}
|
|
2937
2241
|
const shown = secure ? `https://${host}` : `http://${host}:${port}`;
|
|
2938
2242
|
const done = requestEvent(res, {
|
|
2939
2243
|
method: req.method ?? "GET",
|
|
@@ -2943,6 +2247,7 @@ function createEgressProxy(options) {
|
|
|
2943
2247
|
via: secure ? "decrypted" : "http",
|
|
2944
2248
|
requestHeaders: plainHeaders(req.headers)
|
|
2945
2249
|
});
|
|
2250
|
+
const path = url.pathname + url.search;
|
|
2946
2251
|
check(host).then((verdict) => {
|
|
2947
2252
|
if (!verdict.allowed) {
|
|
2948
2253
|
log(`reeval:egress ${req.method} ${shown} denied (${verdict.reason})`);
|
|
@@ -2951,41 +2256,224 @@ function createEgressProxy(options) {
|
|
|
2951
2256
|
return res.writeHead(verdict.status).end(`blocked by the reeval egress policy: ${verdict.reason}\n`);
|
|
2952
2257
|
}
|
|
2953
2258
|
contact(req.socket, host, port);
|
|
2259
|
+
const target = {
|
|
2260
|
+
host,
|
|
2261
|
+
port,
|
|
2262
|
+
address: verdict.address
|
|
2263
|
+
};
|
|
2954
2264
|
if (secure) {
|
|
2955
2265
|
const headers = {
|
|
2956
2266
|
...req.headers,
|
|
2957
2267
|
host: url.host
|
|
2958
2268
|
};
|
|
2959
|
-
onDecrypted(
|
|
2960
|
-
host,
|
|
2961
|
-
port,
|
|
2962
|
-
address: verdict.address
|
|
2963
|
-
}, req, res, url.pathname + url.search, headers, done);
|
|
2269
|
+
onDecrypted(target, req, res, path, headers, done);
|
|
2964
2270
|
return;
|
|
2965
2271
|
}
|
|
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
|
-
});
|
|
2272
|
+
onPlain(target, req, res, path, url.host, done);
|
|
2983
2273
|
});
|
|
2984
2274
|
});
|
|
2985
2275
|
front.on("upgrade", (_req, socket) => {
|
|
2986
2276
|
reply(socket, 501, "reeval egress gateway: use CONNECT for websockets");
|
|
2987
2277
|
});
|
|
2988
2278
|
/**
|
|
2279
|
+
* Sends a plain-HTTP request upstream as the sandbox sent it: never given credentials or
|
|
2280
|
+
* substitutions, so a placeholder sent over plain HTTP goes out as the placeholder.
|
|
2281
|
+
*/
|
|
2282
|
+
function onPlain(target, req, res, path, host, done) {
|
|
2283
|
+
const url = `http://${target.host}:${target.port}${pathOnly(path)}`;
|
|
2284
|
+
log(`reeval:egress ${req.method} ${url}`);
|
|
2285
|
+
const upstream = http.request({
|
|
2286
|
+
host: target.address,
|
|
2287
|
+
port: target.port,
|
|
2288
|
+
method: req.method,
|
|
2289
|
+
path,
|
|
2290
|
+
headers: {
|
|
2291
|
+
...endToEnd(req.headers),
|
|
2292
|
+
host
|
|
2293
|
+
}
|
|
2294
|
+
});
|
|
2295
|
+
forwardHttp1(req.pipe(counter(done.sent)), res, upstream, {
|
|
2296
|
+
own: [],
|
|
2297
|
+
creds: [],
|
|
2298
|
+
url,
|
|
2299
|
+
t: done
|
|
2300
|
+
});
|
|
2301
|
+
}
|
|
2302
|
+
/**
|
|
2303
|
+
* Calls `then` with the connection's first byte once it arrives, left unread for the next
|
|
2304
|
+
* reader, or `idle` with why there's none: the client closed it first, or it waited
|
|
2305
|
+
* `firstByteTimeout` and closed it.
|
|
2306
|
+
*/
|
|
2307
|
+
function firstByte(socket, then, idle) {
|
|
2308
|
+
const timer = setTimeout(() => {
|
|
2309
|
+
stop();
|
|
2310
|
+
socket.destroy();
|
|
2311
|
+
idle(`the client sent nothing within ${firstByteTimeout / 1e3}s`);
|
|
2312
|
+
}, firstByteTimeout);
|
|
2313
|
+
const onReadable = () => {
|
|
2314
|
+
const chunk = socket.read();
|
|
2315
|
+
if (!chunk?.length) return;
|
|
2316
|
+
stop();
|
|
2317
|
+
socket.unshift(chunk);
|
|
2318
|
+
then(chunk[0]);
|
|
2319
|
+
};
|
|
2320
|
+
const onClose = () => {
|
|
2321
|
+
stop();
|
|
2322
|
+
idle("the client closed the connection without sending anything");
|
|
2323
|
+
};
|
|
2324
|
+
const stop = () => {
|
|
2325
|
+
clearTimeout(timer);
|
|
2326
|
+
socket.off("readable", onReadable);
|
|
2327
|
+
socket.off("close", onClose);
|
|
2328
|
+
};
|
|
2329
|
+
socket.on("readable", onReadable);
|
|
2330
|
+
socket.once("close", onClose);
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* The path a request in a plain tunnel asks for, or why it's refused: its Host or absolute-form
|
|
2334
|
+
* URL names a host other than the CONNECT target, which a server sharing the target's address
|
|
2335
|
+
* could route it to.
|
|
2336
|
+
*/
|
|
2337
|
+
function inTunnel(target, req) {
|
|
2338
|
+
const asked = req.url ?? "/";
|
|
2339
|
+
const absolute = asked.startsWith("/") ? void 0 : URL.parse(asked);
|
|
2340
|
+
const path = absolute ? absolute.pathname + absolute.search : asked;
|
|
2341
|
+
for (const named of [absolute?.host, req.headers.host]) {
|
|
2342
|
+
if (!named) continue;
|
|
2343
|
+
const host = parseAuthority(named, target.port).host;
|
|
2344
|
+
if (host === target.host) continue;
|
|
2345
|
+
const shown = `http://${authorityOf(target.host, target.port)}${pathOnly(path)}`;
|
|
2346
|
+
log(`reeval:egress ${req.method} ${shown} refused (Host ${host})`);
|
|
2347
|
+
return {
|
|
2348
|
+
path,
|
|
2349
|
+
refused: `reeval egress gateway: the request names ${host}, but the connection is to ${target.host}; send it on a connection to ${host}.`
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
return { path };
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Serves a CONNECT to a decrypted host whose client speaks plain HTTP/1.1 in the tunnel, as a
|
|
2356
|
+
* Node client sends an `http://` request through a proxy: each request goes upstream as an
|
|
2357
|
+
* absolute-form `http://` one does, with no credentials or substitutions.
|
|
2358
|
+
*/
|
|
2359
|
+
function plainInTunnel(socket, target) {
|
|
2360
|
+
const authority = authorityOf(target.host, target.port);
|
|
2361
|
+
const refuse = (s, reason) => {
|
|
2362
|
+
emit({
|
|
2363
|
+
type: "request",
|
|
2364
|
+
method: "CONNECT",
|
|
2365
|
+
url: authority,
|
|
2366
|
+
host: target.host,
|
|
2367
|
+
port: target.port,
|
|
2368
|
+
via: "http",
|
|
2369
|
+
allowed: false,
|
|
2370
|
+
status: 400,
|
|
2371
|
+
reason,
|
|
2372
|
+
sent: 0,
|
|
2373
|
+
received: 0,
|
|
2374
|
+
substituted: [],
|
|
2375
|
+
credentials: [],
|
|
2376
|
+
ms: 0
|
|
2377
|
+
});
|
|
2378
|
+
reply(s, 400, reason);
|
|
2379
|
+
};
|
|
2380
|
+
const server = http.createServer((req, res) => {
|
|
2381
|
+
const { path, refused } = inTunnel(target, req);
|
|
2382
|
+
const done = requestEvent(res, {
|
|
2383
|
+
method: req.method ?? "GET",
|
|
2384
|
+
url: `http://${authority}${pathOnly(path)}`,
|
|
2385
|
+
host: target.host,
|
|
2386
|
+
port: target.port,
|
|
2387
|
+
via: "http",
|
|
2388
|
+
requestHeaders: plainHeaders(req.headers)
|
|
2389
|
+
});
|
|
2390
|
+
if (refused) {
|
|
2391
|
+
done.refuse(refused);
|
|
2392
|
+
req.resume();
|
|
2393
|
+
return res.writeHead(421, { "content-type": "text/plain" }).end(`${refused}\n`);
|
|
2394
|
+
}
|
|
2395
|
+
onPlain(target, req, res, path, req.headers.host ?? authority, done);
|
|
2396
|
+
});
|
|
2397
|
+
server.on("upgrade", (req, s, head) => onPlainUpgrade(target, req, track(s), head));
|
|
2398
|
+
server.on("connect", (req, s) => {
|
|
2399
|
+
log(`reeval:egress CONNECT ${authority} refused (CONNECT ${req.url} inside it)`);
|
|
2400
|
+
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.`);
|
|
2401
|
+
});
|
|
2402
|
+
server.on("clientError", (error, s) => {
|
|
2403
|
+
if (!error.code?.startsWith("HPE_") || error.code === "HPE_INVALID_EOF_STATE") return s.destroy();
|
|
2404
|
+
log(`reeval:egress CONNECT ${authority} refused (neither TLS nor HTTP/1.1)`);
|
|
2405
|
+
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.`);
|
|
2406
|
+
});
|
|
2407
|
+
server.emit("connection", socket);
|
|
2408
|
+
}
|
|
2409
|
+
/** A plain-HTTP upgrade (a `ws://` WebSocket) in a tunnel, passed upstream as it is. */
|
|
2410
|
+
function onPlainUpgrade(target, req, socket, head) {
|
|
2411
|
+
const method = req.method ?? "GET";
|
|
2412
|
+
const startedAt = Date.now();
|
|
2413
|
+
const authority = authorityOf(target.host, target.port);
|
|
2414
|
+
const { path, refused } = inTunnel(target, req);
|
|
2415
|
+
const upgraded = (fields) => emit({
|
|
2416
|
+
type: "request",
|
|
2417
|
+
method,
|
|
2418
|
+
url: `http://${authority}${pathOnly(path)}`,
|
|
2419
|
+
host: target.host,
|
|
2420
|
+
port: target.port,
|
|
2421
|
+
via: "http",
|
|
2422
|
+
allowed: true,
|
|
2423
|
+
sent: 0,
|
|
2424
|
+
received: 0,
|
|
2425
|
+
substituted: [],
|
|
2426
|
+
credentials: [],
|
|
2427
|
+
requestHeaders: plainHeaders(req.headers),
|
|
2428
|
+
...fields,
|
|
2429
|
+
ms: Date.now() - startedAt
|
|
2430
|
+
});
|
|
2431
|
+
if (refused) {
|
|
2432
|
+
upgraded({
|
|
2433
|
+
allowed: false,
|
|
2434
|
+
status: 421,
|
|
2435
|
+
reason: refused
|
|
2436
|
+
});
|
|
2437
|
+
return reply(socket, 421, refused);
|
|
2438
|
+
}
|
|
2439
|
+
log(`reeval:egress ${method} http://${authority}${pathOnly(path)} (upgrade)`);
|
|
2440
|
+
const upstream = http.request({
|
|
2441
|
+
host: target.address,
|
|
2442
|
+
port: target.port,
|
|
2443
|
+
method,
|
|
2444
|
+
path,
|
|
2445
|
+
headers: {
|
|
2446
|
+
...endToEnd(req.headers, ["upgrade", "connection"]),
|
|
2447
|
+
host: req.headers.host ?? authority
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2450
|
+
upstream.once("upgrade", (up, upSocket, upHead) => {
|
|
2451
|
+
upgraded({
|
|
2452
|
+
status: up.statusCode,
|
|
2453
|
+
responseHeaders: plainHeaders(up.headers)
|
|
2454
|
+
});
|
|
2455
|
+
const lines = [`HTTP/1.1 ${up.statusCode} ${up.statusMessage}`];
|
|
2456
|
+
for (let i = 0; i < up.rawHeaders.length; i += 2) lines.push(`${up.rawHeaders[i]}: ${up.rawHeaders[i + 1] ?? ""}`);
|
|
2457
|
+
socket.write(`${lines.join("\r\n")}\r\n\r\n`);
|
|
2458
|
+
if (head.length) upSocket.write(head);
|
|
2459
|
+
if (upHead.length) socket.write(upHead);
|
|
2460
|
+
link(socket, track(upSocket));
|
|
2461
|
+
});
|
|
2462
|
+
upstream.once("response", (up) => {
|
|
2463
|
+
upgraded({ status: up.statusCode });
|
|
2464
|
+
reply(socket, up.statusCode ?? 502, `upstream refused the upgrade (${up.statusCode})`);
|
|
2465
|
+
up.resume();
|
|
2466
|
+
});
|
|
2467
|
+
upstream.once("error", (error) => {
|
|
2468
|
+
upgraded({
|
|
2469
|
+
status: 502,
|
|
2470
|
+
reason: error.message
|
|
2471
|
+
});
|
|
2472
|
+
reply(socket, 502, `reeval egress gateway: ${error.message}`);
|
|
2473
|
+
});
|
|
2474
|
+
upstream.end();
|
|
2475
|
+
}
|
|
2476
|
+
/**
|
|
2989
2477
|
* Terminates TLS with a certificate for the CONNECT host. One server per connection, since the
|
|
2990
2478
|
* host comes from CONNECT; it serves HTTP/2 and HTTP/1.1 (with upgrades) by ALPN.
|
|
2991
2479
|
*/
|
|
@@ -3107,9 +2595,11 @@ function createEgressProxy(options) {
|
|
|
3107
2595
|
* The request body as sent upstream: through the substituter when a secret there opts in to
|
|
3108
2596
|
* bodies, unless the body is encoded (gzip and the like), which is sent as is and fails closed.
|
|
3109
2597
|
*/
|
|
3110
|
-
function requestBody(req, headers, own, t) {
|
|
3111
|
-
const
|
|
3112
|
-
|
|
2598
|
+
function requestBody(req, headers, own, t, readsEffort = false) {
|
|
2599
|
+
const encoded = String(headers["content-encoding"] ?? "identity") !== "identity";
|
|
2600
|
+
const sent = t ? req.pipe(counter(t.sent)) : req;
|
|
2601
|
+
const counted = readsEffort && t && !encoded ? sent.pipe(effortReader(t)) : sent;
|
|
2602
|
+
if (encoded || !own.some((s) => s.in.includes("body"))) return counted;
|
|
3113
2603
|
delete headers["content-length"];
|
|
3114
2604
|
return counted.pipe(bodySubstituter(own));
|
|
3115
2605
|
}
|
|
@@ -3184,30 +2674,81 @@ function createEgressProxy(options) {
|
|
|
3184
2674
|
* echoes the request's instructions and tools before it.
|
|
3185
2675
|
*/
|
|
3186
2676
|
const MODEL_WINDOW = 524288;
|
|
2677
|
+
const PROVIDER = /"provider"\s*:\s*"([^"\\]{1,200})"/;
|
|
3187
2678
|
/**
|
|
3188
|
-
*
|
|
3189
|
-
* `
|
|
3190
|
-
|
|
2679
|
+
* The provider of the endpoint a gateway's routing metadata marks `"selected": true`
|
|
2680
|
+
* (OpenRouter's `openrouter_metadata.endpoints.available`, which lists the others too).
|
|
2681
|
+
*/
|
|
2682
|
+
const selectedProvider = (text) => {
|
|
2683
|
+
const endpoint = /\{[^{}]*"selected"\s*:\s*true[^{}]*\}/.exec(text);
|
|
2684
|
+
return endpoint ? PROVIDER.exec(endpoint[0])?.[1] : void 0;
|
|
2685
|
+
};
|
|
2686
|
+
/**
|
|
2687
|
+
* Records the first `"model"` or `"modelId"` value in the response body and the `"effort"` of the
|
|
2688
|
+
* `"reasoning"` object after it, within {@link MODEL_WINDOW}; the provider of a selected endpoint
|
|
2689
|
+
* there or in the body's {@link TAIL}, else the first `"provider"` string in the window; and the
|
|
2690
|
+
* last `"cost"` number in the whole body, reading alongside its flow. Inside a JSON string the
|
|
2691
|
+
* quotes are escaped, so text that merely mentions them doesn't match.
|
|
3191
2692
|
*/
|
|
3192
2693
|
function readModel(up, t) {
|
|
3193
2694
|
let seen = "";
|
|
2695
|
+
let tail = "";
|
|
2696
|
+
let model = null;
|
|
2697
|
+
let effort = null;
|
|
2698
|
+
let provider;
|
|
2699
|
+
let selected;
|
|
3194
2700
|
const onData = (chunk) => {
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
2701
|
+
const text = chunk.toString("utf8");
|
|
2702
|
+
if (seen.length <= MODEL_WINDOW && !(effort && selected)) {
|
|
2703
|
+
seen += text;
|
|
2704
|
+
model ??= /"model(?:Id)?"\s*:\s*"([^"\\]{1,200})"/.exec(seen);
|
|
2705
|
+
effort ??= model ? /"reasoning"\s*:\s*\{[^{}]*?"effort"\s*:\s*"(\w{1,40})"/.exec(seen.slice(model.index)) : null;
|
|
2706
|
+
provider ??= PROVIDER.exec(seen)?.[1];
|
|
2707
|
+
selected ??= selectedProvider(seen);
|
|
2708
|
+
if (model) t.set({ responseModel: model[1] });
|
|
2709
|
+
if (effort) t.set({ responseEffort: effort[1] });
|
|
2710
|
+
}
|
|
2711
|
+
tail = (tail + text).slice(-16384);
|
|
2712
|
+
selected ??= selectedProvider(tail);
|
|
2713
|
+
const served = selected ?? provider;
|
|
2714
|
+
if (served) t.set({ responseProvider: served });
|
|
2715
|
+
const cost = [...tail.matchAll(/"cost"\s*:\s*(\d+(?:\.\d+)?(?:[eE][-+]?\d+)?)/g)].at(-1);
|
|
2716
|
+
if (cost) t.set({ responseCost: Number(cost[1]) });
|
|
3201
2717
|
};
|
|
3202
2718
|
up.on("data", onData);
|
|
3203
2719
|
}
|
|
2720
|
+
/** Most of a request body the gateway reads for its reasoning settings: a long session's. */
|
|
2721
|
+
const EFFORT_LIMIT = 16777216;
|
|
2722
|
+
/**
|
|
2723
|
+
* The body passed on as it flows, recording the reasoning settings its JSON carries once it
|
|
2724
|
+
* ends. A transform, not a `data` listener: that would start the body flowing before the
|
|
2725
|
+
* upstream request is there to take it.
|
|
2726
|
+
*/
|
|
2727
|
+
function effortReader(t) {
|
|
2728
|
+
const chunks = [];
|
|
2729
|
+
let size = 0;
|
|
2730
|
+
return new Transform({
|
|
2731
|
+
transform(chunk, _encoding, done) {
|
|
2732
|
+
size += chunk.length;
|
|
2733
|
+
if (size <= EFFORT_LIMIT) chunks.push(chunk);
|
|
2734
|
+
done(null, chunk);
|
|
2735
|
+
},
|
|
2736
|
+
flush(done) {
|
|
2737
|
+
if (size <= EFFORT_LIMIT) {
|
|
2738
|
+
const effort = requestedEffort(Buffer.concat(chunks).toString("utf8"));
|
|
2739
|
+
if (effort) t.set({ requestEffort: effort });
|
|
2740
|
+
}
|
|
2741
|
+
done();
|
|
2742
|
+
}
|
|
2743
|
+
});
|
|
2744
|
+
}
|
|
3204
2745
|
/** Most an exchange's response may be; it's a few hundred bytes of JSON. */
|
|
3205
2746
|
const EXCHANGE_LIMIT = 1 << 20;
|
|
3206
2747
|
/**
|
|
3207
2748
|
* A token exchange's response, read whole, with each token replaced by a placeholder. A success
|
|
3208
2749
|
* that can't be read (compressed, too big, not JSON) is a 502: the real tokens never go through.
|
|
3209
2750
|
*/
|
|
3210
|
-
function
|
|
2751
|
+
function tokenized(exchange, url, status, headers, up, res, own, creds, t) {
|
|
3211
2752
|
const chunks = [];
|
|
3212
2753
|
let size = 0;
|
|
3213
2754
|
const refuse = (why) => {
|
|
@@ -3237,12 +2778,12 @@ function createEgressProxy(options) {
|
|
|
3237
2778
|
if (size > EXCHANGE_LIMIT) return refuse(`the response is over ${EXCHANGE_LIMIT} bytes`);
|
|
3238
2779
|
let result;
|
|
3239
2780
|
try {
|
|
3240
|
-
result =
|
|
2781
|
+
result = tokenizeResponse(exchange, body.toString("utf8"), tokens);
|
|
3241
2782
|
} catch (error) {
|
|
3242
2783
|
return refuse(error.message);
|
|
3243
2784
|
}
|
|
3244
2785
|
tokens = [...tokens, ...result.added];
|
|
3245
|
-
log(`reeval:egress ${url}
|
|
2786
|
+
log(`reeval:egress ${url} tokenized ${result.fields.join(", ") || "nothing"} (${exchange.name})`);
|
|
3246
2787
|
const text = Buffer.from(result.body);
|
|
3247
2788
|
delete out["content-encoding"];
|
|
3248
2789
|
res.writeHead(status, {
|
|
@@ -3272,9 +2813,28 @@ function createEgressProxy(options) {
|
|
|
3272
2813
|
req.resume();
|
|
3273
2814
|
return res.writeHead(refused.status, { "content-type": "text/plain" }).end(`${refused.reason}\n`);
|
|
3274
2815
|
}
|
|
2816
|
+
const local = locals.find((l) => onEndpoint([l.match], {
|
|
2817
|
+
host: target.host,
|
|
2818
|
+
method,
|
|
2819
|
+
path: asked,
|
|
2820
|
+
headers: {}
|
|
2821
|
+
}));
|
|
2822
|
+
if (local) {
|
|
2823
|
+
log(`reeval:egress ${method} ${url} answered by the gateway (${local.status})`);
|
|
2824
|
+
req.resume();
|
|
2825
|
+
const out = {
|
|
2826
|
+
"content-type": "application/json",
|
|
2827
|
+
...local.headers
|
|
2828
|
+
};
|
|
2829
|
+
t.set({
|
|
2830
|
+
status: local.status,
|
|
2831
|
+
responseHeaders: out
|
|
2832
|
+
});
|
|
2833
|
+
return res.writeHead(local.status, out).end(local.body);
|
|
2834
|
+
}
|
|
3275
2835
|
delete headers.upgrade;
|
|
3276
2836
|
delete headers.connection;
|
|
3277
|
-
const body = requestBody(req, headers, own, t);
|
|
2837
|
+
const body = requestBody(req, headers, own, t, !!readsModel || setsCredential(rules, target.host) || substitutes(allSubs(), target.host) || hostAllowed(tokenHosts, target.host));
|
|
3278
2838
|
const authority = authorityOf(target.host, target.port);
|
|
3279
2839
|
const session = req.httpVersionMajor === 2 ? await upstreamSession(target) : null;
|
|
3280
2840
|
if (!session) return forwardHttp1(body, res, https.request({
|
|
@@ -3312,7 +2872,7 @@ function createEgressProxy(options) {
|
|
|
3312
2872
|
const creds = credentialScrubs(target.host);
|
|
3313
2873
|
stream.once("response", (h) => {
|
|
3314
2874
|
const status = Number(h[":status"]);
|
|
3315
|
-
if (exchange) return
|
|
2875
|
+
if (exchange) return tokenized(exchange, url, status, h, stream, res, own, creds, t);
|
|
3316
2876
|
if (!respond(status, h, stream, res, own, creds, url, t, readsModel)) return;
|
|
3317
2877
|
stream.once("trailers", (trailers) => res.addTrailers(scrubbedHeaders(trailers, [...own, ...creds])));
|
|
3318
2878
|
});
|
|
@@ -3339,7 +2899,7 @@ function createEgressProxy(options) {
|
|
|
3339
2899
|
const { own, creds, url, exchange, t } = to;
|
|
3340
2900
|
upstream.once("response", (up) => {
|
|
3341
2901
|
const status = up.statusCode ?? 502;
|
|
3342
|
-
if (exchange) return
|
|
2902
|
+
if (exchange) return tokenized(exchange, url, status, up.headers, up, res, own, creds, t);
|
|
3343
2903
|
if (!respond(status, up.headers, up, res, own, creds, url, t, to.readsModel)) return;
|
|
3344
2904
|
up.once("end", () => {
|
|
3345
2905
|
if (Object.keys(up.trailers).length) res.addTrailers(scrubbedHeaders(up.trailers, [...own, ...creds]));
|
|
@@ -3517,7 +3077,7 @@ const installCa = (containerId, cert, signal, engine) => docker([
|
|
|
3517
3077
|
engine
|
|
3518
3078
|
});
|
|
3519
3079
|
/**
|
|
3520
|
-
* Starts the egress gateway for one container: a forwarder inside it,
|
|
3080
|
+
* Starts the egress gateway for one container: a forwarder inside it, tunneled over one
|
|
3521
3081
|
* `docker exec -i`, and the proxy in this process, which holds the real credentials.
|
|
3522
3082
|
*/
|
|
3523
3083
|
async function startGateway(containerId, options, signal, engine) {
|
|
@@ -3621,7 +3181,7 @@ async function startGateway(containerId, options, signal, engine) {
|
|
|
3621
3181
|
signal?.removeEventListener("abort", onAbort);
|
|
3622
3182
|
}
|
|
3623
3183
|
const proxyUrl = `http://127.0.0.1:${PROXY_PORT}`;
|
|
3624
|
-
const noProxy = "localhost,127.0.0.1,::1";
|
|
3184
|
+
const noProxy = "localhost,127.0.0.1,::1,[::1]";
|
|
3625
3185
|
return {
|
|
3626
3186
|
env: {
|
|
3627
3187
|
HTTPS_PROXY: proxyUrl,
|
|
@@ -4283,7 +3843,7 @@ const BOOTSTRAPS = {
|
|
|
4283
3843
|
name: "Cursor",
|
|
4284
3844
|
cli: "@cursor/sdk",
|
|
4285
3845
|
version: `node -p "'@cursor/sdk ' + require(process.env.HOME + '/.ai-sdk-harness/.harness-bootstrap/cursor-sdk/node_modules/@cursor/sdk/package.json').version"`,
|
|
4286
|
-
adapter: async () => (await import("./src-
|
|
3846
|
+
adapter: async () => (await import("./src-DMo2eCOJ.js")).createCursorSdk()
|
|
4287
3847
|
},
|
|
4288
3848
|
"claude-code": {
|
|
4289
3849
|
name: "Claude Code",
|
|
@@ -4293,12 +3853,12 @@ const BOOTSTRAPS = {
|
|
|
4293
3853
|
antigravity: {
|
|
4294
3854
|
name: "Antigravity",
|
|
4295
3855
|
cli: "agy",
|
|
4296
|
-
adapter: async () => (await import("./src-
|
|
3856
|
+
adapter: async () => (await import("./src-OESRtvOi.js")).createAntigravity()
|
|
4297
3857
|
},
|
|
4298
3858
|
opencode: {
|
|
4299
3859
|
name: "OpenCode",
|
|
4300
3860
|
cli: "opencode",
|
|
4301
|
-
adapter: async () => (await import("./src-
|
|
3861
|
+
adapter: async () => (await import("./src-CgJrz5p0.js")).createOpenCode({
|
|
4302
3862
|
auth: { GOOGLE_GENERATIVE_AI_API_KEY: "unused" },
|
|
4303
3863
|
model: "google/unused"
|
|
4304
3864
|
})
|
|
@@ -4306,7 +3866,7 @@ const BOOTSTRAPS = {
|
|
|
4306
3866
|
goose: {
|
|
4307
3867
|
name: "Goose",
|
|
4308
3868
|
cli: "goose",
|
|
4309
|
-
adapter: async () => (await import("./src-
|
|
3869
|
+
adapter: async () => (await import("./src-BTqJbvj6.js")).createGoose({
|
|
4310
3870
|
auth: { GOOGLE_API_KEY: "unused" },
|
|
4311
3871
|
model: "unused"
|
|
4312
3872
|
})
|
|
@@ -4314,17 +3874,17 @@ const BOOTSTRAPS = {
|
|
|
4314
3874
|
pi: {
|
|
4315
3875
|
name: "pi",
|
|
4316
3876
|
cli: "pi",
|
|
4317
|
-
adapter: async () => (await import("./src-
|
|
3877
|
+
adapter: async () => (await import("./src-BkiComGh.js")).createPi({ auth: { GEMINI_API_KEY: "unused" } })
|
|
4318
3878
|
},
|
|
4319
3879
|
codex: {
|
|
4320
3880
|
name: "Codex",
|
|
4321
3881
|
cli: "codex",
|
|
4322
|
-
adapter: async () => (await import("./src-
|
|
3882
|
+
adapter: async () => (await import("./src-BvgeZ4tS.js")).createCodex({ auth: { OPENAI_API_KEY: "unused" } })
|
|
4323
3883
|
},
|
|
4324
3884
|
fx: {
|
|
4325
3885
|
name: "fx",
|
|
4326
3886
|
cli: "fx",
|
|
4327
|
-
adapter: async () => (await import("./src-
|
|
3887
|
+
adapter: async () => (await import("./src-Dk2Na0b-.js")).createFx({
|
|
4328
3888
|
auth: { AI_GATEWAY_API_KEY: "unused" },
|
|
4329
3889
|
model: "unused/unused"
|
|
4330
3890
|
})
|
|
@@ -4332,7 +3892,7 @@ const BOOTSTRAPS = {
|
|
|
4332
3892
|
"grok-build": {
|
|
4333
3893
|
name: "Grok Build",
|
|
4334
3894
|
cli: "grok",
|
|
4335
|
-
adapter: async () => (await import("./src-
|
|
3895
|
+
adapter: async () => (await import("./src-Cp-2Hdib.js")).createGrokBuild({
|
|
4336
3896
|
auth: { XAI_API_KEY: "unused" },
|
|
4337
3897
|
model: "unused"
|
|
4338
3898
|
})
|
|
@@ -4846,61 +4406,6 @@ async function buildPluginLayer(parent, b, options) {
|
|
|
4846
4406
|
}
|
|
4847
4407
|
/** The build arg a Dockerfile can start `FROM` to layer on reeval's sandbox image. */
|
|
4848
4408
|
const REEVAL_BASE_ARG = "REEVAL_BASE";
|
|
4849
|
-
/**
|
|
4850
|
-
* `.dockerignore` rules as Docker reads them: paths from the context root, `*`, `?` and `**`
|
|
4851
|
-
* globs, a pattern that matches a directory excludes what's in it, `!` re-includes, and the last
|
|
4852
|
-
* matching rule wins.
|
|
4853
|
-
*/
|
|
4854
|
-
function dockerignoreMatcher(text) {
|
|
4855
|
-
const rules = text.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => {
|
|
4856
|
-
const negate = line.startsWith("!");
|
|
4857
|
-
const body = (negate ? line.slice(1) : line).trim().replace(/^(?:\.?\/)+/, "").replace(/\/+$/, "");
|
|
4858
|
-
let re = "";
|
|
4859
|
-
for (let i = 0; i < body.length; i++) {
|
|
4860
|
-
const c = body[i];
|
|
4861
|
-
if (c === "*" && body[i + 1] === "*") {
|
|
4862
|
-
i++;
|
|
4863
|
-
if (body[i + 1] === "/") {
|
|
4864
|
-
i++;
|
|
4865
|
-
re += "(?:.*/)?";
|
|
4866
|
-
} else re += ".*";
|
|
4867
|
-
} else if (c === "*") re += "[^/]*";
|
|
4868
|
-
else if (c === "?") re += "[^/]";
|
|
4869
|
-
else re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
4870
|
-
}
|
|
4871
|
-
return {
|
|
4872
|
-
negate,
|
|
4873
|
-
re: new RegExp(`^${re}$`)
|
|
4874
|
-
};
|
|
4875
|
-
});
|
|
4876
|
-
return (path) => {
|
|
4877
|
-
const parts = path.split("/");
|
|
4878
|
-
const prefixes = parts.map((_, i) => parts.slice(0, i + 1).join("/"));
|
|
4879
|
-
let excluded = false;
|
|
4880
|
-
for (const rule of rules) if (prefixes.some((p) => rule.re.test(p))) excluded = !rule.negate;
|
|
4881
|
-
return excluded;
|
|
4882
|
-
};
|
|
4883
|
-
}
|
|
4884
|
-
/**
|
|
4885
|
-
* Files in the build context that `docker build` would send, sorted, relative to `context`. A
|
|
4886
|
-
* Dockerfile read from stdin (`dockerfile` null) has no `<Dockerfile>.dockerignore` of its own.
|
|
4887
|
-
*/
|
|
4888
|
-
function contextFiles(context, dockerfile) {
|
|
4889
|
-
const own = [...dockerfile ? [`${dockerfile}.dockerignore`] : [], join(context, ".dockerignore")].find(existsSync);
|
|
4890
|
-
const ignored = dockerignoreMatcher(own ? readFileSync(own, "utf8") : "");
|
|
4891
|
-
const always = /* @__PURE__ */ new Set([...dockerfile ? [relative(context, dockerfile)] : [], ".dockerignore"]);
|
|
4892
|
-
const files = [];
|
|
4893
|
-
const walk = (rel) => {
|
|
4894
|
-
for (const entry of readdirSync(join(context, rel), { withFileTypes: true })) {
|
|
4895
|
-
const path = rel ? `${rel}/${entry.name}` : entry.name;
|
|
4896
|
-
if (ignored(path) && !always.has(path)) continue;
|
|
4897
|
-
if (entry.isDirectory()) walk(path);
|
|
4898
|
-
else files.push(path);
|
|
4899
|
-
}
|
|
4900
|
-
};
|
|
4901
|
-
walk("");
|
|
4902
|
-
return files.sort();
|
|
4903
|
-
}
|
|
4904
4409
|
/** Whether the Dockerfile starts from reeval's sandbox image, which then has to exist first. */
|
|
4905
4410
|
const usesReevalBase = (dockerfile) => new RegExp(`\\$\\{?${REEVAL_BASE_ARG}\\b`).test(readFileSync(dockerfile, "utf8"));
|
|
4906
4411
|
/**
|
|
@@ -4975,6 +4480,6 @@ async function buildDockerfile(dockerfile, options) {
|
|
|
4975
4480
|
*/
|
|
4976
4481
|
const MCP_TIMER = fileURLToPath(ownFileURL("bin/mcp-timer.cjs"));
|
|
4977
4482
|
//#endregion
|
|
4978
|
-
export {
|
|
4483
|
+
export { contextFiles as $, applyTransformations as A, BRIDGE_PORT as B, PRIVILEGED_CAPABILITIES as C, engineSpec 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, dockerSeccompFile 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 _, failureCause as _t, buildDockerfile as a, dockerState as at, usesReevalBase as b, retryTransient as bt, buildPluginLayer as c, isRegistryDigest as ct, harnessImageFor as d, onDockerCommand as dt, dockerignoreMatcher as et, installLayerTag as f, run as ft, pluginLayerTag as g, causeLine as gt, pluginBuildKey as h, RETRY_DELAYS 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, ImageBuildError as mt, DOCKER_CONTEXT as n, dockerAvailable as nt, buildImage as o, imageInfo as ot, installScript as p, shellQuote 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, OPAQUE_OUTPUT as ut, resolveFrom as v, isTransient as vt, ROOT_CAPABILITIES as w, normalizeImageId as wt, DEFAULT_LIMITS as x, ENGINES as xt, sourceTreeHash as y, parseBuildOutput as yt, BASE_IMAGE as z };
|
|
4979
4484
|
|
|
4980
|
-
//# sourceMappingURL=src-
|
|
4485
|
+
//# sourceMappingURL=src-C0ySiej5.js.map
|