Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use canoncial for staging and content #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ static void extractZip(ObjectMapper mapper, Path archivePath, Path stagingPath)
ZipEntry entry = zipStream.getNextEntry();
while (Objects.nonNull(entry)) {
final Path contentPath = stagingPath.resolve(entry.getName());
if (!contentPath.toFile().getAbsolutePath().startsWith(stagingPath.toAbsolutePath().toString())) {
final String contentCanonical = contentPath.toFile().getCanonicalPath();
final String stagingCanonical = stagingPath.toFile().getCanonicalPath();
if (!contentCanonical.startsWith(stagingCanonical)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember Urvashi facing an issue in windows tests , so we switched to absolute path. We should verify this works on windows before merging this in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@urvashijain18 has confirmed that this works for both Mac (host) and Windows (DUT), so I think we're good here.

LOGGER.warn("Archive attempted to write {} outside of {}, skipping",
contentPath.toFile().getAbsolutePath(), stagingPath.toAbsolutePath());
contentCanonical, stagingCanonical);
entry = zipStream.getNextEntry();
continue;
}
Expand Down