Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(server): strip credentials from the repo url in repo responses (#3346)
Raghav Chamadiya0c40a4b02fac
diff --git a/packages/server/src/repowise/server/schemas/repository.py b/packages/server/src/repowise/server/schemas/repository.pyindex f78a9721f..44981d6b6 100644--- a/packages/server/src/repowise/server/schemas/repository.py+++ b/packages/server/src/repowise/server/schemas/repository.py@@ -136,7 +136,7 @@ class RepoResponse(BaseModel):return cls(id=obj.id, # type: ignore[attr-defined]name=obj.name, # type: ignore[attr-defined]- url=obj.url, # type: ignore[attr-defined]+ url=strip_credentials(obj.url) or "", # type: ignore[attr-defined]local_path=local_path,default_branch=obj.default_branch, # type: ignore[attr-defined]head_commit=obj.head_commit, # type: ignore[attr-defined]diff --git a/tests/unit/server/test_overview_remote_url.py b/tests/unit/server/test_overview_remote_url.pyindex bee1b9cc3..552743f6f 100644--- a/tests/unit/server/test_overview_remote_url.py+++ b/tests/unit/server/test_overview_remote_url.py@@ -11,11 +11,14 @@ load, and a malformed git config is not a reason to fail the Overview.from __future__ import annotations+from datetime import UTC, datetimefrom pathlib import Path+from types import SimpleNamespaceimport pytestfrom repowise.server.routers.overview import _remote_url+from repowise.server.schemas.repository import RepoResponse_ORIGIN = "https://github.com/repowise-dev/repowise.git"@@ -126,3 +129,19 @@ def test_credentials_never_reach_the_ui(tmp_path: Path, remote: str, expected: s_write_config(tmp_path / ".git", f'[remote "origin"]\n\turl = {remote}\n')assert _remote_url("", str(tmp_path)) == expected++def test_repo_response_url_is_stripped(tmp_path: Path) -> None:+ """The repo list and detail echo the stored URL, which a client may have sent with a token."""+ now = datetime.now(UTC)+ row = SimpleNamespace(+ id="r1",+ name="p",+ url="https://user:[email protected]/g/p.git",+ local_path=str(tmp_path),+ default_branch="main",+ head_commit=None,+ settings_json="{}",+ created_at=now,+ updated_at=now,+ )+ assert RepoResponse.from_orm(row).url == "https://gitlab.com/g/p.git"