feat: リポジトリ URL バリデーションを緩和しエラー文言を具体化 (v2.1.263-e)
Helm Chart Release / release-chart (push) Failing after 9s
Build Session Image / build-push (push) Successful in 2m9s

claude@host:path のような SSH ユーザー違いの URL が「形式が不正」で弾かれ
原因が分かりにくかった。Gitea/GitHub の SSH ユーザーは常に git。

- REPO_RE を ssh://<user>@host/… / <user>@host:path / host:path も受理するよう緩和
  (// 始まりは拒否、ホスト allowlist は全形式に適用)
- URL 形式エラーで受理形式と「SSH ユーザーは常に git」を明記、
  ホスト不許可で許可済み一覧を併記
- UI のリポジトリ URL 入力欄にヒントを追加、README に URL 形式表を追加
This commit is contained in:
2026-09-09 11:41:41 +09:00
parent 1b74e230ad
commit 6514747b4e
5 changed files with 73 additions and 8 deletions
+16 -7
View File
@@ -105,12 +105,19 @@ ANN_PREFIX = "claude-code.cafepieters.com/"
SESSION_SELECTOR = LABEL_COMPONENT + "=session," + LABEL_APP + "=claude-code"
SID_RE = re.compile(r"^[a-f0-9]{10}$")
# 受け入れる repo URL: https://host/... または ssh://git@host/... または git@host:path
# 受け入れる repo URL:
# https://host[:port]/path
# ssh://[user@]host[:port]/path
# [user@]host:path (SCP 形式。Gitea/GitHub の SSH ユーザーは常に "git")
_USER = r"(?:[A-Za-z0-9_.\-]+@)?"
REPO_RE = re.compile(
r"^(?:https://(?P<h1>[A-Za-z0-9.\-]+)(?::\d+)?/[\w./\-~%]+"
r"|ssh://git@(?P<h2>[A-Za-z0-9.\-]+)(?::\d+)?/[\w./\-~%]+"
r"|git@(?P<h3>[A-Za-z0-9.\-]+):[\w./\-~%]+)$"
r"|ssh://" + _USER + r"(?P<h2>[A-Za-z0-9.\-]+)(?::\d+)?/[\w./\-~%]+"
r"|" + _USER + r"(?P<h3>[A-Za-z0-9.\-]+):(?!//)[\w./\-~%]+)$"
)
REPO_HELP = ("URL の形式: https://<host>/<org>/<repo>.git / "
"ssh://git@<host>/<org>/<repo>.git / git@<host>:<org>/<repo>.git "
"(Gitea・GitHub の SSH ユーザーは常に 'git'。あなたのアカウント名ではありません)")
REF_RE = re.compile(r"^[\w./\-]{1,200}$")
# --------------------------------------------------------------------------
@@ -411,12 +418,13 @@ def create_session(repo, ref, identity_name, owner):
repo = (repo or "").strip()
ref = (ref or "main").strip()
if not REPO_RE.match(repo):
return None, "リポジトリ URL の形式が不正です"
return None, "リポジトリ URL の形式が不正です。" + REPO_HELP
if not REF_RE.match(ref):
return None, "ref の形式が不正です"
return None, "ref(ブランチ / タグ)の形式が不正です"
host = repo_host(repo)
if not GIT_ALLOW_ARBITRARY and host not in GIT_ALLOWED_HOSTS:
return None, "許可されていない Git ホストです: " + str(host)
return None, ("許可されていない Git ホストです: %s(許可済み: %s)"
% (host, ", ".join(GIT_ALLOWED_HOSTS) or "なし"))
if identity_name and identity_name not in GIT_IDENTITIES:
return None, "未知の git identity: " + identity_name
if active_session_count() >= MAX_SESSIONS:
@@ -570,7 +578,8 @@ pre#logbox{white-space:pre-wrap;background:#111;color:#eee;padding:.8rem;border-
<div id="app" hidden>
<form onsubmit="return doCreate(event)">
<label for="repo">リポジトリ URL</label>
<input id="repo" placeholder="https://github.com/owner/repo.git または git@host:owner/repo.git" required>
<input id="repo" placeholder="https://host/org/repo.git または git@host:org/repo.git(SSH ユーザーは常に git)" required>
<div class="muted">SSH は <code>git@&lt;host&gt;:&lt;org&gt;/&lt;repo&gt;.git</code>(ユーザー名は自分のアカウントではなく必ず <code>git</code>)。認証は下で選ぶ identity の鍵で行われます。</div>
<div class="row">
<div style="flex:1"><label for="ref">ブランチ / タグ</label><input id="ref" value="main"></div>
<div style="flex:1"><label for="ident">認証 identity</label><select id="ident"></select></div>