Skip to content

Commit fb9eef8

Browse files
committed
[red] Require bundled parser hardening and attribution
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent 1204d34 commit fb9eef8

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

‎tools/web/src/test/build-contract.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,47 @@ describe("production build contract", () => {
147147
).toEqual([]);
148148
});
149149

150+
it("hardens and attributes the image parser bundled inside vinext", async () => {
151+
const bundledParserPath = join(
152+
process.cwd(),
153+
"node_modules",
154+
"vinext",
155+
"dist",
156+
"deps",
157+
".pnpm",
158+
"image-size@2.0.2",
159+
"deps",
160+
"image-size",
161+
"dist",
162+
"index.js",
163+
);
164+
const [packageJson, parserSource, notice] = await Promise.all([
165+
readFile(join(process.cwd(), "package.json"), "utf8").then(JSON.parse),
166+
readFile(bundledParserPath, "utf8"),
167+
readFile(
168+
join(process.cwd(), "public", "WEBSITE_THIRD_PARTY_LICENSES.txt"),
169+
"utf8",
170+
),
171+
]);
172+
173+
expect(packageJson.scripts?.postinstall).toBe(
174+
"node scripts/patch-vinext-image-size.js",
175+
);
176+
expect(parserSource).toContain(
177+
'if (imageHeader[1] <= 0) throw new TypeError("Invalid ICNS, zero-length image entry");',
178+
);
179+
expect(parserSource).toContain(
180+
'if (ispeBox.size <= 0) throw new TypeError("Invalid HEIF, zero-length ispe box");',
181+
);
182+
expect(parserSource).toContain(
183+
'if (jxlpBox.size <= 0) throw new TypeError("Invalid JXL, zero-length jxlp box");',
184+
);
185+
expect(notice).toContain("image-size 2.0.2");
186+
expect(notice).toContain(
187+
"Copyright © 2013-Present Aditya Yadav, http://netroy.in",
188+
);
189+
});
190+
150191
it("checks and publishes a deterministic notice for the exact website dependency closure", async () => {
151192
const [packageJson, notice] = await Promise.all([
152193
readFile(join(process.cwd(), "package.json"), "utf8").then(

0 commit comments

Comments
 (0)