Skip to content

fix(git): reject scp-style embedded credentials and align clone timeout - #308

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
jeff-r2026:fix/generic-git-scp-credentials
Aug 24, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
jeff-r2026:fix/generic-git-scp-credentials

Conversation

@jeff-r2026

Copy link
Copy Markdown
Collaborator

Summary

Two follow-up fixes for the generic Git provider added in #301, found in code review.

1. scp-style URLs leaked embedded credentials (security)

parseGenericGitRepoInput rejected embedded credentials on the HTTPS/ssh:// path, but the scp-style branch (user@host:group/repo.git) returned the input verbatim. An input like oauth2:[email protected]:Enterprise/repo.git was preserved as-is and could be written back into teamai.yaml (repo:) / localConfig.remote, contradicting the no-credentials-in-URL guarantee that the HTTPS path and the redact util both promise.

A colon in the SSH user field is a credential (oauth2:token), never a real login, so we now reject it with the same message the HTTPS path uses. Normal git@host:group/repo.git logins are unaffected.

2. Clone timeout shorter than the shallow-clone path

cloneRepo hardcoded a 120s timeout, shorter than the 180s default used by the shallow-clone path in clone.ts. Large self-hosted repos over slow/VPN links could time out where the equivalent path would not. Aligned to 180s.

Test Plan

  • npx tsc --noEmit — no new type errors in changed files
  • npx vitest run src/__tests__/generic-git-provider.test.ts — 16/16 pass (added a scp-credential case; updated the timeout assertion)
  • npm run build — success; confirmed timeout: 18e4 (180000) compiled into the generic cloneRepo
  • Real CLI E2E: node dist/index.js init "oauth2:[email protected]:Enterprise/repo.git" → rejected with Do not embed credentials
  • Real CLI E2E: node dist/index.js init "[email protected]:..." → not rejected for credentials (normal scp login preserved)

🤖 Generated with Claude Code

Two follow-up fixes for the generic Git provider (Tencent#301):

- parseGenericGitRepoInput accepted scp-style URLs whose user field
  carried credentials (e.g. "oauth2:token@host:group/repo.git"),
  returning them verbatim while the HTTPS path already rejected embedded
  credentials. A colon in the SSH user field is a credential, never a
  real login, so reject it. Normal "git@host:..." logins are unaffected.
- Clone timeout was 120s, shorter than the 180s default used by the
  shallow-clone path in clone.ts. Large self-hosted repos over slow/VPN
  links could time out where the equivalent path would not. Align to 180s.

Co-Authored-By: Claude Fable 5 <[email protected]>
@jeff-r2026
jeff-r2026 merged commit 40180e5 into Tencent:main Aug 24, 2026
7 checks passed
@jeff-r2026
jeff-r2026 deleted the fix/generic-git-scp-credentials branch August 24, 2026 06:49
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…ut (Tencent#308)

Two follow-up fixes for the generic Git provider (Tencent#301):

- parseGenericGitRepoInput accepted scp-style URLs whose user field
  carried credentials (e.g. "oauth2:token@host:group/repo.git"),
  returning them verbatim while the HTTPS path already rejected embedded
  credentials. A colon in the SSH user field is a credential, never a
  real login, so reject it. Normal "git@host:..." logins are unaffected.
- Clone timeout was 120s, shorter than the 180s default used by the
  shallow-clone path in clone.ts. Large self-hosted repos over slow/VPN
  links could time out where the equivalent path would not. Align to 180s.

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant