Commit 80c8f12
committed
feat(archives): add secure archive extraction with ZIP/TAR/TGZ support
Add generic archive extraction utilities with comprehensive security features
for handling ZIP, TAR, TAR.GZ, and TGZ formats. Includes path traversal
protection, zip bomb prevention, symlink blocking, and configurable size limits.
Core Features:
- Generic extractArchive() with auto-format detection
- Format-specific extractors: extractZip(), extractTar(), extractTarGz()
- Cross-platform path normalization support
- Strip option for removing leading path components
Security Features:
- Path traversal validation (blocks ../../ attacks)
- File size limits (default: 100MB per file)
- Total extraction size limits (default: 1GB)
- Symlink/hardlink detection and blocking (TAR/TGZ)
- Configurable limits for trusted sources
External Dependencies (bundled, pinned):
- adm-zip@0.5.16 (104KB, zero dependencies)
- tar-fs@3.1.2 (108KB, includes tar-stream + deps)
- Total bundle size increase: +212KB (+4.3%)
GitHub Integration:
- downloadAndExtractArchive() for any supported format
- Enhanced downloadAndExtractZip() using generic helpers
- Auto-detection from asset filenames
- Maintains backward compatibility
Testing:
- 38 archive tests passing (27 existing + 11 security tests)
- 4637 total tests passing across entire test suite
- Path traversal protection validated
- Zip bomb protection validated
- Symlink attack protection validated
- Custom size limits validated
- Cross-platform compatibility verified
Note: Vitest shows "unhandled error" warning in archive security tests.
This is a false positive - errors are properly caught by pipeline, but
Vitest detects Error construction in stream callbacks. All tests pass.1 parent d52e12d commit 80c8f12
13 files changed
Lines changed: 1732 additions & 5 deletions
File tree
- scripts/build-externals
- src
- external
- releases
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| |||
737 | 741 | | |
738 | 742 | | |
739 | 743 | | |
| 744 | + | |
740 | 745 | | |
741 | 746 | | |
742 | 747 | | |
| |||
771 | 776 | | |
772 | 777 | | |
773 | 778 | | |
| 779 | + | |
| 780 | + | |
774 | 781 | | |
775 | 782 | | |
776 | 783 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| 88 | + | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
| |||
0 commit comments