fix(security): mask forge tokens in logs and disk
CI / test (push) Canceled after 0s

Close two token-leak paths in the git mirror and harden the supply
chain per the OWASP audit (audit/2026-08-11/security-report.md).

Runtime fixes:
- mirror GitError masks the embedded oauth2:<token> in both the
  failing command line and git's stderr before raising; cli now
  catches GitError with a clean message instead of an uncaught
  traceback that printed the live token.
- Scrub token-bearing remote URLs from the bare config at the end
  of each run so tokens aren't persisted in .git/config.
- Default mirror workdir is per-user 0700 (/tmp/cb2gitea-<uid>),
  not a world-readable /tmp/cb2gitea.

Supply chain:
- Commit uv.lock; CI installs via uv sync --frozen (hash-verified).
- Pin Gitea Actions to commit SHAs, not mutable @vN tags.
- Pin the ruff rule set and exclude audit/ for reproducible linting.

Adds tests/test_mirror.py for the redaction helpers.
This commit is contained in:
AlexKucera committed 2026-08-11 11:48:32 +02:00
1 parent 7d26e2d4ca
commit 299c061f26
10 files changed
+633 -11

No files matched your search

+9 -6
View File
@@ -9,11 +9,14 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
# Pinned to commit SHAs (not mutable tags) to guard against tag-swap supply-chain attacks.
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.11"
- run: python -m pip install -e ".[dev]"
- run: ruff check .
- run: ruff format --check .
- run: pytest
# Install deps from the committed, hash-verified uv.lock (reproducible builds).
- run: python -m pip install uv
- run: uv sync --frozen --extra dev
- run: uv run ruff check .
- run: uv run ruff format --check .
- run: uv run pytest