Skip to content

fix(release): trust origin by its host, not by a substring of its URL - #50

Merged
maksimtech merged 1 commit into
mainfrom
fix/bump-version-origin-host
Oct 15, 2026
Merged

maksimtech merged 1 commit into
mainfrom
fix/bump-version-origin-host

Conversation

@maksimtech

Copy link
Copy Markdown
Owner

Why

scripts/bump_version.py opens the release PR with auto-merge only when origin is this repository on GitHub. _origin_is_github tested "github.com" in url and RELEASE_REPO in url, which any host that merely mentions github.com satisfies. CodeQL alert #60 (py/incomplete-url-substring-sanitization, high) flagged it, and Security Posture has been red on main since #48 landed.

What

  • _github_repo(url) splits the remote URL into host and path (urllib.parse.urlsplit, or the scp-like user@host:path form). The host must be exactly github.com, and the path must be the repository, whole.
  • _origin_is_github compares that owner/name with RELEASE_REPO.

Tests (TDD)

New cases in tests/test_release_through_pr.py run against a real clone whose origin is set with git remote set-url. Nothing is mocked, and git does not contact the URLs.

  • Before the fix: 7 of 13 failed. Six look-alike URLs were trusted, and https://GitHub.com/... was refused.
  • After the fix: all 13 pass, and the full suite passes (2089 passed, 4 skipped, Windows). ruff check src tests benchmarks scripts tools is clean.

🤖 Generated with Claude Code

bump_version.py opens the release pull request with auto-merge only when
origin is this repository on GitHub. It asked whether "github.com" and
"maksimtech/patchradar" occurred anywhere in the URL, so a host of anyone's
choosing passed (https://evil.example/github.com/maksimtech/patchradar), and
an upper-case host that is GitHub did not. CodeQL alert #60,
py/incomplete-url-substring-sanitization, high, has kept Security Posture red
on main since the change landed.

The URL is now split into host and path (urlsplit, or the scp-like
user@host:path form), the host must be github.com and the path must be the
repository, whole. The new cases run against a real clone whose origin is set
with `git remote set-url`; they failed 7 of 13 before the fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@codspeed

codspeed Bot commented Oct 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 11 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 17 untouched benchmarks


Comparing fix/bump-version-origin-host (92afc14) with main (2f685d7)

Open in CodSpeed

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@maksimtech
maksimtech merged commit 658965e into main Oct 15, 2026
25 checks passed
@maksimtech
maksimtech deleted the fix/bump-version-origin-host branch October 15, 2026 12:25
maksimtech added a commit that referenced this pull request Oct 15, 2026
The gate lists these entries as settled: their alerts are closed because the
scanners stopped reporting them, not because anything left the image.
`patchradar debian` on 2026-10-15 still reports gcc-14 no-dsa in trixie at
14.2.0-19 (fix only in sid, 14.4.0-3), so the flaws are still
present and only the reporting changed. The entries stay, and each now
records when the scanner fell silent and what Debian said, in the words the
CVE-2026-82560 entry already uses. Deleting a flaw that is demonstrably
present because a scanner fell silent is the one direction the file must
not drift in.

Checked, not inferred: a script read this repository's live open and closed
code-scanning alerts and listed every kept settled entry that did not say
why (4 before, 0 after), and tools/security_exceptions.py on the same
alerts still exits 1, only for CodeQL #60, which #50 fixes.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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