You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mask tar header file modes during extraction - #369
Some bundle tar headers include Unix file-type bits in Mode (for example, 0100644). Passing those bits directly to os.Root.OpenFile can fail with “unsupported file mode.”
Mask the tar mode with os.ModePerm before opening the extracted file. Add a regression test that extracts a regular tar entry with file-type bits and verifies its contents.
Summary by CodeRabbit
Bug Fixes
Improved OCI archive extraction for files with standard archive metadata. Extracted files now retain their expected contents, with permissions applied only from the permission bits rather than other file metadata. This helps prevent file type information in an archive from interfering with extraction.
No actionable comments were generated in the recent review.
Walkthrough
Regular files extracted from tar archives are now created with permission bits from the header. A test covers extraction of an entry whose mode includes file-type bits.
This change lets tar layers whose headers include file-type bits in the mode extract successfully, and regular files are created with permission bits only. A regression test covers the case. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "Mask tar header file modes during extraction" matches the main change. The raw summary says tar extraction now masks regular-file modes with os.ModePerm before creating files, and a regress…
Linked Issues check
[#332] The issue requires that extractTarToDir mask tar header mode bits with os.ModePerm before calling root.OpenFile, so file-type bits such as 0100644 do not cause an "unsupported file mode…
Out of Scope Changes check
The changes stay within #332. The production change is one expression in the regular-file open call. The added test exercises that exact path. The whole-PR diff of ocihelper_test.go shows a new file…
Full details: Title check
Explanation
The title "Mask tar header file modes during extraction" matches the main change. The raw summary says tar extraction now masks regular-file modes with os.ModePerm before creating files, and a regression test was added. The PR objectives describe the same fix for issue #332, where tar header file-type bits caused Root.OpenFile to reject the mode.
Full details: Linked Issues check
Explanation
[#332] The issue requires that extractTarToDir mask tar header mode bits with os.ModePerm before calling root.OpenFile, so file-type bits such as 0100644 do not cause an "unsupported file mode" error. At the current head (f4aed2f), internal/ocihelper/ocihelper.go in the tar.TypeReg branch calls root.OpenFile(entryName, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.FileMode(header.Mode)&os.ModePerm). This matches the fix that the issue specifies. The new test TestExtractTarToDirMasksFileTypeBits in internal/ocihelper/ocihelper_test.go builds a tar entry crd.yaml with Mode: 0o100644, calls extractTarToDir, and verifies the extracted contents. Without the mask, the open call fails, so the test covers the reported failure. The whole-PR text diff for ocihelper.go was unavailable (changed blobs missing from checkout). The base version was therefore not compared line by line. The head file read and the PR summary together establish the change. The changes since the previous review are not visible in the current evidence, so the earlier conclusion is preserved on the current head file.
Full details: Out of Scope Changes check
Explanation
The changes stay within #332. The production change is one expression in the regular-file open call. The added test exercises that exact path. The whole-PR diff of ocihelper_test.go shows a new file with 40 added lines and no other edits. The directory, symlink, and default branches of extractTarToDir are unchanged in the reviewed head evidence. The ocihelper.go whole-PR diff was unavailable, so the claim that no other production lines changed rests on the PR summary (+1/-1), not on a direct diff read.
Reviewing files that changed from the base of the PR and between 5c2adb5 and f4aed2f.
Files selected for processing: 1
internal/ocihelper/ocihelper_test.go
Files skipped from review as they are similar to previous changes: 1
internal/ocihelper/ocihelper_test.go
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #332
Some bundle tar headers include Unix file-type bits in
Mode(for example,0100644). Passing those bits directly toos.Root.OpenFilecan fail with “unsupported file mode.”Mask the tar mode with
os.ModePermbefore opening the extracted file. Add a regression test that extracts a regular tar entry with file-type bits and verifies its contents.Summary by CodeRabbit