Skip to content

[9.4.0] Materialize stripped Git repository contents (#30321) - #32981

Closed
deepalak56 wants to merge 1 commit into
bazelbuild:release-9.4.0from
deepalak56:cp30321-940
Closed

deepalak56 wants to merge 1 commit into
bazelbuild:release-9.4.0from
deepalak56:cp30321-940

Conversation

@deepalak56

Copy link
Copy Markdown
Contributor

git_repository keeps a complete checkout under .tmp_git_root and
symlinks the selected strip_prefix entries into the repository root.
Recursive package discovery can then see discarded sibling packages,
and traversal or an escaping directory symlink can expose data outside
the checkout.

Complete Git operations before stripping, reject paths that escape the
checkout or resolve into Git metadata, and move only the selected
subtree into place. Remove discarded entries and .git, preserve
add_prefix and patch behavior, and cover recursive queries, collisions,
and escape cases.

Fixes #26628.

— Description updated by Codex, on Tamir’s behalf.

git_repository keeps a complete checkout under .tmp_git_root and
symlinks the selected strip_prefix entries into the repository root.
Recursive package discovery can then see discarded sibling packages,
and traversal or an escaping directory symlink can expose data outside
the checkout.

Complete Git operations before stripping, reject paths that escape the
checkout or resolve into Git metadata, and move only the selected
subtree into place. Remove discarded entries and .git, preserve
add_prefix and patch behavior, and cover recursive queries, collisions,
and escape cases.

Fixes bazelbuild#26628.

— Description updated by Codex, on Tamir’s behalf.

Closes bazelbuild#30321

COPYBARA_INTEGRATE_REVIEW=bazelbuild#30321 from tamird:tamird/fix-git-strip-prefix e4df189
PiperOrigin-RevId: 978535521
Change-Id: I6937876c24f417901bcce9f42a0600fe391b0651
@deepalak56
deepalak56 requested a review from a team as a code owner November 27, 2026 08:45
@deepalak56 deepalak56 added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website awaiting-review PR is awaiting review from an assigned reviewer labels Nov 27, 2026
@deepalak56
deepalak56 requested a review from kotlaja November 27, 2026 08:45
@deepalak56

Copy link
Copy Markdown
Contributor Author

Manual cherry-pick of commit d4e306a (#30321) onto release-9.4.0 for tracker #32323.

Conflict resolution:

  • tools/build_defs/repo/git.bzl: the upstream change builds on add_prefix (Add add_prefix attribute to git_repository #29453), which is not on 9.4.0. Used the repository root (ctx.path(".")) as the checkout path in place of master's _checkout_path(ctx) helper, and deleted .git from the root. The strip/validation logic is otherwise unchanged. repository_ctx.rename and path.realpath/is_dir, which it relies on, already exist on 9.4.0.
  • src/test/shell/bazel/starlark_git_repository_test.sh: kept the new strip_prefix_root, strip_prefix_query and strip_prefix_errors tests. Dropped test_git_repository_add_and_strip_prefix, which needs add_prefix.

Verified locally: bazel test //src/test/shell/bazel:starlark_git_repository_test passed.

@deepalak56 deepalak56 closed this Nov 30, 2026
@github-actions github-actions Bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants