Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe578f46bd |
@@ -0,0 +1,39 @@
|
||||
name: Verify
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: verify-${{ gitea.repository }}-${{ gitea.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
env:
|
||||
CI: "true"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: npm
|
||||
- name: Select declared npm version
|
||||
run: npm install --global npm@11.17.0
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Audit runtime dependencies
|
||||
run: npm audit --omit=dev --audit-level=moderate
|
||||
- name: Check, test, and build
|
||||
run: npm run check
|
||||
- name: Install browser engines
|
||||
run: npx playwright install --with-deps chromium firefox webkit
|
||||
- name: Browser tests
|
||||
run: npm run test:browser
|
||||
@@ -1,5 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## 0.2.0 - 2026-09-02
|
||||
|
||||
- Adopted shared byte-size, portable filename, Blob download, typed byte-cursor
|
||||
and CRC helpers from `@add-ideas/toolbox-helpers` 0.2.0.
|
||||
- Changed bounded gzip verification to update CRC-32 incrementally while output
|
||||
chunks are produced, avoiding a second full pass over expanded data.
|
||||
- Added bounded GNU TAR long-name/long-link metadata and independently verified
|
||||
concatenated gzip members.
|
||||
- Added local AES-256 and legacy ZipCrypto ZIP creation/readback with
|
||||
memory-only passwords and generic wrong-password/integrity errors.
|
||||
- Added bounded structural 7z inspection with validated signature, start-header
|
||||
offsets/sizes, independent CRC-32 checks, encoded/plain next-header evidence,
|
||||
and safe plain FilesInfo name/empty-entry inventory where available.
|
||||
- Added bounded RAR4/RAR5 block framing and header-CRC validation with plaintext
|
||||
file-header inventory for names, sizes, compression, encryption and split
|
||||
flags. Encrypted headers stop inspection; RAR/7z decompression and extraction
|
||||
remain explicitly unsupported.
|
||||
|
||||
## 0.1.0 - 2026-09-01
|
||||
|
||||
- Added the initial local-first Archive Tools workbench.
|
||||
|
||||
@@ -6,15 +6,23 @@ Archive Tools is a standalone local-first application in the [add·ideas Toolbox
|
||||
|
||||
## Version 0.1 scope
|
||||
|
||||
Binary reads use checked offset arithmetic and bounded cursors. gzip CRC-32 is
|
||||
updated incrementally during decompression; temporary previews and downloads
|
||||
use explicitly revoked shared Blob URL leases.
|
||||
|
||||
- Inspect ZIP and ZIP64 central directories, TAR/USTAR/PAX archives, gzip streams and tar.gz archives.
|
||||
- Structurally inspect 7z start/next headers and RAR4/RAR5 plaintext headers under fixed header/count bounds. Header CRCs are checked before metadata is accepted; entry content is never decoded.
|
||||
- List normalized paths, kinds, sizes, compression, timestamps, ZIP64 state, CRC-32 values and policy diagnostics.
|
||||
- Preview bounded UTF-8 text, hexadecimal bytes and static JPEG/PNG/WebP images. HTML and SVG are shown as text, never rendered as active content.
|
||||
- Select regular safe files, verify their bytes and CRC where available, and repackage them into a newly created ZIP. Archive paths are never restored directly to a filesystem.
|
||||
- Create deterministic ZIP, TAR/PAX and tar.gz output from local files with sorted paths and normalized metadata.
|
||||
- Read and create password-protected ZIP entries with local ZipCrypto or WinZip AES support. AES-256 is the recommended creation mode; legacy ZipCrypto is clearly labelled weak.
|
||||
- Create deterministic unencrypted ZIP, TAR/PAX and tar.gz output from local files with sorted paths and normalized metadata. Encrypted ZIPs use fresh random salt and are intentionally not byte-reproducible.
|
||||
- Compare two archive inventories by collision-safe path, entry kind, expanded size and CRC-32, independent of container format and timestamps.
|
||||
- Download machine-readable inspection and comparison reports.
|
||||
|
||||
Encryption, split/multipart ZIPs, nested archive expansion, GNU TAR extensions, symlinks, hardlinks, devices and FIFOs are intentionally unsupported. Those entry kinds are either rejected or listed as blocked; they are never restored.
|
||||
Bounded GNU TAR long-name and long-link records and concatenated gzip members are supported. For 7z, the start-header offsets/sizes and both CRC-32 fields are validated; a plain FilesInfo header can expose names and empty-file/directory markers, while encoded headers are reported without decoding. For RAR4/RAR5, block framing and header CRCs are validated and plaintext file headers expose names, sizes, compression method identifiers, encryption and split-volume flags. Encrypted headers stop inspection.
|
||||
|
||||
Split/multipart ZIPs, nested archive expansion, GNU sparse files, symlinks, hardlinks, devices and FIFOs remain unsupported for restoration. 7z/RAR codec chains, solid dictionaries, passwords, recovery data, decompression and extraction are explicitly unsupported; their inventories are evidence, not proof that packed file data is intact.
|
||||
|
||||
The application treats every imported file as untrusted, applies explicit count/path/expanded-byte/compression-ratio limits, and never executes imported active content. See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) and [docs/PRIVACY-SECURITY.md](docs/PRIVACY-SECURITY.md).
|
||||
|
||||
@@ -30,6 +38,10 @@ The application treats every imported file as untrusted, applies explicit count/
|
||||
| Compression ratio | 200:1 |
|
||||
| Path | 4,096 UTF-8 bytes / 64 segments |
|
||||
| Creation | 5,000 files / 512 MiB |
|
||||
| Concatenated gzip members | 256 |
|
||||
| Password | 1,024 UTF-8 bytes |
|
||||
| One 7z/RAR metadata header | 16 MiB |
|
||||
| RAR header blocks | 40,000 |
|
||||
| Text / hex / image preview | 2 MiB / 128 KiB / 24 MiB |
|
||||
|
||||
These are application-level ceilings, not a promise that every device can comfortably process files near the maximum.
|
||||
@@ -37,7 +49,7 @@ These are application-level ceilings, not a promise that every device can comfor
|
||||
## Using the workspaces
|
||||
|
||||
1. **Inspect & extract** opens one archive, displays its safety inventory and previews eligible files. Select safe regular files and choose **Verify & download safe ZIP** to create a fresh archive.
|
||||
2. **Create** accepts local files and produces reproducible ZIP, TAR or tar.gz output. Browser file selection exposes relative paths only when the browser supplies them.
|
||||
2. **Create** accepts local files and produces reproducible ZIP, TAR or tar.gz output, or a locally encrypted AES-256/ZipCrypto ZIP. Browser file selection exposes relative paths only when the browser supplies them.
|
||||
3. **Compare** opens two archives and reports same, changed, type-changed and one-sided entries.
|
||||
|
||||
## Development
|
||||
@@ -54,7 +66,7 @@ Runtime dependencies are exactly pinned. `npm audit` should be checked with ever
|
||||
|
||||
## Release
|
||||
|
||||
`npm run release:artifact` creates a deterministic `release/archive-tools-0.1.0.zip` and checksum sidecar.
|
||||
`npm run release:artifact` creates a deterministic `release/archive-tools-0.2.0.zip` and checksum sidecar.
|
||||
|
||||
## Licence
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Corresponding source
|
||||
|
||||
The corresponding source for Archive Tools 0.1.0 is available at:
|
||||
The corresponding source for Archive Tools 0.2.0 is available at:
|
||||
|
||||
https://git.add-ideas.de/lotobo/archive-tools/src/tag/v0.1.0
|
||||
https://git.add-ideas.de/lotobo/archive-tools/src/tag/v0.2.0
|
||||
|
||||
Build with Node.js 22, npm 11, `npm ci`, and `npm run release:artifact`.
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
Archive Tools is GPL-3.0-or-later. Its runtime dependencies retain their own licences:
|
||||
|
||||
- `@add-ideas/toolbox-contract` 0.2.3 — Apache-2.0
|
||||
- `@add-ideas/toolbox-shell-react` 0.2.3 — Apache-2.0
|
||||
- `@add-ideas/toolbox-contract` 0.3.0 — Apache-2.0
|
||||
- `@add-ideas/toolbox-shell-react` 0.3.0 — Apache-2.0
|
||||
- `@zip.js/zip.js` 2.9.0 — BSD-3-Clause
|
||||
- `fflate` 0.8.3 — MIT
|
||||
- `react` and `react-dom` 19.2.8 — MIT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Accessibility
|
||||
|
||||
The workbench uses semantic landmarks, heading order, labelled native file/search/select controls and real tables with row/column headers. Workspace tabs expose their selected state. Every inventory checkbox includes the corresponding path in its accessible name; blocked controls are disabled rather than visually implied.
|
||||
The workbench uses semantic landmarks, heading order, labelled native file/search/select controls and real tables with row/column headers. Workspace view buttons expose their pressed state. Every inventory checkbox includes the corresponding path in its accessible name; blocked controls are disabled rather than visually implied.
|
||||
|
||||
Status and parser errors use live `status` and `alert` roles. Safety and comparison states include text and do not rely on colour. Preview images receive entry-derived alternative text; textual and hexadecimal previews remain selectable and scrollable.
|
||||
|
||||
|
||||
+20
-6
@@ -5,9 +5,23 @@ Archive Tools is a relocatable static React application. It has no backend, pers
|
||||
## Layers
|
||||
|
||||
- `src/archive/paths.ts` owns cross-platform path assessment and collision keys. It rejects traversal, absolute/drive/UNC paths, controls, ambiguous segments, Windows devices, alternate streams and excessive depth/length.
|
||||
- `src/archive/zip.ts` uses exactly pinned `@zip.js/zip.js` for ZIP/ZIP64 inventory, CRC-checked reads and deterministic writing. Listing uses bounded entry iteration. Content reads request strict local/central-header agreement, CRC-32 validation and overlapping-entry checks.
|
||||
- `src/archive/tar.ts` is a checked-offset TAR/USTAR/PAX reader and deterministic writer. Every header checksum is validated. PAX metadata is capped before UTF-8 decoding.
|
||||
- `src/archive/gzip.ts` streams compressed input through fflate in small chunks, stops at the expanded-byte ceiling and independently checks the single-member CRC-32 and ISIZE footer. Concatenated members are unsupported.
|
||||
- `src/archive/zip.ts` uses exactly pinned `@zip.js/zip.js` for ZIP/ZIP64 inventory, CRC/authentication-checked ZipCrypto and WinZip AES reads, and deterministic unencrypted writing. Listing uses bounded entry iteration. Content reads request strict local/central-header agreement and overlapping-entry checks. Passwords are caller-owned strings held only in component memory.
|
||||
- `src/archive/tar.ts` is a checked-offset TAR/USTAR/PAX reader and deterministic writer. Every header checksum is validated. PAX and GNU long-name/long-link metadata are capped before strict UTF-8 decoding; links remain inventory-only.
|
||||
- `src/archive/gzip.ts` uses the shared bounded byte cursor for headers and
|
||||
footers, streams compressed input through fflate in small chunks, updates the
|
||||
shared incremental CRC-32 state as output arrives, stops at the expanded-byte
|
||||
ceiling and checks every member's CRC-32 and ISIZE footer independently.
|
||||
Concatenation is capped at 256 members and exposed in inspection diagnostics.
|
||||
- `src/archive/sevenzip.ts` is a structural parser, not a decompressor. It
|
||||
validates the 7z signature, safe start-header arithmetic and both header
|
||||
CRC-32 values. It distinguishes empty, plain and encoded next headers. For a
|
||||
bounded plain Header it walks StreamsInfo framing and accepts only bounded,
|
||||
inline FilesInfo names and empty-entry maps; codec streams are never opened.
|
||||
- `src/archive/rar.ts` walks RAR4/RAR5 headers using Blob slices, so packed data
|
||||
is skipped rather than retained. It validates every accepted block-header
|
||||
CRC, checked header/data ranges, required main/end framing and bounded counts.
|
||||
Plaintext file headers provide inventory evidence. Header encryption stops
|
||||
the walk and all RAR entries remain non-extractable.
|
||||
- `src/archive/service.ts` detects formats, applies aggregate policies and exposes inspection, reading, safe repackaging, creation and reports.
|
||||
- `src/archive/preview.ts` recognizes only bounded plain text, bytes and static raster images. Nested archives are never recursively expanded.
|
||||
- `src/archive/compare.ts` compares normalized inventories without interpreting content.
|
||||
@@ -15,14 +29,14 @@ Archive Tools is a relocatable static React application. It has no backend, pers
|
||||
|
||||
## Data flow
|
||||
|
||||
Inspection checks the source size and format before parsing. ZIP inventory reads only archive metadata. TAR and gzip inputs are held in memory only after the source ceiling is satisfied and gzip expansion is stopped at its output ceiling. TAR/gzip payloads remain in the current React document solely to support later previews and selection; replacing the document releases those references.
|
||||
Inspection checks the source size and format before parsing. ZIP inventory reads only archive metadata. 7z reads only its fixed start header and bounded next header; RAR reads bounded headers through Blob slices and seeks over packed data. TAR and gzip inputs are held in memory only after the source ceiling is satisfied and gzip expansion is stopped at its output ceiling. TAR/gzip payloads remain in the current React document solely to support later previews and selection; replacing the document releases those references.
|
||||
|
||||
Preview and extraction never write source paths to the local filesystem. A selected entry is decoded into a bounded in-memory buffer, verified, and passed to a new deterministic ZIP writer using its already-assessed normalized path.
|
||||
|
||||
## Determinism
|
||||
|
||||
Creation sorts normalized paths by code-unit order. ZIP uses zip.js's bundled DEFLATE implementation at level 6 with native compression streams and workers disabled, fixed DOS dates, normalized regular-file modes, no extended timestamps and no data descriptors. TAR uses zero timestamps/IDs, regular mode `0644`, USTAR when possible and deterministic PAX path headers otherwise. gzip uses level 6 and mtime zero.
|
||||
Creation sorts normalized paths by code-unit order. Unencrypted ZIP uses zip.js's bundled DEFLATE implementation at level 6 with native compression streams and workers disabled, fixed DOS dates, normalized regular-file modes, no extended timestamps and no data descriptors. AES/ZipCrypto output necessarily uses fresh random encryption material and is not byte-deterministic. TAR uses zero timestamps/IDs, regular mode `0644`, USTAR when possible and deterministic PAX path headers otherwise. gzip uses level 6 and mtime zero.
|
||||
|
||||
## Memory model
|
||||
|
||||
The parser refuses unsafe declared sizes before entry decompression. A bounded writable collects ZIP output and stops when actual output crosses the operation ceiling. gzip is pushed in 32 KiB source chunks and output is counted before retention. Creation and TAR parsing are deliberately capped because they currently use in-memory output/payloads.
|
||||
The parser refuses unsafe declared sizes before entry decompression. 7z/RAR offsets use safe checked addition, individual metadata headers are capped at 16 MiB and RAR walks at most 40,000 blocks. A bounded writable collects ZIP output and stops when actual output crosses the operation ceiling. gzip is pushed in 32 KiB source chunks and output is counted before retention. Creation and TAR parsing are deliberately capped because they currently use in-memory output/payloads.
|
||||
|
||||
@@ -14,14 +14,18 @@ Archive Tools responds as follows:
|
||||
- byte arithmetic uses checked safe integers and bounds before slicing;
|
||||
- extraction never targets the filesystem: eligible content is verified and repackaged into a newly created ZIP;
|
||||
- ZIP content reads enable CRC-32, strict local/central agreement and overlapping-entry checks;
|
||||
- every TAR header checksum is verified, PAX metadata is bounded and GNU long-name extensions are refused;
|
||||
- gzip output is counted during streaming and its CRC-32/ISIZE footer is independently verified;
|
||||
- every TAR header checksum is verified; PAX and GNU long-name/link metadata are bounded and decoded strictly;
|
||||
- gzip output and member count are bounded during streaming and every member's CRC-32/ISIZE footer is independently verified;
|
||||
- path collision keys are Unicode-normalized and conservative across case-insensitive platforms;
|
||||
- symlinks, hardlinks, devices, FIFOs and unknown types are never restored;
|
||||
- imported text is rendered as text, and HTML/SVG are not mounted as documents;
|
||||
- raster images must pass byte/dimension/pixel/static checks before a browser decoder sees their Blob URL;
|
||||
- nested archives are shown as bytes and never recursively opened;
|
||||
- encrypted and multipart ZIP data is unsupported, with no password collection.
|
||||
- ZipCrypto and WinZip AES entries require an explicit memory-only password; CRC-32 (where present) and AES authentication codes are checked. ZipCrypto is labelled cryptographically weak;
|
||||
- multipart ZIP plus 7z/RAR decompression and extraction remain explicitly
|
||||
unsupported. Bounded 7z/RAR structural inspection validates container/header
|
||||
CRC evidence and inventories safe plaintext metadata only; encrypted or
|
||||
encoded headers are not decrypted.
|
||||
|
||||
## Limits
|
||||
|
||||
|
||||
Generated
+24
-16
@@ -1,23 +1,24 @@
|
||||
{
|
||||
"name": "archive-tools",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "archive-tools",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@add-ideas/toolbox-contract": "0.2.3",
|
||||
"@add-ideas/toolbox-shell-react": "0.2.3",
|
||||
"@add-ideas/toolbox-contract": "0.3.0",
|
||||
"@add-ideas/toolbox-helpers": "0.2.0",
|
||||
"@add-ideas/toolbox-shell-react": "0.3.0",
|
||||
"@zip.js/zip.js": "2.9.0",
|
||||
"fflate": "0.8.3",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@add-ideas/toolbox-testkit": "0.2.3",
|
||||
"@add-ideas/toolbox-testkit": "0.3.0",
|
||||
"@eslint/js": "10.0.1",
|
||||
"@playwright/test": "1.62.1",
|
||||
"@testing-library/jest-dom": "6.9.1",
|
||||
@@ -43,18 +44,25 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@add-ideas/toolbox-contract": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://git.add-ideas.de/api/packages/lotobo/npm/%40add-ideas%2Ftoolbox-contract/-/0.2.3/toolbox-contract-0.2.3.tgz",
|
||||
"integrity": "sha512-T0PVSuMT40GjTDfQJhEEY3ZawQq8zz1/ry95JdKI6W39CdLacaRXdGnEpDCMHt+jUbf1Jz7Nat/M5dFCgKVM9A==",
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://git.add-ideas.de/api/packages/lotobo/npm/%40add-ideas%2Ftoolbox-contract/-/0.3.0/toolbox-contract-0.3.0.tgz",
|
||||
"integrity": "sha512-dKrK7BjOFwqJaBfJuhKxZKIld4sH0AKjEn6a0yLnbdMUFY+fFv4VSLGV2tNSBD016gumc2iNqOjUj/ld7x4rtA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@add-ideas/toolbox-helpers": {
|
||||
"version": "0.2.0",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@add-ideas/toolbox-shell-react": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://git.add-ideas.de/api/packages/lotobo/npm/%40add-ideas%2Ftoolbox-shell-react/-/0.2.3/toolbox-shell-react-0.2.3.tgz",
|
||||
"integrity": "sha512-DT5lQDH48BFkFcmFLZnQh7+Cm73JzBPcmp5WzUXypfkUXpEyDYHzaXgmW4kZ0edSwh4RK4sPmx+JPtK0X4aKCQ==",
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://git.add-ideas.de/api/packages/lotobo/npm/%40add-ideas%2Ftoolbox-shell-react/-/0.3.0/toolbox-shell-react-0.3.0.tgz",
|
||||
"integrity": "sha512-74p6JzAOG0YCAKdlc1hLofV4ZIko7vb448S75cIiM88PKm93EHl5VD7g8YVyfM56Ui97UY9dmy+Whiq4sGzpsg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@add-ideas/toolbox-contract": "0.2.3"
|
||||
"@add-ideas/toolbox-contract": "0.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18 <20",
|
||||
@@ -62,13 +70,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@add-ideas/toolbox-testkit": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://git.add-ideas.de/api/packages/lotobo/npm/%40add-ideas%2Ftoolbox-testkit/-/0.2.3/toolbox-testkit-0.2.3.tgz",
|
||||
"integrity": "sha512-sq1MwhKWfFKen+N+124hl74qQimRSvmQ9sOU7jdcI+2qCKZ67+2B8rWyezeV80uTFu4Jv6deHksfYQ/tKNV6XQ==",
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://git.add-ideas.de/api/packages/lotobo/npm/%40add-ideas%2Ftoolbox-testkit/-/0.3.0/toolbox-testkit-0.3.0.tgz",
|
||||
"integrity": "sha512-4Fk+oSvZFspOMIXr8Xy040nhAaBsIQAzsGyXWSpjn3+k3yBKq7nB1r5zCHhsXzfdLzvPDAx2KcmSNOhM330D9w==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@add-ideas/toolbox-contract": "0.2.3"
|
||||
"@add-ideas/toolbox-contract": "0.3.0"
|
||||
},
|
||||
"bin": {
|
||||
"toolbox-check": "dist/cli.js"
|
||||
|
||||
+6
-5
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "archive-tools",
|
||||
"version": "0.1.0",
|
||||
"description": "Inspect, create, compare and safely extract archives locally.",
|
||||
"version": "0.2.0",
|
||||
"description": "Inspect, create, compare and safely repackage archives locally, including structural 7z/RAR evidence.",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"author": "Albrecht Degering",
|
||||
"repository": {
|
||||
@@ -39,15 +39,16 @@
|
||||
"release:artifact": "npm run check && npm run test:browser && npm run package:release -- --force"
|
||||
},
|
||||
"dependencies": {
|
||||
"@add-ideas/toolbox-contract": "0.2.3",
|
||||
"@add-ideas/toolbox-shell-react": "0.2.3",
|
||||
"@add-ideas/toolbox-contract": "0.3.0",
|
||||
"@add-ideas/toolbox-helpers": "0.2.0",
|
||||
"@add-ideas/toolbox-shell-react": "0.3.0",
|
||||
"@zip.js/zip.js": "2.9.0",
|
||||
"fflate": "0.8.3",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@add-ideas/toolbox-testkit": "0.2.3",
|
||||
"@add-ideas/toolbox-testkit": "0.3.0",
|
||||
"@eslint/js": "10.0.1",
|
||||
"@playwright/test": "1.62.1",
|
||||
"@testing-library/jest-dom": "6.9.1",
|
||||
|
||||
+20
-2
@@ -15,7 +15,25 @@ export default defineConfig({
|
||||
timeout: 180_000,
|
||||
},
|
||||
projects: [
|
||||
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
|
||||
{ name: "firefox", use: { ...devices["Desktop Firefox"] } },
|
||||
{
|
||||
name: "chromium",
|
||||
testIgnore: /responsive\.spec\.ts/,
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
{
|
||||
name: "firefox",
|
||||
testIgnore: /responsive\.spec\.ts/,
|
||||
use: { ...devices["Desktop Firefox"] },
|
||||
},
|
||||
{
|
||||
name: "webkit",
|
||||
testIgnore: /responsive\.spec\.ts/,
|
||||
use: { ...devices["Desktop Safari"] },
|
||||
},
|
||||
{
|
||||
name: "mobile-chromium",
|
||||
testMatch: /responsive\.spec\.ts/,
|
||||
use: { ...devices["Pixel 5"] },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## 0.2.0 - 2026-09-02
|
||||
|
||||
- Adopted shared byte-size, portable filename, Blob download, typed byte-cursor
|
||||
and CRC helpers from `@add-ideas/toolbox-helpers` 0.2.0.
|
||||
- Changed bounded gzip verification to update CRC-32 incrementally while output
|
||||
chunks are produced, avoiding a second full pass over expanded data.
|
||||
- Added bounded GNU TAR long-name/long-link metadata and independently verified
|
||||
concatenated gzip members.
|
||||
- Added local AES-256 and legacy ZipCrypto ZIP creation/readback with
|
||||
memory-only passwords and generic wrong-password/integrity errors.
|
||||
- Added bounded structural 7z inspection with validated signature, start-header
|
||||
offsets/sizes, independent CRC-32 checks, encoded/plain next-header evidence,
|
||||
and safe plain FilesInfo name/empty-entry inventory where available.
|
||||
- Added bounded RAR4/RAR5 block framing and header-CRC validation with plaintext
|
||||
file-header inventory for names, sizes, compression, encryption and split
|
||||
flags. Encrypted headers stop inspection; RAR/7z decompression and extraction
|
||||
remain explicitly unsupported.
|
||||
|
||||
## 0.1.0 - 2026-09-01
|
||||
|
||||
- Added the initial local-first Archive Tools workbench.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
==============================================================================
|
||||
@add-ideas/toolbox-contract@0.2.3
|
||||
@add-ideas/toolbox-contract@0.3.0
|
||||
Declared licence: Apache-2.0
|
||||
==============================================================================
|
||||
--- LICENSE ---
|
||||
@@ -198,7 +198,688 @@ Declared licence: Apache-2.0
|
||||
|
||||
|
||||
==============================================================================
|
||||
@add-ideas/toolbox-shell-react@0.2.3
|
||||
@add-ideas/toolbox-helpers@0.2.0
|
||||
Declared licence: GPL-3.0-or-later
|
||||
==============================================================================
|
||||
--- LICENSE ---
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
||||
|
||||
==============================================================================
|
||||
@add-ideas/toolbox-shell-react@0.3.0
|
||||
Declared licence: Apache-2.0
|
||||
==============================================================================
|
||||
--- LICENSE ---
|
||||
|
||||
+16
-4
@@ -6,15 +6,23 @@ Archive Tools is a standalone local-first application in the [add·ideas Toolbox
|
||||
|
||||
## Version 0.1 scope
|
||||
|
||||
Binary reads use checked offset arithmetic and bounded cursors. gzip CRC-32 is
|
||||
updated incrementally during decompression; temporary previews and downloads
|
||||
use explicitly revoked shared Blob URL leases.
|
||||
|
||||
- Inspect ZIP and ZIP64 central directories, TAR/USTAR/PAX archives, gzip streams and tar.gz archives.
|
||||
- Structurally inspect 7z start/next headers and RAR4/RAR5 plaintext headers under fixed header/count bounds. Header CRCs are checked before metadata is accepted; entry content is never decoded.
|
||||
- List normalized paths, kinds, sizes, compression, timestamps, ZIP64 state, CRC-32 values and policy diagnostics.
|
||||
- Preview bounded UTF-8 text, hexadecimal bytes and static JPEG/PNG/WebP images. HTML and SVG are shown as text, never rendered as active content.
|
||||
- Select regular safe files, verify their bytes and CRC where available, and repackage them into a newly created ZIP. Archive paths are never restored directly to a filesystem.
|
||||
- Create deterministic ZIP, TAR/PAX and tar.gz output from local files with sorted paths and normalized metadata.
|
||||
- Read and create password-protected ZIP entries with local ZipCrypto or WinZip AES support. AES-256 is the recommended creation mode; legacy ZipCrypto is clearly labelled weak.
|
||||
- Create deterministic unencrypted ZIP, TAR/PAX and tar.gz output from local files with sorted paths and normalized metadata. Encrypted ZIPs use fresh random salt and are intentionally not byte-reproducible.
|
||||
- Compare two archive inventories by collision-safe path, entry kind, expanded size and CRC-32, independent of container format and timestamps.
|
||||
- Download machine-readable inspection and comparison reports.
|
||||
|
||||
Encryption, split/multipart ZIPs, nested archive expansion, GNU TAR extensions, symlinks, hardlinks, devices and FIFOs are intentionally unsupported. Those entry kinds are either rejected or listed as blocked; they are never restored.
|
||||
Bounded GNU TAR long-name and long-link records and concatenated gzip members are supported. For 7z, the start-header offsets/sizes and both CRC-32 fields are validated; a plain FilesInfo header can expose names and empty-file/directory markers, while encoded headers are reported without decoding. For RAR4/RAR5, block framing and header CRCs are validated and plaintext file headers expose names, sizes, compression method identifiers, encryption and split-volume flags. Encrypted headers stop inspection.
|
||||
|
||||
Split/multipart ZIPs, nested archive expansion, GNU sparse files, symlinks, hardlinks, devices and FIFOs remain unsupported for restoration. 7z/RAR codec chains, solid dictionaries, passwords, recovery data, decompression and extraction are explicitly unsupported; their inventories are evidence, not proof that packed file data is intact.
|
||||
|
||||
The application treats every imported file as untrusted, applies explicit count/path/expanded-byte/compression-ratio limits, and never executes imported active content. See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) and [docs/PRIVACY-SECURITY.md](docs/PRIVACY-SECURITY.md).
|
||||
|
||||
@@ -30,6 +38,10 @@ The application treats every imported file as untrusted, applies explicit count/
|
||||
| Compression ratio | 200:1 |
|
||||
| Path | 4,096 UTF-8 bytes / 64 segments |
|
||||
| Creation | 5,000 files / 512 MiB |
|
||||
| Concatenated gzip members | 256 |
|
||||
| Password | 1,024 UTF-8 bytes |
|
||||
| One 7z/RAR metadata header | 16 MiB |
|
||||
| RAR header blocks | 40,000 |
|
||||
| Text / hex / image preview | 2 MiB / 128 KiB / 24 MiB |
|
||||
|
||||
These are application-level ceilings, not a promise that every device can comfortably process files near the maximum.
|
||||
@@ -37,7 +49,7 @@ These are application-level ceilings, not a promise that every device can comfor
|
||||
## Using the workspaces
|
||||
|
||||
1. **Inspect & extract** opens one archive, displays its safety inventory and previews eligible files. Select safe regular files and choose **Verify & download safe ZIP** to create a fresh archive.
|
||||
2. **Create** accepts local files and produces reproducible ZIP, TAR or tar.gz output. Browser file selection exposes relative paths only when the browser supplies them.
|
||||
2. **Create** accepts local files and produces reproducible ZIP, TAR or tar.gz output, or a locally encrypted AES-256/ZipCrypto ZIP. Browser file selection exposes relative paths only when the browser supplies them.
|
||||
3. **Compare** opens two archives and reports same, changed, type-changed and one-sided entries.
|
||||
|
||||
## Development
|
||||
@@ -54,7 +66,7 @@ Runtime dependencies are exactly pinned. `npm audit` should be checked with ever
|
||||
|
||||
## Release
|
||||
|
||||
`npm run release:artifact` creates a deterministic `release/archive-tools-0.1.0.zip` and checksum sidecar.
|
||||
`npm run release:artifact` creates a deterministic `release/archive-tools-0.2.0.zip` and checksum sidecar.
|
||||
|
||||
## Licence
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
# Corresponding source
|
||||
|
||||
The corresponding source for Archive Tools 0.1.0 is available at:
|
||||
The corresponding source for Archive Tools 0.2.0 is available at:
|
||||
|
||||
https://git.add-ideas.de/lotobo/archive-tools/src/tag/v0.1.0
|
||||
https://git.add-ideas.de/lotobo/archive-tools/src/tag/v0.2.0
|
||||
|
||||
Build with Node.js 22, npm 11, `npm ci`, and `npm run release:artifact`.
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
Archive Tools is GPL-3.0-or-later. Its runtime dependencies retain their own licences:
|
||||
|
||||
- `@add-ideas/toolbox-contract` 0.2.3 — Apache-2.0
|
||||
- `@add-ideas/toolbox-shell-react` 0.2.3 — Apache-2.0
|
||||
- `@add-ideas/toolbox-contract` 0.3.0 — Apache-2.0
|
||||
- `@add-ideas/toolbox-shell-react` 0.3.0 — Apache-2.0
|
||||
- `@zip.js/zip.js` 2.9.0 — BSD-3-Clause
|
||||
- `fflate` 0.8.3 — MIT
|
||||
- `react` and `react-dom` 19.2.8 — MIT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Accessibility
|
||||
|
||||
The workbench uses semantic landmarks, heading order, labelled native file/search/select controls and real tables with row/column headers. Workspace tabs expose their selected state. Every inventory checkbox includes the corresponding path in its accessible name; blocked controls are disabled rather than visually implied.
|
||||
The workbench uses semantic landmarks, heading order, labelled native file/search/select controls and real tables with row/column headers. Workspace view buttons expose their pressed state. Every inventory checkbox includes the corresponding path in its accessible name; blocked controls are disabled rather than visually implied.
|
||||
|
||||
Status and parser errors use live `status` and `alert` roles. Safety and comparison states include text and do not rely on colour. Preview images receive entry-derived alternative text; textual and hexadecimal previews remain selectable and scrollable.
|
||||
|
||||
|
||||
@@ -5,9 +5,23 @@ Archive Tools is a relocatable static React application. It has no backend, pers
|
||||
## Layers
|
||||
|
||||
- `src/archive/paths.ts` owns cross-platform path assessment and collision keys. It rejects traversal, absolute/drive/UNC paths, controls, ambiguous segments, Windows devices, alternate streams and excessive depth/length.
|
||||
- `src/archive/zip.ts` uses exactly pinned `@zip.js/zip.js` for ZIP/ZIP64 inventory, CRC-checked reads and deterministic writing. Listing uses bounded entry iteration. Content reads request strict local/central-header agreement, CRC-32 validation and overlapping-entry checks.
|
||||
- `src/archive/tar.ts` is a checked-offset TAR/USTAR/PAX reader and deterministic writer. Every header checksum is validated. PAX metadata is capped before UTF-8 decoding.
|
||||
- `src/archive/gzip.ts` streams compressed input through fflate in small chunks, stops at the expanded-byte ceiling and independently checks the single-member CRC-32 and ISIZE footer. Concatenated members are unsupported.
|
||||
- `src/archive/zip.ts` uses exactly pinned `@zip.js/zip.js` for ZIP/ZIP64 inventory, CRC/authentication-checked ZipCrypto and WinZip AES reads, and deterministic unencrypted writing. Listing uses bounded entry iteration. Content reads request strict local/central-header agreement and overlapping-entry checks. Passwords are caller-owned strings held only in component memory.
|
||||
- `src/archive/tar.ts` is a checked-offset TAR/USTAR/PAX reader and deterministic writer. Every header checksum is validated. PAX and GNU long-name/long-link metadata are capped before strict UTF-8 decoding; links remain inventory-only.
|
||||
- `src/archive/gzip.ts` uses the shared bounded byte cursor for headers and
|
||||
footers, streams compressed input through fflate in small chunks, updates the
|
||||
shared incremental CRC-32 state as output arrives, stops at the expanded-byte
|
||||
ceiling and checks every member's CRC-32 and ISIZE footer independently.
|
||||
Concatenation is capped at 256 members and exposed in inspection diagnostics.
|
||||
- `src/archive/sevenzip.ts` is a structural parser, not a decompressor. It
|
||||
validates the 7z signature, safe start-header arithmetic and both header
|
||||
CRC-32 values. It distinguishes empty, plain and encoded next headers. For a
|
||||
bounded plain Header it walks StreamsInfo framing and accepts only bounded,
|
||||
inline FilesInfo names and empty-entry maps; codec streams are never opened.
|
||||
- `src/archive/rar.ts` walks RAR4/RAR5 headers using Blob slices, so packed data
|
||||
is skipped rather than retained. It validates every accepted block-header
|
||||
CRC, checked header/data ranges, required main/end framing and bounded counts.
|
||||
Plaintext file headers provide inventory evidence. Header encryption stops
|
||||
the walk and all RAR entries remain non-extractable.
|
||||
- `src/archive/service.ts` detects formats, applies aggregate policies and exposes inspection, reading, safe repackaging, creation and reports.
|
||||
- `src/archive/preview.ts` recognizes only bounded plain text, bytes and static raster images. Nested archives are never recursively expanded.
|
||||
- `src/archive/compare.ts` compares normalized inventories without interpreting content.
|
||||
@@ -15,14 +29,14 @@ Archive Tools is a relocatable static React application. It has no backend, pers
|
||||
|
||||
## Data flow
|
||||
|
||||
Inspection checks the source size and format before parsing. ZIP inventory reads only archive metadata. TAR and gzip inputs are held in memory only after the source ceiling is satisfied and gzip expansion is stopped at its output ceiling. TAR/gzip payloads remain in the current React document solely to support later previews and selection; replacing the document releases those references.
|
||||
Inspection checks the source size and format before parsing. ZIP inventory reads only archive metadata. 7z reads only its fixed start header and bounded next header; RAR reads bounded headers through Blob slices and seeks over packed data. TAR and gzip inputs are held in memory only after the source ceiling is satisfied and gzip expansion is stopped at its output ceiling. TAR/gzip payloads remain in the current React document solely to support later previews and selection; replacing the document releases those references.
|
||||
|
||||
Preview and extraction never write source paths to the local filesystem. A selected entry is decoded into a bounded in-memory buffer, verified, and passed to a new deterministic ZIP writer using its already-assessed normalized path.
|
||||
|
||||
## Determinism
|
||||
|
||||
Creation sorts normalized paths by code-unit order. ZIP uses zip.js's bundled DEFLATE implementation at level 6 with native compression streams and workers disabled, fixed DOS dates, normalized regular-file modes, no extended timestamps and no data descriptors. TAR uses zero timestamps/IDs, regular mode `0644`, USTAR when possible and deterministic PAX path headers otherwise. gzip uses level 6 and mtime zero.
|
||||
Creation sorts normalized paths by code-unit order. Unencrypted ZIP uses zip.js's bundled DEFLATE implementation at level 6 with native compression streams and workers disabled, fixed DOS dates, normalized regular-file modes, no extended timestamps and no data descriptors. AES/ZipCrypto output necessarily uses fresh random encryption material and is not byte-deterministic. TAR uses zero timestamps/IDs, regular mode `0644`, USTAR when possible and deterministic PAX path headers otherwise. gzip uses level 6 and mtime zero.
|
||||
|
||||
## Memory model
|
||||
|
||||
The parser refuses unsafe declared sizes before entry decompression. A bounded writable collects ZIP output and stops when actual output crosses the operation ceiling. gzip is pushed in 32 KiB source chunks and output is counted before retention. Creation and TAR parsing are deliberately capped because they currently use in-memory output/payloads.
|
||||
The parser refuses unsafe declared sizes before entry decompression. 7z/RAR offsets use safe checked addition, individual metadata headers are capped at 16 MiB and RAR walks at most 40,000 blocks. A bounded writable collects ZIP output and stops when actual output crosses the operation ceiling. gzip is pushed in 32 KiB source chunks and output is counted before retention. Creation and TAR parsing are deliberately capped because they currently use in-memory output/payloads.
|
||||
|
||||
@@ -14,14 +14,18 @@ Archive Tools responds as follows:
|
||||
- byte arithmetic uses checked safe integers and bounds before slicing;
|
||||
- extraction never targets the filesystem: eligible content is verified and repackaged into a newly created ZIP;
|
||||
- ZIP content reads enable CRC-32, strict local/central agreement and overlapping-entry checks;
|
||||
- every TAR header checksum is verified, PAX metadata is bounded and GNU long-name extensions are refused;
|
||||
- gzip output is counted during streaming and its CRC-32/ISIZE footer is independently verified;
|
||||
- every TAR header checksum is verified; PAX and GNU long-name/link metadata are bounded and decoded strictly;
|
||||
- gzip output and member count are bounded during streaming and every member's CRC-32/ISIZE footer is independently verified;
|
||||
- path collision keys are Unicode-normalized and conservative across case-insensitive platforms;
|
||||
- symlinks, hardlinks, devices, FIFOs and unknown types are never restored;
|
||||
- imported text is rendered as text, and HTML/SVG are not mounted as documents;
|
||||
- raster images must pass byte/dimension/pixel/static checks before a browser decoder sees their Blob URL;
|
||||
- nested archives are shown as bytes and never recursively opened;
|
||||
- encrypted and multipart ZIP data is unsupported, with no password collection.
|
||||
- ZipCrypto and WinZip AES entries require an explicit memory-only password; CRC-32 (where present) and AES authentication codes are checked. ZipCrypto is labelled cryptographically weak;
|
||||
- multipart ZIP plus 7z/RAR decompression and extraction remain explicitly
|
||||
unsupported. Bounded 7z/RAR structural inspection validates container/header
|
||||
CRC evidence and inventories safe plaintext metadata only; encrypted or
|
||||
encoded headers are not decrypted.
|
||||
|
||||
## Limits
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
const CACHE_PREFIX = "archive-tools-shell-";
|
||||
const CACHE_NAME = CACHE_PREFIX + "0.1.0";
|
||||
const CACHE_NAME = CACHE_PREFIX + "0.2.0";
|
||||
const CORE = ["./", "./manifest.webmanifest", "./favicon.svg"];
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(
|
||||
|
||||
+67
-4
@@ -3,12 +3,23 @@
|
||||
"schemaVersion": 1,
|
||||
"id": "de.add-ideas.archive-tools",
|
||||
"name": "Archive Tools",
|
||||
"version": "0.1.0",
|
||||
"description": "Inspect, create, compare and safely extract archives locally.",
|
||||
"version": "0.2.0",
|
||||
"description": "Inspect, create, compare and safely repackage archives locally, including structural 7z/RAR evidence.",
|
||||
"entry": "./",
|
||||
"icon": "./favicon.svg",
|
||||
"categories": ["files", "archives", "developer"],
|
||||
"tags": ["zip", "tar", "gzip", "extract", "archive"],
|
||||
"tags": [
|
||||
"zip",
|
||||
"tar",
|
||||
"gzip",
|
||||
"extract",
|
||||
"archive",
|
||||
"aes",
|
||||
"zipcrypto",
|
||||
"compare",
|
||||
"7z",
|
||||
"rar"
|
||||
],
|
||||
"integration": {
|
||||
"contextVersion": 1,
|
||||
"launchModes": ["navigate", "new-tab"],
|
||||
@@ -21,9 +32,61 @@
|
||||
"crossOriginIsolated": false,
|
||||
"topLevelContext": false
|
||||
},
|
||||
"io": {
|
||||
"accepts": [
|
||||
{
|
||||
"mediaType": "application/zip",
|
||||
"extensions": [".zip"],
|
||||
"label": "ZIP and ZIP64, including AES or ZipCrypto entries"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/x-tar",
|
||||
"extensions": [".tar"],
|
||||
"label": "TAR, USTAR and bounded PAX/GNU metadata"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/gzip",
|
||||
"extensions": [".gz", ".tgz", ".tar.gz"],
|
||||
"label": "gzip and tar.gz, including concatenated members"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/x-7z-compressed",
|
||||
"extensions": [".7z"],
|
||||
"label": "7z structural headers and safe plain metadata; decompression unsupported"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/vnd.rar",
|
||||
"extensions": [".rar"],
|
||||
"label": "RAR4/RAR5 plaintext header inventory; decompression unsupported"
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
{
|
||||
"mediaType": "application/zip",
|
||||
"extensions": [".zip"],
|
||||
"label": "ZIP, AES-256 ZIP or legacy ZipCrypto ZIP"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/x-tar",
|
||||
"extensions": [".tar"],
|
||||
"label": "Deterministic TAR/PAX"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/gzip",
|
||||
"extensions": [".tgz", ".tar.gz"],
|
||||
"label": "Deterministic tar.gz"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/json",
|
||||
"extensions": [".json"],
|
||||
"label": "Inspection and comparison reports"
|
||||
}
|
||||
]
|
||||
},
|
||||
"capabilities": { "required": [], "optional": ["web-crypto"] },
|
||||
"privacy": {
|
||||
"processing": "local",
|
||||
"fileUploads": false,
|
||||
"fileUploads": true,
|
||||
"telemetry": false,
|
||||
"label": "Inputs stay in this browser; nothing is uploaded."
|
||||
},
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
const table = (() => {
|
||||
const values = new Uint32Array(256);
|
||||
for (let index = 0; index < values.length; index += 1) {
|
||||
let value = index;
|
||||
for (let bit = 0; bit < 8; bit += 1)
|
||||
value = value & 1 ? 0xedb88320 ^ (value >>> 1) : value >>> 1;
|
||||
values[index] = value >>> 0;
|
||||
}
|
||||
return values;
|
||||
})();
|
||||
import {
|
||||
crc32 as sharedCrc32,
|
||||
formatChecksum,
|
||||
} from "@add-ideas/toolbox-helpers";
|
||||
import { ARCHIVE_LIMITS } from "./limits";
|
||||
|
||||
export function crc32(bytes: Uint8Array): number {
|
||||
let value = 0xffffffff;
|
||||
for (const byte of bytes)
|
||||
value = table[(value ^ byte) & 0xff]! ^ (value >>> 8);
|
||||
return (value ^ 0xffffffff) >>> 0;
|
||||
return sharedCrc32(bytes, ARCHIVE_LIMITS.maxExpandedBytes);
|
||||
}
|
||||
|
||||
export function crc32Hex(bytes: Uint8Array): string {
|
||||
return crc32(bytes).toString(16).padStart(8, "0");
|
||||
return formatChecksum(crc32(bytes));
|
||||
}
|
||||
|
||||
export function uint32Hex(value: number): string {
|
||||
return (value >>> 0).toString(16).padStart(8, "0");
|
||||
return formatChecksum(value >>> 0);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
import {
|
||||
sanitizeDownloadFilename,
|
||||
triggerBlobDownload,
|
||||
} from "@add-ideas/toolbox-helpers";
|
||||
|
||||
export function downloadBlob(blob: Blob, filename: string): void {
|
||||
const url = URL.createObjectURL(blob);
|
||||
try {
|
||||
const anchor = document.createElement("a");
|
||||
anchor.href = url;
|
||||
anchor.download = safeFilename(filename);
|
||||
anchor.rel = "noopener";
|
||||
anchor.click();
|
||||
} finally {
|
||||
window.setTimeout(() => URL.revokeObjectURL(url), 0);
|
||||
}
|
||||
triggerBlobDownload(blob, safeFilename(filename));
|
||||
}
|
||||
|
||||
export function safeFilename(value: string): string {
|
||||
const withoutControls = [...value]
|
||||
.map((character) => {
|
||||
const code = character.codePointAt(0)!;
|
||||
return code <= 0x1f || code === 0x7f ? "_" : character;
|
||||
})
|
||||
.join("");
|
||||
const cleaned = withoutControls
|
||||
.normalize("NFC")
|
||||
.replaceAll(/[/\\:*?"<>|]/gu, "_")
|
||||
.replaceAll(/[ .]+$/gu, "")
|
||||
.slice(0, 180);
|
||||
return cleaned || "archive-output";
|
||||
return sanitizeDownloadFilename(value, "archive-output", 180);
|
||||
}
|
||||
|
||||
export function outputStem(name: string): string {
|
||||
|
||||
+114
-54
@@ -1,63 +1,82 @@
|
||||
import { Gunzip, gzipSync } from "fflate";
|
||||
import { crc32 } from "./checksums";
|
||||
import {
|
||||
ByteCursor,
|
||||
HelperLimitError,
|
||||
createIncrementalChecksum,
|
||||
} from "@add-ideas/toolbox-helpers";
|
||||
import { ArchivePolicyError } from "./errors";
|
||||
import { throwIfAborted } from "./limits";
|
||||
import { ARCHIVE_LIMITS, throwIfAborted } from "./limits";
|
||||
|
||||
export interface GzipHeader {
|
||||
originalName?: string;
|
||||
modifiedAt?: string;
|
||||
}
|
||||
|
||||
export interface GzipMemberInfo extends GzipHeader {
|
||||
readonly index: number;
|
||||
readonly sourceOffset: number;
|
||||
readonly expandedBytes: number;
|
||||
}
|
||||
|
||||
export interface GunzipResult {
|
||||
readonly bytes: Uint8Array;
|
||||
readonly members: readonly GzipMemberInfo[];
|
||||
}
|
||||
|
||||
export function parseGzipHeader(bytes: Uint8Array): GzipHeader {
|
||||
if (bytes.length < 18) {
|
||||
throw new ArchivePolicyError(
|
||||
"INVALID_GZIP",
|
||||
"The file is not a complete DEFLATE gzip stream.",
|
||||
);
|
||||
}
|
||||
try {
|
||||
const cursor = new ByteCursor(bytes, {
|
||||
littleEndian: true,
|
||||
maximumBytes: ARCHIVE_LIMITS.maxSourceBytes,
|
||||
});
|
||||
if (
|
||||
bytes.length < 18 ||
|
||||
bytes[0] !== 0x1f ||
|
||||
bytes[1] !== 0x8b ||
|
||||
bytes[2] !== 8
|
||||
cursor.readUint8() !== 0x1f ||
|
||||
cursor.readUint8() !== 0x8b ||
|
||||
cursor.readUint8() !== 8
|
||||
) {
|
||||
throw new ArchivePolicyError(
|
||||
"INVALID_GZIP",
|
||||
"The file is not a complete DEFLATE gzip stream.",
|
||||
);
|
||||
}
|
||||
const flags = bytes[3]!;
|
||||
const flags = cursor.readUint8();
|
||||
if (flags & 0xe0)
|
||||
throw new ArchivePolicyError(
|
||||
"INVALID_GZIP",
|
||||
"The gzip header uses reserved flags.",
|
||||
);
|
||||
let offset = 10;
|
||||
if (flags & 4) {
|
||||
if (offset + 2 > bytes.length)
|
||||
throw new ArchivePolicyError(
|
||||
"TRUNCATED_GZIP",
|
||||
"The gzip extra field is truncated.",
|
||||
);
|
||||
const length = bytes[offset]! | (bytes[offset + 1]! << 8);
|
||||
offset += 2 + length;
|
||||
}
|
||||
const modifiedSeconds = cursor.readUint32();
|
||||
cursor.skip(2);
|
||||
if (flags & 4) cursor.skip(cursor.readUint16());
|
||||
let originalName: string | undefined;
|
||||
if (flags & 8) {
|
||||
const end = findZero(bytes, offset);
|
||||
originalName = decodeLatin1(bytes.subarray(offset, end));
|
||||
offset = end + 1;
|
||||
const end = findZero(bytes, cursor.offset);
|
||||
originalName = decodeLatin1(bytes.subarray(cursor.offset, end));
|
||||
cursor.seek(end + 1);
|
||||
}
|
||||
if (flags & 16) offset = findZero(bytes, offset) + 1;
|
||||
if (flags & 2) offset += 2;
|
||||
if (offset + 8 > bytes.length)
|
||||
throw new ArchivePolicyError(
|
||||
"TRUNCATED_GZIP",
|
||||
"The gzip payload is truncated.",
|
||||
);
|
||||
|
||||
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||
const modifiedSeconds = view.getUint32(4, true);
|
||||
if (flags & 16) cursor.seek(findZero(bytes, cursor.offset) + 1);
|
||||
if (flags & 2) cursor.skip(2);
|
||||
cursor.ensure(8);
|
||||
return {
|
||||
originalName,
|
||||
modifiedAt: modifiedSeconds
|
||||
? new Date(modifiedSeconds * 1000).toISOString()
|
||||
: undefined,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error instanceof ArchivePolicyError) throw error;
|
||||
if (!(error instanceof HelperLimitError)) throw error;
|
||||
throw new ArchivePolicyError(
|
||||
"TRUNCATED_GZIP",
|
||||
"The gzip header or payload is truncated.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function gunzipBounded(
|
||||
@@ -65,12 +84,57 @@ export function gunzipBounded(
|
||||
maxOutputBytes: number,
|
||||
signal?: AbortSignal,
|
||||
): Uint8Array {
|
||||
return gunzipBoundedDetailed(bytes, maxOutputBytes, signal).bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode every RFC 1952 member, enforcing one aggregate output budget and
|
||||
* validating the CRC-32/ISIZE footer of each member independently.
|
||||
*/
|
||||
export function gunzipBoundedDetailed(
|
||||
bytes: Uint8Array,
|
||||
maxOutputBytes: number,
|
||||
signal?: AbortSignal,
|
||||
): GunzipResult {
|
||||
throwIfAborted(signal);
|
||||
parseGzipHeader(bytes);
|
||||
const firstHeader = parseGzipHeader(bytes);
|
||||
const chunks: Uint8Array[] = [];
|
||||
const members: GzipMemberInfo[] = [];
|
||||
let total = 0;
|
||||
let memberBytes = 0;
|
||||
let memberOffset = 0;
|
||||
let memberHeader = firstHeader;
|
||||
let checksum = createIncrementalChecksum("CRC-32", maxOutputBytes);
|
||||
let completed = false;
|
||||
let callbackError: unknown;
|
||||
|
||||
const finishMember = (endOffset: number) => {
|
||||
if (endOffset < memberOffset + 8 || endOffset > bytes.byteLength)
|
||||
throw new ArchivePolicyError(
|
||||
"TRUNCATED_GZIP",
|
||||
"A gzip member has no complete integrity footer.",
|
||||
);
|
||||
const footer = new ByteCursor(bytes, {
|
||||
byteOffset: endOffset - 8,
|
||||
byteLength: 8,
|
||||
littleEndian: true,
|
||||
maximumBytes: ARCHIVE_LIMITS.maxSourceBytes,
|
||||
});
|
||||
const expectedCrc = footer.readUint32();
|
||||
const expectedSize = footer.readUint32();
|
||||
if (checksum.digest() !== expectedCrc || memberBytes >>> 0 !== expectedSize)
|
||||
throw new ArchivePolicyError(
|
||||
"GZIP_INTEGRITY",
|
||||
`gzip member ${members.length + 1} has a CRC-32 or size mismatch.`,
|
||||
);
|
||||
members.push({
|
||||
...memberHeader,
|
||||
index: members.length,
|
||||
sourceOffset: memberOffset,
|
||||
expandedBytes: memberBytes,
|
||||
});
|
||||
};
|
||||
|
||||
const gunzip = new Gunzip((chunk, final) => {
|
||||
try {
|
||||
throwIfAborted(signal);
|
||||
@@ -81,6 +145,8 @@ export function gunzipBounded(
|
||||
"gzip output exceeds the expanded-byte safety limit.",
|
||||
);
|
||||
}
|
||||
checksum.update(chunk);
|
||||
memberBytes += chunk.byteLength;
|
||||
chunks.push(chunk.slice());
|
||||
completed = final;
|
||||
} catch (error) {
|
||||
@@ -88,12 +154,22 @@ export function gunzipBounded(
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
gunzip.onmember = () => {
|
||||
callbackError = new ArchivePolicyError(
|
||||
"MULTI_MEMBER_GZIP",
|
||||
"Concatenated multi-member gzip streams are unsupported.",
|
||||
gunzip.onmember = (offset) => {
|
||||
try {
|
||||
if (members.length + 1 >= ARCHIVE_LIMITS.maxGzipMembers)
|
||||
throw new ArchivePolicyError(
|
||||
"GZIP_MEMBER_LIMIT",
|
||||
`gzip contains more than ${ARCHIVE_LIMITS.maxGzipMembers} members.`,
|
||||
);
|
||||
throw callbackError;
|
||||
finishMember(offset);
|
||||
memberOffset = offset;
|
||||
memberHeader = parseGzipHeader(bytes.subarray(offset));
|
||||
memberBytes = 0;
|
||||
checksum = createIncrementalChecksum("CRC-32", maxOutputBytes);
|
||||
} catch (error) {
|
||||
callbackError = error;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const inputChunk = 32 * 1024;
|
||||
@@ -114,24 +190,8 @@ export function gunzipBounded(
|
||||
"gzip stream did not finish cleanly.",
|
||||
);
|
||||
|
||||
const output = concatenate(chunks, total);
|
||||
const footer = new DataView(
|
||||
bytes.buffer,
|
||||
bytes.byteOffset + bytes.byteLength - 8,
|
||||
8,
|
||||
);
|
||||
const expectedCrc = footer.getUint32(0, true);
|
||||
const expectedSize = footer.getUint32(4, true);
|
||||
if (
|
||||
crc32(output) !== expectedCrc ||
|
||||
output.byteLength >>> 0 !== expectedSize
|
||||
) {
|
||||
throw new ArchivePolicyError(
|
||||
"GZIP_INTEGRITY",
|
||||
"gzip CRC-32 or size footer does not match. Concatenated gzip members are intentionally unsupported.",
|
||||
);
|
||||
}
|
||||
return output;
|
||||
finishMember(bytes.byteLength);
|
||||
return { bytes: concatenate(chunks, total), members };
|
||||
}
|
||||
|
||||
export function gzipDeterministic(bytes: Uint8Array): Uint8Array {
|
||||
|
||||
+6
-11
@@ -1,3 +1,4 @@
|
||||
import { formatBytes } from "@add-ideas/toolbox-helpers";
|
||||
import { ArchivePolicyError } from "./errors";
|
||||
|
||||
export const ARCHIVE_LIMITS = Object.freeze({
|
||||
@@ -18,6 +19,10 @@ export const ARCHIVE_LIMITS = Object.freeze({
|
||||
maxCreateFiles: 5_000,
|
||||
maxCreateBytes: 512 * 1024 * 1024,
|
||||
maxPaxHeaderBytes: 1024 * 1024,
|
||||
maxGzipMembers: 256,
|
||||
maxPasswordBytes: 1_024,
|
||||
maxStructuralHeaderBytes: 16 * 1024 * 1024,
|
||||
maxArchiveHeaderBlocks: 40_000,
|
||||
});
|
||||
|
||||
export function assertFiniteSafeInteger(value: number, label: string): void {
|
||||
@@ -38,17 +43,7 @@ export function assertSourceSize(file: Blob): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (!Number.isFinite(bytes)) return "unknown";
|
||||
const units = ["B", "KiB", "MiB", "GiB"];
|
||||
let value = Math.max(0, bytes);
|
||||
let unit = 0;
|
||||
while (value >= 1024 && unit < units.length - 1) {
|
||||
value /= 1024;
|
||||
unit += 1;
|
||||
}
|
||||
return `${value >= 10 || unit === 0 ? value.toFixed(0) : value.toFixed(1)} ${units[unit]}`;
|
||||
}
|
||||
export { formatBytes };
|
||||
|
||||
export function throwIfAborted(signal?: AbortSignal): void {
|
||||
if (signal?.aborted) {
|
||||
|
||||
@@ -40,6 +40,7 @@ export async function previewEntry(
|
||||
document: ArchiveDocument,
|
||||
entry: ArchiveEntryRecord,
|
||||
signal?: AbortSignal,
|
||||
password?: string,
|
||||
): Promise<PreviewResult> {
|
||||
if (entry.kind !== "file")
|
||||
throw new ArchivePolicyError(
|
||||
@@ -57,6 +58,7 @@ export async function previewEntry(
|
||||
entry,
|
||||
ARCHIVE_LIMITS.maxPreviewImageBytes,
|
||||
signal,
|
||||
password,
|
||||
);
|
||||
const nested = isArchive(bytes, entry.path);
|
||||
if (nested) {
|
||||
|
||||
@@ -0,0 +1,625 @@
|
||||
import { ByteCursor, checkedOffsetAdd } from "@add-ideas/toolbox-helpers";
|
||||
import { crc32 } from "./checksums";
|
||||
import { ArchivePolicyError } from "./errors";
|
||||
import { ARCHIVE_LIMITS, throwIfAborted } from "./limits";
|
||||
import { assessArchivePath } from "./paths";
|
||||
import type {
|
||||
ArchiveDocument,
|
||||
ArchiveEntryRecord,
|
||||
ArchiveIssue,
|
||||
} from "./types";
|
||||
|
||||
const RAR4_SIGNATURE = new Uint8Array([
|
||||
0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00,
|
||||
]);
|
||||
const RAR5_SIGNATURE = new Uint8Array([
|
||||
0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00,
|
||||
]);
|
||||
|
||||
export async function inspectRar(
|
||||
file: File,
|
||||
version: "rar4" | "rar5",
|
||||
signal?: AbortSignal,
|
||||
): Promise<ArchiveDocument> {
|
||||
return version === "rar5"
|
||||
? inspectRar5(file, signal)
|
||||
: inspectRar4(file, signal);
|
||||
}
|
||||
|
||||
async function inspectRar5(
|
||||
file: File,
|
||||
signal?: AbortSignal,
|
||||
): Promise<ArchiveDocument> {
|
||||
await validateSignature(file, RAR5_SIGNATURE, signal);
|
||||
let offset = RAR5_SIGNATURE.length;
|
||||
let blocks = 0;
|
||||
let mainSeen = false;
|
||||
let ended = false;
|
||||
let encryptedHeaders = false;
|
||||
const entries: ArchiveEntryRecord[] = [];
|
||||
const issues: ArchiveIssue[] = [];
|
||||
|
||||
while (offset < file.size) {
|
||||
throwIfAborted(signal);
|
||||
if (++blocks > ARCHIVE_LIMITS.maxArchiveHeaderBlocks)
|
||||
limit(
|
||||
"RAR5_HEADER_COUNT",
|
||||
"RAR5 header-block count exceeds the inspection limit.",
|
||||
);
|
||||
const prefix = await readAtMost(file, offset, 20, signal);
|
||||
if (prefix.length < 7) malformed("RAR5 block header is truncated.");
|
||||
const expectedCrc = new DataView(
|
||||
prefix.buffer,
|
||||
prefix.byteOffset,
|
||||
prefix.byteLength,
|
||||
).getUint32(0, true);
|
||||
const sizeCursor = new ByteCursor(prefix.subarray(4), {
|
||||
maximumBytes: prefix.length - 4,
|
||||
});
|
||||
const sizeField = readVint(sizeCursor, "RAR5 header size", 3);
|
||||
if (sizeField.value > ARCHIVE_LIMITS.maxStructuralHeaderBytes)
|
||||
limit(
|
||||
"RAR5_HEADER_SIZE",
|
||||
"RAR5 block header exceeds the structural-inspection limit.",
|
||||
);
|
||||
const totalHeader = safeAdd(
|
||||
4 + sizeField.bytes,
|
||||
sizeField.value,
|
||||
file.size - offset,
|
||||
"RAR5 header range",
|
||||
);
|
||||
const header = await readExact(
|
||||
file,
|
||||
offset,
|
||||
totalHeader,
|
||||
signal,
|
||||
"RAR5 block header",
|
||||
);
|
||||
if (crc32(header.subarray(4)) !== expectedCrc)
|
||||
malformed("RAR5 block-header CRC-32 does not match.", "RAR5_HEADER_CRC");
|
||||
|
||||
const cursor = new ByteCursor(header.subarray(4 + sizeField.bytes), {
|
||||
maximumBytes: ARCHIVE_LIMITS.maxStructuralHeaderBytes,
|
||||
});
|
||||
const type = readVint(cursor, "RAR5 header type").value;
|
||||
const flags = readVint(cursor, "RAR5 header flags").value;
|
||||
const extraSize =
|
||||
flags & 0x01 ? readVint(cursor, "RAR5 extra-area size").value : 0;
|
||||
const dataSize =
|
||||
flags & 0x02 ? readVint(cursor, "RAR5 data size").value : 0;
|
||||
if (extraSize > cursor.remaining)
|
||||
malformed("RAR5 extra area exceeds its block header.");
|
||||
const specific = cursor.subcursor(cursor.remaining - extraSize);
|
||||
const extra = cursor.subcursor(extraSize);
|
||||
const extraTypes = parseRar5Extra(extra);
|
||||
|
||||
if (!mainSeen && type !== 1)
|
||||
malformed("RAR5 main archive header is missing.");
|
||||
if (type === 1) {
|
||||
if (mainSeen) malformed("RAR5 archive has duplicate main headers.");
|
||||
const archiveFlags = readVint(specific, "RAR5 archive flags").value;
|
||||
if (archiveFlags & 0x02) readVint(specific, "RAR5 volume number");
|
||||
if (!specific.done)
|
||||
malformed("RAR5 main header has unexpected trailing fields.");
|
||||
mainSeen = true;
|
||||
if (archiveFlags & 0x01)
|
||||
issues.push({
|
||||
code: "RAR5_MULTIVOLUME",
|
||||
message:
|
||||
"RAR5 multi-volume archive detected; only headers present in this file are inventoried.",
|
||||
severity: "warning",
|
||||
});
|
||||
} else if (type === 2 || type === 3) {
|
||||
if (type === 2) {
|
||||
if (entries.length >= ARCHIVE_LIMITS.maxEntries)
|
||||
limit(
|
||||
"RAR_ENTRY_COUNT",
|
||||
"RAR entry count exceeds the inspection limit.",
|
||||
);
|
||||
entries.push(
|
||||
parseRar5File(specific, extraTypes, flags, dataSize, entries.length),
|
||||
);
|
||||
} else
|
||||
parseRar5File(specific, extraTypes, flags, dataSize, entries.length);
|
||||
} else if (type === 4) {
|
||||
encryptedHeaders = true;
|
||||
issues.push({
|
||||
code: "RAR5_ENCRYPTED_HEADERS",
|
||||
message:
|
||||
"RAR5 encrypted headers detected; inspection stopped without attempting password or metadata decoding.",
|
||||
severity: "error",
|
||||
});
|
||||
} else if (type === 5) {
|
||||
readVint(specific, "RAR5 end flags");
|
||||
ended = true;
|
||||
} else if (!(flags & 0x04)) {
|
||||
malformed(`Unknown mandatory RAR5 block type ${type}.`);
|
||||
}
|
||||
|
||||
const headerEnd = safeAdd(
|
||||
offset,
|
||||
totalHeader,
|
||||
file.size,
|
||||
"RAR5 header end",
|
||||
);
|
||||
offset = safeAdd(headerEnd, dataSize, file.size, "RAR5 block data");
|
||||
if (encryptedHeaders || ended) break;
|
||||
}
|
||||
if (!mainSeen) malformed("RAR5 main archive header is missing.");
|
||||
if (!ended && !encryptedHeaders)
|
||||
malformed("RAR5 archive ended without a validated end header.");
|
||||
if (offset < file.size && ended)
|
||||
issues.push({
|
||||
code: "RAR_TRAILING_DATA",
|
||||
message: `${(file.size - offset).toLocaleString()} bytes follow the RAR5 end header and were not interpreted.`,
|
||||
severity: "info",
|
||||
});
|
||||
|
||||
return rarDocument(file, "rar5", markCollisions(entries), issues, {
|
||||
blocks,
|
||||
ended,
|
||||
encryptedHeaders,
|
||||
signature: "52 61 72 21 1A 07 01 00",
|
||||
});
|
||||
}
|
||||
|
||||
function parseRar5File(
|
||||
cursor: ByteCursor,
|
||||
extraTypes: Set<number>,
|
||||
commonFlags: number,
|
||||
packedSize: number,
|
||||
index: number,
|
||||
): ArchiveEntryRecord {
|
||||
const fileFlags = readVint(cursor, "RAR5 file flags").value;
|
||||
const unpackedSize = readVint(cursor, "RAR5 unpacked size").value;
|
||||
readVint(cursor, "RAR5 file attributes");
|
||||
if (fileFlags & 0x02) cursor.readUint32(true);
|
||||
let entryCrc: string | undefined;
|
||||
if (fileFlags & 0x04)
|
||||
entryCrc = cursor.readUint32(true).toString(16).padStart(8, "0");
|
||||
const compressionInfo = readVint(
|
||||
cursor,
|
||||
"RAR5 compression information",
|
||||
).value;
|
||||
readVint(cursor, "RAR5 host OS");
|
||||
const nameSize = readVint(cursor, "RAR5 filename size").value;
|
||||
if (nameSize > ARCHIVE_LIMITS.maxPathBytes)
|
||||
limit("RAR_PATH_LIMIT", "RAR5 filename exceeds the path-byte limit.");
|
||||
const rawPath = decodeUtf8(cursor.readBytes(nameSize), "RAR5 filename");
|
||||
if (!cursor.done)
|
||||
malformed("RAR5 file header has unexpected trailing fields.");
|
||||
const kind: ArchiveEntryRecord["kind"] =
|
||||
fileFlags & 0x01 ? "directory" : "file";
|
||||
const encrypted = extraTypes.has(1);
|
||||
const method = (compressionInfo >>> 7) & 0x07;
|
||||
return structuralEntry({
|
||||
index,
|
||||
rawPath:
|
||||
kind === "directory" && !rawPath.endsWith("/") ? `${rawPath}/` : rawPath,
|
||||
kind,
|
||||
size: unpackedSize,
|
||||
sizeKnown: !(fileFlags & 0x08),
|
||||
compressedSize: packedSize,
|
||||
crc32: entryCrc,
|
||||
compression: method === 0 ? "RAR5 stored" : `RAR5 method ${method}`,
|
||||
encrypted,
|
||||
splitBefore: Boolean(commonFlags & 0x08),
|
||||
splitAfter: Boolean(commonFlags & 0x10),
|
||||
});
|
||||
}
|
||||
|
||||
function parseRar5Extra(cursor: ByteCursor): Set<number> {
|
||||
const types = new Set<number>();
|
||||
while (!cursor.done) {
|
||||
const recordSize = readVint(cursor, "RAR5 extra record size").value;
|
||||
if (!recordSize || recordSize > cursor.remaining)
|
||||
malformed("RAR5 extra record exceeds its declared area.");
|
||||
const record = cursor.subcursor(recordSize);
|
||||
const type = readVint(record, "RAR5 extra record type").value;
|
||||
types.add(type);
|
||||
record.skip(record.remaining);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
async function inspectRar4(
|
||||
file: File,
|
||||
signal?: AbortSignal,
|
||||
): Promise<ArchiveDocument> {
|
||||
await validateSignature(file, RAR4_SIGNATURE, signal);
|
||||
let offset = RAR4_SIGNATURE.length;
|
||||
let blocks = 0;
|
||||
let mainSeen = false;
|
||||
let ended = false;
|
||||
let encryptedHeaders = false;
|
||||
const entries: ArchiveEntryRecord[] = [];
|
||||
const issues: ArchiveIssue[] = [];
|
||||
while (offset < file.size) {
|
||||
throwIfAborted(signal);
|
||||
if (++blocks > ARCHIVE_LIMITS.maxArchiveHeaderBlocks)
|
||||
limit(
|
||||
"RAR4_HEADER_COUNT",
|
||||
"RAR4 header-block count exceeds the inspection limit.",
|
||||
);
|
||||
const base = await readExact(file, offset, 7, signal, "RAR4 base header");
|
||||
const baseView = new DataView(
|
||||
base.buffer,
|
||||
base.byteOffset,
|
||||
base.byteLength,
|
||||
);
|
||||
const expectedCrc = baseView.getUint16(0, true);
|
||||
const type = base[2]!;
|
||||
const flags = baseView.getUint16(3, true);
|
||||
const headSize = baseView.getUint16(5, true);
|
||||
if (headSize < 7 || headSize > ARCHIVE_LIMITS.maxStructuralHeaderBytes)
|
||||
malformed("RAR4 header size is invalid.");
|
||||
const header = await readExact(
|
||||
file,
|
||||
offset,
|
||||
headSize,
|
||||
signal,
|
||||
"RAR4 block header",
|
||||
);
|
||||
if ((crc32(header.subarray(2)) & 0xffff) !== expectedCrc)
|
||||
malformed("RAR4 block-header CRC does not match.", "RAR4_HEADER_CRC");
|
||||
if (!mainSeen && type !== 0x73)
|
||||
malformed("RAR4 main archive header is missing.");
|
||||
|
||||
let dataSize = 0;
|
||||
if (type === 0x73) {
|
||||
if (mainSeen || headSize < 13)
|
||||
malformed("RAR4 main archive header is invalid.");
|
||||
mainSeen = true;
|
||||
if (flags & 0x0001)
|
||||
issues.push({
|
||||
code: "RAR4_MULTIVOLUME",
|
||||
message:
|
||||
"RAR4 multi-volume archive detected; only headers present in this file are inventoried.",
|
||||
severity: "warning",
|
||||
});
|
||||
if (flags & 0x0080) {
|
||||
encryptedHeaders = true;
|
||||
issues.push({
|
||||
code: "RAR4_ENCRYPTED_HEADERS",
|
||||
message:
|
||||
"RAR4 encrypted headers detected; inspection stopped without attempting password or metadata decoding.",
|
||||
severity: "error",
|
||||
});
|
||||
}
|
||||
} else if (type === 0x74) {
|
||||
if (entries.length >= ARCHIVE_LIMITS.maxEntries)
|
||||
limit(
|
||||
"RAR_ENTRY_COUNT",
|
||||
"RAR entry count exceeds the inspection limit.",
|
||||
);
|
||||
const parsed = parseRar4File(header, flags, entries.length);
|
||||
entries.push(parsed.entry);
|
||||
dataSize = parsed.packedSize;
|
||||
if (parsed.partialUnicodeName)
|
||||
issues.push({
|
||||
code: "RAR4_UNICODE_NAME_PARTIAL",
|
||||
message: `RAR4's legacy encoded Unicode tail for ${parsed.entry.path} was not decoded; its safe ANSI fallback name is shown.`,
|
||||
severity: "warning",
|
||||
});
|
||||
} else if (type === 0x7b) {
|
||||
ended = true;
|
||||
} else if (flags & 0x8000) {
|
||||
if (headSize < 11) malformed("RAR4 long block lacks ADD_SIZE.");
|
||||
dataSize = new DataView(
|
||||
header.buffer,
|
||||
header.byteOffset,
|
||||
header.byteLength,
|
||||
).getUint32(7, true);
|
||||
}
|
||||
|
||||
const headerEnd = safeAdd(offset, headSize, file.size, "RAR4 header end");
|
||||
offset = safeAdd(headerEnd, dataSize, file.size, "RAR4 block data");
|
||||
if (encryptedHeaders || ended) break;
|
||||
}
|
||||
if (!mainSeen) malformed("RAR4 main archive header is missing.");
|
||||
if (!ended && !encryptedHeaders)
|
||||
malformed("RAR4 archive ended without a validated end header.");
|
||||
if (offset < file.size && ended)
|
||||
issues.push({
|
||||
code: "RAR_TRAILING_DATA",
|
||||
message: `${(file.size - offset).toLocaleString()} bytes follow the RAR4 end header and were not interpreted.`,
|
||||
severity: "info",
|
||||
});
|
||||
return rarDocument(file, "rar4", markCollisions(entries), issues, {
|
||||
blocks,
|
||||
ended,
|
||||
encryptedHeaders,
|
||||
signature: "52 61 72 21 1A 07 00",
|
||||
});
|
||||
}
|
||||
|
||||
function parseRar4File(
|
||||
header: Uint8Array,
|
||||
flags: number,
|
||||
index: number,
|
||||
): {
|
||||
entry: ArchiveEntryRecord;
|
||||
packedSize: number;
|
||||
partialUnicodeName: boolean;
|
||||
} {
|
||||
if (header.length < 32) malformed("RAR4 file header is truncated.");
|
||||
const cursor = new ByteCursor(header.subarray(7), {
|
||||
littleEndian: true,
|
||||
maximumBytes: ARCHIVE_LIMITS.maxStructuralHeaderBytes,
|
||||
});
|
||||
const packedLow = cursor.readUint32();
|
||||
const unpackedLow = cursor.readUint32();
|
||||
cursor.readUint8();
|
||||
const entryCrc = cursor.readUint32().toString(16).padStart(8, "0");
|
||||
cursor.readUint32();
|
||||
cursor.readUint8();
|
||||
const method = cursor.readUint8();
|
||||
const nameSize = cursor.readUint16();
|
||||
cursor.readUint32();
|
||||
let packedSize = packedLow;
|
||||
let unpackedSize = unpackedLow;
|
||||
if (flags & 0x0100) {
|
||||
const packedHigh = cursor.readUint32();
|
||||
const unpackedHigh = cursor.readUint32();
|
||||
packedSize = safe64(packedHigh, packedLow, "RAR4 packed size");
|
||||
unpackedSize = safe64(unpackedHigh, unpackedLow, "RAR4 unpacked size");
|
||||
}
|
||||
if (nameSize > ARCHIVE_LIMITS.maxPathBytes)
|
||||
limit("RAR_PATH_LIMIT", "RAR4 filename exceeds the path-byte limit.");
|
||||
const nameBytes = cursor.readBytes(nameSize);
|
||||
const unicodeSeparator = flags & 0x0200 ? nameBytes.indexOf(0) : -1;
|
||||
const partialUnicodeName = unicodeSeparator >= 0;
|
||||
const displayBytes = partialUnicodeName
|
||||
? nameBytes.subarray(0, unicodeSeparator)
|
||||
: nameBytes;
|
||||
const rawName = new TextDecoder("windows-1252").decode(displayBytes);
|
||||
if (!rawName)
|
||||
malformed("RAR4 filename is empty or cannot be represented safely.");
|
||||
const kind: ArchiveEntryRecord["kind"] =
|
||||
(flags & 0x00e0) === 0x00e0 ? "directory" : "file";
|
||||
const entry = structuralEntry({
|
||||
index,
|
||||
rawPath:
|
||||
kind === "directory" && !rawName.endsWith("/") ? `${rawName}/` : rawName,
|
||||
kind,
|
||||
size: unpackedSize,
|
||||
sizeKnown: true,
|
||||
compressedSize: packedSize,
|
||||
crc32: entryCrc,
|
||||
compression:
|
||||
method === 0x30 ? "RAR4 stored" : `RAR4 method 0x${method.toString(16)}`,
|
||||
encrypted: Boolean(flags & 0x0004),
|
||||
splitBefore: Boolean(flags & 0x0001),
|
||||
splitAfter: Boolean(flags & 0x0002),
|
||||
});
|
||||
return { entry, packedSize, partialUnicodeName };
|
||||
}
|
||||
|
||||
interface StructuralEntryInput {
|
||||
index: number;
|
||||
rawPath: string;
|
||||
kind: ArchiveEntryRecord["kind"];
|
||||
size: number;
|
||||
sizeKnown: boolean;
|
||||
compressedSize?: number;
|
||||
crc32?: string;
|
||||
compression: string;
|
||||
encrypted: boolean;
|
||||
splitBefore: boolean;
|
||||
splitAfter: boolean;
|
||||
}
|
||||
|
||||
function structuralEntry(input: StructuralEntryInput): ArchiveEntryRecord {
|
||||
const id = String(input.index);
|
||||
const assessed = assessArchivePath(input.rawPath);
|
||||
const issues = assessed.issues.map((issue) => ({ ...issue, entryId: id }));
|
||||
if (input.encrypted)
|
||||
issues.push({
|
||||
code: "RAR_ENCRYPTED_ENTRY",
|
||||
message:
|
||||
"RAR file data is encrypted; no password or content decoding is attempted.",
|
||||
severity: "error",
|
||||
entryId: id,
|
||||
});
|
||||
if (input.splitBefore || input.splitAfter)
|
||||
issues.push({
|
||||
code: "RAR_SPLIT_ENTRY",
|
||||
message: `RAR split-file flags detected (${input.splitBefore ? "continues from previous volume" : "starts here"}${input.splitAfter ? ", continues in next volume" : ""}).`,
|
||||
severity: "error",
|
||||
entryId: id,
|
||||
});
|
||||
issues.push({
|
||||
code: "RAR_EXTRACTION_UNSUPPORTED",
|
||||
message:
|
||||
"RAR entries are inventory-only; decompression and extraction are unsupported.",
|
||||
severity: "error",
|
||||
entryId: id,
|
||||
});
|
||||
return {
|
||||
id,
|
||||
sourceIndex: input.index,
|
||||
rawPath: input.rawPath,
|
||||
path: assessed.normalized || input.rawPath,
|
||||
collisionKey: assessed.collisionKey,
|
||||
kind: input.kind,
|
||||
size: input.size,
|
||||
sizeKnown: input.sizeKnown,
|
||||
compressedSize: input.compressedSize,
|
||||
crc32: input.crc32,
|
||||
compression: input.compression,
|
||||
encrypted: input.encrypted,
|
||||
encryption: input.encrypted ? "unknown" : undefined,
|
||||
extractable: false,
|
||||
issues,
|
||||
};
|
||||
}
|
||||
|
||||
function rarDocument(
|
||||
file: File,
|
||||
format: "rar4" | "rar5",
|
||||
entries: ArchiveEntryRecord[],
|
||||
issues: ArchiveIssue[],
|
||||
evidence: {
|
||||
blocks: number;
|
||||
ended: boolean;
|
||||
encryptedHeaders: boolean;
|
||||
signature: string;
|
||||
},
|
||||
): ArchiveDocument {
|
||||
return {
|
||||
name: file.name,
|
||||
format,
|
||||
source: file,
|
||||
sourceBytes: file.size,
|
||||
entries,
|
||||
issues,
|
||||
expandedBytes: entries.reduce(
|
||||
(sum, entry) => sum + (entry.sizeKnown === false ? 0 : entry.size),
|
||||
0,
|
||||
),
|
||||
compressedBytes: entries.reduce(
|
||||
(sum, entry) => sum + (entry.compressedSize ?? 0),
|
||||
0,
|
||||
),
|
||||
zip64: false,
|
||||
structural: {
|
||||
parser: format,
|
||||
signature: evidence.signature,
|
||||
headerCrcs: { verified: evidence.blocks, failed: 0 },
|
||||
blocks: evidence.blocks,
|
||||
ended: evidence.ended,
|
||||
encryptedHeaders: evidence.encryptedHeaders,
|
||||
notes: [
|
||||
"Header framing and header CRCs were validated before metadata was accepted.",
|
||||
"RAR compression, passwords, solid dictionaries, recovery records and extraction are unsupported.",
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function markCollisions(entries: ArchiveEntryRecord[]): ArchiveEntryRecord[] {
|
||||
const groups = new Map<string, ArchiveEntryRecord[]>();
|
||||
for (const entry of entries) {
|
||||
const group = groups.get(entry.collisionKey) ?? [];
|
||||
group.push(entry);
|
||||
groups.set(entry.collisionKey, group);
|
||||
}
|
||||
for (const group of groups.values()) {
|
||||
if (group.length < 2) continue;
|
||||
for (const entry of group)
|
||||
entry.issues.push({
|
||||
code: "DUPLICATE_PATH",
|
||||
message: "Path collides with another entry after safe normalization.",
|
||||
severity: "error",
|
||||
entryId: entry.id,
|
||||
});
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
function readVint(
|
||||
cursor: ByteCursor,
|
||||
label: string,
|
||||
maximumBytes = 10,
|
||||
): { value: number; bytes: number } {
|
||||
let value = 0n;
|
||||
for (let index = 0; index < maximumBytes; index += 1) {
|
||||
const byte = cursor.readUint8();
|
||||
value |= BigInt(byte & 0x7f) << BigInt(index * 7);
|
||||
if (!(byte & 0x80)) {
|
||||
if (value > BigInt(Number.MAX_SAFE_INTEGER))
|
||||
limit(
|
||||
"RAR_INTEGER_LIMIT",
|
||||
`${label} exceeds safe browser integer arithmetic.`,
|
||||
);
|
||||
return { value: Number(value), bytes: index + 1 };
|
||||
}
|
||||
}
|
||||
malformed(`${label} uses an overlong variable-width integer.`);
|
||||
}
|
||||
|
||||
function safe64(high: number, low: number, label: string): number {
|
||||
const value = BigInt(high) * 0x1_0000_0000n + BigInt(low);
|
||||
if (value > BigInt(Number.MAX_SAFE_INTEGER))
|
||||
limit(
|
||||
"RAR_INTEGER_LIMIT",
|
||||
`${label} exceeds safe browser integer arithmetic.`,
|
||||
);
|
||||
return Number(value);
|
||||
}
|
||||
|
||||
function safeAdd(
|
||||
base: number,
|
||||
length: number,
|
||||
maximum: number,
|
||||
label: string,
|
||||
): number {
|
||||
try {
|
||||
return checkedOffsetAdd(base, length, maximum, label);
|
||||
} catch {
|
||||
malformed(`${label} points outside the archive.`);
|
||||
}
|
||||
}
|
||||
|
||||
function decodeUtf8(bytes: Uint8Array, label: string): string {
|
||||
try {
|
||||
const value = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
||||
if (!value) malformed(`${label} is empty.`);
|
||||
return value;
|
||||
} catch (error) {
|
||||
if (error instanceof ArchivePolicyError) throw error;
|
||||
malformed(`${label} is not valid UTF-8.`);
|
||||
}
|
||||
}
|
||||
|
||||
async function validateSignature(
|
||||
file: File,
|
||||
expected: Uint8Array,
|
||||
signal?: AbortSignal,
|
||||
): Promise<void> {
|
||||
const actual = await readExact(
|
||||
file,
|
||||
0,
|
||||
expected.length,
|
||||
signal,
|
||||
"RAR signature",
|
||||
);
|
||||
for (const [index, byte] of expected.entries())
|
||||
if (actual[index] !== byte) malformed("RAR signature is invalid.");
|
||||
}
|
||||
|
||||
async function readAtMost(
|
||||
file: Blob,
|
||||
offset: number,
|
||||
length: number,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Uint8Array> {
|
||||
throwIfAborted(signal);
|
||||
const bytes = new Uint8Array(
|
||||
await file
|
||||
.slice(offset, Math.min(file.size, offset + length))
|
||||
.arrayBuffer(),
|
||||
);
|
||||
throwIfAborted(signal);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
async function readExact(
|
||||
file: Blob,
|
||||
offset: number,
|
||||
length: number,
|
||||
signal: AbortSignal | undefined,
|
||||
label: string,
|
||||
): Promise<Uint8Array> {
|
||||
const bytes = await readAtMost(file, offset, length, signal);
|
||||
if (bytes.length !== length) malformed(`${label} is truncated.`);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
function malformed(message: string, code = "MALFORMED_RAR"): never {
|
||||
throw new ArchivePolicyError(code, message);
|
||||
}
|
||||
|
||||
function limit(code: string, message: string): never {
|
||||
throw new ArchivePolicyError(code, message);
|
||||
}
|
||||
+82
-11
@@ -1,8 +1,14 @@
|
||||
import { ArchivePolicyError } from "./errors";
|
||||
import { crc32Hex } from "./checksums";
|
||||
import { gunzipBounded, gzipDeterministic, parseGzipHeader } from "./gzip";
|
||||
import {
|
||||
gunzipBoundedDetailed,
|
||||
gzipDeterministic,
|
||||
parseGzipHeader,
|
||||
} from "./gzip";
|
||||
import { ARCHIVE_LIMITS, assertSourceSize, throwIfAborted } from "./limits";
|
||||
import { assessArchivePath, creationPath } from "./paths";
|
||||
import { inspectRar } from "./rar";
|
||||
import { inspectSevenZip } from "./sevenzip";
|
||||
import { createTar, looksLikeTar, parseTar } from "./tar";
|
||||
import type {
|
||||
ArchiveDocument,
|
||||
@@ -12,6 +18,7 @@ import type {
|
||||
CreateFormat,
|
||||
CreateInput,
|
||||
ProgressUpdate,
|
||||
ZipEncryptionOptions,
|
||||
} from "./types";
|
||||
import { createZip, parseZip, readZipEntries } from "./zip";
|
||||
|
||||
@@ -24,6 +31,10 @@ export async function inspectArchive(
|
||||
const probe = new Uint8Array(await file.slice(0, 512).arrayBuffer());
|
||||
const format = detectArchiveFormat(file.name, probe);
|
||||
|
||||
if (format === "7z") return inspectSevenZip(file, signal);
|
||||
if (format === "rar4" || format === "rar5")
|
||||
return inspectRar(file, format, signal);
|
||||
|
||||
if (format === "zip") {
|
||||
const parsed = await parseZip(file, signal);
|
||||
return {
|
||||
@@ -41,9 +52,9 @@ export async function inspectArchive(
|
||||
|
||||
const source = new Uint8Array(await file.arrayBuffer());
|
||||
throwIfAborted(signal);
|
||||
const payload =
|
||||
const gzipResult =
|
||||
format === "gzip" || format === "tar.gz"
|
||||
? gunzipBounded(
|
||||
? gunzipBoundedDetailed(
|
||||
source,
|
||||
Math.min(
|
||||
ARCHIVE_LIMITS.maxExpandedBytes,
|
||||
@@ -51,7 +62,18 @@ export async function inspectArchive(
|
||||
),
|
||||
signal,
|
||||
)
|
||||
: source;
|
||||
: undefined;
|
||||
const payload = gzipResult?.bytes ?? source;
|
||||
const gzipIssues =
|
||||
gzipResult && gzipResult.members.length > 1
|
||||
? [
|
||||
{
|
||||
code: "CONCATENATED_GZIP",
|
||||
message: `Validated and decoded ${gzipResult.members.length.toLocaleString()} concatenated gzip members.`,
|
||||
severity: "info" as const,
|
||||
},
|
||||
]
|
||||
: [];
|
||||
if (
|
||||
(format === "gzip" || format === "tar.gz") &&
|
||||
payload.byteLength / Math.max(1, file.size) >
|
||||
@@ -71,7 +93,7 @@ export async function inspectArchive(
|
||||
source: file,
|
||||
sourceBytes: file.size,
|
||||
entries: parsed.entries,
|
||||
issues: parsed.issues,
|
||||
issues: [...gzipIssues, ...parsed.issues],
|
||||
expandedBytes: parsed.expandedBytes,
|
||||
compressedBytes: format === "tar" ? parsed.expandedBytes : file.size,
|
||||
zip64: false,
|
||||
@@ -114,7 +136,7 @@ export async function inspectArchive(
|
||||
source: file,
|
||||
sourceBytes: file.size,
|
||||
entries: [entry],
|
||||
issues: [],
|
||||
issues: gzipIssues,
|
||||
expandedBytes: payload.byteLength,
|
||||
compressedBytes: file.size,
|
||||
zip64: false,
|
||||
@@ -127,6 +149,7 @@ export async function readEntryBytes(
|
||||
entry: ArchiveEntryRecord,
|
||||
maxBytes: number,
|
||||
signal?: AbortSignal,
|
||||
password?: string,
|
||||
): Promise<Uint8Array> {
|
||||
if (!entry.extractable)
|
||||
throw new ArchivePolicyError(
|
||||
@@ -145,6 +168,7 @@ export async function readEntryBytes(
|
||||
[entry.sourceIndex],
|
||||
maxBytes,
|
||||
signal,
|
||||
password,
|
||||
)
|
||||
).get(entry.sourceIndex)!;
|
||||
}
|
||||
@@ -170,6 +194,7 @@ export async function createSafeSelectionZip(
|
||||
entryIds: string[],
|
||||
signal?: AbortSignal,
|
||||
onProgress?: (update: ProgressUpdate) => void,
|
||||
password?: string,
|
||||
): Promise<Blob> {
|
||||
const selected = entryIds.map((id) =>
|
||||
document.entries.find((entry) => entry.id === id),
|
||||
@@ -208,6 +233,7 @@ export async function createSafeSelectionZip(
|
||||
entries.map((entry) => entry.sourceIndex),
|
||||
ARCHIVE_LIMITS.maxEntryBytes,
|
||||
signal,
|
||||
password,
|
||||
);
|
||||
}
|
||||
const inputs: CreateInput[] = [];
|
||||
@@ -220,6 +246,7 @@ export async function createSafeSelectionZip(
|
||||
entry,
|
||||
ARCHIVE_LIMITS.maxEntryBytes,
|
||||
signal,
|
||||
password,
|
||||
));
|
||||
inputs.push({
|
||||
path: entry.path,
|
||||
@@ -241,9 +268,16 @@ export async function createArchive(
|
||||
format: CreateFormat,
|
||||
signal?: AbortSignal,
|
||||
onProgress?: (update: ProgressUpdate) => void,
|
||||
encryption?: ZipEncryptionOptions,
|
||||
): Promise<Blob> {
|
||||
const inputs = validateCreationInputs(files);
|
||||
if (format === "zip") return createZip(inputs, signal, onProgress);
|
||||
if (format === "zip")
|
||||
return createZip(inputs, signal, onProgress, encryption);
|
||||
if (encryption)
|
||||
throw new ArchivePolicyError(
|
||||
"ENCRYPTION_FORMAT",
|
||||
"Password encryption is available only for ZIP output.",
|
||||
);
|
||||
const tar = await createTar(inputs, signal, onProgress);
|
||||
if (format === "tar")
|
||||
return new Blob([ownedBuffer(tar)], { type: "application/x-tar" });
|
||||
@@ -335,15 +369,22 @@ export function reportJson(document: ArchiveDocument): string {
|
||||
summary: archiveSummary(document),
|
||||
policy: {
|
||||
...ARCHIVE_LIMITS,
|
||||
encryption: "unsupported",
|
||||
encryption:
|
||||
"ZipCrypto and WinZip AES-128/192/256 entries are identified and can be read locally with an explicit password; creation offers AES-256 and compatibility-only ZipCrypto",
|
||||
multipartZip: "unsupported",
|
||||
nestedExpansion: "unsupported",
|
||||
specialEntries: "listed but never restored",
|
||||
zipIntegrity:
|
||||
"CRC-32 and strict local/central header agreement are verified when content is read",
|
||||
tarIntegrity: "every header checksum is verified",
|
||||
gzipIntegrity: "CRC-32 and ISIZE are verified",
|
||||
gzipIntegrity:
|
||||
"CRC-32 and ISIZE are verified independently for every bounded concatenated member",
|
||||
sevenZipInspection:
|
||||
"signature, start-header fields and CRCs are validated; only safe plain FilesInfo metadata is inventoried; codecs and extraction are unsupported",
|
||||
rarInspection:
|
||||
"RAR4/RAR5 block framing and header CRCs are validated and plaintext file headers are inventoried; decompression and extraction are unsupported",
|
||||
},
|
||||
structural: document.structural,
|
||||
entries: document.entries.map((entry) => {
|
||||
const reportEntry = { ...entry };
|
||||
delete reportEntry.dataOffset;
|
||||
@@ -357,6 +398,30 @@ export function detectArchiveFormat(
|
||||
name: string,
|
||||
probe: Uint8Array,
|
||||
): ArchiveFormat {
|
||||
if (
|
||||
probe[0] === 0x37 &&
|
||||
probe[1] === 0x7a &&
|
||||
probe[2] === 0xbc &&
|
||||
probe[3] === 0xaf &&
|
||||
probe[4] === 0x27 &&
|
||||
probe[5] === 0x1c
|
||||
)
|
||||
return "7z";
|
||||
if (
|
||||
probe[0] === 0x52 &&
|
||||
probe[1] === 0x61 &&
|
||||
probe[2] === 0x72 &&
|
||||
probe[3] === 0x21 &&
|
||||
probe[4] === 0x1a &&
|
||||
probe[5] === 0x07
|
||||
) {
|
||||
if (probe[6] === 0x00) return "rar4";
|
||||
if (probe[6] === 0x01 && probe[7] === 0x00) return "rar5";
|
||||
throw new ArchivePolicyError(
|
||||
"UNSUPPORTED_RAR_VERSION",
|
||||
"The RAR marker is present, but its archive version signature is not RAR4 or RAR5.",
|
||||
);
|
||||
}
|
||||
if (
|
||||
probe[0] === 0x50 &&
|
||||
probe[1] === 0x4b &&
|
||||
@@ -366,10 +431,16 @@ export function detectArchiveFormat(
|
||||
if (probe[0] === 0x1f && probe[1] === 0x8b)
|
||||
return /\.t(?:ar\.)?gz$|\.tgz$/iu.test(name) ? "tar.gz" : "gzip";
|
||||
if (looksLikeTar(probe) || /\.tar$/iu.test(name)) return "tar";
|
||||
if (/\.(?:rar|7z|bz2|xz|zst|lz4)$/iu.test(name)) {
|
||||
if (/\.7z$/iu.test(name)) return "7z";
|
||||
if (/\.rar$/iu.test(name))
|
||||
throw new ArchivePolicyError(
|
||||
"MISSING_RAR_SIGNATURE",
|
||||
"The .rar extension is present, but no supported RAR4/RAR5 signature was found.",
|
||||
);
|
||||
if (/\.(?:bz2|xz|zst|lz4)$/iu.test(name)) {
|
||||
throw new ArchivePolicyError(
|
||||
"UNSUPPORTED_FORMAT",
|
||||
"This release supports ZIP/ZIP64, TAR/USTAR/PAX and gzip/tar.gz only.",
|
||||
"This release supports ZIP/ZIP64, TAR/USTAR/PAX, gzip/tar.gz, and structural-only 7z/RAR4/RAR5 inspection.",
|
||||
);
|
||||
}
|
||||
throw new ArchivePolicyError(
|
||||
|
||||
@@ -0,0 +1,566 @@
|
||||
import { ByteCursor, checkedOffsetAdd } from "@add-ideas/toolbox-helpers";
|
||||
import { crc32, uint32Hex } from "./checksums";
|
||||
import { ArchivePolicyError } from "./errors";
|
||||
import { ARCHIVE_LIMITS, throwIfAborted } from "./limits";
|
||||
import { assessArchivePath } from "./paths";
|
||||
import type {
|
||||
ArchiveDocument,
|
||||
ArchiveEntryRecord,
|
||||
ArchiveIssue,
|
||||
} from "./types";
|
||||
|
||||
const SIGNATURE = new Uint8Array([0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c]);
|
||||
const NID = Object.freeze({
|
||||
end: 0x00,
|
||||
header: 0x01,
|
||||
archiveProperties: 0x02,
|
||||
additionalStreamsInfo: 0x03,
|
||||
mainStreamsInfo: 0x04,
|
||||
filesInfo: 0x05,
|
||||
packInfo: 0x06,
|
||||
unpackInfo: 0x07,
|
||||
subStreamsInfo: 0x08,
|
||||
size: 0x09,
|
||||
crc: 0x0a,
|
||||
folder: 0x0b,
|
||||
codersUnpackSize: 0x0c,
|
||||
numUnpackStream: 0x0d,
|
||||
emptyStream: 0x0e,
|
||||
emptyFile: 0x0f,
|
||||
anti: 0x10,
|
||||
name: 0x11,
|
||||
encodedHeader: 0x17,
|
||||
});
|
||||
|
||||
interface SevenZipMetadata {
|
||||
entries: ArchiveEntryRecord[];
|
||||
parsed: boolean;
|
||||
}
|
||||
|
||||
export async function inspectSevenZip(
|
||||
file: File,
|
||||
signal?: AbortSignal,
|
||||
): Promise<ArchiveDocument> {
|
||||
throwIfAborted(signal);
|
||||
if (file.size < 32) malformed("7z start header is truncated.");
|
||||
const start = await readExact(file, 0, 32, signal);
|
||||
for (const [index, byte] of SIGNATURE.entries()) {
|
||||
if (start[index] !== byte) malformed("7z signature is invalid.");
|
||||
}
|
||||
const view = new DataView(start.buffer, start.byteOffset, start.byteLength);
|
||||
const expectedStartCrc = view.getUint32(8, true);
|
||||
const actualStartCrc = crc32(start.subarray(12, 32));
|
||||
if (expectedStartCrc !== actualStartCrc) {
|
||||
malformed("7z start-header CRC-32 does not match.", "7Z_START_CRC");
|
||||
}
|
||||
|
||||
const nextOffset = safeBigUint(
|
||||
view.getBigUint64(12, true),
|
||||
"7z next-header offset",
|
||||
);
|
||||
const nextSize = safeBigUint(
|
||||
view.getBigUint64(20, true),
|
||||
"7z next-header size",
|
||||
);
|
||||
if (nextSize > ARCHIVE_LIMITS.maxStructuralHeaderBytes) {
|
||||
throw new ArchivePolicyError(
|
||||
"7Z_HEADER_LIMIT",
|
||||
`7z next header exceeds the ${ARCHIVE_LIMITS.maxStructuralHeaderBytes.toLocaleString()}-byte structural-inspection limit.`,
|
||||
);
|
||||
}
|
||||
const nextStart = checkedArchiveOffset(
|
||||
32,
|
||||
nextOffset,
|
||||
file.size,
|
||||
"7z next-header offset",
|
||||
);
|
||||
checkedArchiveOffset(nextStart, nextSize, file.size, "7z next-header range");
|
||||
const next = await readExact(file, nextStart, nextSize, signal);
|
||||
const expectedNextCrc = view.getUint32(28, true);
|
||||
const actualNextCrc = crc32(next);
|
||||
if (expectedNextCrc !== actualNextCrc) {
|
||||
malformed("7z next-header CRC-32 does not match.", "7Z_NEXT_CRC");
|
||||
}
|
||||
|
||||
let kind: "empty" | "plain" | "encoded" | "unknown" = "empty";
|
||||
let metadata: SevenZipMetadata = { entries: [], parsed: false };
|
||||
const issues: ArchiveIssue[] = [];
|
||||
if (next.length) {
|
||||
if (next[0] === NID.header) {
|
||||
kind = "plain";
|
||||
metadata = parsePlainHeader(next);
|
||||
issues.push({
|
||||
code: "SEVEN_ZIP_STRUCTURAL_ONLY",
|
||||
message:
|
||||
"7z plain metadata was inventoried, but packed streams are not decoded or extracted.",
|
||||
severity: "info",
|
||||
});
|
||||
} else if (next[0] === NID.encodedHeader) {
|
||||
kind = "encoded";
|
||||
issues.push({
|
||||
code: "SEVEN_ZIP_ENCODED_HEADER",
|
||||
message:
|
||||
"The 7z next header is encoded (compressed or encrypted); structural inspection stops before metadata decoding.",
|
||||
severity: "warning",
|
||||
});
|
||||
} else {
|
||||
kind = "unknown";
|
||||
malformed(
|
||||
`Unsupported 7z next-header marker 0x${next[0]!.toString(16).padStart(2, "0")}.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const entries = markCollisions(metadata.entries);
|
||||
return {
|
||||
name: file.name,
|
||||
format: "7z",
|
||||
source: file,
|
||||
sourceBytes: file.size,
|
||||
entries,
|
||||
issues,
|
||||
expandedBytes: entries.reduce(
|
||||
(sum, entry) => sum + (entry.sizeKnown === false ? 0 : entry.size),
|
||||
0,
|
||||
),
|
||||
compressedBytes: file.size,
|
||||
zip64: false,
|
||||
structural: {
|
||||
parser: "7z",
|
||||
signature: "37 7A BC AF 27 1C",
|
||||
version: `${start[6]}.${start[7]}`,
|
||||
headerCrcs: { verified: 2, failed: 0 },
|
||||
nextHeader: {
|
||||
offset: nextStart,
|
||||
size: nextSize,
|
||||
crc32: uint32Hex(expectedNextCrc),
|
||||
kind,
|
||||
metadataParsed: metadata.parsed,
|
||||
},
|
||||
notes: [
|
||||
kind === "plain"
|
||||
? "Plain FilesInfo names and empty-file/directory markers were parsed when present."
|
||||
: kind === "encoded"
|
||||
? "Encoded headers are not decoded and may conceal filenames or encryption."
|
||||
: "The archive has no next-header payload.",
|
||||
"7z packed streams, codec chains, passwords and extraction are unsupported.",
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function parsePlainHeader(bytes: Uint8Array): SevenZipMetadata {
|
||||
try {
|
||||
const cursor = new ByteCursor(bytes, {
|
||||
maximumBytes: ARCHIVE_LIMITS.maxStructuralHeaderBytes,
|
||||
});
|
||||
expectNid(cursor, NID.header, "7z Header");
|
||||
let entries: ArchiveEntryRecord[] = [];
|
||||
let filesSeen = false;
|
||||
while (!cursor.done) {
|
||||
const nid = cursor.readUint8();
|
||||
if (nid === NID.end) {
|
||||
if (!cursor.done)
|
||||
malformed("7z plain header has trailing bytes after End.");
|
||||
return { entries, parsed: filesSeen };
|
||||
}
|
||||
if (nid === NID.archiveProperties) skipArchiveProperties(cursor);
|
||||
else if (nid === NID.additionalStreamsInfo || nid === NID.mainStreamsInfo)
|
||||
skipStreamsInfo(cursor);
|
||||
else if (nid === NID.filesInfo) {
|
||||
if (filesSeen)
|
||||
malformed("7z header contains duplicate FilesInfo sections.");
|
||||
entries = parseFilesInfo(cursor);
|
||||
filesSeen = true;
|
||||
} else malformed(`Unsupported 7z Header property 0x${hexByte(nid)}.`);
|
||||
}
|
||||
malformed("7z plain header is missing its End marker.");
|
||||
} catch (error) {
|
||||
if (error instanceof ArchivePolicyError) throw error;
|
||||
malformed(
|
||||
error instanceof Error
|
||||
? `Malformed 7z plain header: ${error.message}`
|
||||
: "Malformed 7z plain header.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function skipArchiveProperties(cursor: ByteCursor): void {
|
||||
while (true) {
|
||||
const nid = cursor.readUint8();
|
||||
if (nid === NID.end) return;
|
||||
cursor.skip(readSevenZipUint(cursor, "archive property size"));
|
||||
}
|
||||
}
|
||||
|
||||
interface FolderState {
|
||||
outputStreams: number;
|
||||
crcDefined: boolean;
|
||||
}
|
||||
|
||||
function skipStreamsInfo(cursor: ByteCursor): void {
|
||||
let folders: FolderState[] = [];
|
||||
while (true) {
|
||||
const nid = cursor.readUint8();
|
||||
if (nid === NID.end) return;
|
||||
if (nid === NID.packInfo) skipPackInfo(cursor);
|
||||
else if (nid === NID.unpackInfo) folders = skipUnpackInfo(cursor);
|
||||
else if (nid === NID.subStreamsInfo) skipSubStreamsInfo(cursor, folders);
|
||||
else malformed(`Unsupported 7z StreamsInfo property 0x${hexByte(nid)}.`);
|
||||
}
|
||||
}
|
||||
|
||||
function skipPackInfo(cursor: ByteCursor): void {
|
||||
readSevenZipUint(cursor, "pack position");
|
||||
const streams = boundedCount(
|
||||
readSevenZipUint(cursor, "pack stream count"),
|
||||
"pack streams",
|
||||
);
|
||||
while (true) {
|
||||
const nid = cursor.readUint8();
|
||||
if (nid === NID.end) return;
|
||||
if (nid === NID.size) {
|
||||
for (let index = 0; index < streams; index += 1)
|
||||
readSevenZipUint(cursor, "packed stream size");
|
||||
} else if (nid === NID.crc) readDigestSet(cursor, streams);
|
||||
else malformed(`Unsupported 7z PackInfo property 0x${hexByte(nid)}.`);
|
||||
}
|
||||
}
|
||||
|
||||
function skipUnpackInfo(cursor: ByteCursor): FolderState[] {
|
||||
expectNid(cursor, NID.folder, "7z Folder");
|
||||
const count = boundedCount(
|
||||
readSevenZipUint(cursor, "folder count"),
|
||||
"folders",
|
||||
);
|
||||
if (cursor.readUint8() !== 0)
|
||||
malformed("External 7z folder metadata is unsupported.");
|
||||
const folders: FolderState[] = [];
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
folders.push({ outputStreams: skipFolder(cursor), crcDefined: false });
|
||||
}
|
||||
expectNid(cursor, NID.codersUnpackSize, "7z CodersUnpackSize");
|
||||
for (const folder of folders) {
|
||||
for (let index = 0; index < folder.outputStreams; index += 1)
|
||||
readSevenZipUint(cursor, "coder unpack size");
|
||||
}
|
||||
let nid = cursor.readUint8();
|
||||
if (nid === NID.crc) {
|
||||
const defined = readDigestSet(cursor, count);
|
||||
folders.forEach(
|
||||
(folder, index) => (folder.crcDefined = defined[index] ?? false),
|
||||
);
|
||||
nid = cursor.readUint8();
|
||||
}
|
||||
if (nid !== NID.end) malformed("7z UnpackInfo is missing its End marker.");
|
||||
return folders;
|
||||
}
|
||||
|
||||
function skipFolder(cursor: ByteCursor): number {
|
||||
const coderCount = boundedCount(
|
||||
readSevenZipUint(cursor, "coder count"),
|
||||
"coders",
|
||||
1024,
|
||||
);
|
||||
if (!coderCount) malformed("7z folder has no coders.");
|
||||
let inputs = 0;
|
||||
let outputs = 0;
|
||||
for (let index = 0; index < coderCount; index += 1) {
|
||||
const flags = cursor.readUint8();
|
||||
if (flags & 0x80)
|
||||
malformed("Alternative 7z coder methods are unsupported.");
|
||||
const idSize = flags & 0x0f;
|
||||
if (!idSize) malformed("7z coder method ID is empty.");
|
||||
cursor.skip(idSize);
|
||||
const complex = Boolean(flags & 0x10);
|
||||
const coderInputs = complex ? readSevenZipUint(cursor, "coder inputs") : 1;
|
||||
const coderOutputs = complex
|
||||
? readSevenZipUint(cursor, "coder outputs")
|
||||
: 1;
|
||||
inputs = checkedSmallAdd(inputs, coderInputs, "coder input streams");
|
||||
outputs = checkedSmallAdd(outputs, coderOutputs, "coder output streams");
|
||||
if (flags & 0x20)
|
||||
cursor.skip(readSevenZipUint(cursor, "coder property size"));
|
||||
}
|
||||
if (!outputs || inputs < outputs - 1)
|
||||
malformed("Invalid 7z folder stream graph.");
|
||||
const bindPairs = outputs - 1;
|
||||
for (let index = 0; index < bindPairs; index += 1) {
|
||||
readSevenZipUint(cursor, "bind input index");
|
||||
readSevenZipUint(cursor, "bind output index");
|
||||
}
|
||||
const packedStreams = inputs - bindPairs;
|
||||
if (packedStreams > 1) {
|
||||
for (let index = 0; index < packedStreams; index += 1)
|
||||
readSevenZipUint(cursor, "packed stream index");
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
|
||||
function skipSubStreamsInfo(cursor: ByteCursor, folders: FolderState[]): void {
|
||||
let counts = folders.map(() => 1);
|
||||
let nid = cursor.readUint8();
|
||||
if (nid === NID.numUnpackStream) {
|
||||
counts = folders.map(() =>
|
||||
boundedCount(readSevenZipUint(cursor, "substream count"), "substreams"),
|
||||
);
|
||||
nid = cursor.readUint8();
|
||||
}
|
||||
if (nid === NID.size) {
|
||||
for (const count of counts) {
|
||||
for (let index = 1; index < count; index += 1)
|
||||
readSevenZipUint(cursor, "substream size");
|
||||
}
|
||||
nid = cursor.readUint8();
|
||||
}
|
||||
if (nid === NID.crc) {
|
||||
const digestCount = counts.reduce(
|
||||
(sum, count, index) =>
|
||||
checkedSmallAdd(
|
||||
sum,
|
||||
count === 1 && folders[index]?.crcDefined ? 0 : count,
|
||||
"substream digests",
|
||||
),
|
||||
0,
|
||||
);
|
||||
readDigestSet(cursor, digestCount);
|
||||
nid = cursor.readUint8();
|
||||
}
|
||||
if (nid !== NID.end)
|
||||
malformed("7z SubStreamsInfo is missing its End marker.");
|
||||
}
|
||||
|
||||
function readDigestSet(cursor: ByteCursor, count: number): boolean[] {
|
||||
const allDefined = cursor.readUint8() !== 0;
|
||||
const defined = allDefined
|
||||
? Array<boolean>(count).fill(true)
|
||||
: readBitSet(cursor, count);
|
||||
for (const present of defined) if (present) cursor.skip(4);
|
||||
return defined;
|
||||
}
|
||||
|
||||
function parseFilesInfo(cursor: ByteCursor): ArchiveEntryRecord[] {
|
||||
const count = boundedCount(readSevenZipUint(cursor, "file count"), "files");
|
||||
let names: string[] | undefined;
|
||||
let emptyStreams = Array<boolean>(count).fill(false);
|
||||
let emptyFiles: boolean[] = [];
|
||||
while (true) {
|
||||
const property = cursor.readUint8();
|
||||
if (property === NID.end) break;
|
||||
const size = readSevenZipUint(cursor, "FilesInfo property size");
|
||||
const propertyCursor = cursor.subcursor(size);
|
||||
if (property === NID.name) names = parseNames(propertyCursor, count);
|
||||
else if (property === NID.emptyStream)
|
||||
emptyStreams = readBitSet(propertyCursor, count);
|
||||
else if (property === NID.emptyFile)
|
||||
emptyFiles = readBitSet(
|
||||
propertyCursor,
|
||||
emptyStreams.filter(Boolean).length,
|
||||
);
|
||||
else if (property === NID.anti)
|
||||
readBitSet(propertyCursor, emptyStreams.filter(Boolean).length);
|
||||
else propertyCursor.skip(propertyCursor.remaining);
|
||||
if (!propertyCursor.done)
|
||||
malformed(
|
||||
`7z FilesInfo property 0x${hexByte(property)} has trailing bytes.`,
|
||||
);
|
||||
}
|
||||
if (!names) {
|
||||
return Array.from({ length: count }, (_, index) =>
|
||||
createEntry(index, `unnamed-${index + 1}`, "other", false),
|
||||
);
|
||||
}
|
||||
let emptyIndex = 0;
|
||||
return names.map((name, index) => {
|
||||
const isEmptyStream = emptyStreams[index] ?? false;
|
||||
const isFile = !isEmptyStream || (emptyFiles[emptyIndex] ?? false);
|
||||
if (isEmptyStream) emptyIndex += 1;
|
||||
return createEntry(
|
||||
index,
|
||||
name,
|
||||
isFile ? "file" : "directory",
|
||||
isEmptyStream,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function parseNames(cursor: ByteCursor, count: number): string[] {
|
||||
if (cursor.readUint8() !== 0)
|
||||
malformed("External 7z filename metadata is unsupported.");
|
||||
if (cursor.remaining % 2)
|
||||
malformed("7z UTF-16 filename data has an odd byte length.");
|
||||
let decoded: string;
|
||||
try {
|
||||
decoded = new TextDecoder("utf-16le", { fatal: true }).decode(
|
||||
cursor.readBytes(cursor.remaining),
|
||||
);
|
||||
} catch {
|
||||
malformed("7z filename metadata is not valid UTF-16LE.");
|
||||
}
|
||||
if (!decoded.endsWith("\0"))
|
||||
malformed("7z filename metadata lacks a terminator.");
|
||||
const names = decoded.slice(0, -1).split("\0");
|
||||
if (names.length !== count)
|
||||
malformed("7z filename count does not match FilesInfo.");
|
||||
return names;
|
||||
}
|
||||
|
||||
function createEntry(
|
||||
index: number,
|
||||
rawName: string,
|
||||
kind: ArchiveEntryRecord["kind"],
|
||||
sizeKnown: boolean,
|
||||
): ArchiveEntryRecord {
|
||||
const rawPath =
|
||||
kind === "directory" && !rawName.endsWith("/") ? `${rawName}/` : rawName;
|
||||
const assessed = assessArchivePath(rawPath);
|
||||
const issues = assessed.issues.map((issue) => ({
|
||||
...issue,
|
||||
entryId: String(index),
|
||||
}));
|
||||
issues.push({
|
||||
code: "SEVEN_ZIP_EXTRACTION_UNSUPPORTED",
|
||||
message:
|
||||
"7z entries are inventory-only; packed-stream decoding and extraction are unsupported.",
|
||||
severity: "error",
|
||||
entryId: String(index),
|
||||
});
|
||||
return {
|
||||
id: String(index),
|
||||
sourceIndex: index,
|
||||
rawPath,
|
||||
path: assessed.normalized || rawPath,
|
||||
collisionKey: assessed.collisionKey,
|
||||
kind,
|
||||
size: 0,
|
||||
sizeKnown,
|
||||
compression: "7z (not decoded)",
|
||||
extractable: false,
|
||||
issues,
|
||||
};
|
||||
}
|
||||
|
||||
function markCollisions(entries: ArchiveEntryRecord[]): ArchiveEntryRecord[] {
|
||||
const groups = new Map<string, ArchiveEntryRecord[]>();
|
||||
for (const entry of entries) {
|
||||
const group = groups.get(entry.collisionKey) ?? [];
|
||||
group.push(entry);
|
||||
groups.set(entry.collisionKey, group);
|
||||
}
|
||||
for (const group of groups.values()) {
|
||||
if (group.length < 2) continue;
|
||||
for (const entry of group) {
|
||||
entry.issues.push({
|
||||
code: "DUPLICATE_PATH",
|
||||
message: "Path collides with another entry after safe normalization.",
|
||||
severity: "error",
|
||||
entryId: entry.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
function readBitSet(cursor: ByteCursor, count: number): boolean[] {
|
||||
const result: boolean[] = [];
|
||||
let current = 0;
|
||||
let mask = 0;
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
if (!mask) {
|
||||
current = cursor.readUint8();
|
||||
mask = 0x80;
|
||||
}
|
||||
result.push(Boolean(current & mask));
|
||||
mask >>= 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function readSevenZipUint(cursor: ByteCursor, label: string): number {
|
||||
const first = cursor.readUint8();
|
||||
let mask = 0x80;
|
||||
let value = 0n;
|
||||
for (let index = 0; index < 8; index += 1) {
|
||||
if ((first & mask) === 0) {
|
||||
value |= BigInt(first & (mask - 1)) << BigInt(index * 8);
|
||||
return safeBigUint(value, label);
|
||||
}
|
||||
value |= BigInt(cursor.readUint8()) << BigInt(index * 8);
|
||||
mask >>= 1;
|
||||
}
|
||||
return safeBigUint(value, label);
|
||||
}
|
||||
|
||||
function expectNid(cursor: ByteCursor, expected: number, label: string): void {
|
||||
const actual = cursor.readUint8();
|
||||
if (actual !== expected)
|
||||
malformed(`${label} marker is invalid (found 0x${hexByte(actual)}).`);
|
||||
}
|
||||
|
||||
function boundedCount(
|
||||
value: number,
|
||||
label: string,
|
||||
maximum: number = ARCHIVE_LIMITS.maxEntries,
|
||||
): number {
|
||||
if (value > maximum)
|
||||
throw new ArchivePolicyError(
|
||||
"7Z_COUNT_LIMIT",
|
||||
`7z ${label} exceed the bounded limit of ${maximum.toLocaleString()}.`,
|
||||
);
|
||||
return value;
|
||||
}
|
||||
|
||||
function checkedSmallAdd(left: number, right: number, label: string): number {
|
||||
const result = checkedOffsetAdd(
|
||||
left,
|
||||
right,
|
||||
ARCHIVE_LIMITS.maxEntries * 16,
|
||||
label,
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
function checkedArchiveOffset(
|
||||
base: number,
|
||||
length: number,
|
||||
maximum: number,
|
||||
label: string,
|
||||
): number {
|
||||
try {
|
||||
return checkedOffsetAdd(base, length, maximum, label);
|
||||
} catch {
|
||||
malformed(`${label} points outside the archive.`);
|
||||
}
|
||||
}
|
||||
|
||||
async function readExact(
|
||||
file: Blob,
|
||||
offset: number,
|
||||
length: number,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Uint8Array> {
|
||||
throwIfAborted(signal);
|
||||
const bytes = new Uint8Array(
|
||||
await file.slice(offset, offset + length).arrayBuffer(),
|
||||
);
|
||||
throwIfAborted(signal);
|
||||
if (bytes.byteLength !== length) malformed("7z header is truncated.");
|
||||
return bytes;
|
||||
}
|
||||
|
||||
function safeBigUint(value: bigint, label: string): number {
|
||||
if (value > BigInt(Number.MAX_SAFE_INTEGER))
|
||||
throw new ArchivePolicyError(
|
||||
"7Z_OFFSET_LIMIT",
|
||||
`${label} exceeds safe browser offset arithmetic.`,
|
||||
);
|
||||
return Number(value);
|
||||
}
|
||||
|
||||
function hexByte(value: number): string {
|
||||
return value.toString(16).padStart(2, "0");
|
||||
}
|
||||
|
||||
function malformed(message: string, code = "MALFORMED_7Z"): never {
|
||||
throw new ArchivePolicyError(code, message);
|
||||
}
|
||||
+48
-3
@@ -46,6 +46,8 @@ export function parseTar(bytes: Uint8Array, signal?: AbortSignal): ParsedTar {
|
||||
let expandedBytes = 0;
|
||||
let pendingPax: Record<string, string> | undefined;
|
||||
let globalPax: Record<string, string> = {};
|
||||
let pendingLongPath: string | undefined;
|
||||
let pendingLongLink: string | undefined;
|
||||
|
||||
while (offset + BLOCK_SIZE <= bytes.byteLength) {
|
||||
throwIfAborted(signal);
|
||||
@@ -99,11 +101,20 @@ export function parseTar(bytes: Uint8Array, signal?: AbortSignal): ParsedTar {
|
||||
}
|
||||
|
||||
if (typeFlag === 0x4c || typeFlag === 0x4b) {
|
||||
if (headerSize > ARCHIVE_LIMITS.maxPaxHeaderBytes) {
|
||||
throw new ArchivePolicyError(
|
||||
"UNSUPPORTED_GNU_TAR",
|
||||
"GNU long-name/link TAR extensions are unsupported; use PAX instead.",
|
||||
"GNU_METADATA_TOO_LARGE",
|
||||
"A GNU long-name or long-link record exceeds the metadata safety limit.",
|
||||
);
|
||||
}
|
||||
const value = parseGnuLongValue(
|
||||
bytes.subarray(dataOffset, dataOffset + headerSize),
|
||||
);
|
||||
if (typeFlag === 0x4c) pendingLongPath = value;
|
||||
else pendingLongLink = value;
|
||||
offset = dataOffset + paddedSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
const pax = { ...globalPax, ...pendingPax };
|
||||
pendingPax = undefined;
|
||||
@@ -111,7 +122,11 @@ export function parseTar(bytes: Uint8Array, signal?: AbortSignal): ParsedTar {
|
||||
readString(header.subarray(345, 500)),
|
||||
readString(header.subarray(0, 100)),
|
||||
);
|
||||
const rawPath = pax.path ?? basePath;
|
||||
const rawPath = pax.path ?? pendingLongPath ?? basePath;
|
||||
const linkTarget =
|
||||
pax.linkpath ?? pendingLongLink ?? readString(header.subarray(157, 257));
|
||||
pendingLongPath = undefined;
|
||||
pendingLongLink = undefined;
|
||||
const size =
|
||||
pax.size === undefined
|
||||
? headerSize
|
||||
@@ -207,6 +222,7 @@ export function parseTar(bytes: Uint8Array, signal?: AbortSignal): ParsedTar {
|
||||
kind === "file" &&
|
||||
entryIssues.every((candidate) => candidate.severity !== "error"),
|
||||
issues: entryIssues,
|
||||
linkTarget: linkTarget || undefined,
|
||||
dataOffset,
|
||||
};
|
||||
entries.push(entry);
|
||||
@@ -230,9 +246,38 @@ export function parseTar(bytes: Uint8Array, signal?: AbortSignal): ParsedTar {
|
||||
message: "Trailing PAX metadata has no following entry.",
|
||||
severity: "warning",
|
||||
});
|
||||
if (pendingLongPath || pendingLongLink)
|
||||
issues.push({
|
||||
code: "ORPHAN_GNU_METADATA",
|
||||
message: "Trailing GNU long-name/link metadata has no following entry.",
|
||||
severity: "warning",
|
||||
});
|
||||
return { entries, issues, expandedBytes };
|
||||
}
|
||||
|
||||
function parseGnuLongValue(bytes: Uint8Array): string {
|
||||
let end = bytes.byteLength;
|
||||
while (end > 0 && (bytes[end - 1] === 0 || bytes[end - 1] === 0x0a)) end -= 1;
|
||||
if (end === 0)
|
||||
throw new ArchivePolicyError(
|
||||
"INVALID_GNU_METADATA",
|
||||
"A GNU long-name/link record is empty.",
|
||||
);
|
||||
if (bytes.subarray(0, end).includes(0))
|
||||
throw new ArchivePolicyError(
|
||||
"INVALID_GNU_METADATA",
|
||||
"A GNU long-name/link record contains an embedded NUL byte.",
|
||||
);
|
||||
try {
|
||||
return decoder.decode(bytes.subarray(0, end));
|
||||
} catch {
|
||||
throw new ArchivePolicyError(
|
||||
"INVALID_GNU_METADATA",
|
||||
"A GNU long-name/link record is not valid UTF-8.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function createTar(
|
||||
inputs: CreateInput[],
|
||||
signal?: AbortSignal,
|
||||
|
||||
+33
-1
@@ -1,4 +1,5 @@
|
||||
export type ArchiveFormat = "zip" | "tar" | "tar.gz" | "gzip";
|
||||
export type ArchiveFormat =
|
||||
"zip" | "tar" | "tar.gz" | "gzip" | "7z" | "rar4" | "rar5";
|
||||
|
||||
export type ArchiveEntryKind =
|
||||
"file" | "directory" | "symlink" | "hardlink" | "device" | "fifo" | "other";
|
||||
@@ -20,18 +21,42 @@ export interface ArchiveEntryRecord {
|
||||
collisionKey: string;
|
||||
kind: ArchiveEntryKind;
|
||||
size: number;
|
||||
/** False when a structural-only parser cannot recover an expanded size. */
|
||||
sizeKnown?: boolean;
|
||||
compressedSize?: number;
|
||||
modifiedAt?: string;
|
||||
crc32?: string;
|
||||
compression?: string;
|
||||
zip64?: boolean;
|
||||
encrypted?: boolean;
|
||||
/** The entry encryption scheme when it can be identified safely. */
|
||||
encryption?: "ZipCrypto" | "AES-128" | "AES-192" | "AES-256" | "unknown";
|
||||
/** Link target from TAR metadata. Links are inventory-only and never restored. */
|
||||
linkTarget?: string;
|
||||
extractable: boolean;
|
||||
issues: ArchiveIssue[];
|
||||
/** Internal byte offset for TAR/GZIP-backed documents. */
|
||||
dataOffset?: number;
|
||||
}
|
||||
|
||||
export interface ArchiveStructuralEvidence {
|
||||
parser: "7z" | "rar4" | "rar5";
|
||||
signature: string;
|
||||
version?: string;
|
||||
headerCrcs: { verified: number; failed: number };
|
||||
blocks?: number;
|
||||
ended?: boolean;
|
||||
encryptedHeaders?: boolean;
|
||||
nextHeader?: {
|
||||
offset: number;
|
||||
size: number;
|
||||
crc32: string;
|
||||
kind: "empty" | "plain" | "encoded" | "unknown";
|
||||
metadataParsed: boolean;
|
||||
};
|
||||
notes: string[];
|
||||
}
|
||||
|
||||
export interface ArchiveDocument {
|
||||
name: string;
|
||||
format: ArchiveFormat;
|
||||
@@ -42,6 +67,8 @@ export interface ArchiveDocument {
|
||||
expandedBytes: number;
|
||||
compressedBytes: number;
|
||||
zip64: boolean;
|
||||
/** Structural evidence for inventory-only formats that are not decoded. */
|
||||
structural?: ArchiveStructuralEvidence;
|
||||
/** Bounded decompressed TAR or GZIP bytes retained for local previews. */
|
||||
payload?: Uint8Array;
|
||||
}
|
||||
@@ -96,6 +123,11 @@ export interface CreateInput {
|
||||
|
||||
export type CreateFormat = "zip" | "tar" | "tar.gz";
|
||||
|
||||
export interface ZipEncryptionOptions {
|
||||
readonly password: string;
|
||||
readonly method: "aes-256" | "zipcrypto";
|
||||
}
|
||||
|
||||
export interface ProgressUpdate {
|
||||
stage: string;
|
||||
completed: number;
|
||||
|
||||
+57
-7
@@ -19,6 +19,7 @@ import type {
|
||||
ArchiveIssue,
|
||||
CreateInput,
|
||||
ProgressUpdate,
|
||||
ZipEncryptionOptions,
|
||||
} from "./types";
|
||||
|
||||
export interface ParsedZip {
|
||||
@@ -101,14 +102,22 @@ export async function parseZip(
|
||||
entryId: id,
|
||||
});
|
||||
}
|
||||
if (candidate.encrypted) {
|
||||
const encryption = encryptionName(candidate);
|
||||
if (candidate.encrypted && encryption === "unknown") {
|
||||
entryIssues.push({
|
||||
code: "ENCRYPTED_ENTRY",
|
||||
code: "UNSUPPORTED_ENCRYPTION",
|
||||
message:
|
||||
"Encrypted entries are listed but cannot be previewed or exported.",
|
||||
"The ZIP entry uses an encryption scheme this local implementation cannot identify safely.",
|
||||
severity: "error",
|
||||
entryId: id,
|
||||
});
|
||||
} else if (candidate.encrypted) {
|
||||
entryIssues.push({
|
||||
code: "PASSWORD_REQUIRED",
|
||||
message: `${encryption} encryption is supported locally; content operations require its password.`,
|
||||
severity: "info",
|
||||
entryId: id,
|
||||
});
|
||||
}
|
||||
if (kind !== "file" && kind !== "directory") {
|
||||
entryIssues.push({
|
||||
@@ -201,6 +210,7 @@ export async function parseZip(
|
||||
compression: compressionName(candidate.compressionMethod),
|
||||
zip64: candidate.zip64,
|
||||
encrypted: candidate.encrypted,
|
||||
encryption,
|
||||
extractable:
|
||||
kind === "file" &&
|
||||
entryIssues.every((item) => item.severity !== "error"),
|
||||
@@ -227,6 +237,7 @@ export async function readZipEntries(
|
||||
sourceIndices: number[],
|
||||
maxEntryBytes: number,
|
||||
signal?: AbortSignal,
|
||||
password?: string,
|
||||
): Promise<Map<number, Uint8Array>> {
|
||||
const wanted = new Set(sourceIndices);
|
||||
const selected = new Map<number, FileEntry>();
|
||||
@@ -255,11 +266,12 @@ export async function readZipEntries(
|
||||
const result = new Map<number, Uint8Array>();
|
||||
for (const sourceIndex of sourceIndices) {
|
||||
const entry = selected.get(sourceIndex)!;
|
||||
if (entry.encrypted)
|
||||
if (entry.encrypted && !password)
|
||||
throw new ArchivePolicyError(
|
||||
"ENCRYPTED_ENTRY",
|
||||
"Encrypted ZIP entries are unsupported.",
|
||||
"PASSWORD_REQUIRED",
|
||||
"A password is required to read the encrypted ZIP entry.",
|
||||
);
|
||||
if (password) assertPassword(password);
|
||||
if (entry.uncompressedSize > maxEntryBytes) {
|
||||
throw new ArchivePolicyError(
|
||||
"ENTRY_TOO_LARGE",
|
||||
@@ -267,13 +279,25 @@ export async function readZipEntries(
|
||||
);
|
||||
}
|
||||
const collector = boundedCollector(maxEntryBytes, signal);
|
||||
try {
|
||||
await entry.getData(collector.stream, {
|
||||
signal,
|
||||
password,
|
||||
strictness: "strict",
|
||||
checkCrc32: true,
|
||||
checkAuthenticationCode: true,
|
||||
checkOverlappingEntry: true,
|
||||
useWebWorkers: false,
|
||||
});
|
||||
} catch (error) {
|
||||
if (signal?.aborted || error instanceof ArchivePolicyError) throw error;
|
||||
if (entry.encrypted)
|
||||
throw new ArchivePolicyError(
|
||||
"PASSWORD_OR_INTEGRITY",
|
||||
"The password is incorrect, or the encrypted ZIP entry is damaged.",
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
result.set(sourceIndex, collector.bytes());
|
||||
}
|
||||
return result;
|
||||
@@ -286,7 +310,9 @@ export async function createZip(
|
||||
inputs: CreateInput[],
|
||||
signal?: AbortSignal,
|
||||
onProgress?: (update: ProgressUpdate) => void,
|
||||
encryption?: ZipEncryptionOptions,
|
||||
): Promise<Blob> {
|
||||
if (encryption) assertPassword(encryption.password);
|
||||
const writer = new ZipWriter(new BlobWriter("application/zip"), {
|
||||
level: 6,
|
||||
bufferedWrite: true,
|
||||
@@ -305,11 +331,14 @@ export async function createZip(
|
||||
rawLastModDate: 0x00210000,
|
||||
lastModDate: new Date("1980-01-01T00:00:00.000Z"),
|
||||
extendedTimestamp: false,
|
||||
dataDescriptor: false,
|
||||
dataDescriptor: encryption?.method === "zipcrypto",
|
||||
useWebWorkers: false,
|
||||
useCompressionStream: false,
|
||||
unixMode: 0o100644,
|
||||
signal,
|
||||
password: encryption?.password,
|
||||
encryptionStrength: encryption?.method === "aes-256" ? 3 : undefined,
|
||||
zipCrypto: encryption?.method === "zipcrypto",
|
||||
});
|
||||
onProgress?.({
|
||||
stage: "Creating ZIP",
|
||||
@@ -346,6 +375,27 @@ function compressionName(method: number): string {
|
||||
return `method ${method}`;
|
||||
}
|
||||
|
||||
function encryptionName(
|
||||
entry: Entry,
|
||||
): ArchiveEntryRecord["encryption"] | undefined {
|
||||
if (!entry.encrypted) return undefined;
|
||||
if (entry.zipCrypto) return "ZipCrypto";
|
||||
const strength = entry.extraFieldAES?.strength;
|
||||
if (strength === 1) return "AES-128";
|
||||
if (strength === 2) return "AES-192";
|
||||
if (strength === 3) return "AES-256";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
function assertPassword(password: string): void {
|
||||
const length = new TextEncoder().encode(password).byteLength;
|
||||
if (length < 1 || length > ARCHIVE_LIMITS.maxPasswordBytes)
|
||||
throw new ArchivePolicyError(
|
||||
"PASSWORD_LIMIT",
|
||||
`Password must contain 1–${ARCHIVE_LIMITS.maxPasswordBytes.toLocaleString()} UTF-8 bytes.`,
|
||||
);
|
||||
}
|
||||
|
||||
function validDate(date: Date): string | undefined {
|
||||
return Number.isFinite(date.getTime()) ? date.toISOString() : undefined;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ export function HelpDialog({
|
||||
</div>
|
||||
<div className="help-copy">
|
||||
<p>
|
||||
Inspect ZIP/ZIP64, TAR/USTAR/PAX, gzip and tar.gz files without
|
||||
uploading them.
|
||||
Inspect ZIP/ZIP64, TAR/USTAR/PAX/GNU metadata, concatenated gzip and
|
||||
tar.gz files without uploading them. Passwords for supported ZIP
|
||||
encryption remain in memory.
|
||||
</p>
|
||||
<h3>Safe repackaging</h3>
|
||||
<p>
|
||||
@@ -44,10 +45,12 @@ export function HelpDialog({
|
||||
</p>
|
||||
<h3>Intentional boundaries</h3>
|
||||
<p>
|
||||
Encryption, split ZIPs, nested archive expansion, GNU TAR extensions,
|
||||
symlinks, hardlinks, device nodes and FIFOs are unsupported. Unsafe
|
||||
paths, duplicates, excessive sizes and suspicious compression ratios
|
||||
are blocked.
|
||||
AES and legacy ZipCrypto ZIP entries are supported. Split ZIPs, nested
|
||||
archive expansion, sparse files, and restoration of symlinks,
|
||||
hardlinks, devices or FIFOs remain unsupported. 7z and RAR receive a
|
||||
bounded structural/header inventory, but their compressed content is
|
||||
never decoded or extracted. Unsafe paths, duplicates, excessive sizes
|
||||
and suspicious compression ratios are blocked.
|
||||
</p>
|
||||
<h3>Previews and comparison</h3>
|
||||
<p>
|
||||
@@ -59,7 +62,8 @@ export function HelpDialog({
|
||||
<p>
|
||||
Creation sorts files by path and normalizes timestamps, ownership and
|
||||
permissions. ZIP compression is pinned to a fixed implementation and
|
||||
level.
|
||||
level. Unencrypted archives are deterministic; encrypted ZIPs use
|
||||
fresh random salt and are intentionally not byte-reproducible.
|
||||
</p>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
@@ -47,7 +47,7 @@ export function Workbench() {
|
||||
<button
|
||||
key={item.id}
|
||||
type="button"
|
||||
aria-selected={workspace === item.id}
|
||||
aria-pressed={workspace === item.id}
|
||||
onClick={() => setWorkspace(item.id)}
|
||||
title={item.description}
|
||||
>
|
||||
|
||||
@@ -50,9 +50,45 @@ export function ArchiveSummaryView({
|
||||
</div>
|
||||
</dl>
|
||||
<p className="policy-note">
|
||||
CRC is verified when ZIP content is read. TAR headers and gzip payloads
|
||||
were verified during inspection.
|
||||
{document.structural
|
||||
? "Container and plaintext metadata headers were validated during structural inspection. Packed 7z/RAR content was not decoded."
|
||||
: "CRC is verified when ZIP content is read. TAR headers and gzip payloads were verified during inspection."}
|
||||
</p>
|
||||
{document.structural ? (
|
||||
<details className="evidence-details">
|
||||
<summary>Structural inspection evidence</summary>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>Parser</dt>
|
||||
<dd>{document.structural.parser.toLocaleUpperCase("en-US")}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Header CRCs</dt>
|
||||
<dd>{document.structural.headerCrcs.verified} verified</dd>
|
||||
</div>
|
||||
{document.structural.nextHeader ? (
|
||||
<div>
|
||||
<dt>7z next header</dt>
|
||||
<dd>
|
||||
{document.structural.nextHeader.kind} ·{" "}
|
||||
{formatBytes(document.structural.nextHeader.size)}
|
||||
</dd>
|
||||
</div>
|
||||
) : null}
|
||||
{document.structural.blocks !== undefined ? (
|
||||
<div>
|
||||
<dt>RAR blocks</dt>
|
||||
<dd>{document.structural.blocks.toLocaleString()}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
</dl>
|
||||
<ul>
|
||||
{document.structural.notes.map((note) => (
|
||||
<li key={note}>{note}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
) : null}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ export function CreateWorkspace() {
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
const [format, setFormat] = useState<CreateFormat>("zip");
|
||||
const [name, setName] = useState("archive");
|
||||
const [encryption, setEncryption] = useState<
|
||||
"none" | "aes-256" | "zipcrypto"
|
||||
>("none");
|
||||
const [password, setPassword] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [status, setStatus] = useState<string>();
|
||||
const [error, setError] = useState<string>();
|
||||
@@ -23,16 +27,26 @@ export function CreateWorkspace() {
|
||||
setBusy(true);
|
||||
setError(undefined);
|
||||
try {
|
||||
const blob = await createArchive(files, format, next.signal, (progress) =>
|
||||
const blob = await createArchive(
|
||||
files,
|
||||
format,
|
||||
next.signal,
|
||||
(progress) =>
|
||||
setStatus(
|
||||
`${progress.stage}: ${progress.completed} / ${progress.total}`,
|
||||
),
|
||||
format === "zip" && encryption !== "none"
|
||||
? { password, method: encryption }
|
||||
: undefined,
|
||||
);
|
||||
const extension = format === "tar.gz" ? "tar.gz" : format;
|
||||
downloadBlob(blob, `${name.trim() || "archive"}.${extension}`);
|
||||
setStatus(
|
||||
`Created deterministic ${format.toLocaleUpperCase("en-US")} locally.`,
|
||||
encryption === "none" || format !== "zip"
|
||||
? `Created deterministic ${format.toLocaleUpperCase("en-US")} locally.`
|
||||
: `Created encrypted ${format.toLocaleUpperCase("en-US")} locally; random salt makes encrypted bytes intentionally non-deterministic.`,
|
||||
);
|
||||
if (encryption !== "none") setPassword("");
|
||||
} catch (reason) {
|
||||
if (!next.signal.aborted) setError(errorMessage(reason));
|
||||
} finally {
|
||||
@@ -88,13 +102,52 @@ export function CreateWorkspace() {
|
||||
permissions are normalized; ZIP compression uses a fixed
|
||||
implementation and level.
|
||||
</p>
|
||||
{format === "zip" ? (
|
||||
<div className="field-grid">
|
||||
<label className="field">
|
||||
<span>Encryption</span>
|
||||
<select
|
||||
value={encryption}
|
||||
onChange={(event) =>
|
||||
setEncryption(
|
||||
event.target.value as "none" | "aes-256" | "zipcrypto",
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="none">None</option>
|
||||
<option value="aes-256">AES-256 (recommended)</option>
|
||||
<option value="zipcrypto">ZipCrypto (legacy, weak)</option>
|
||||
</select>
|
||||
</label>
|
||||
{encryption !== "none" ? (
|
||||
<label className="field">
|
||||
<span>Password (memory only)</span>
|
||||
<input
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{format === "zip" && encryption === "zipcrypto" ? (
|
||||
<p className="policy-note" role="note">
|
||||
ZipCrypto is offered only for compatibility and is not secure
|
||||
against modern password attacks. Prefer AES-256.
|
||||
</p>
|
||||
) : null}
|
||||
<StatusMessage error={error} status={status} />
|
||||
<div className="button-row">
|
||||
<button
|
||||
className="primary-button"
|
||||
type="button"
|
||||
disabled={
|
||||
!files.length || busy || total > ARCHIVE_LIMITS.maxCreateBytes
|
||||
!files.length ||
|
||||
busy ||
|
||||
total > ARCHIVE_LIMITS.maxCreateBytes ||
|
||||
(format === "zip" && encryption !== "none" && !password)
|
||||
}
|
||||
onClick={() => void build()}
|
||||
>
|
||||
|
||||
@@ -32,6 +32,7 @@ export function InspectWorkspace() {
|
||||
const [preview, setPreview] = useState<PreviewResult>();
|
||||
const [previewBusy, setPreviewBusy] = useState(false);
|
||||
const [previewError, setPreviewError] = useState<string>();
|
||||
const [password, setPassword] = useState("");
|
||||
const operation = useRef<AbortController | undefined>(undefined);
|
||||
const generation = useRef(0);
|
||||
|
||||
@@ -63,6 +64,7 @@ export function InspectWorkspace() {
|
||||
setBusy(true);
|
||||
setPreviewBusy(false);
|
||||
setError(undefined);
|
||||
setPassword("");
|
||||
setStatus(`Inspecting ${file.name}…`);
|
||||
try {
|
||||
const next = await inspectArchive(file, controller.signal);
|
||||
@@ -94,7 +96,12 @@ export function InspectWorkspace() {
|
||||
setPreviewBusy(true);
|
||||
setPreviewError(undefined);
|
||||
try {
|
||||
const next = await previewEntry(document, entry, controller.signal);
|
||||
const next = await previewEntry(
|
||||
document,
|
||||
entry,
|
||||
controller.signal,
|
||||
password,
|
||||
);
|
||||
if (current === generation.current) setPreview(next);
|
||||
} catch (reason) {
|
||||
if (!controller.signal.aborted && current === generation.current)
|
||||
@@ -119,6 +126,7 @@ export function InspectWorkspace() {
|
||||
[...selected],
|
||||
controller.signal,
|
||||
progressStatus(setStatus),
|
||||
password,
|
||||
);
|
||||
if (current !== generation.current) return;
|
||||
downloadBlob(blob, `${outputStem(document.name)}-safe-selection.zip`);
|
||||
@@ -160,7 +168,7 @@ export function InspectWorkspace() {
|
||||
>
|
||||
<div className="panel-heading">
|
||||
<div>
|
||||
<p className="eyebrow">ZIP · TAR · gzip</p>
|
||||
<p className="eyebrow">ZIP · TAR · gzip · 7z/RAR inventory</p>
|
||||
<h2 id="inspect-heading">Inspect and safely repackage</h2>
|
||||
</div>
|
||||
<div className="button-row">
|
||||
@@ -169,7 +177,7 @@ export function InspectWorkspace() {
|
||||
<input
|
||||
className="visually-hidden"
|
||||
type="file"
|
||||
accept=".zip,.tar,.tgz,.gz,application/zip,application/gzip,application/x-tar"
|
||||
accept=".zip,.tar,.tgz,.gz,.7z,.rar,application/zip,application/gzip,application/x-tar"
|
||||
onChange={(event) => {
|
||||
const file = event.currentTarget.files?.[0];
|
||||
event.currentTarget.value = "";
|
||||
@@ -185,8 +193,10 @@ export function InspectWorkspace() {
|
||||
</div>
|
||||
</div>
|
||||
<p className="policy-note">
|
||||
Encrypted and multipart ZIPs, nested expansion, symlinks, hardlinks,
|
||||
devices and FIFOs are intentionally unsupported.
|
||||
ZIP AES and ZipCrypto entries can be opened with an explicit password.
|
||||
7z and RAR headers can be inventoried structurally, but their codecs,
|
||||
passwords and extraction remain intentionally unsupported. Multipart
|
||||
ZIPs, nested expansion, links and devices are also unsupported.
|
||||
</p>
|
||||
<StatusMessage error={error} status={status} />
|
||||
{document ? (
|
||||
@@ -213,6 +223,23 @@ export function InspectWorkspace() {
|
||||
placeholder="Search entries"
|
||||
/>
|
||||
</label>
|
||||
{document.format === "zip" &&
|
||||
document.entries.some((entry) => entry.encrypted) ? (
|
||||
<label className="field">
|
||||
<span>ZIP password (memory only)</span>
|
||||
<input
|
||||
type="password"
|
||||
autoComplete="off"
|
||||
value={password}
|
||||
onChange={(event) => {
|
||||
setPassword(event.target.value);
|
||||
setPreview(undefined);
|
||||
setPreviewError(undefined);
|
||||
}}
|
||||
placeholder="Required for locked entries"
|
||||
/>
|
||||
</label>
|
||||
) : null}
|
||||
<label className="field">
|
||||
<span>Show</span>
|
||||
<select
|
||||
@@ -289,14 +316,20 @@ export function InspectWorkspace() {
|
||||
</button>
|
||||
</th>
|
||||
<td>{entry.kind}</td>
|
||||
<td>{formatBytes(entry.size)}</td>
|
||||
<td>
|
||||
{entry.sizeKnown === false
|
||||
? "Unknown"
|
||||
: formatBytes(entry.size)}
|
||||
</td>
|
||||
<td
|
||||
title={entry.issues
|
||||
.map((issue) => issue.message)
|
||||
.join(" ")}
|
||||
>
|
||||
{entry.extractable
|
||||
? "Safe file"
|
||||
? entry.encrypted
|
||||
? `${entry.encryption ?? "Encrypted"} · password required`
|
||||
: "Safe file"
|
||||
: entry.kind === "directory"
|
||||
? "Directory"
|
||||
: (entry.issues[0]?.message ?? "Blocked")}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createObjectUrlLease } from "@add-ideas/toolbox-helpers";
|
||||
import { useEffect, useRef } from "react";
|
||||
import type { ArchiveEntryRecord, PreviewResult } from "../../archive/types";
|
||||
|
||||
@@ -16,11 +17,11 @@ export function PreviewPane({
|
||||
useEffect(() => {
|
||||
const node = image.current;
|
||||
if (!node || preview?.kind !== "image") return;
|
||||
const url = URL.createObjectURL(preview.blob);
|
||||
node.src = url;
|
||||
const lease = createObjectUrlLease(preview.blob);
|
||||
node.src = lease.url;
|
||||
return () => {
|
||||
node.removeAttribute("src");
|
||||
URL.revokeObjectURL(url);
|
||||
lease.revoke();
|
||||
};
|
||||
}, [preview]);
|
||||
return (
|
||||
|
||||
+19
-1
@@ -167,7 +167,7 @@ input[type="checkbox"] {
|
||||
.workspace-tabs button {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.workspace-tabs button[aria-selected="true"] {
|
||||
.workspace-tabs button[aria-pressed="true"] {
|
||||
border-color: var(--toolbox-accent);
|
||||
background: var(--toolbox-accent);
|
||||
color: var(--toolbox-accent-contrast);
|
||||
@@ -290,6 +290,24 @@ input[type="checkbox"] {
|
||||
font-weight: 760;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.evidence-details {
|
||||
margin-top: 0.7rem;
|
||||
padding-top: 0.7rem;
|
||||
border-top: 1px solid var(--toolbox-border);
|
||||
}
|
||||
.evidence-details summary {
|
||||
cursor: pointer;
|
||||
font-weight: 750;
|
||||
}
|
||||
.evidence-details[open] summary {
|
||||
margin-bottom: 0.65rem;
|
||||
}
|
||||
.evidence-details ul {
|
||||
margin: 0.65rem 0 0;
|
||||
padding-left: 1.2rem;
|
||||
color: var(--toolbox-muted);
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.inspect-layout {
|
||||
display: grid;
|
||||
|
||||
@@ -3,12 +3,23 @@
|
||||
"schemaVersion": 1,
|
||||
"id": "de.add-ideas.archive-tools",
|
||||
"name": "Archive Tools",
|
||||
"version": "0.1.0",
|
||||
"description": "Inspect, create, compare and safely extract archives locally.",
|
||||
"version": "0.2.0",
|
||||
"description": "Inspect, create, compare and safely repackage archives locally, including structural 7z/RAR evidence.",
|
||||
"entry": "./",
|
||||
"icon": "./favicon.svg",
|
||||
"categories": ["files", "archives", "developer"],
|
||||
"tags": ["zip", "tar", "gzip", "extract", "archive"],
|
||||
"tags": [
|
||||
"zip",
|
||||
"tar",
|
||||
"gzip",
|
||||
"extract",
|
||||
"archive",
|
||||
"aes",
|
||||
"zipcrypto",
|
||||
"compare",
|
||||
"7z",
|
||||
"rar"
|
||||
],
|
||||
"integration": {
|
||||
"contextVersion": 1,
|
||||
"launchModes": ["navigate", "new-tab"],
|
||||
@@ -21,9 +32,64 @@
|
||||
"crossOriginIsolated": false,
|
||||
"topLevelContext": false
|
||||
},
|
||||
"io": {
|
||||
"accepts": [
|
||||
{
|
||||
"mediaType": "application/zip",
|
||||
"extensions": [".zip"],
|
||||
"label": "ZIP and ZIP64, including AES or ZipCrypto entries"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/x-tar",
|
||||
"extensions": [".tar"],
|
||||
"label": "TAR, USTAR and bounded PAX/GNU metadata"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/gzip",
|
||||
"extensions": [".gz", ".tgz", ".tar.gz"],
|
||||
"label": "gzip and tar.gz, including concatenated members"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/x-7z-compressed",
|
||||
"extensions": [".7z"],
|
||||
"label": "7z structural headers and safe plain metadata; decompression unsupported"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/vnd.rar",
|
||||
"extensions": [".rar"],
|
||||
"label": "RAR4/RAR5 plaintext header inventory; decompression unsupported"
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
{
|
||||
"mediaType": "application/zip",
|
||||
"extensions": [".zip"],
|
||||
"label": "ZIP, AES-256 ZIP or legacy ZipCrypto ZIP"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/x-tar",
|
||||
"extensions": [".tar"],
|
||||
"label": "Deterministic TAR/PAX"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/gzip",
|
||||
"extensions": [".tgz", ".tar.gz"],
|
||||
"label": "Deterministic tar.gz"
|
||||
},
|
||||
{
|
||||
"mediaType": "application/json",
|
||||
"extensions": [".json"],
|
||||
"label": "Inspection and comparison reports"
|
||||
}
|
||||
]
|
||||
},
|
||||
"capabilities": {
|
||||
"required": [],
|
||||
"optional": ["web-crypto"]
|
||||
},
|
||||
"privacy": {
|
||||
"processing": "local",
|
||||
"fileUploads": false,
|
||||
"fileUploads": true,
|
||||
"telemetry": false,
|
||||
"label": "Inputs stay in this browser; nothing is uploaded."
|
||||
},
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
export const APP_VERSION = "0.1.0";
|
||||
export const APP_VERSION = "0.2.0";
|
||||
|
||||
@@ -0,0 +1,277 @@
|
||||
// @vitest-environment node
|
||||
import { File as NodeFile } from "node:buffer";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { crc32 } from "../../src/archive/checksums";
|
||||
import { inspectArchive, reportJson } from "../../src/archive/service";
|
||||
|
||||
const asFile = (bytes: Uint8Array, name: string) =>
|
||||
new NodeFile([new Uint8Array(bytes).buffer], name) as unknown as File;
|
||||
|
||||
describe("bounded 7z structural inspection", () => {
|
||||
it("validates both start CRCs and inventories plain FilesInfo names", async () => {
|
||||
const names = utf16le("alpha.txt\0folder\0");
|
||||
const next = bytes(
|
||||
[
|
||||
0x01,
|
||||
0x05,
|
||||
0x02,
|
||||
0x0e,
|
||||
0x01,
|
||||
0x40,
|
||||
0x0f,
|
||||
0x01,
|
||||
0x00,
|
||||
0x11,
|
||||
names.length + 1,
|
||||
0x00,
|
||||
],
|
||||
names,
|
||||
[0x00, 0x00],
|
||||
);
|
||||
const document = await inspectArchive(asFile(sevenZip(next), "plain.7z"));
|
||||
expect(document.structural).toMatchObject({
|
||||
parser: "7z",
|
||||
headerCrcs: { verified: 2, failed: 0 },
|
||||
nextHeader: { kind: "plain", metadataParsed: true },
|
||||
});
|
||||
expect(
|
||||
document.entries.map(({ path, kind, sizeKnown, extractable }) => ({
|
||||
path,
|
||||
kind,
|
||||
sizeKnown,
|
||||
extractable,
|
||||
})),
|
||||
).toEqual([
|
||||
{ path: "alpha.txt", kind: "file", sizeKnown: false, extractable: false },
|
||||
{
|
||||
path: "folder/",
|
||||
kind: "directory",
|
||||
sizeKnown: true,
|
||||
extractable: false,
|
||||
},
|
||||
]);
|
||||
expect(reportJson(document)).toContain(
|
||||
"packed streams, codec chains, passwords and extraction are unsupported",
|
||||
);
|
||||
});
|
||||
|
||||
it("reports an encoded next header without decoding it", async () => {
|
||||
const document = await inspectArchive(
|
||||
asFile(sevenZip(new Uint8Array([0x17])), "encoded.7z"),
|
||||
);
|
||||
expect(document.entries).toEqual([]);
|
||||
expect(document.structural?.nextHeader).toMatchObject({
|
||||
kind: "encoded",
|
||||
metadataParsed: false,
|
||||
});
|
||||
expect(document.issues.map((issue) => issue.code)).toContain(
|
||||
"SEVEN_ZIP_ENCODED_HEADER",
|
||||
);
|
||||
});
|
||||
|
||||
it("fails closed on a corrupt next-header CRC", async () => {
|
||||
const input = sevenZip(new Uint8Array([0x17]));
|
||||
input[input.length - 1] = input[input.length - 1]! ^ 1;
|
||||
await expect(inspectArchive(asFile(input, "corrupt.7z"))).rejects.toThrow(
|
||||
/next-header CRC/iu,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("bounded RAR structural inspection", () => {
|
||||
it("validates RAR5 blocks and inventories a stored file", async () => {
|
||||
const name = new TextEncoder().encode("hello.txt");
|
||||
const archive = bytes(
|
||||
[0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00],
|
||||
rar5Block([0x01, 0x00, 0x00]),
|
||||
rar5Block(
|
||||
[0x02, 0x1b, 0x02, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, name.length],
|
||||
bytes(name, [0x01, 0x01]),
|
||||
[1, 2, 3],
|
||||
),
|
||||
rar5Block([0x05, 0x00, 0x00]),
|
||||
);
|
||||
const document = await inspectArchive(asFile(archive, "sample.rar"));
|
||||
expect(document.structural).toMatchObject({
|
||||
parser: "rar5",
|
||||
blocks: 3,
|
||||
ended: true,
|
||||
});
|
||||
expect(document.entries[0]).toMatchObject({
|
||||
path: "hello.txt",
|
||||
size: 3,
|
||||
compressedSize: 3,
|
||||
compression: "RAR5 stored",
|
||||
encrypted: true,
|
||||
extractable: false,
|
||||
});
|
||||
expect(document.entries[0]?.issues.map((issue) => issue.code)).toEqual(
|
||||
expect.arrayContaining(["RAR_ENCRYPTED_ENTRY", "RAR_SPLIT_ENTRY"]),
|
||||
);
|
||||
});
|
||||
|
||||
it("validates RAR4 blocks and inventories legacy file metadata", async () => {
|
||||
const name = new TextEncoder().encode("legacy.txt");
|
||||
const fileBody = new Uint8Array(25 + name.length);
|
||||
const view = new DataView(fileBody.buffer);
|
||||
view.setUint32(0, 3, true);
|
||||
view.setUint32(4, 3, true);
|
||||
view.setUint32(9, 0x352441c2, true);
|
||||
fileBody[17] = 20;
|
||||
fileBody[18] = 0x30;
|
||||
view.setUint16(19, name.length, true);
|
||||
name.forEach((byte, index) => (fileBody[25 + index] = byte));
|
||||
const archive = bytes(
|
||||
[0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00],
|
||||
rar4Block(0x73, 0, new Uint8Array(6)),
|
||||
rar4Block(0x74, 0x8000, fileBody, new Uint8Array([1, 2, 3])),
|
||||
rar4Block(0x7b, 0, new Uint8Array()),
|
||||
);
|
||||
const document = await inspectArchive(asFile(archive, "legacy.rar"));
|
||||
expect(document.structural).toMatchObject({
|
||||
parser: "rar4",
|
||||
blocks: 3,
|
||||
ended: true,
|
||||
});
|
||||
expect(document.entries[0]).toMatchObject({
|
||||
path: "legacy.txt",
|
||||
size: 3,
|
||||
compressedSize: 3,
|
||||
compression: "RAR4 stored",
|
||||
extractable: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("stops safely at an encrypted RAR5 header and rejects bad header CRCs", async () => {
|
||||
const main = rar5Block([0x01, 0x00, 0x00]);
|
||||
const encryptedHeader = rar5Block([0x04, 0x00, 0x00]);
|
||||
const encrypted = bytes(
|
||||
[0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00],
|
||||
main,
|
||||
encryptedHeader,
|
||||
new Uint8Array([1, 2, 3]),
|
||||
);
|
||||
const document = await inspectArchive(
|
||||
asFile(encrypted, "headers-encrypted.rar"),
|
||||
);
|
||||
expect(document.structural).toMatchObject({
|
||||
encryptedHeaders: true,
|
||||
ended: false,
|
||||
});
|
||||
expect(document.issues.map((issue) => issue.code)).toContain(
|
||||
"RAR5_ENCRYPTED_HEADERS",
|
||||
);
|
||||
|
||||
const corrupt = bytes(
|
||||
[0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00],
|
||||
main,
|
||||
);
|
||||
corrupt[8] = corrupt[8]! ^ 1;
|
||||
await expect(
|
||||
inspectArchive(asFile(corrupt, "corrupt.rar")),
|
||||
).rejects.toThrow(/CRC-32/iu);
|
||||
await expect(
|
||||
inspectArchive(
|
||||
asFile(
|
||||
bytes([0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00], [1, 2, 3]),
|
||||
"truncated.rar",
|
||||
),
|
||||
),
|
||||
).rejects.toThrow(/truncated/iu);
|
||||
});
|
||||
|
||||
it("stops safely before encrypted RAR4 file headers", async () => {
|
||||
const archive = bytes(
|
||||
[0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00],
|
||||
rar4Block(0x73, 0x0080, new Uint8Array(6)),
|
||||
[9, 9, 9],
|
||||
);
|
||||
const document = await inspectArchive(
|
||||
asFile(archive, "rar4-encrypted-headers.rar"),
|
||||
);
|
||||
expect(document.entries).toEqual([]);
|
||||
expect(document.structural).toMatchObject({
|
||||
parser: "rar4",
|
||||
encryptedHeaders: true,
|
||||
ended: false,
|
||||
});
|
||||
expect(document.issues.map((issue) => issue.code)).toContain(
|
||||
"RAR4_ENCRYPTED_HEADERS",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function sevenZip(next: Uint8Array): Uint8Array {
|
||||
const result = new Uint8Array(32 + next.length);
|
||||
result.set([0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c, 0x00, 0x04]);
|
||||
const view = new DataView(result.buffer);
|
||||
view.setBigUint64(12, 0n, true);
|
||||
view.setBigUint64(20, BigInt(next.length), true);
|
||||
view.setUint32(28, crc32(next), true);
|
||||
view.setUint32(8, crc32(result.subarray(12, 32)), true);
|
||||
result.set(next, 32);
|
||||
return result;
|
||||
}
|
||||
|
||||
function rar5Block(
|
||||
body: number[] | Uint8Array,
|
||||
suffix?: Uint8Array,
|
||||
data?: number[] | Uint8Array,
|
||||
): Uint8Array {
|
||||
const headerBody = bytes(body, suffix ?? new Uint8Array());
|
||||
const size = vint(headerBody.length);
|
||||
const crcInput = bytes(size, headerBody);
|
||||
const header = new Uint8Array(4 + crcInput.length);
|
||||
new DataView(header.buffer).setUint32(0, crc32(crcInput), true);
|
||||
header.set(crcInput, 4);
|
||||
return bytes(header, data ?? new Uint8Array());
|
||||
}
|
||||
|
||||
function rar4Block(
|
||||
type: number,
|
||||
flags: number,
|
||||
body: Uint8Array,
|
||||
data = new Uint8Array(),
|
||||
): Uint8Array {
|
||||
const header = new Uint8Array(7 + body.length);
|
||||
const view = new DataView(header.buffer);
|
||||
header[2] = type;
|
||||
view.setUint16(3, flags, true);
|
||||
view.setUint16(5, header.length, true);
|
||||
header.set(body, 7);
|
||||
view.setUint16(0, crc32(header.subarray(2)) & 0xffff, true);
|
||||
return bytes(header, data);
|
||||
}
|
||||
|
||||
function vint(value: number): Uint8Array {
|
||||
const result: number[] = [];
|
||||
do {
|
||||
const next = value & 0x7f;
|
||||
value >>>= 7;
|
||||
result.push(value ? next | 0x80 : next);
|
||||
} while (value);
|
||||
return new Uint8Array(result);
|
||||
}
|
||||
|
||||
function utf16le(value: string): Uint8Array {
|
||||
const result = new Uint8Array(value.length * 2);
|
||||
const view = new DataView(result.buffer);
|
||||
for (let index = 0; index < value.length; index += 1)
|
||||
view.setUint16(index * 2, value.charCodeAt(index), true);
|
||||
return result;
|
||||
}
|
||||
|
||||
function bytes(...parts: (number[] | Uint8Array)[]): Uint8Array {
|
||||
const arrays = parts.map((part) =>
|
||||
part instanceof Uint8Array ? part : new Uint8Array(part),
|
||||
);
|
||||
const result = new Uint8Array(
|
||||
arrays.reduce((sum, part) => sum + part.length, 0),
|
||||
);
|
||||
let offset = 0;
|
||||
for (const part of arrays) {
|
||||
result.set(part, offset);
|
||||
offset += part.length;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
// @vitest-environment node
|
||||
import { File } from "node:buffer";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { gzipDeterministic, gunzipBounded } from "../../src/archive/gzip";
|
||||
import {
|
||||
gzipDeterministic,
|
||||
gunzipBounded,
|
||||
gunzipBoundedDetailed,
|
||||
} from "../../src/archive/gzip";
|
||||
import { createTar, parseTar } from "../../src/archive/tar";
|
||||
|
||||
function input(path: string, text: string) {
|
||||
@@ -73,15 +77,80 @@ describe("TAR, USTAR, PAX and gzip", () => {
|
||||
expect(() => gunzipBounded(compressed, 1024)).toThrow(/expanded-byte/iu);
|
||||
});
|
||||
|
||||
it("explicitly rejects concatenated gzip members", () => {
|
||||
it("decodes concatenated gzip members and validates each footer", () => {
|
||||
const left = gzipDeterministic(new TextEncoder().encode("left"));
|
||||
const right = gzipDeterministic(new TextEncoder().encode("right"));
|
||||
const joined = new Uint8Array(left.length + right.length);
|
||||
joined.set(left);
|
||||
joined.set(right, left.length);
|
||||
expect(() => gunzipBounded(joined, 1024)).toThrow(/multi-member/iu);
|
||||
expect(new TextDecoder().decode(gunzipBounded(joined, 1024))).toBe(
|
||||
"leftright",
|
||||
);
|
||||
expect(gunzipBoundedDetailed(joined, 1024).members).toMatchObject([
|
||||
{ index: 0, expandedBytes: 4 },
|
||||
{ index: 1, expandedBytes: 5 },
|
||||
]);
|
||||
joined[left.length - 8] = joined[left.length - 8]! ^ 1;
|
||||
expect(() => gunzipBounded(joined, 1024)).toThrow(/member 1/iu);
|
||||
});
|
||||
|
||||
it("reads bounded GNU long-name and long-link metadata", async () => {
|
||||
const regular = await createTar([input("placeholder", "data")]);
|
||||
const longPath = `${"gnu/".repeat(35)}entry.txt`;
|
||||
const named = prependGnuMetadata(regular, 0x4c, longPath);
|
||||
expect(parseTar(named).entries[0]?.path).toBe(longPath);
|
||||
|
||||
const linkTarget = `${"target/".repeat(24)}file.txt`;
|
||||
const linked = prependGnuMetadata(regular.slice(), 0x4b, linkTarget);
|
||||
linked[512 + paddedPayloadSize(linkTarget) + 156] = 0x32;
|
||||
rewriteChecksum(
|
||||
linked.subarray(
|
||||
512 + paddedPayloadSize(linkTarget),
|
||||
1024 + paddedPayloadSize(linkTarget),
|
||||
),
|
||||
);
|
||||
expect(parseTar(linked).entries[0]).toMatchObject({
|
||||
kind: "symlink",
|
||||
linkTarget,
|
||||
extractable: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function paddedPayloadSize(value: string): number {
|
||||
return (
|
||||
Math.ceil(new TextEncoder().encode(`${value}\0`).byteLength / 512) * 512
|
||||
);
|
||||
}
|
||||
|
||||
function prependGnuMetadata(
|
||||
tar: Uint8Array,
|
||||
type: number,
|
||||
value: string,
|
||||
): Uint8Array {
|
||||
const payload = new TextEncoder().encode(`${value}\0`);
|
||||
const padded = Math.ceil(payload.byteLength / 512) * 512;
|
||||
const output = new Uint8Array(512 + padded + tar.byteLength);
|
||||
const header = output.subarray(0, 512);
|
||||
header.set(new TextEncoder().encode("././@LongLink"), 0);
|
||||
header.set(new TextEncoder().encode("0000644\0"), 100);
|
||||
header.set(new TextEncoder().encode("0000000\0"), 108);
|
||||
header.set(new TextEncoder().encode("0000000\0"), 116);
|
||||
header.set(
|
||||
new TextEncoder().encode(
|
||||
`${payload.byteLength.toString(8).padStart(11, "0")}\0`,
|
||||
),
|
||||
124,
|
||||
);
|
||||
header.set(new TextEncoder().encode("00000000000\0"), 136);
|
||||
header[156] = type;
|
||||
header.set(new TextEncoder().encode("ustar\0"), 257);
|
||||
header.set(new TextEncoder().encode("00"), 263);
|
||||
rewriteChecksum(header);
|
||||
output.set(payload, 512);
|
||||
output.set(tar, 512 + padded);
|
||||
return output;
|
||||
}
|
||||
|
||||
function rewriteChecksum(header: Uint8Array) {
|
||||
header.fill(0x20, 148, 156);
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
createSafeSelectionZip,
|
||||
inspectArchive,
|
||||
readEntryBytes,
|
||||
detectArchiveFormat,
|
||||
} from "../../src/archive/service";
|
||||
|
||||
const asFile = (
|
||||
@@ -18,6 +19,26 @@ const asFile = (
|
||||
) => new NodeFile(parts, name, { type }) as unknown as globalThis.File;
|
||||
|
||||
describe("ZIP inspection and safe workflows", () => {
|
||||
it("identifies structural-only 7z, RAR4 and RAR5 inputs", () => {
|
||||
expect(
|
||||
detectArchiveFormat(
|
||||
"archive.bin",
|
||||
new Uint8Array([0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c]),
|
||||
),
|
||||
).toBe("7z");
|
||||
expect(
|
||||
detectArchiveFormat(
|
||||
"archive.bin",
|
||||
new Uint8Array([0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00]),
|
||||
),
|
||||
).toBe("rar4");
|
||||
expect(
|
||||
detectArchiveFormat(
|
||||
"archive.bin",
|
||||
new Uint8Array([0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00]),
|
||||
),
|
||||
).toBe("rar5");
|
||||
});
|
||||
it("creates byte-deterministic ZIPs, reads CRC-checked content and previews text", async () => {
|
||||
const files = [
|
||||
asFile(["hello"], "hello.txt"),
|
||||
@@ -41,7 +62,7 @@ describe("ZIP inspection and safe workflows", () => {
|
||||
).resolves.toMatchObject({ kind: "text", text: "hello" });
|
||||
});
|
||||
|
||||
it("blocks traversal, case-colliding and encrypted entries at inspection", async () => {
|
||||
it("blocks unsafe paths while opening AES entries only with a password", async () => {
|
||||
const blobWriter = new BlobWriter("application/zip");
|
||||
const writer = new ZipWriter(blobWriter, { useWebWorkers: false });
|
||||
await writer.add("../escape.txt", new TextReader("bad"), {
|
||||
@@ -67,11 +88,61 @@ describe("ZIP inspection and safe workflows", () => {
|
||||
expect(document.entries[2]?.issues.map((issue) => issue.code)).toContain(
|
||||
"DUPLICATE_PATH",
|
||||
);
|
||||
expect(document.entries[3]?.issues.map((issue) => issue.code)).toContain(
|
||||
"ENCRYPTED_ENTRY",
|
||||
);
|
||||
expect(document.entries.filter((entry) => entry.extractable)).toEqual([]);
|
||||
expect(document.entries[3]).toMatchObject({
|
||||
encrypted: true,
|
||||
encryption: "AES-256",
|
||||
extractable: true,
|
||||
});
|
||||
await expect(
|
||||
readEntryBytes(document, document.entries[3]!, 1024),
|
||||
).rejects.toThrow(/password is required/iu);
|
||||
await expect(
|
||||
readEntryBytes(document, document.entries[3]!, 1024, undefined, "wrong"),
|
||||
).rejects.toThrow(/incorrect|damaged/iu);
|
||||
expect(
|
||||
new TextDecoder().decode(
|
||||
await readEntryBytes(
|
||||
document,
|
||||
document.entries[3]!,
|
||||
1024,
|
||||
undefined,
|
||||
"test-password",
|
||||
),
|
||||
),
|
||||
).toBe("secret");
|
||||
});
|
||||
|
||||
it.each([
|
||||
["aes-256", "AES-256"],
|
||||
["zipcrypto", "ZipCrypto"],
|
||||
] as const)(
|
||||
"creates and reads %s encrypted ZIPs locally",
|
||||
async (method, label) => {
|
||||
const encrypted = await createArchive(
|
||||
[asFile(["classified"], "secret.txt")],
|
||||
"zip",
|
||||
undefined,
|
||||
undefined,
|
||||
{ password: "correct horse battery staple", method },
|
||||
);
|
||||
const document = await inspectArchive(
|
||||
asFile([await encrypted.arrayBuffer()], `${method}.zip`),
|
||||
);
|
||||
expect(document.entries[0]).toMatchObject({
|
||||
encrypted: true,
|
||||
encryption: label,
|
||||
extractable: true,
|
||||
});
|
||||
const bytes = await readEntryBytes(
|
||||
document,
|
||||
document.entries[0]!,
|
||||
1024,
|
||||
undefined,
|
||||
"correct horse battery staple",
|
||||
);
|
||||
expect(new TextDecoder().decode(bytes)).toBe("classified");
|
||||
},
|
||||
);
|
||||
|
||||
it("enforces compression-ratio policy before decompression", async () => {
|
||||
const blob = await createArchive(
|
||||
|
||||
+108
-1
@@ -42,7 +42,7 @@ test("serves the release identity and hardened headers", async ({
|
||||
const manifest = await request.get("/deep/nested/archive/toolbox-app.json");
|
||||
await expect(manifest.json()).resolves.toMatchObject({
|
||||
id: "de.add-ideas.archive-tools",
|
||||
version: "0.1.0",
|
||||
version: "0.2.0",
|
||||
entry: "./",
|
||||
requirements: { workers: false },
|
||||
});
|
||||
@@ -77,6 +77,51 @@ test("inspects, previews and safely repackages a ZIP locally", async ({
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
|
||||
test("shows validated RAR5 structural evidence without offering extraction", async ({
|
||||
page,
|
||||
}) => {
|
||||
const external = await localOnly(page);
|
||||
await page.goto("/deep/nested/archive/");
|
||||
const name = new TextEncoder().encode("evidence.txt");
|
||||
const archive = concatBytes(
|
||||
new Uint8Array([0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00]),
|
||||
rar5FixtureBlock(new Uint8Array([0x01, 0x00, 0x00])),
|
||||
rar5FixtureBlock(
|
||||
concatBytes(
|
||||
new Uint8Array([
|
||||
0x02,
|
||||
0x02,
|
||||
0x03,
|
||||
0x00,
|
||||
0x03,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
name.length,
|
||||
]),
|
||||
name,
|
||||
),
|
||||
new Uint8Array([1, 2, 3]),
|
||||
),
|
||||
rar5FixtureBlock(new Uint8Array([0x05, 0x00, 0x00])),
|
||||
);
|
||||
await page.getByLabel("Choose archive").setInputFiles({
|
||||
name: "evidence.rar",
|
||||
mimeType: "application/vnd.rar",
|
||||
buffer: Buffer.from(archive),
|
||||
});
|
||||
await expect(page.getByText("Inspected 1 entries locally.")).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: /evidence\.txt/iu }),
|
||||
).toContainText("RAR entries are inventory-only");
|
||||
await page.getByText("Structural inspection evidence").click();
|
||||
await expect(page.getByText("3 verified")).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("checkbox", { name: "Select evidence.txt" }),
|
||||
).toBeDisabled();
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
|
||||
test("blocks traversal and case-colliding ZIP paths", async ({ page }) => {
|
||||
await page.goto("/deep/nested/archive/");
|
||||
const archive = zipSync({
|
||||
@@ -156,3 +201,65 @@ test("creates a TAR and compares archive inventories", async ({ page }) => {
|
||||
page.getByRole("row", { name: /same\.txt same/u }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("creates and opens an AES-256 ZIP with a memory-only password", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/archive/");
|
||||
await page.getByRole("button", { name: "Create" }).click();
|
||||
await page.getByLabel("Files").setInputFiles({
|
||||
name: "secret.txt",
|
||||
mimeType: "text/plain",
|
||||
buffer: Buffer.from("local secret"),
|
||||
});
|
||||
await page.getByLabel("Encryption").selectOption("aes-256");
|
||||
await page.getByLabel("Password (memory only)").fill("correct horse");
|
||||
const encryptedPromise = page.waitForEvent("download");
|
||||
await page.getByRole("button", { name: "Create & download" }).click();
|
||||
const encrypted = await encryptedPromise;
|
||||
|
||||
await page.getByRole("button", { name: "Inspect & extract" }).click();
|
||||
await page.getByLabel("Choose archive").setInputFiles(await encrypted.path());
|
||||
await expect(
|
||||
page.getByRole("row", {
|
||||
name: /secret\.txt.*AES-256.*password required/iu,
|
||||
}),
|
||||
).toBeVisible();
|
||||
await page.getByLabel("ZIP password (memory only)").fill("correct horse");
|
||||
await page.getByRole("button", { name: "secret.txt" }).click();
|
||||
await expect(page.getByText("local secret")).toBeVisible();
|
||||
});
|
||||
|
||||
function rar5FixtureBlock(
|
||||
body: Uint8Array,
|
||||
data = new Uint8Array(),
|
||||
): Uint8Array {
|
||||
const size = new Uint8Array([body.length]);
|
||||
const crcInput = concatBytes(size, body);
|
||||
const header = new Uint8Array(4 + crcInput.length);
|
||||
new DataView(header.buffer).setUint32(0, fixtureCrc32(crcInput), true);
|
||||
header.set(crcInput, 4);
|
||||
return concatBytes(header, data);
|
||||
}
|
||||
|
||||
function fixtureCrc32(input: Uint8Array): number {
|
||||
let value = 0xffffffff;
|
||||
for (const byte of input) {
|
||||
value ^= byte;
|
||||
for (let bit = 0; bit < 8; bit += 1)
|
||||
value = (value >>> 1) ^ (value & 1 ? 0xedb88320 : 0);
|
||||
}
|
||||
return (value ^ 0xffffffff) >>> 0;
|
||||
}
|
||||
|
||||
function concatBytes(...parts: Uint8Array[]): Uint8Array {
|
||||
const output = new Uint8Array(
|
||||
parts.reduce((total, part) => total + part.length, 0),
|
||||
);
|
||||
let offset = 0;
|
||||
for (const part of parts) {
|
||||
output.set(part, offset);
|
||||
offset += part.length;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("keeps the primary workspace inside a narrow viewport", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/archive/");
|
||||
await expect(page.locator("main").first()).toBeVisible();
|
||||
await expect(
|
||||
page.locator("main .loading, main .workbench-loading"),
|
||||
).toHaveCount(0);
|
||||
|
||||
const widths = await page.evaluate(() => ({
|
||||
content: document.documentElement.scrollWidth,
|
||||
viewport: document.documentElement.clientWidth,
|
||||
}));
|
||||
expect(widths.viewport).toBeLessThanOrEqual(430);
|
||||
expect(widths.content).toBeLessThanOrEqual(widths.viewport + 1);
|
||||
});
|
||||
@@ -12,6 +12,8 @@ describe("Archive Tools", () => {
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "Archive Tools" }),
|
||||
).toBeVisible();
|
||||
expect(await screen.findByText("Browser-local")).toBeVisible();
|
||||
expect(
|
||||
await screen.findByText("Browser-local", {}, { timeout: 5_000 }),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user