Skip to content

Commit 0ef07ef

Browse files
committed
fix(ci): replaced GitPython pin with a compat shim
Follow-up to 5107894, which unblocked the release job by pinning GitPython below 3.1.60. The pin works, but it holds every consuming repository's release job on GitPython 3.1.59 for as long as python-semantic-release takes to ship #1477 -- and 3.1.59 carries two open advisories that 3.1.60 fixes: GHSA-g5vv-9gxw-82hx (high, ReDoS in commit author/committer parsing) and GHSA-whh4-5q6c-9v3x (medium). GitPython therefore stays current and only the removed attribute is restored. This is security-preferable rather than merely equivalent: Actor._from_string no longer uses the regex, so untrusted commit data keeps the hardened parser, and PSR applies the restored attribute solely to the configured author string from pyproject.toml or the environment. The shim is written to $RUNNER_TEMP and loaded through PYTHONPATH scoped to the semantic-release invocation, so it does not reach the package build or any other Python process in the job. Note for anyone reproducing this from the issue: the shim published there does not work. The attribute `git.util` resolves to git.index.util, not git.util, so `import git.util` patches the wrong module; its bare `except Exception: pass` then swallows the AttributeError and the shim silently does nothing. It has to be `from git.util import Actor`. An assertion in the install step now fails the run if the shim is ever ineffective, so that failure mode cannot reach the release step again. Verified against python-semantic-release 10.6.1 with GitPython 3.1.60: the release aborts without the shim and returns a version with it, the guard exits non-zero when the shim is bypassed, the attribute does not leak into unrelated interpreters, and Actor._from_string remains regex-free. actionlint 1.7.7 reports no findings; shellcheck is clean on the changed step. REMOVE THIS SHIM once a python-semantic-release release newer than 10.6.1 ships, containing python-semantic-release#1477. Refs: python-semantic-release/python-semantic-release#1476 Closes #79
1 parent 7bb5e8d commit 0ef07ef

1 file changed

Lines changed: 42 additions & 9 deletions

File tree

‎.github/workflows/python-semantic-release.yml‎

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,47 @@ jobs:
323323
- name: 📦 Install python-semantic-release and build tools
324324
run: |
325325
python -m pip install --upgrade pip
326-
# GitPython 3.1.60 (2026-08-25) removed Actor.name_email_regex, which
327-
# python-semantic-release 10.6.1 still calls while loading its config
328-
# (cli/config.py). Unpinned, every release run dies with
329-
# "type object 'Actor' has no attribute 'name_email_regex'".
330-
# PSR's fix is merged on main but unreleased -- REMOVE THIS PIN once a
331-
# release newer than 10.6.1 ships. Tracking:
332-
# https://github.com/python-semantic-release/python-semantic-release/issues/1476
333-
pip install python-semantic-release "GitPython<3.1.60" build
326+
pip install python-semantic-release build
327+
328+
# Compatibility shim: python-semantic-release 10.6.1 + GitPython >= 3.1.60
329+
#
330+
# GitPython 3.1.60 removed Actor.name_email_regex while fixing GHSA-g5vv-9gxw-82hx
331+
# (ReDoS in commit author/committer parsing). PSR 10.6.1 still reads that attribute
332+
# on every config load, so `semantic-release version` aborts before inspecting a
333+
# single commit with: type object 'Actor' has no attribute 'name_email_regex'
334+
#
335+
# We deliberately keep GitPython current rather than pinning back to 3.1.59:
336+
# Actor._from_string no longer uses the regex, so untrusted commit data stays on the
337+
# hardened code path. PSR applies it only to the configured (trusted) author string
338+
# from pyproject.toml or the environment.
339+
#
340+
# The shim is loaded via PYTHONPATH scoped to the semantic-release call only, so it
341+
# does not leak into the package build or any other Python process in this job.
342+
#
343+
# Upstream fix: python-semantic-release#1477 (open, unreleased as of 2026-08-26).
344+
# TODO: remove this shim once a PSR release containing #1477 is available.
345+
mkdir -p "$RUNNER_TEMP/psr-compat"
346+
cat > "$RUNNER_TEMP/psr-compat/sitecustomize.py" <<'PSR_COMPAT'
347+
import re
348+
349+
# NOTE: import via `from git.util import ...` -- the attribute `git.util` resolves to
350+
# git.index.util, so `import git.util` would silently patch the wrong module.
351+
try:
352+
from git.util import Actor
353+
except ImportError:
354+
pass
355+
else:
356+
if not hasattr(Actor, "name_email_regex"):
357+
Actor.name_email_regex = re.compile(r"(.*) <(.*?)>")
358+
PSR_COMPAT
359+
360+
# Fail loudly here rather than silently shipping an ineffective shim into the
361+
# release step (e.g. if a future GitPython moves Actor again).
362+
PYTHONPATH="$RUNNER_TEMP/psr-compat" python -c "
363+
from git import Actor
364+
assert Actor.name_email_regex.match('github-actions[bot] <[email protected]>')
365+
print('OK: Actor.name_email_regex available for python-semantic-release')
366+
"
334367
335368
# Install tomli for Python <3.11 compatibility (needed for pyproject.toml parsing)
336369
python -c "import sys; sys.exit(0 if sys.version_info >= (3,11) else 1)" || pip install tomli
@@ -372,7 +405,7 @@ jobs:
372405
fi
373406
374407
# Run semantic release (creates version, commit, tag, release, and builds packages)
375-
semantic-release --verbose version
408+
PYTHONPATH="$RUNNER_TEMP/psr-compat" semantic-release --verbose version
376409
377410
# Check if release was created and extract build information
378411
if git describe --exact-match --tags HEAD 2>/dev/null; then

0 commit comments

Comments
 (0)