Introduce git.GitRunner as the sole git-op seam: the only place git is invoked. It owns subprocess execution, per-op timeout, error redaction, and auth delivery. Forge tokens move off the remote URL entirely onto a non-persisted per-op http.<host>.extraHeader, so they never reach the command line, a remote URL, or .git/config. Rewrite the mirror procedure to drive GitRunner and retire the URL-token helpers (_authed/_bare/_redact/_scrub_remote_tokens) plus the try/finally scrub -- their reason to exist vanishes. mirror_repo's signature and report stay unchanged; cli/migrate import the re-exported GitError/timeout unchanged. The procedure's ordering invariants are now locked by a recording-fake test, and an AST guard fails the suite if any git op bypasses the seam. Closes the 2026-08-11 audit's HIGH (token in GitError) and MEDIUM (token in .git/config) at one structural root cause. Closes #1
This commit is contained in:
1 parent
137734673d
commit
1613ec72b8
10 files changed
+669
-223
No files matched your search
+2
-1
@@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. The format
|
||||
|
||||
### security
|
||||
|
||||
- **migrator:** keep forge API tokens out of error text and on-disk git config. Git failures now surface a redacted `oauth2:***@` URL instead of the live token, and the CLI catches `GitError` with a clean message instead of dumping a traceback. The mirror's remote URLs are scrubbed to bare form after each run (no token persisted in `.git/config`), and the default workdir is per-user `0700` (`/tmp/cb2gitea-<uid>`) so it isn't world-readable on shared hosts.
|
||||
- **migrator:** keep forge API tokens out of error text, the command line, and on-disk git config. Git auth is delivered through a single `git.GitRunner` seam as a non-persisted per-op `http.<host>.extraHeader` (`Authorization: token <T>`), so the token never enters a remote URL or `.git/config`; failures raise a redacted `GitError` (known-secret + `oauth2:` fallback) and the CLI catches it cleanly. The default workdir stays per-user `0700`. Closes the 2026-08-11 audit's HIGH (token in error text) and MEDIUM (token in git config) at one structural root cause.
|
||||
- **deps:** reproducible, hash-verified installs — commit `uv.lock` and install from it in CI (`uv sync --frozen`); pin Gitea Actions to commit SHAs instead of mutable `@vN` tags; pin the ruff rule set explicitly (`select = ["E4","E7","E9","F"]`) and exclude `audit/`.
|
||||
|
||||
### perf
|
||||
@@ -27,6 +27,7 @@ All notable changes to this project will be documented in this file. The format
|
||||
### refactor
|
||||
|
||||
- **cli:** drop the `typer` dependency; the CLI now uses stdlib `argparse` (same `migrate`/`version` subcommands, flags, and `CODEBERG_TOKEN`/`GITEA_TOKEN` env vars). Removes `typer` and its transitive `rich`/`shellingham` from the install (3 fewer packages).
|
||||
- **migrator:** introduce `git.GitRunner` as the sole git-op seam — the only place git is invoked. The mirror procedure (`mirror.py`) is rewritten to drive it (`run`/`capture`/`ok` verbs; `Forge` value type for per-op auth), retiring the URL-tokenization, token-stripping, and on-exit config-scrub helpers (their reason to exist vanishes). The procedure's ordering invariants (pull-head capture → prune → mirror push → deleted-branch PR-head restore → LFS) are now locked by a recording-fake test; an AST guard fails the suite if any git op bypasses the seam.
|
||||
- **migrator:** remove dead code surfaced by a whole-repo over-engineering audit — `has_lfs`/`LFS_MARKERS` (uncalled), the `name_map` return of `migrate_labels` (sole caller discarded it), the unused `owner_repo` rewrite param, and a stored-but-unread `_base_url`.
|
||||
|
||||
### feat
|
||||
|
||||
Reference in new issue
Block a user