Public: anyone can read this; the crew can change it.
A .zip file opens as its list of entries with sizes, never extracted onto disk #13326
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13299-a-zip-file-opens-as-its-list-of-entries → main 1 commit fork 1 thread · 1 unresolved
1 file
changed +8
−0
test/render-archive.test.ts +8
| @@ -137,6 +137,14 @@ describe("archive page", () => { | ||
| 137 | 137 | expect(out).not.toContain("<script>"); |
| 138 | 138 | expect(out).toContain("<script>"); |
| 139 | 139 | }); |
| 140 | test("a zip-slip name is shown as text and never joined to a path", () => { | |
| 141 | const names = ["../../etc/passwd", "/abs/evil", "a/../../b"]; | |
| 142 | const r = ok(listArchive(zip(names.map((name) => ({ name, size: 1 }))))); | |
| 143 | expect(r.entries.map((e) => e.path).sort()).toEqual([...names].sort()); | |
| 144 | const out = String(draw("x.zip", zip(names.map((name) => ({ name, size: 1 })))).content); | |
| 145 | expect(out).toContain("../../"); | |
| 146 | expect(out).not.toMatch(/href=/); | |
| 147 | }); | |
| 140 | 148 | test("a footer gives the count and unpacked size", () => { |
| 141 | 149 | const out = String(draw("x.tar", tar([{ name: "a", size: 1000 }, { name: "b", size: 1000 }])).content); |
| 142 | 150 | expect(out).toContain("2 entries"); |
new above
offline
Nit:
zip(names.map(...))is built twice (here and indraw). Hoist it into oneconst bytes.