Repository navigation
Conversation
added 5 commits
November 15, 2026 10:30
…s-host token leak Every git command now carries a cnb.cool-scoped credential block that clears inherited helpers, answers with the user's CNB token or quit=1, and disables redirects. CNB remotes never get the global Git token, RewriteRemoteForToken or the global askpass. Runner >= 0.10.2 is required for CNB repositories at dispatch and claim; older runners get no Git token for such tasks. Also stores the personal CNB token (user_configs.cnb_token, migration 033).
internal/cnb wraps the swagger-checked pull request, default branch and user endpoints with Bearer auth, no redirects and bounded bodies. cnbHandlers saves, clears and verifies the signed-in user's CNB token (401 invalid, 403 valid without a login name). The user_configs.cnb_token store and migration 033 came with the credential pipeline in the previous commit.
…it, and tracker sync Repositories on cnb.cool bind as provider cnb with project cnb:<group>/<repo> (any depth, sub pages stripped) and read their default branch with the binder's CNB token. Conversation push and workbench_workspace_submit_mr use the requester's CNB token, create or update the open pull request and return https://cnb.cool/<slug>/-/pulls/<n>. The tracker serves cnb: projects through the pullHost seam with the project owner's token, merging only the repository's own pull request and failing unless CNB reports merged.
…in web and chatbot The personal CNB token is saved and cleared with the other credentials (cnbToken, cnbTokenClear on PUT /api/users/:id/credentials) and verified before saving; the separate save and clear endpoints are dropped. web and the chatbot quick-access wizard accept https://cnb.cool/<group>/.../<repo> in any depth, replace the 'CNB only supports HTTPS + token' notice, leave the default branch empty for CNB so the server reads it, and link PRs, branches and compares with /-/pulls/, /-/tree/ and /-/compare/. No third-party logo is used. A checkout that fails because the CNB token is missing or rejected now says so instead of blaming the GitHub token.
Yanami-2K
requested changes
Nov 16, 2026
Yanami-2K
left a comment
Collaborator
There was a problem hiding this comment.
已读前 50 个文件(共 86 个,工具单页上限,internal/gitwork/https_credential.go 等部分 patch 未展开)。安全边界设计清楚:CNB 地址解析拒绝 userinfo/http/伪造域名,cloneRemoteForGit 不再把全局 Git Token 嵌进 cnb.cool 远端,PublicRunnerTask 会清掉 GitHTTPSCredentials,旧 Runner 由 RunnerVersionCNB 拒绝派发,cnb.Client 不跟随重定向,并且都有对应测试。但目前不能合入:
- CI 失败(checksState=failure):
validate (3.8)、py3.8 e2e、e2e-browser、e2e-required失败,和同期 #214/#888/#902 一致,是ubuntu-latest切到 26.04 导致的(#885,修复在 #886)。请在 #886 合入后 rebase 重跑,确认没有本 PR 自身的失败。 - 迁移编号冲突:
docs/deployment.md引用的migrations/033_cnb_credentials.sql和 open 的 #894 新增的 033 迁移是同一编号。两者都合入后顺序不确定,手动执行迁移的部署会漏执行或重复执行。请和 #894 协调,后合的一方顺延到 034,并同步文档。 - 与 #503 重叠:本 PR 在
internal/gitwork/https_credential.go新增按主机限定的 HTTPS credential helper,并在domain.RunnerInvocation加了GitHTTPSUserID/GitHTTPSCredentials/RunnerRepository.ScopedHTTPS。#503(GitLab PAT)也在 gitwork 和 Runner 凭据下发里实现了同类机制,先合的一方会让另一方大面积冲突,而且会留下两套并行的“主机限定凭据”实现。建议保留 #503 作为通用的主机限定 HTTPS 凭据底座(它更早提交,评审也更完整),本 PR rebase 上去,把 cnb.cool 作为一个 provider 接入,只保留internal/cnb客户端和 PR 生命周期部分。如果维护者决定反过来,也请在两个 PR 里写明合入顺序。 - 次要:
RunnerVersionCNB = "0.10.2"请确认和实际发版计划一致,如果其他 PR 也在提升最低 Runner 版本,要统一。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #890.
What changed
This PR adds Phase 1 native CNB (
https://cnb.cool) support across credentials, Git transport isolation, repository binding, workspace PR submission, tracker state sync/merge, and Web/Chatbot UI:internal/gitwork,internal/runtime,internal/runner):https://cnb.coolwithGIT_CONFIG_COUNTand an inlineshcredential helper (quit=1,followRedirects=false,AGENTFLOW_SCOPED_GIT_TOKEN_0) so scoped CNB tokens never fall back to globalGIT_ASKPASS,AuthConfigArgs, orRewriteRemoteForToken, and GitHub/Gongfeng PATs cannot leak tocnb.cool.0.10.2(domain.RunnerVersionCNB): runners< 0.10.2receive zero CNB credentials; runners>= 0.10.2receive uncached (Cache-Control: no-store) host-scoped HTTPS credentials per claimed task without runner-side persistence.internal/cnb,internal/httpapi,internal/repo):net/httpclient againsthttps://api.cnb.cool(redirects disabled, 8 MiB response limit, Bearer token redacted inAPIError).PUT /api/users/:id/credentials(cnbToken/cnbTokenClear, stored inuser_configs.cnb_token) and addsGET/POST /api/users/:id/cnb-token/verify(403on/useraccepted as valid when scoped torepo-code:rw+repo-pr:rw).commit_titleinMergePull(verified required by livehttps://api.cnb.cool, even thoughswagger.jsonomits it fromrequired).cnb:<slug>delivery & actor identity split (internal/domain,internal/tracker,internal/engine,internal/httpapi):internal/tracker.pullHostso GitHub and CNB share MR delivery/sync behind one seam.https://cnb.cool/<org>/.../<repo>URLs (stripping/-/...subpaths) into canonicalcnb:<slug>, auto-detectsdefaultBranchvia live/-/git/headwhen omitted, routes SOP pull/push toResponsibleUserID, workspacesubmit_mrtorequesterID, and tracker merge/sync to ProjectOwnerID.web/,chatbot/,webtest/,docs/):CNB 访问令牌credential card (verify-on-save, redaction, clear) and multi-depthcnb.coolURL parsing/links (/-/pulls/,/-/tree/,/-/compare/) across project setup and workbench.Commit Breakdown (5 Atomic Commits)
0bd1d11refactor(tracker): extract pullHost seam for GitHub MR delivery and sync22b33c9feat(gitwork): add host-scoped HTTPS credential helper and block cross-host token leak972ea4efeat(cnb): add CNB OpenAPI client and cnbHandlers for the personal tokenbd0e89efeat(delivery): wire cnb:<slug> repository binding, workspace PR submit, and tracker sync00184d6feat(ui): add CNB credential card and multi-segment cnb.cool support in web and chatbotVisual Verification (Tabbit Browser + Live Local MySQL 8.4 on
00184d6)CNB 访问令牌card (verify-on-save, masked state)cnb.cool/tencent/loopforge/demo(cnb:tencent/loopforge/demo) card5xxresponsesScope
Compatibility
migrations/033_cnb_credentials.sql(ALTER TABLE user_configs ADD COLUMN cnb_token TEXT NULL;). Existing databases without migration need the column added manually perdocs/deployment.md.0.10.2(domain.RunnerVersionCNB). Runners older than0.10.2continue executing GitHub/Gongfeng/SSH tasks normally and are blocked from receiving CNB credentials.Validation
Note: The code, frontend assets, SQL migration, and tests on this branch (
00184d6) are byte-for-byte identical to the fork CI verification run (wycocoyu/LoopForge#5atc934233), which only added.github/workflows/{e2e,validate}.ymlfrom open PR#886(37d3377) temporarily so Ubuntu 26.04 Python 3.8 / Playwright jobs could run in the fork (15/15green). Commitc934233is intentionally omitted here to keep#886separate.15/15passing,0failed,0skipped onwycocoyu/LoopForge#5):validate(#43794818847):validate (3.8),validate (3.12),secrets,tcmcp,curl-installe2e(#43794818933):e2e (ubuntu-24.04),e2e (ubuntu-latest, 3.8),e2e (ubuntu-latest, 3.12),e2e (macos-latest),e2e-browser (dashboard),e2e-requiredplatform(#43794818827):first-run(2m31s),browser(6m40s),core(15m3sincl. full Linux Go suites, real Chromium Go tests, coverage gate,govulncheck),platform-required(3s)https://cnb.cool&https://api.cnb.coolEnd-to-End Smoke (00184d6):repo-code:rw,repo-pr:rw, no/userscope) passedPOST /api/users/:id/cnb-token/verify(200 {"valid": true}) andPUT /api/users/:id/credentials(cnbTokenConfigured: true).git ls-remotefailed closed (rc=128) without CNB token +GIT_ASKPASS, andgit pushsucceeded (rc=0) via the scoped helper.POST /api/repositoriesomittingdefaultBranchresolveddefaultBranch: "main"via livehttps://api.cnb.cool/-/git/head, andsubmitCNBPull-> idempotent update ->trackerfindPull->mergePull->pullconfirmedState: "merged"against live CNB (temporary token revoked and disposable repo deleted afterward).0):scripts/scan-secrets.shdownloads a Linux binary (passed remotely viavalidate/secrets); 4 pre-existing unmodified upstream tests fail on macOS (TestGitDiscoveryStopsBeforeParentRepository,TestLocalWorkspaceGitDiscoveryCannotReachParent,TestProcessSandboxPathsProfilesAndCommands,TestProjectAgentGitIndexLockWaitStopsOnCancel, all passing in Linux CIplatform/core). Upstream CIvalidate/e2eUbuntu 26.04 legs depend on#886.Safety
scripts/collect-go-notices.pyacross 86 modules; no new Go/npm dependencies or third-party logos added.)中文说明
关联并关闭上游议题
#890。变更内容
本 PR 实现第一阶段原生 CNB(
https://cnb.cool) 全链路支持,涵盖凭证存储、域名作用域 Git 传输隔离、多级仓库绑定、工作区自动提 PR、状态机同步合并与 Web / Chatbot 界面:internal/gitwork、internal/runtime、internal/runner):GIT_CONFIG_COUNT为https://cnb.cool注入内联sh凭证助手(quit=1、followRedirects=false、AGENTFLOW_SCOPED_GIT_TOKEN_0),阻断GIT_ASKPASS、AuthConfigArgs与RewriteRemoteForToken跨站回退,防止 GitHub / 工蜂 PAT 泄露给cnb.cool。0.10.2(domain.RunnerVersionCNB):低于0.10.2的 Runner 不下发 CNB 凭证,达标 Runner 每次领取任务通过Cache-Control: no-store实时获取单次凭证,不在 Runner 侧落盘。internal/cnb、internal/httpapi、internal/repo):net/http对接https://api.cnb.cool(禁止自动重定向、响应上限 8 MiB、APIError自动脱敏 Bearer Token)。PUT /api/users/:id/credentials(cnbToken/cnbTokenClear,持久化于user_configs.cnb_token),新增GET/POST /api/users/:id/cnb-token/verify(仅授予repo-code:rw+repo-pr:rw时/user返回403仍判定为有效)。MergePull请求中显式携带commit_title(经真实线上接口实测必填,而官网swagger.json未标注必填)。cnb:<slug>绑定与三端操作者身份隔离(internal/domain、internal/tracker、internal/engine、internal/httpapi):internal/tracker.pullHost抽象层,由 GitHub 与 CNB 共同实现 MR 交付与同步。https://cnb.cool/<org>/.../<repo>解析(自动剔除/-/...子页面)为规范标识cnb:<slug>;未填默认分支时调用/-/git/head自动回填;SOP 拉推使用ResponsibleUserID,工作区submit_mr使用requesterID,状态同步与合并使用项目OwnerID。web/、chatbot/、webtest/、docs/):CNB 访问令牌凭证卡片(保存前校验、密文脱敏、清除),并在项目配置与工作台支持多段cnb.cool地址及/-/pulls/、/-/tree/、/-/compare/跳转。提交拆分(5 个原子提交)
0bd1d11refactor(tracker): extract pullHost seam for GitHub MR delivery and sync22b33c9feat(gitwork): add host-scoped HTTPS credential helper and block cross-host token leak972ea4efeat(cnb): add CNB OpenAPI client and cnbHandlers for the personal tokenbd0e89efeat(delivery): wire cnb:<slug> repository binding, workspace PR submit, and tracker sync00184d6feat(ui): add CNB credential card and multi-segment cnb.cool support in web and chatbot实机界面视觉验证(
00184d6+ Tabbit 浏览器 + 本地 MySQL 8.4)CNB 访问令牌卡片(保存前校验、脱敏态)cnb.cool/tencent/loopforge/demo(cnb:tencent/loopforge/demo)仓库卡5xx请求影响范围(Scope)
兼容性(Compatibility)
migrations/033_cnb_credentials.sql(ALTER TABLE user_configs ADD COLUMN cnb_token TEXT NULL;)。存量部署按docs/deployment.md手动执行即可。0.10.2(domain.RunnerVersionCNB)。低于0.10.2的旧 Runner 仍可正常执行 GitHub / 工蜂 / SSH 任务,仅禁止领取或接收 CNB 凭证。验证情况(Validation)
说明:本分支(
00184d6)的业务代码、前端构建产物、SQL 与测试与个人 Fork 验证分支(wycocoyu/LoopForge#5提交c934233)完全一致;c934233仅临时叠加了待合并 PR#886(37d3377)的两个工作流修复文件,以在个人 Fork 上跑通15/15云端检查。本上游 PR 刻意剔除了c934233,避免与#886重复。wycocoyu/LoopForge#515/15全绿、0失败、0跳过):validate(#43794818847):validate (3.8)、validate (3.12)、secrets、tcmcp、curl-installe2e(#43794818933):e2e (ubuntu-24.04)、e2e (ubuntu-latest, 3.8)、e2e (ubuntu-latest, 3.12)、e2e (macos-latest)、e2e-browser (dashboard)、e2e-requiredplatform(#43794818827):first-run(2m31s)、browser(6m40s)、core(15m3s,含 Linux 全量 Go 单测、真浏览器 Go 测试、覆盖率门禁与govulncheck)、platform-required(3s)https://cnb.cool与https://api.cnb.cool线上端到端冒烟(00184d6):repo-code:rw+repo-pr:rw,无/user权限)通过POST /api/users/:id/cnb-token/verify(返回200 {"valid": true})并经PUT /api/users/:id/credentials脱敏保存。GIT_ASKPASS时git ls-remote熔断失败(rc=128),带域控 Helper 后git push成功(rc=0)。defaultBranch调用POST /api/repositories时经实时https://api.cnb.cool/-/git/head自动补全main,完整走通submitCNBPull建单 → 幂等更新 →trackerfindPull→mergePull→pull回读State: "merged"(测试后已吊销临时令牌并删除临时私有仓)。0):scripts/check-public.py、scripts/collect-go-notices.py(86 模块)、go vet ./...、local/scripts/validate.shlocal/scripts/test-observability.sh(131×3)、local/scripts/e2e.sh(34 项,本机因未装 Playwright 跳过test_e2e_dashboard_browser,已在云端e2e-browser覆盖)、scripts/build-chatbot.sh(55 文件 / 370 Vitest)、webtest(189 项全过)./internal/cnb/...、./internal/tracker/...、./internal/domain/...、./web/...、./internal/httpapi/...、./internal/engine/...、非浏览器./internal/runner/...(-skip "$REAL_BROWSER_TESTS")、./internal/gitwork/...与./internal/runtime/...的 CNB/HTTPS 用例、./internal/repo/... -run 'CNB|User|Runner'(本机未传AGENTFLOW_TEST_MYSQL_DSN时跳过 4 项 MySQL 用例;MySQL 8.4 全量已于aeb89c4实测通过)scripts/scan-secrets.sh下载 Linux 二进制未在本机执行(已在云端validate/secrets通过);4 项未改动上游单测因 macOS/var/folders软链及 Seatbelt 差异在本机失败,已在 Linux CIplatform/core全绿通过。上游validate与e2e在 Ubuntu 26.04 运行环境上依赖#886合入。安全性自检(Safety)
scripts/collect-go-notices.py86 模块校验通过,未新增 Go/npm 依赖或第三方图标。)