-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardize the filename of Archive Entries so path traversal charact…
…ers cannot be used to manipulate file output location
- Loading branch information
1 parent
88cf773
commit 40f5fa8
Showing
5 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// ZZPathTraversalUnzipTests.h | ||
// ZipZapTests | ||
// | ||
// Created by Ethan Arbuckle on 5/31/18. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
@interface ZZPathTraversalUnzipTests : XCTestCase | ||
|
||
@end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// ZZPathTraversalUnzipTests.m | ||
// ZipZapTests | ||
// | ||
// Created by Ethan Arbuckle on 5/31/18. | ||
// | ||
|
||
#import "ZZPathTraversalUnzipTests.h" | ||
#import <ZipZap/ZipZap.h> | ||
|
||
@implementation ZZPathTraversalUnzipTests | ||
|
||
- (void)testExtractingZipContainingPathTraversalEntries | ||
{ | ||
// This zip archive contains a file titled '../../../../../../../../../../..//tmp/test.txt'. ZipZap should ignore the path traversing and write the file to "tmp/test.txt" | ||
ZZArchive* zipFile = [ZZArchive archiveWithURL:[[NSBundle bundleForClass:self.class] URLForResource:@"path-traversal" withExtension:@"zip"] error:nil]; | ||
|
||
for (NSUInteger index = 0, count = zipFile.entries.count; index < count; ++index) | ||
{ | ||
ZZArchiveEntry* nextEntry = zipFile.entries[index]; | ||
|
||
// Assert that the entry does not begin with '..' | ||
XCTAssertFalse([[[nextEntry fileName] substringToIndex:2] isEqualToString:@".."]); | ||
} | ||
} | ||
|
||
@end |
Binary file not shown.