1
1
mirror of https://github.com/wader/fq.git synced 2024-12-25 22:34:14 +03:00

Merge pull request #280 from wader/zip-tests-cleanup

zip: Add uncompress=false test and some docs
This commit is contained in:
Mattias Wadman 2022-05-26 16:46:24 +02:00 committed by GitHub
commit d07a8520b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 516 additions and 1 deletions

View File

@ -453,6 +453,8 @@ Current only supports plain RTMP (not RTMPT or encrypted variants etc) with AMF0
### zip ### zip
Supports ZIP64.
#### Options #### Options
|Name |Default|Description| |Name |Default|Description|
@ -471,6 +473,10 @@ Decode value as zip
... | zip({uncompress: true}) ... | zip({uncompress: true})
``` ```
#### References and links
- https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
[#]: sh-end [#]: sh-end

View File

@ -763,6 +763,7 @@ out # Decode value as xing
out ... | xing out ... | xing
"help(zip)" "help(zip)"
out zip: ZIP archive decoder out zip: ZIP archive decoder
out Supports ZIP64.
out Options: out Options:
out uncompress=true Decompress and probe files out uncompress=true Decompress and probe files
out Examples: out Examples:
@ -774,3 +775,5 @@ out # Decode file using zip options
out $ fq -d zip -o uncompress=true . file out $ fq -d zip -o uncompress=true . file
out # Decode value as zip out # Decode value as zip
out ... | zip({uncompress: true}) out ... | zip({uncompress: true})
out References and links
out https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

495
format/zip/testdata/uncompress.fqtest vendored Normal file
View File

@ -0,0 +1,495 @@
$ fq -d zip -o uncompress=false dv test9.zip
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: test9.zip (zip) 0x0-0x3c7.7 (968)
| | | local_files[0:5]: 0x0-0x227.7 (552)
| | | [0]{}: local_file 0x0-0x3e.7 (63)
0x000|50 4b 03 04 |PK.. | signature: raw bits (valid) 0x0-0x3.7 (4)
0x000| 0a 00 | .. | version_needed: 10 0x4-0x5.7 (2)
| | | flags{}: 0x6-0x7.7 (2)
0x000| 00 | . | unused0: 0 0x6-0x6 (0.1)
0x000| 00 | . | strong_encryption: false 0x6.1-0x6.1 (0.1)
0x000| 00 | . | compressed_patched_data: false 0x6.2-0x6.2 (0.1)
0x000| 00 | . | enhanced_deflation: false 0x6.3-0x6.3 (0.1)
0x000| 00 | . | data_descriptor: false 0x6.4-0x6.4 (0.1)
0x000| 00 | . | compression0: false 0x6.5-0x6.5 (0.1)
0x000| 00 | . | compression1: false 0x6.6-0x6.6 (0.1)
0x000| 00 | . | encrypted: false 0x6.7-0x6.7 (0.1)
0x000| 00 | . | reserved0: 0 0x7-0x7.1 (0.2)
0x000| 00 | . | mask_header_values: false 0x7.2-0x7.2 (0.1)
0x000| 00 | . | reserved1: false 0x7.3-0x7.3 (0.1)
0x000| 00 | . | language_encoding: false 0x7.4-0x7.4 (0.1)
0x000| 00 | . | unused1: 0 0x7.5-0x7.7 (0.3)
0x000| 00 00 | .. | compression_method: "none" (0) 0x8-0x9.7 (2)
| | | last_modification_date{}: 0xa-0xb.7 (2)
0x000| 73 | s | hours: 14 0xa-0xa.4 (0.5)
0x000| 73 0a | s. | minutes: 24 0xa.5-0xb.2 (0.6)
0x000| 0a | . | seconds: 10 0xb.3-0xb.7 (0.5)
| | | last_modification_time{}: 0xc-0xd.7 (2)
0x000| 75 | u | year: 58 0xc-0xc.6 (0.7)
0x000| 75 53 | uS | month: 10 0xc.7-0xd.2 (0.4)
0x000| 53 | S | day: 19 0xd.3-0xd.7 (0.5)
0x000| 00 00| ..| crc32_uncompressed: 0x0 0xe-0x11.7 (4)
0x010|00 00 |.. |
0x010| 00 00 00 00 | .... | compressed_size: 0 0x12-0x15.7 (4)
0x010| 00 00 00 00 | .... | uncompressed_size: 0 0x16-0x19.7 (4)
0x010| 05 00 | .. | file_name_length: 5 0x1a-0x1b.7 (2)
0x010| 1c 00 | .. | extra_field_length: 28 0x1c-0x1d.7 (2)
0x010| 74 65| te| file_name: "test/" 0x1e-0x22.7 (5)
0x020|73 74 2f |st/ |
| | | extra_fields[0:2]: 0x23-0x3e.7 (28)
| | | [0]{}: extra_field 0x23-0x2f.7 (13)
0x020| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x23-0x24.7 (2)
0x020| 09 00 | .. | data_size: 9 0x25-0x26.7 (2)
0x020| 03 9a 90 99 61 9b 90 99 61| ....a...a| data: raw bits 0x27-0x2f.7 (9)
| | | [1]{}: extra_field 0x30-0x3e.7 (15)
0x030|75 78 |ux | header_id: 0x7875 (UNIX UID/GID) 0x30-0x31.7 (2)
0x030| 0b 00 | .. | data_size: 11 0x32-0x33.7 (2)
0x030| 01 04 f5 01 00 00 04 14 00 00 00 | ........... | data: raw bits 0x34-0x3e.7 (11)
| | | uncompressed: raw bits 0x3f-NA (0)
| | | [1]{}: local_file 0x3f-0x7f.7 (65)
0x030| 50| P| signature: raw bits (valid) 0x3f-0x42.7 (4)
0x040|4b 03 04 |K.. |
0x040| 0a 00 | .. | version_needed: 10 0x43-0x44.7 (2)
| | | flags{}: 0x45-0x46.7 (2)
0x040| 00 | . | unused0: 0 0x45-0x45 (0.1)
0x040| 00 | . | strong_encryption: false 0x45.1-0x45.1 (0.1)
0x040| 00 | . | compressed_patched_data: false 0x45.2-0x45.2 (0.1)
0x040| 00 | . | enhanced_deflation: false 0x45.3-0x45.3 (0.1)
0x040| 00 | . | data_descriptor: false 0x45.4-0x45.4 (0.1)
0x040| 00 | . | compression0: false 0x45.5-0x45.5 (0.1)
0x040| 00 | . | compression1: false 0x45.6-0x45.6 (0.1)
0x040| 00 | . | encrypted: false 0x45.7-0x45.7 (0.1)
0x040| 00 | . | reserved0: 0 0x46-0x46.1 (0.2)
0x040| 00 | . | mask_header_values: false 0x46.2-0x46.2 (0.1)
0x040| 00 | . | reserved1: false 0x46.3-0x46.3 (0.1)
0x040| 00 | . | language_encoding: false 0x46.4-0x46.4 (0.1)
0x040| 00 | . | unused1: 0 0x46.5-0x46.7 (0.3)
0x040| 00 00 | .. | compression_method: "none" (0) 0x47-0x48.7 (2)
| | | last_modification_date{}: 0x49-0x4a.7 (2)
0x040| 81 | . | hours: 16 0x49-0x49.4 (0.5)
0x040| 81 01 | .. | minutes: 8 0x49.5-0x4a.2 (0.6)
0x040| 01 | . | seconds: 1 0x4a.3-0x4a.7 (0.5)
| | | last_modification_time{}: 0x4b-0x4c.7 (2)
0x040| 73 | s | year: 57 0x4b-0x4b.6 (0.7)
0x040| 73 53 | sS | month: 10 0x4b.7-0x4c.2 (0.4)
0x040| 53 | S | day: 19 0x4c.3-0x4c.7 (0.5)
0x040| 00 00 00| ...| crc32_uncompressed: 0x0 0x4d-0x50.7 (4)
0x050|00 |. |
0x050| 00 00 00 00 | .... | compressed_size: 0 0x51-0x54.7 (4)
0x050| 00 00 00 00 | .... | uncompressed_size: 0 0x55-0x58.7 (4)
0x050| 07 00 | .. | file_name_length: 7 0x59-0x5a.7 (2)
0x050| 1c 00 | .. | extra_field_length: 28 0x5b-0x5c.7 (2)
0x050| 74 65 73| tes| file_name: "test/a/" 0x5d-0x63.7 (7)
0x060|74 2f 61 2f |t/a/ |
| | | extra_fields[0:2]: 0x64-0x7f.7 (28)
| | | [0]{}: extra_field 0x64-0x70.7 (13)
0x060| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x64-0x65.7 (2)
0x060| 09 00 | .. | data_size: 9 0x66-0x67.7 (2)
0x060| 03 c2 dd 96 61 c2 dd 96| ....a...| data: raw bits 0x68-0x70.7 (9)
0x070|61 |a |
| | | [1]{}: extra_field 0x71-0x7f.7 (15)
0x070| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x71-0x72.7 (2)
0x070| 0b 00 | .. | data_size: 11 0x73-0x74.7 (2)
0x070| 01 04 f5 01 00 00 04 14 00 00 00| ...........| data: raw bits 0x75-0x7f.7 (11)
| | | uncompressed: raw bits 0x80-NA (0)
| | | [2]{}: local_file 0x80-0xc9.7 (74)
0x080|50 4b 03 04 |PK.. | signature: raw bits (valid) 0x80-0x83.7 (4)
0x080| 0a 00 | .. | version_needed: 10 0x84-0x85.7 (2)
| | | flags{}: 0x86-0x87.7 (2)
0x080| 02 | . | unused0: 0 0x86-0x86 (0.1)
0x080| 02 | . | strong_encryption: false 0x86.1-0x86.1 (0.1)
0x080| 02 | . | compressed_patched_data: false 0x86.2-0x86.2 (0.1)
0x080| 02 | . | enhanced_deflation: false 0x86.3-0x86.3 (0.1)
0x080| 02 | . | data_descriptor: false 0x86.4-0x86.4 (0.1)
0x080| 02 | . | compression0: false 0x86.5-0x86.5 (0.1)
0x080| 02 | . | compression1: true 0x86.6-0x86.6 (0.1)
0x080| 02 | . | encrypted: false 0x86.7-0x86.7 (0.1)
0x080| 00 | . | reserved0: 0 0x87-0x87.1 (0.2)
0x080| 00 | . | mask_header_values: false 0x87.2-0x87.2 (0.1)
0x080| 00 | . | reserved1: false 0x87.3-0x87.3 (0.1)
0x080| 00 | . | language_encoding: false 0x87.4-0x87.4 (0.1)
0x080| 00 | . | unused1: 0 0x87.5-0x87.7 (0.3)
0x080| 00 00 | .. | compression_method: "none" (0) 0x88-0x89.7 (2)
| | | last_modification_date{}: 0x8a-0x8b.7 (2)
0x080| 81 | . | hours: 16 0x8a-0x8a.4 (0.5)
0x080| 81 01 | .. | minutes: 8 0x8a.5-0x8b.2 (0.6)
0x080| 01 | . | seconds: 1 0x8b.3-0x8b.7 (0.5)
| | | last_modification_time{}: 0x8c-0x8d.7 (2)
0x080| 73 | s | year: 57 0x8c-0x8c.6 (0.7)
0x080| 73 53 | sS | month: 10 0x8c.7-0x8d.2 (0.4)
0x080| 53 | S | day: 19 0x8d.3-0x8d.7 (0.5)
0x080| 45 e5| E.| crc32_uncompressed: 0xad98e545 0x8e-0x91.7 (4)
0x090|98 ad |.. |
0x090| 04 00 00 00 | .... | compressed_size: 4 0x92-0x95.7 (4)
0x090| 04 00 00 00 | .... | uncompressed_size: 4 0x96-0x99.7 (4)
0x090| 0c 00 | .. | file_name_length: 12 0x9a-0x9b.7 (2)
0x090| 1c 00 | .. | extra_field_length: 28 0x9c-0x9d.7 (2)
0x090| 74 65| te| file_name: "test/a/a.txt" 0x9e-0xa9.7 (12)
0x0a0|73 74 2f 61 2f 61 2e 74 78 74 |st/a/a.txt |
| | | extra_fields[0:2]: 0xaa-0xc5.7 (28)
| | | [0]{}: extra_field 0xaa-0xb6.7 (13)
0x0a0| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0xaa-0xab.7 (2)
0x0a0| 09 00 | .. | data_size: 9 0xac-0xad.7 (2)
0x0a0| 03 c2| ..| data: raw bits 0xae-0xb6.7 (9)
0x0b0|dd 96 61 32 e0 96 61 |..a2..a |
| | | [1]{}: extra_field 0xb7-0xc5.7 (15)
0x0b0| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0xb7-0xb8.7 (2)
0x0b0| 0b 00 | .. | data_size: 11 0xb9-0xba.7 (2)
0x0b0| 01 04 f5 01 00| .....| data: raw bits 0xbb-0xc5.7 (11)
0x0c0|00 04 14 00 00 00 |...... |
0x0c0| 61 61 61 61 | aaaa | uncompressed: raw bits 0xc6-0xc9.7 (4)
| | | [3]{}: local_file 0xca-0x113.7 (74)
0x0c0| 50 4b 03 04 | PK.. | signature: raw bits (valid) 0xca-0xcd.7 (4)
0x0c0| 14 00| ..| version_needed: 20 0xce-0xcf.7 (2)
| | | flags{}: 0xd0-0xd1.7 (2)
0x0d0|02 |. | unused0: 0 0xd0-0xd0 (0.1)
0x0d0|02 |. | strong_encryption: false 0xd0.1-0xd0.1 (0.1)
0x0d0|02 |. | compressed_patched_data: false 0xd0.2-0xd0.2 (0.1)
0x0d0|02 |. | enhanced_deflation: false 0xd0.3-0xd0.3 (0.1)
0x0d0|02 |. | data_descriptor: false 0xd0.4-0xd0.4 (0.1)
0x0d0|02 |. | compression0: false 0xd0.5-0xd0.5 (0.1)
0x0d0|02 |. | compression1: true 0xd0.6-0xd0.6 (0.1)
0x0d0|02 |. | encrypted: false 0xd0.7-0xd0.7 (0.1)
0x0d0| 00 | . | reserved0: 0 0xd1-0xd1.1 (0.2)
0x0d0| 00 | . | mask_header_values: false 0xd1.2-0xd1.2 (0.1)
0x0d0| 00 | . | reserved1: false 0xd1.3-0xd1.3 (0.1)
0x0d0| 00 | . | language_encoding: false 0xd1.4-0xd1.4 (0.1)
0x0d0| 00 | . | unused1: 0 0xd1.5-0xd1.7 (0.3)
0x0d0| 08 00 | .. | compression_method: "deflated" (8) 0xd2-0xd3.7 (2)
| | | last_modification_date{}: 0xd4-0xd5.7 (2)
0x0d0| 81 | . | hours: 16 0xd4-0xd4.4 (0.5)
0x0d0| 81 01 | .. | minutes: 8 0xd4.5-0xd5.2 (0.6)
0x0d0| 01 | . | seconds: 1 0xd5.3-0xd5.7 (0.5)
| | | last_modification_time{}: 0xd6-0xd7.7 (2)
0x0d0| 73 | s | year: 57 0xd6-0xd6.6 (0.7)
0x0d0| 73 53 | sS | month: 10 0xd6.7-0xd7.2 (0.4)
0x0d0| 53 | S | day: 19 0xd7.3-0xd7.7 (0.5)
0x0d0| 2c 89 b3 aa | ,... | crc32_uncompressed: 0xaab3892c 0xd8-0xdb.7 (4)
0x0d0| 06 00 00 00| ....| compressed_size: 6 0xdc-0xdf.7 (4)
0x0e0|35 00 00 00 |5... | uncompressed_size: 53 0xe0-0xe3.7 (4)
0x0e0| 0a 00 | .. | file_name_length: 10 0xe4-0xe5.7 (2)
0x0e0| 1c 00 | .. | extra_field_length: 28 0xe6-0xe7.7 (2)
0x0e0| 74 65 73 74 2f 61 2e 74| test/a.t| file_name: "test/a.txt" 0xe8-0xf1.7 (10)
0x0f0|78 74 |xt |
| | | extra_fields[0:2]: 0xf2-0x10d.7 (28)
| | | [0]{}: extra_field 0xf2-0xfe.7 (13)
0x0f0| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0xf2-0xf3.7 (2)
0x0f0| 09 00 | .. | data_size: 9 0xf4-0xf5.7 (2)
0x0f0| 03 c2 dd 96 61 32 e0 96 61 | ....a2..a | data: raw bits 0xf6-0xfe.7 (9)
| | | [1]{}: extra_field 0xff-0x10d.7 (15)
0x0f0| 75| u| header_id: 0x7875 (UNIX UID/GID) 0xff-0x100.7 (2)
0x100|78 |x |
0x100| 0b 00 | .. | data_size: 11 0x101-0x102.7 (2)
0x100| 01 04 f5 01 00 00 04 14 00 00 00 | ........... | data: raw bits 0x103-0x10d.7 (11)
0x100| 4b 4c| KL| compressed: raw bits 0x10e-0x113.7 (6)
0x110|24 03 00 00 |$... |
| | | [4]{}: local_file 0x114-0x227.7 (276)
0x110| 50 4b 03 04 | PK.. | signature: raw bits (valid) 0x114-0x117.7 (4)
0x110| 14 00 | .. | version_needed: 20 0x118-0x119.7 (2)
| | | flags{}: 0x11a-0x11b.7 (2)
0x110| 02 | . | unused0: 0 0x11a-0x11a (0.1)
0x110| 02 | . | strong_encryption: false 0x11a.1-0x11a.1 (0.1)
0x110| 02 | . | compressed_patched_data: false 0x11a.2-0x11a.2 (0.1)
0x110| 02 | . | enhanced_deflation: false 0x11a.3-0x11a.3 (0.1)
0x110| 02 | . | data_descriptor: false 0x11a.4-0x11a.4 (0.1)
0x110| 02 | . | compression0: false 0x11a.5-0x11a.5 (0.1)
0x110| 02 | . | compression1: true 0x11a.6-0x11a.6 (0.1)
0x110| 02 | . | encrypted: false 0x11a.7-0x11a.7 (0.1)
0x110| 00 | . | reserved0: 0 0x11b-0x11b.1 (0.2)
0x110| 00 | . | mask_header_values: false 0x11b.2-0x11b.2 (0.1)
0x110| 00 | . | reserved1: false 0x11b.3-0x11b.3 (0.1)
0x110| 00 | . | language_encoding: false 0x11b.4-0x11b.4 (0.1)
0x110| 00 | . | unused1: 0 0x11b.5-0x11b.7 (0.3)
0x110| 08 00 | .. | compression_method: "deflated" (8) 0x11c-0x11d.7 (2)
| | | last_modification_date{}: 0x11e-0x11f.7 (2)
0x110| 73 | s | hours: 14 0x11e-0x11e.4 (0.5)
0x110| 73 0a| s.| minutes: 24 0x11e.5-0x11f.2 (0.6)
0x110| 0a| .| seconds: 10 0x11f.3-0x11f.7 (0.5)
| | | last_modification_time{}: 0x120-0x121.7 (2)
0x120|75 |u | year: 58 0x120-0x120.6 (0.7)
0x120|75 53 |uS | month: 10 0x120.7-0x121.2 (0.4)
0x120| 53 | S | day: 19 0x121.3-0x121.7 (0.5)
0x120| cd 66 90 fb | .f.. | crc32_uncompressed: 0xfb9066cd 0x122-0x125.7 (4)
0x120| d0 00 00 00 | .... | compressed_size: 208 0x126-0x129.7 (4)
0x120| 03 01 00 00 | .... | uncompressed_size: 259 0x12a-0x12d.7 (4)
0x120| 0a 00| ..| file_name_length: 10 0x12e-0x12f.7 (2)
0x130|1c 00 |.. | extra_field_length: 28 0x130-0x131.7 (2)
0x130| 74 65 73 74 2f 62 2e 70 6e 67 | test/b.png | file_name: "test/b.png" 0x132-0x13b.7 (10)
| | | extra_fields[0:2]: 0x13c-0x157.7 (28)
| | | [0]{}: extra_field 0x13c-0x148.7 (13)
0x130| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x13c-0x13d.7 (2)
0x130| 09 00| ..| data_size: 9 0x13e-0x13f.7 (2)
0x140|03 9a 90 99 61 9c 90 99 61 |....a...a | data: raw bits 0x140-0x148.7 (9)
| | | [1]{}: extra_field 0x149-0x157.7 (15)
0x140| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x149-0x14a.7 (2)
0x140| 0b 00 | .. | data_size: 11 0x14b-0x14c.7 (2)
0x140| 01 04 f5| ...| data: raw bits 0x14d-0x157.7 (11)
0x150|01 00 00 04 14 00 00 00 |........ |
0x150| eb 0c f0 73 e7 e5 92 e2| ...s....| compressed: raw bits 0x158-0x227.7 (208)
0x160|62 60 60 e0 f5 f4 70 09 02 d2 2c 20 cc 08 24 18|b``...p..., ..$.|
* |until 0x227.7 (208) | |
| | | central_directories[0:5]: 0x228-0x3b1.7 (394)
| | | [0]{}: central_directory 0x228-0x272.7 (75)
0x220| 50 4b 01 02 | PK.. | signature: raw bits (valid) 0x228-0x22b.7 (4)
0x220| 1e 03 | .. | version_made_by: 798 0x22c-0x22d.7 (2)
0x220| 0a 00| ..| version_needed: 10 0x22e-0x22f.7 (2)
| | | flags{}: 0x230-0x231.7 (2)
0x230|00 |. | unused0: 0 0x230-0x230 (0.1)
0x230|00 |. | strong_encryption: false 0x230.1-0x230.1 (0.1)
0x230|00 |. | compressed_patched_data: false 0x230.2-0x230.2 (0.1)
0x230|00 |. | enhanced_deflation: false 0x230.3-0x230.3 (0.1)
0x230|00 |. | data_descriptor: false 0x230.4-0x230.4 (0.1)
0x230|00 |. | compression0: false 0x230.5-0x230.5 (0.1)
0x230|00 |. | compression1: false 0x230.6-0x230.6 (0.1)
0x230|00 |. | encrypted: false 0x230.7-0x230.7 (0.1)
0x230| 00 | . | reserved0: 0 0x231-0x231.1 (0.2)
0x230| 00 | . | mask_header_values: false 0x231.2-0x231.2 (0.1)
0x230| 00 | . | reserved1: false 0x231.3-0x231.3 (0.1)
0x230| 00 | . | language_encoding: false 0x231.4-0x231.4 (0.1)
0x230| 00 | . | unused1: 0 0x231.5-0x231.7 (0.3)
0x230| 00 00 | .. | compression_method: "none" (0) 0x232-0x233.7 (2)
| | | last_modification_date{}: 0x234-0x235.7 (2)
0x230| 73 | s | hours: 14 0x234-0x234.4 (0.5)
0x230| 73 0a | s. | minutes: 24 0x234.5-0x235.2 (0.6)
0x230| 0a | . | seconds: 10 0x235.3-0x235.7 (0.5)
| | | last_modification_time{}: 0x236-0x237.7 (2)
0x230| 75 | u | year: 58 0x236-0x236.6 (0.7)
0x230| 75 53 | uS | month: 10 0x236.7-0x237.2 (0.4)
0x230| 53 | S | day: 19 0x237.3-0x237.7 (0.5)
0x230| 00 00 00 00 | .... | crc32_uncompressed: 0x0 0x238-0x23b.7 (4)
0x230| 00 00 00 00| ....| compressed_size: 0 0x23c-0x23f.7 (4)
0x240|00 00 00 00 |.... | uncompressed_size: 0 0x240-0x243.7 (4)
0x240| 05 00 | .. | file_name_length: 5 0x244-0x245.7 (2)
0x240| 18 00 | .. | extra_field_length: 24 0x246-0x247.7 (2)
0x240| 00 00 | .. | file_comment_length: 0 0x248-0x249.7 (2)
0x240| 00 00 | .. | disk_number_where_file_starts: 0 0x24a-0x24b.7 (2)
0x240| 00 00 | .. | internal_file_attributes: 0 0x24c-0x24d.7 (2)
0x240| 10 00| ..| external_file_attributes: 1106051088 0x24e-0x251.7 (4)
0x250|ed 41 |.A |
0x250| 00 00 00 00 | .... | relative_offset_of_local_file_header: 0 0x252-0x255.7 (4)
0x250| 74 65 73 74 2f | test/ | file_name: "test/" 0x256-0x25a.7 (5)
| | | extra_fields[0:2]: 0x25b-0x272.7 (24)
| | | [0]{}: extra_field 0x25b-0x263.7 (9)
0x250| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x25b-0x25c.7 (2)
0x250| 05 00 | .. | data_size: 5 0x25d-0x25e.7 (2)
0x250| 03| .| data: raw bits 0x25f-0x263.7 (5)
0x260|9a 90 99 61 |...a |
| | | [1]{}: extra_field 0x264-0x272.7 (15)
0x260| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x264-0x265.7 (2)
0x260| 0b 00 | .. | data_size: 11 0x266-0x267.7 (2)
0x260| 01 04 f5 01 00 00 04 14| ........| data: raw bits 0x268-0x272.7 (11)
0x270|00 00 00 |... |
| | | file_comment: "" 0x273-NA (0)
| | | [1]{}: central_directory 0x273-0x2bf.7 (77)
0x270| 50 4b 01 02 | PK.. | signature: raw bits (valid) 0x273-0x276.7 (4)
0x270| 1e 03 | .. | version_made_by: 798 0x277-0x278.7 (2)
0x270| 0a 00 | .. | version_needed: 10 0x279-0x27a.7 (2)
| | | flags{}: 0x27b-0x27c.7 (2)
0x270| 00 | . | unused0: 0 0x27b-0x27b (0.1)
0x270| 00 | . | strong_encryption: false 0x27b.1-0x27b.1 (0.1)
0x270| 00 | . | compressed_patched_data: false 0x27b.2-0x27b.2 (0.1)
0x270| 00 | . | enhanced_deflation: false 0x27b.3-0x27b.3 (0.1)
0x270| 00 | . | data_descriptor: false 0x27b.4-0x27b.4 (0.1)
0x270| 00 | . | compression0: false 0x27b.5-0x27b.5 (0.1)
0x270| 00 | . | compression1: false 0x27b.6-0x27b.6 (0.1)
0x270| 00 | . | encrypted: false 0x27b.7-0x27b.7 (0.1)
0x270| 00 | . | reserved0: 0 0x27c-0x27c.1 (0.2)
0x270| 00 | . | mask_header_values: false 0x27c.2-0x27c.2 (0.1)
0x270| 00 | . | reserved1: false 0x27c.3-0x27c.3 (0.1)
0x270| 00 | . | language_encoding: false 0x27c.4-0x27c.4 (0.1)
0x270| 00 | . | unused1: 0 0x27c.5-0x27c.7 (0.3)
0x270| 00 00 | .. | compression_method: "none" (0) 0x27d-0x27e.7 (2)
| | | last_modification_date{}: 0x27f-0x280.7 (2)
0x270| 81| .| hours: 16 0x27f-0x27f.4 (0.5)
0x270| 81| .| minutes: 8 0x27f.5-0x280.2 (0.6)
0x280|01 |. |
0x280|01 |. | seconds: 1 0x280.3-0x280.7 (0.5)
| | | last_modification_time{}: 0x281-0x282.7 (2)
0x280| 73 | s | year: 57 0x281-0x281.6 (0.7)
0x280| 73 53 | sS | month: 10 0x281.7-0x282.2 (0.4)
0x280| 53 | S | day: 19 0x282.3-0x282.7 (0.5)
0x280| 00 00 00 00 | .... | crc32_uncompressed: 0x0 0x283-0x286.7 (4)
0x280| 00 00 00 00 | .... | compressed_size: 0 0x287-0x28a.7 (4)
0x280| 00 00 00 00 | .... | uncompressed_size: 0 0x28b-0x28e.7 (4)
0x280| 07| .| file_name_length: 7 0x28f-0x290.7 (2)
0x290|00 |. |
0x290| 18 00 | .. | extra_field_length: 24 0x291-0x292.7 (2)
0x290| 00 00 | .. | file_comment_length: 0 0x293-0x294.7 (2)
0x290| 00 00 | .. | disk_number_where_file_starts: 0 0x295-0x296.7 (2)
0x290| 00 00 | .. | internal_file_attributes: 0 0x297-0x298.7 (2)
0x290| 10 00 ed 41 | ...A | external_file_attributes: 1106051088 0x299-0x29c.7 (4)
0x290| 3f 00 00| ?..| relative_offset_of_local_file_header: 63 0x29d-0x2a0.7 (4)
0x2a0|00 |. |
0x2a0| 74 65 73 74 2f 61 2f | test/a/ | file_name: "test/a/" 0x2a1-0x2a7.7 (7)
| | | extra_fields[0:2]: 0x2a8-0x2bf.7 (24)
| | | [0]{}: extra_field 0x2a8-0x2b0.7 (9)
0x2a0| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x2a8-0x2a9.7 (2)
0x2a0| 05 00 | .. | data_size: 5 0x2aa-0x2ab.7 (2)
0x2a0| 03 c2 dd 96| ....| data: raw bits 0x2ac-0x2b0.7 (5)
0x2b0|61 |a |
| | | [1]{}: extra_field 0x2b1-0x2bf.7 (15)
0x2b0| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x2b1-0x2b2.7 (2)
0x2b0| 0b 00 | .. | data_size: 11 0x2b3-0x2b4.7 (2)
0x2b0| 01 04 f5 01 00 00 04 14 00 00 00| ...........| data: raw bits 0x2b5-0x2bf.7 (11)
| | | file_comment: "" 0x2c0-NA (0)
| | | [2]{}: central_directory 0x2c0-0x311.7 (82)
0x2c0|50 4b 01 02 |PK.. | signature: raw bits (valid) 0x2c0-0x2c3.7 (4)
0x2c0| 1e 03 | .. | version_made_by: 798 0x2c4-0x2c5.7 (2)
0x2c0| 0a 00 | .. | version_needed: 10 0x2c6-0x2c7.7 (2)
| | | flags{}: 0x2c8-0x2c9.7 (2)
0x2c0| 02 | . | unused0: 0 0x2c8-0x2c8 (0.1)
0x2c0| 02 | . | strong_encryption: false 0x2c8.1-0x2c8.1 (0.1)
0x2c0| 02 | . | compressed_patched_data: false 0x2c8.2-0x2c8.2 (0.1)
0x2c0| 02 | . | enhanced_deflation: false 0x2c8.3-0x2c8.3 (0.1)
0x2c0| 02 | . | data_descriptor: false 0x2c8.4-0x2c8.4 (0.1)
0x2c0| 02 | . | compression0: false 0x2c8.5-0x2c8.5 (0.1)
0x2c0| 02 | . | compression1: true 0x2c8.6-0x2c8.6 (0.1)
0x2c0| 02 | . | encrypted: false 0x2c8.7-0x2c8.7 (0.1)
0x2c0| 00 | . | reserved0: 0 0x2c9-0x2c9.1 (0.2)
0x2c0| 00 | . | mask_header_values: false 0x2c9.2-0x2c9.2 (0.1)
0x2c0| 00 | . | reserved1: false 0x2c9.3-0x2c9.3 (0.1)
0x2c0| 00 | . | language_encoding: false 0x2c9.4-0x2c9.4 (0.1)
0x2c0| 00 | . | unused1: 0 0x2c9.5-0x2c9.7 (0.3)
0x2c0| 00 00 | .. | compression_method: "none" (0) 0x2ca-0x2cb.7 (2)
| | | last_modification_date{}: 0x2cc-0x2cd.7 (2)
0x2c0| 81 | . | hours: 16 0x2cc-0x2cc.4 (0.5)
0x2c0| 81 01 | .. | minutes: 8 0x2cc.5-0x2cd.2 (0.6)
0x2c0| 01 | . | seconds: 1 0x2cd.3-0x2cd.7 (0.5)
| | | last_modification_time{}: 0x2ce-0x2cf.7 (2)
0x2c0| 73 | s | year: 57 0x2ce-0x2ce.6 (0.7)
0x2c0| 73 53| sS| month: 10 0x2ce.7-0x2cf.2 (0.4)
0x2c0| 53| S| day: 19 0x2cf.3-0x2cf.7 (0.5)
0x2d0|45 e5 98 ad |E... | crc32_uncompressed: 0xad98e545 0x2d0-0x2d3.7 (4)
0x2d0| 04 00 00 00 | .... | compressed_size: 4 0x2d4-0x2d7.7 (4)
0x2d0| 04 00 00 00 | .... | uncompressed_size: 4 0x2d8-0x2db.7 (4)
0x2d0| 0c 00 | .. | file_name_length: 12 0x2dc-0x2dd.7 (2)
0x2d0| 18 00| ..| extra_field_length: 24 0x2de-0x2df.7 (2)
0x2e0|00 00 |.. | file_comment_length: 0 0x2e0-0x2e1.7 (2)
0x2e0| 00 00 | .. | disk_number_where_file_starts: 0 0x2e2-0x2e3.7 (2)
0x2e0| 01 00 | .. | internal_file_attributes: 1 0x2e4-0x2e5.7 (2)
0x2e0| 00 00 a4 81 | .... | external_file_attributes: 2175008768 0x2e6-0x2e9.7 (4)
0x2e0| 80 00 00 00 | .... | relative_offset_of_local_file_header: 128 0x2ea-0x2ed.7 (4)
0x2e0| 74 65| te| file_name: "test/a/a.txt" 0x2ee-0x2f9.7 (12)
0x2f0|73 74 2f 61 2f 61 2e 74 78 74 |st/a/a.txt |
| | | extra_fields[0:2]: 0x2fa-0x311.7 (24)
| | | [0]{}: extra_field 0x2fa-0x302.7 (9)
0x2f0| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x2fa-0x2fb.7 (2)
0x2f0| 05 00 | .. | data_size: 5 0x2fc-0x2fd.7 (2)
0x2f0| 03 c2| ..| data: raw bits 0x2fe-0x302.7 (5)
0x300|dd 96 61 |..a |
| | | [1]{}: extra_field 0x303-0x311.7 (15)
0x300| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x303-0x304.7 (2)
0x300| 0b 00 | .. | data_size: 11 0x305-0x306.7 (2)
0x300| 01 04 f5 01 00 00 04 14 00| .........| data: raw bits 0x307-0x311.7 (11)
0x310|00 00 |.. |
| | | file_comment: "" 0x312-NA (0)
| | | [3]{}: central_directory 0x312-0x361.7 (80)
0x310| 50 4b 01 02 | PK.. | signature: raw bits (valid) 0x312-0x315.7 (4)
0x310| 1e 03 | .. | version_made_by: 798 0x316-0x317.7 (2)
0x310| 14 00 | .. | version_needed: 20 0x318-0x319.7 (2)
| | | flags{}: 0x31a-0x31b.7 (2)
0x310| 02 | . | unused0: 0 0x31a-0x31a (0.1)
0x310| 02 | . | strong_encryption: false 0x31a.1-0x31a.1 (0.1)
0x310| 02 | . | compressed_patched_data: false 0x31a.2-0x31a.2 (0.1)
0x310| 02 | . | enhanced_deflation: false 0x31a.3-0x31a.3 (0.1)
0x310| 02 | . | data_descriptor: false 0x31a.4-0x31a.4 (0.1)
0x310| 02 | . | compression0: false 0x31a.5-0x31a.5 (0.1)
0x310| 02 | . | compression1: true 0x31a.6-0x31a.6 (0.1)
0x310| 02 | . | encrypted: false 0x31a.7-0x31a.7 (0.1)
0x310| 00 | . | reserved0: 0 0x31b-0x31b.1 (0.2)
0x310| 00 | . | mask_header_values: false 0x31b.2-0x31b.2 (0.1)
0x310| 00 | . | reserved1: false 0x31b.3-0x31b.3 (0.1)
0x310| 00 | . | language_encoding: false 0x31b.4-0x31b.4 (0.1)
0x310| 00 | . | unused1: 0 0x31b.5-0x31b.7 (0.3)
0x310| 08 00 | .. | compression_method: "deflated" (8) 0x31c-0x31d.7 (2)
| | | last_modification_date{}: 0x31e-0x31f.7 (2)
0x310| 81 | . | hours: 16 0x31e-0x31e.4 (0.5)
0x310| 81 01| ..| minutes: 8 0x31e.5-0x31f.2 (0.6)
0x310| 01| .| seconds: 1 0x31f.3-0x31f.7 (0.5)
| | | last_modification_time{}: 0x320-0x321.7 (2)
0x320|73 |s | year: 57 0x320-0x320.6 (0.7)
0x320|73 53 |sS | month: 10 0x320.7-0x321.2 (0.4)
0x320| 53 | S | day: 19 0x321.3-0x321.7 (0.5)
0x320| 2c 89 b3 aa | ,... | crc32_uncompressed: 0xaab3892c 0x322-0x325.7 (4)
0x320| 06 00 00 00 | .... | compressed_size: 6 0x326-0x329.7 (4)
0x320| 35 00 00 00 | 5... | uncompressed_size: 53 0x32a-0x32d.7 (4)
0x320| 0a 00| ..| file_name_length: 10 0x32e-0x32f.7 (2)
0x330|18 00 |.. | extra_field_length: 24 0x330-0x331.7 (2)
0x330| 00 00 | .. | file_comment_length: 0 0x332-0x333.7 (2)
0x330| 00 00 | .. | disk_number_where_file_starts: 0 0x334-0x335.7 (2)
0x330| 01 00 | .. | internal_file_attributes: 1 0x336-0x337.7 (2)
0x330| 00 00 a4 81 | .... | external_file_attributes: 2175008768 0x338-0x33b.7 (4)
0x330| ca 00 00 00| ....| relative_offset_of_local_file_header: 202 0x33c-0x33f.7 (4)
0x340|74 65 73 74 2f 61 2e 74 78 74 |test/a.txt | file_name: "test/a.txt" 0x340-0x349.7 (10)
| | | extra_fields[0:2]: 0x34a-0x361.7 (24)
| | | [0]{}: extra_field 0x34a-0x352.7 (9)
0x340| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x34a-0x34b.7 (2)
0x340| 05 00 | .. | data_size: 5 0x34c-0x34d.7 (2)
0x340| 03 c2| ..| data: raw bits 0x34e-0x352.7 (5)
0x350|dd 96 61 |..a |
| | | [1]{}: extra_field 0x353-0x361.7 (15)
0x350| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x353-0x354.7 (2)
0x350| 0b 00 | .. | data_size: 11 0x355-0x356.7 (2)
0x350| 01 04 f5 01 00 00 04 14 00| .........| data: raw bits 0x357-0x361.7 (11)
0x360|00 00 |.. |
| | | file_comment: "" 0x362-NA (0)
| | | [4]{}: central_directory 0x362-0x3b1.7 (80)
0x360| 50 4b 01 02 | PK.. | signature: raw bits (valid) 0x362-0x365.7 (4)
0x360| 1e 03 | .. | version_made_by: 798 0x366-0x367.7 (2)
0x360| 14 00 | .. | version_needed: 20 0x368-0x369.7 (2)
| | | flags{}: 0x36a-0x36b.7 (2)
0x360| 02 | . | unused0: 0 0x36a-0x36a (0.1)
0x360| 02 | . | strong_encryption: false 0x36a.1-0x36a.1 (0.1)
0x360| 02 | . | compressed_patched_data: false 0x36a.2-0x36a.2 (0.1)
0x360| 02 | . | enhanced_deflation: false 0x36a.3-0x36a.3 (0.1)
0x360| 02 | . | data_descriptor: false 0x36a.4-0x36a.4 (0.1)
0x360| 02 | . | compression0: false 0x36a.5-0x36a.5 (0.1)
0x360| 02 | . | compression1: true 0x36a.6-0x36a.6 (0.1)
0x360| 02 | . | encrypted: false 0x36a.7-0x36a.7 (0.1)
0x360| 00 | . | reserved0: 0 0x36b-0x36b.1 (0.2)
0x360| 00 | . | mask_header_values: false 0x36b.2-0x36b.2 (0.1)
0x360| 00 | . | reserved1: false 0x36b.3-0x36b.3 (0.1)
0x360| 00 | . | language_encoding: false 0x36b.4-0x36b.4 (0.1)
0x360| 00 | . | unused1: 0 0x36b.5-0x36b.7 (0.3)
0x360| 08 00 | .. | compression_method: "deflated" (8) 0x36c-0x36d.7 (2)
| | | last_modification_date{}: 0x36e-0x36f.7 (2)
0x360| 73 | s | hours: 14 0x36e-0x36e.4 (0.5)
0x360| 73 0a| s.| minutes: 24 0x36e.5-0x36f.2 (0.6)
0x360| 0a| .| seconds: 10 0x36f.3-0x36f.7 (0.5)
| | | last_modification_time{}: 0x370-0x371.7 (2)
0x370|75 |u | year: 58 0x370-0x370.6 (0.7)
0x370|75 53 |uS | month: 10 0x370.7-0x371.2 (0.4)
0x370| 53 | S | day: 19 0x371.3-0x371.7 (0.5)
0x370| cd 66 90 fb | .f.. | crc32_uncompressed: 0xfb9066cd 0x372-0x375.7 (4)
0x370| d0 00 00 00 | .... | compressed_size: 208 0x376-0x379.7 (4)
0x370| 03 01 00 00 | .... | uncompressed_size: 259 0x37a-0x37d.7 (4)
0x370| 0a 00| ..| file_name_length: 10 0x37e-0x37f.7 (2)
0x380|18 00 |.. | extra_field_length: 24 0x380-0x381.7 (2)
0x380| 00 00 | .. | file_comment_length: 0 0x382-0x383.7 (2)
0x380| 00 00 | .. | disk_number_where_file_starts: 0 0x384-0x385.7 (2)
0x380| 00 00 | .. | internal_file_attributes: 0 0x386-0x387.7 (2)
0x380| 00 00 a4 81 | .... | external_file_attributes: 2175008768 0x388-0x38b.7 (4)
0x380| 14 01 00 00| ....| relative_offset_of_local_file_header: 276 0x38c-0x38f.7 (4)
0x390|74 65 73 74 2f 62 2e 70 6e 67 |test/b.png | file_name: "test/b.png" 0x390-0x399.7 (10)
| | | extra_fields[0:2]: 0x39a-0x3b1.7 (24)
| | | [0]{}: extra_field 0x39a-0x3a2.7 (9)
0x390| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x39a-0x39b.7 (2)
0x390| 05 00 | .. | data_size: 5 0x39c-0x39d.7 (2)
0x390| 03 9a| ..| data: raw bits 0x39e-0x3a2.7 (5)
0x3a0|90 99 61 |..a |
| | | [1]{}: extra_field 0x3a3-0x3b1.7 (15)
0x3a0| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x3a3-0x3a4.7 (2)
0x3a0| 0b 00 | .. | data_size: 11 0x3a5-0x3a6.7 (2)
0x3a0| 01 04 f5 01 00 00 04 14 00| .........| data: raw bits 0x3a7-0x3b1.7 (11)
0x3b0|00 00 |.. |
| | | file_comment: "" 0x3b2-NA (0)
| | | end_of_central_directory_record{}: 0x3b2-0x3c7.7 (22)
0x3b0| 50 4b 05 06 | PK.. | signature: raw bits (valid) 0x3b2-0x3b5.7 (4)
0x3b0| 00 00 | .. | disk_nr: 0 0x3b6-0x3b7.7 (2)
0x3b0| 00 00 | .. | central_directory_start_disk_nr: 0 0x3b8-0x3b9.7 (2)
0x3b0| 05 00 | .. | nr_of_central_directory_records_on_disk: 5 0x3ba-0x3bb.7 (2)
0x3b0| 05 00 | .. | nr_of_central_directory_records: 5 0x3bc-0x3bd.7 (2)
0x3b0| 8a 01| ..| size_of_central_directory: 394 0x3be-0x3c1.7 (4)
0x3c0|00 00 |.. |
0x3c0| 28 02 00 00 | (... | offset_of_start_of_central_directory: 552 0x3c2-0x3c5.7 (4)
0x3c0| 00 00| | ..| | comment_length: 0 0x3c6-0x3c7.7 (2)
| | | comment: "" 0x3c8-NA (0)

View File

@ -2,11 +2,11 @@ package zip
// https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT // https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
// https://opensource.apple.com/source/zip/zip-6/unzip/unzip/proginfo/extra.fld // https://opensource.apple.com/source/zip/zip-6/unzip/unzip/proginfo/extra.fld
// TODO: zip64
import ( import (
"bytes" "bytes"
"compress/flate" "compress/flate"
"embed"
"io" "io"
"github.com/wader/fq/format" "github.com/wader/fq/format"
@ -15,6 +15,9 @@ import (
"github.com/wader/fq/pkg/scalar" "github.com/wader/fq/pkg/scalar"
) )
//go:embed zip.jq
var zipFS embed.FS
var probeFormat decode.Group var probeFormat decode.Group
func init() { func init() {
@ -29,6 +32,8 @@ func init() {
Dependencies: []decode.Dependency{ Dependencies: []decode.Dependency{
{Names: []string{format.PROBE}, Group: &probeFormat}, {Names: []string{format.PROBE}, Group: &probeFormat},
}, },
Files: zipFS,
Functions: []string{"_help"},
}) })
} }

6
format/zip/zip.jq Normal file
View File

@ -0,0 +1,6 @@
def _zip__help:
{ notes: "Supports ZIP64.",
links: [
{url: "https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"}
]
};