Skip to content

Force rctx.{download_and,}extract to create user-readable files#28531

Closed
fmeum wants to merge 2 commits intobazelbuild:masterfrom
fmeum:extract-readable
Closed

Force rctx.{download_and,}extract to create user-readable files#28531
fmeum wants to merge 2 commits intobazelbuild:masterfrom
fmeum:extract-readable

Conversation

@fmeum
Copy link
Collaborator

@fmeum fmeum commented Feb 5, 2026

Archives in the wild do sometimes contain non-readable files, but other tools work around this and thus mask their brokenness.

Context: https://bazelbuild.slack.com/archives/CDCMRLS23/p1770213515354229

In the wild example: https://pypi.org/project/ag-ui-adk/#ag_ui_adk-0.4.2-py3-none-any.whl

@fmeum fmeum requested a review from Copilot February 5, 2026 09:11
@fmeum fmeum marked this pull request as ready for review February 5, 2026 09:11
@fmeum fmeum requested a review from meteorcloudy February 5, 2026 09:11
@fmeum
Copy link
Collaborator Author

fmeum commented Feb 5, 2026

@bazel-io fork 9.1.0

@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Feb 5, 2026
@fmeum
Copy link
Collaborator Author

fmeum commented Feb 5, 2026

@bazel-io fork 8.6.0

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly ensures that files extracted from archives are at least user-readable by adding the 0400 permission bit. The changes are consistently applied across ar, tar, and zip decompressors. The accompanying tests are thorough and validate the new behavior for each archive type. I've included one suggestion to refactor the new tests to reduce code duplication and improve maintainability.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures that files extracted from archives (tar, zip, and ar) are always user-readable, even if the archive contains files with no read permissions. This addresses a real-world issue where some archives contain non-readable files, but other tools work around this and mask the problem.

Changes:

  • Modified three decompressor implementations to force user-readable permissions (0400 bit) on extracted files
  • Added integration tests for tar.gz, zip, and ar archives with non-readable files

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/main/java/com/google/devtools/build/lib/bazel/repository/decompressor/ZipDecompressor.java Added bitwise OR with 0400 to ensure extracted files have user-read permission
src/main/java/com/google/devtools/build/lib/bazel/repository/decompressor/CompressedTarFunction.java Added bitwise OR with 0400 to ensure extracted tar files have user-read permission
src/main/java/com/google/devtools/build/lib/bazel/repository/decompressor/ArFunction.java Added bitwise OR with 0400 to ensure extracted ar files have user-read permission
src/test/shell/bazel/starlark_repository_test.sh Added three test functions that verify files with 0o000 permissions can be read after extraction

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Archives in the wild do sometimes contain non-readable files, but other tools work around this and thus mask their brokenness.
@fmeum fmeum requested a review from meteorcloudy February 5, 2026 10:42
@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Feb 5, 2026
@copybara-service copybara-service bot closed this in 0bb7836 Feb 5, 2026
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Feb 5, 2026
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Feb 5, 2026
…zelbuild#28531)

Archives in the wild do sometimes contain non-readable files, but other tools work around this and thus mask their brokenness.

Context: https://bazelbuild.slack.com/archives/CDCMRLS23/p1770213515354229

Closes bazelbuild#28531.

PiperOrigin-RevId: 865960367
Change-Id: I7273eb983d63d6960d184764cec5040bba77b2c2
iancha1992 pushed a commit to iancha1992/bazel that referenced this pull request Feb 5, 2026
…zelbuild#28531)

Archives in the wild do sometimes contain non-readable files, but other tools work around this and thus mask their brokenness.

Context: https://bazelbuild.slack.com/archives/CDCMRLS23/p1770213515354229

Closes bazelbuild#28531.

PiperOrigin-RevId: 865960367
Change-Id: I7273eb983d63d6960d184764cec5040bba77b2c2
github-merge-queue bot pushed a commit that referenced this pull request Feb 6, 2026
…iles (#28531) (#28547)

Archives in the wild do sometimes contain non-readable files, but other
tools work around this and thus mask their brokenness.

Context:
https://bazelbuild.slack.com/archives/CDCMRLS23/p1770213515354229

Closes #28531.

PiperOrigin-RevId: 865960367
Change-Id: I7273eb983d63d6960d184764cec5040bba77b2c2

Commit
0bb7836

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
github-merge-queue bot pushed a commit that referenced this pull request Feb 10, 2026
…iles (ht… (#28551)

…tps://github.com//pull/28531)

Archives in the wild do sometimes contain non-readable files, but other
tools work around this and thus mask their brokenness.

Context:
https://bazelbuild.slack.com/archives/CDCMRLS23/p1770213515354229

Closes #28531.

PiperOrigin-RevId: 865960367
Change-Id: I7273eb983d63d6960d184764cec5040bba77b2c2

Commit
0bb7836

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
@aignas aignas mentioned this pull request Feb 12, 2026
5 tasks
@fmeum
Copy link
Collaborator Author

fmeum commented Feb 12, 2026

@bazel-io fork 9.0.1

bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Feb 12, 2026
…zelbuild#28531)

Archives in the wild do sometimes contain non-readable files, but other tools work around this and thus mask their brokenness.

Context: https://bazelbuild.slack.com/archives/CDCMRLS23/p1770213515354229

Closes bazelbuild#28531.

PiperOrigin-RevId: 865960367
Change-Id: I7273eb983d63d6960d184764cec5040bba77b2c2
github-merge-queue bot pushed a commit that referenced this pull request Feb 16, 2026
…iles (#28531) (#28649)

Archives in the wild do sometimes contain non-readable files, but other
tools work around this and thus mask their brokenness.

Context:
https://bazelbuild.slack.com/archives/CDCMRLS23/p1770213515354229

Closes #28531.

PiperOrigin-RevId: 865960367
Change-Id: I7273eb983d63d6960d184764cec5040bba77b2c2

Commit
0bb7836

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants