Skip to content

Fix failing symlink tests#130342

Open
alinpahontu2912 wants to merge 1 commit into
dotnet:release/8.0-stagingfrom
alinpahontu2912:tar_fix_8
Open

Fix failing symlink tests#130342
alinpahontu2912 wants to merge 1 commit into
dotnet:release/8.0-stagingfrom
alinpahontu2912:tar_fix_8

Conversation

@alinpahontu2912

Copy link
Copy Markdown
Member

No description provided.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-formats-tar
See info in area-owners.md if you want to be subscribed.

Copilot AI 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.

Pull request overview

This PR re-enables previously skipped symlink-related TarFile.ExtractToDirectory tests and updates tar extraction path validation to better detect directory traversal via symlinks created by earlier archive entries.

Changes:

  • Removed ActiveIssue skips for symlink traversal tests so they run again on macOS (and Windows for the chained traversal test).
  • Updated TarEntry.FilePathEscapesDirectory to compute a logical relative path first and to resolve symlinks during component-by-component traversal (including dangling links).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.File.Tests.cs Re-enables symlink traversal tests by removing ActiveIssue skips.
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs Adjusts path-escape detection logic to better account for symlink resolution during extraction.

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

Comment on lines 419 to 421
// Walk relative components, resolving symlinks at each step
string relative = normalizedFile.Substring(resolvedDest.Length)
string relative = normalizedFile.Substring(logicalPrefix.Length)
.TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
[Theory]
[InlineData(true)]
[InlineData(false)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/129227", TestPlatforms.OSX)]

@svick svick Jul 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are still several tests with this ActiveIssue, in this file and several others. These should be re-enabled as well.

I think the same applies to the other branches as well, but I didn't check those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants