Skip to content

fix(dag-init): encode GitLab version-endpoint auth requirement in the self-hosted probe #312

Description

@LeXwDeX

现象

/dag-init 对自建 GitLab 实例的探测段把裸 curl 放在第一位:

Any other host → probe whether it is a self-hosted GitLab: curl -sSf https://<host>/api/v4/version (or glab api version against that host once authed)

按字面执行的 agent 必然先吃一次 401 才能反应过来——本次 git.ycgame.com 实弹握手中已真实发生(curl 401 → glab 认证通道兜住)。

根因

GET /api/v4/version 按 GitLab API 设计要求认证(官方文档明确 requires authenticated user,版本泄露对攻击者有价值)——健康实例对裸请求返回 401 是标准行为,不是实例故障。命令文本未编码这一事实,把主路径(认证调用)写成了或者备选项。

修复(提示词卫生)

改写 dag-init.txt 自建探测段,编码两个认知点:

  1. 401 是阳性证据:端点存在且返回 GitLab 形状的错误,恰好证明它是 GitLab——探针不得把 401 当失败
  2. 认证调用是主路径:判定为 GitLab 且鉴权通过后以 glab api version 复核

拟稿:

其他 host → 判定是否自建 GitLab。注意:GitLab 的 /api/v4/version 按设计要求认证,健康实例对裸请求返回 401——这是阳性证据(端点存在且在应答),不是失败。 判定序:curl -sSf https://<host>/api/v4/version;返回版本 JSON 401/GitLab 形状错误 → 判定为 GitLab;连接拒绝或非 GitLab 应答 → STOP unsupported platform。判定为 GitLab 后,鉴权通过时以 glab api version 复核。

验收

  • dag-init.txt 探测段包含 401 语义说明与复核步骤
  • 既有测试锚点更新(core command.test.ts 的 DagInitContent 断言)
  • 后续 agent 按文本一次通过自建实例探测,不再消耗失败回合

证据

git.ycgame.com(内网自建实例)实弹记录:裸 curl → 401 insufficient auth;glab api 认证通道 → 全探针通过,握手成功写入 dag-init.json。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions