Skip to content
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