Skip to content

[项目管理] Git 仓库地址有效性校验与错误提示 #22

@beautyarbutin

Description

@beautyarbutin

Summary

当前系统在新建 / 编辑项目填写 Git 仓库地址时,已有一部分安全校验,但错误提示和“明显不是仓库地址”的格式校验仍不够清晰。用户输入无效链接、非仓库页面链接或格式不规范的 remote URL 后,可能要到后续 clone / polling 流程才失败,排障成本较高。

本 issue 关注 Git remote URL 的有效性校验与用户可理解的错误提示,不把 HALF 限制为仅支持 GitHub。

Environment

  • Deployment: local dev
  • OS: Windows
  • Browser or client: Chrome
  • Commit or version: main at report time

Steps To Reproduce

  1. 打开需要填写 Git 仓库地址的页面
  2. 输入一个非标准或无效的仓库地址,例如:
    • github.com/owner/repo
    • https://github.com/owner
    • https://github.com/owner/repo/tree/main
    • https://notgithub.com/test/repo
    • file:///tmp/repo
    • http://127.0.0.1/repo.git
  3. 提交并观察系统行为

Expected Behavior

系统应当对 Git remote URL 做清晰校验,并给出明确错误提示。

建议接受当前产品语义下合法、安全的仓库 remote URL,例如:

  • https://github.com/owner/repo
  • https://github.com/owner/repo.git
  • ssh://git@github.com/owner/repo.git
  • git@github.com:owner/repo.git

建议拒绝并提示:

  • 缺少显式协议或 SSH remote 格式不合法
  • 缺少 owner / repo 这类仓库路径信息
  • GitHub / GitLab 等代码托管站点的 treeblob、issue、PR 等非仓库 remote 页面
  • 危险协议或前缀,例如 file://ext::、以 - 开头的参数注入形式
  • 指向 localhost、内网、link-local metadata service 等不应由后端访问的地址

错误提示应尽量告诉用户“应该填写仓库 clone URL,而不是仓库内页面 URL”。

Actual Behavior

当前输入无效或不规范的 Git 仓库地址时,系统没有始终给出足够明确的校验提示,或者进入后续流程后才失败,用户无法快速判断输入格式是否正确。

Logs Or Screenshots

Image

Metadata

Metadata

Assignees

Labels

area:backendBackend / Python / FastAPI relatedarea:frontendFrontend / React / UI relatedarea:securitySecurity hardening, auth, validation, or threat-model relatedstatus:readyTriaged and ready to pick uptype:bugSomething isn't working

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions