Skip to content

fix(vcs): quote Mercurial branch names as revsets - #23219

Open
nijel wants to merge 2 commits into
mainfrom
review/oss-next-ge21v5v5
Open

nijel wants to merge 2 commits into
mainfrom
review/oss-next-ge21v5v5

Conversation

@nijel

@nijel nijel commented Nov 29, 2026

Copy link
Copy Markdown
Member

Treat branch names as literals and reject remote URL fragments that Mercurial would evaluate as revisions. Strip response bodies from redirected repository errors.

Discovered by Anthropic’s OSS Scanner, as vulnerability ANT-2026-GE21V5V5.

@nijel nijel added this to the 2026.12 milestone Nov 29, 2026
@nijel nijel self-assigned this Nov 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T18:56:44.162780Z b84406e New commits
🔒 Security Review ✅ Completed 2026-11-29T18:46:25.840106Z a04b91a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="weblate/vcs/mercurial.py">

<violation number="1" location="weblate/vcs/mercurial.py:100">
P1: `validate_remote_url` still lets `local:` and `weblate://...` reach Mercurial because the base validator treats those schemes as internal sentinels. Reject these values before calling `super()` so `clone_from` cannot pass them to `hg clone` for path or scheme interpretation.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread weblate/vcs/mercurial.py Outdated
# Mercurial treats URL fragments as revisions and evaluates revsets.
if "#" in url:
raise RepositoryValidationError(0, "repository_url_invalid")
return super().validate_remote_url(url)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: validate_remote_url still lets local: and weblate://... reach Mercurial because the base validator treats those schemes as internal sentinels. Reject these values before calling super() so clone_from cannot pass them to hg clone for path or scheme interpretation.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At weblate/vcs/mercurial.py, line 100:

<comment>`validate_remote_url` still lets `local:` and `weblate://...` reach Mercurial because the base validator treats those schemes as internal sentinels. Reject these values before calling `super()` so `clone_from` cannot pass them to `hg clone` for path or scheme interpretation.</comment>

<file context>
@@ -84,11 +85,20 @@ class HgRepository(Repository):
+        # Mercurial treats URL fragments as revisions and evaluates revsets.
+        if "#" in url:
+            raise RepositoryValidationError(0, "repository_url_invalid")
+        return super().validate_remote_url(url)
+
     def is_valid(self) -> bool:
</file context>
Suggested change
return super().validate_remote_url(url)
if url.startswith(("local:", "weblate://")):
raise RepositoryValidationError(0, "repository_url_invalid")
return super().validate_remote_url(url)

Treat branch names as literals and reject remote URL fragments that Mercurial would evaluate as revisions. Strip response bodies from redirected repository errors.

Discovered by Anthropic’s OSS Scanner, as vulnerability ANT-2026-GE21V5V5.
Keep the merged local-path scheme guard while rejecting revset fragments in the same runtime validator. Move the changelog entry below the shared insertion point.

Discovered by Anthropic’s OSS Scanner, as vulnerability ANT-2026-GE21V5V5.
@nijel
nijel force-pushed the review/oss-next-ge21v5v5 branch from a04b91a to b84406e Compare November 29, 2026 18:54
@nijel
nijel enabled auto-merge (squash) November 29, 2026 20:44

This branch has not been deployed

No deployments
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