Skip to content

Validate allowed git schemes more carefully. - #31147

Open
kayliespace wants to merge 1 commit into
bazelbuild:masterfrom
kayliespace:kaylie-09-15-2026-validate-git-repo-spec-uris
Open

kayliespace wants to merge 1 commit into
bazelbuild:masterfrom
kayliespace:kaylie-09-15-2026-validate-git-repo-spec-uris

Conversation

@kayliespace

@kayliespace kayliespace commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Description

Per a comment in #31129, but I noticed that none of the other allowed schemes are validated either.
This corrects that and validates all schemes.

Stacked on #31129

Motivation

The current git_repository validation attempts to be more strict about allowed/disallowed hosts but does so using simple prefix comparison, PR review suggests this is probably undesirable, so this introduces proper validation.

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES[INC]: Bazel now validates that git repository entries in a bazel registry have correctly formed remote URIs, and rejects malformed URIs.

@kayliespace
kayliespace force-pushed the kaylie-09-15-2026-validate-git-repo-spec-uris branch 2 times, most recently from f07e712 to 714227c Compare September 15, 2026 21:16
new GitSchemeEntry("https", "https://", IndexRegistry::validateUriGitRepoSpec),
new GitSchemeEntry("ssh", "ssh://", IndexRegistry::validateUriGitRepoSpec),
new GitSchemeEntry("git", "git://", IndexRegistry::validateUriGitRepoSpec),
new GitSchemeEntry("file", "file://", IndexRegistry::validateFileUriGitRepoSpec),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remark: This was intentionally loosened, because //src/test/py/bazel:bazel_module_test expects a file URI like file://c:/... to be valid on windows.

This is, however, not ever considered valid by Java and Java is correct (the correct form is either file:///c:/ or file://localhost/c:/.)

Uncertain if making this more restrictive is actually desired or not.

@bazel-docs-pr-commenter

bazel-docs-pr-commenter Bot commented Sep 15, 2026

Copy link
Copy Markdown

✅ Bazel docs preview is ready!

Updated pages

Preview URL: https://bazel-pr-31147.mintlify.app/

Updated for 91bc1474cdbb33bc1c2416383b081c7618bb66d2

@kayliespace
kayliespace force-pushed the kaylie-09-15-2026-validate-git-repo-spec-uris branch 4 times, most recently from c3f72c3 to 942260d Compare September 16, 2026 23:03
Per a comment in bazelbuild#31129, but I noticed that none of the other allowed schemes are validated either.
This corrects that and validates all schemes.

Xona-Autoformatter-Enabled: 0
@kayliespace
kayliespace force-pushed the kaylie-09-15-2026-validate-git-repo-spec-uris branch from 942260d to 91bc147 Compare September 17, 2026 17:17
@kayliespace
kayliespace marked this pull request as ready for review September 17, 2026 17:17
@kayliespace

Copy link
Copy Markdown
Contributor Author

Ready for review.

@github-actions github-actions Bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. area-Bzlmod Bzlmod-specific PRs, issues, and feature requests awaiting-review PR is awaiting review from an assigned reviewer labels Sep 17, 2026

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

area-Bzlmod Bzlmod-specific PRs, issues, and feature requests awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants