diff options
author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-09-15 06:05:01 (GMT) |
---|---|---|
committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-09-15 06:05:01 (GMT) |
commit | 53287645760f083e2fbaf93ea73ec0f1992ca67d (patch) | |
tree | 0ab775f71c57be56b6378c20f3ff60016dd6de91 | |
parent | 748f1c39e564df9766e43843cc48167342d39dc2 (diff) | |
download | tcl-53287645760f083e2fbaf93ea73ec0f1992ca67d.zip tcl-53287645760f083e2fbaf93ea73ec0f1992ca67d.tar.gz tcl-53287645760f083e2fbaf93ea73ec0f1992ca67d.tar.bz2 |
zipfs password tests
-rw-r--r-- | doc/zipfs.n | 12 | ||||
-rw-r--r-- | tests/zipfiles/README | 2 | ||||
-rw-r--r-- | tests/zipfs.test | 46 |
3 files changed, 48 insertions, 12 deletions
diff --git a/doc/zipfs.n b/doc/zipfs.n index b59e072..247cac2 100644 --- a/doc/zipfs.n +++ b/doc/zipfs.n @@ -35,11 +35,14 @@ zipfs \- Mount and work with ZIP files within Tcl .BE .SH DESCRIPTION .PP -The \fBzipfs\fR command (the sole public command provided by the built-in -package with the same name) provides Tcl with the ability to mount the -contents of a ZIP archive file as a virtual file system. ZIP archives support +The \fBzipfs\fR command provides Tcl with the ability to mount the +contents of a ZIP archive file as a virtual file system. Tcl's ZIP +archive support is limited to basic features and options. +Supported storage methods include only STORE and DEFLATE with optional simple encryption, sufficient to prevent casual inspection of their contents but not able to prevent access by even a moderately determined attacker. +Strong encryption, multi-part archives, platform metadata, +zip64 formats and other compression methods like bzip2 are not supported. .TP \fBzipfs canonical\fR ?\fImountpoint\fR? \fIfilename\fR ?\fIinZipfs\fR? . @@ -125,7 +128,8 @@ to access the files inside the mount). Returns a constant string which indicates the mount point for zipfs volumes for the current platform. This value is -.QW \fB//zipfs:/\fR . +.QW \fB//zipfs:/\fR +on most platforms. .TP \fBzipfs unmount \fImountpoint\fR . diff --git a/tests/zipfiles/README b/tests/zipfiles/README index e6c366e..38ce998 100644 --- a/tests/zipfiles/README +++ b/tests/zipfiles/README @@ -1,7 +1,7 @@ The files in this directory are used for testing zipfs file systems. They fall under the following licenses: -test-overlay.zip, test-zip-in-zip.zip - Tcl's license +test-overlay.zip, test-password.zip, test-zip-in-zip.zip - Tcl's license All other files - test files from libzip (https://libzip.org) and are covered by the license in LICENSE-libzip.
\ No newline at end of file diff --git a/tests/zipfs.test b/tests/zipfs.test index 44228c7..4edb629 100644 --- a/tests/zipfs.test +++ b/tests/zipfs.test @@ -665,7 +665,7 @@ namespace eval test_ns_zipfs { mount [zippath test.zip] set newmount [file join [zipfs root] test testdir] mount [zippath test-overlay.zip] $newmount - } -constraints knownBug -cleanup { + } -constraints bug-4ae42446ab -cleanup { cleanup } -body { # KNOWN BUG. The test2 file is also present in parent mount. @@ -712,7 +712,7 @@ namespace eval test_ns_zipfs { # Some tests have !zipfslib constraint because otherwise they dump the entire Tcl library which is mounted on root testzipfslist no-mounts "" {} {} -constraints !zipfslib testzipfslist no-pattern "" {test.zip testmountA} {testmountA testmountA/test testmountA/testdir testmountA/testdir/test2} -constraints !zipfslib - testzipfslist no-pattern-mount-on-root "" {test.zip {}} {{} test testdir testdir/test2} -constraints knownBug + testzipfslist no-pattern-mount-on-root "" {test.zip {}} {{} test testdir testdir/test2} -constraints bug-d056ee6d30 testzipfslist no-pattern-multiple "" {test.zip testmountA test.zip testmountB/subdir} { testmountA testmountA/test testmountA/testdir testmountA/testdir/test2 testmountB/subdir testmountB/subdir/test testmountB/subdir/testdir testmountB/subdir/testdir/test2 @@ -749,7 +749,7 @@ namespace eval test_ns_zipfs { testzipfsexists file [file join $defaultMountPoint test] 1 testzipfsexists dir [file join $defaultMountPoint testdir] 1 testzipfsexists mountpoint $defaultMountPoint 1 - testzipfsexists root [zipfs root] 1 -constraints knownBug + testzipfsexists root [zipfs root] 1 -constraints bug-02acab5aea # # zipfs find @@ -838,7 +838,7 @@ namespace eval test_ns_zipfs { test.zip {} test.zip testmountB/subdir } [lmap path { test testdir testdir/test2 - } {file join [zipfs root] $path}] -constraints knownBug + } {file join [zipfs root] $path}] -constraints bug-6183f535c8 # # zipfs info @@ -928,7 +928,7 @@ namespace eval test_ns_zipfs { set zippath [zippath $zippath] test zipfs-uncompress-$id $id -setup { unset -nocomplain fd - mount $zippath + zipfs mount $zippath $defaultMountPoint } -cleanup { # In case mount succeeded when it should not if {[info exists fd]} { @@ -947,6 +947,38 @@ namespace eval test_ns_zipfs { testuncompress xz testfile-xz.zip {unsupported compression method} -returnCodes error testuncompress zstd testfile-zstd.zip {unsupported compression method} -returnCodes error + proc testpassword {id filename password result args} { + variable defaultMountPoint + set zippath [zippath test-password.zip] + test zipfs-password-read-$id $id -setup { + unset -nocomplain fd + if {$password ne ""} { + zipfs mount $zippath $defaultMountPoint $password + } else { + zipfs mount $zippath $defaultMountPoint + } + } -cleanup { + # In case mount succeeded when it should not + if {[info exists fd]} { + close $fd + } + cleanup + } -body { + set fd [open [file join $defaultMountPoint $filename]] + gets $fd + } -result $result {*}$args + } + testpassword plain plain.txt password plaintext + testpassword plain-nopassword plain.txt "" plaintext + testpassword plain-badpassword plain.txt xxx plaintext + testpassword cipher cipher.bin password ciphertext + testpassword cipher-nopassword cipher.bin {} "decryption failed" -returnCodes error + testpassword cipher-badpassword cipher.bin xxx "decryption failed" -returnCodes error -constraints bug-b3c7429255 + testpassword cipher-deflate cipher-deflate.bin password [lseq 100] + testpassword cipher-deflate-nopassword cipher-deflate.bin {} "decryption failed" -returnCodes error + testpassword cipher-deflate-badpassword cipher-deflate.bin xxx "decryption failed" -returnCodes error bug-b3c7429255 + + # # file stat proc fixupstat {stat} { @@ -992,14 +1024,14 @@ namespace eval test_ns_zipfs { test zipfs-file-stat-root-subdir-mount "Read stat of root when mount is subdir" -setup { mount [zippath test.zip] - } -cleanup cleanup -constraints knownBug -body { + } -cleanup cleanup -constraints bug-02acab5aea -body { lsort -stride 2 [file stat [zipfs root]] } -result [fixupstat {atime 0 ctime 0 dev 0 gid 0 ino 0 mode 16749 mtime 0 nlink 0 size 0 type directory uid 0}] # # TODO - glob of zipfs file - # TODO tests for compress and save + # TODO tests for compress and save, + with password # # TODO - file copy, file rename etc. |