Skip to content

Commit 1204d34

Browse files
committed
[red] Require audited website dependency closure
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent 0cecfc5 commit 1204d34

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe("production build contract", () => {
9898
});
9999
});
100100

101-
it("patches remediable dependencies and bounds the build-only image parser exception", async () => {
101+
it("pins the audited build closure and excludes the vulnerable image parser package", async () => {
102102
const [packageJson, packageLock, appFiles] = await Promise.all([
103103
readFile(join(process.cwd(), "package.json"), "utf8").then(JSON.parse),
104104
readFile(join(process.cwd(), "package-lock.json"), "utf8").then(
@@ -107,13 +107,38 @@ describe("production build contract", () => {
107107
authoredFiles(join(process.cwd(), "src", "app")),
108108
]);
109109

110+
expect(packageJson.dependencies?.vinext).toBe("1.0.0-beta.8");
111+
expect(packageJson.devDependencies?.["@vitejs/plugin-rsc"]).toBe("0.5.34");
112+
expect(packageJson.scripts?.["audit:dependencies"]).toBe(
113+
"npm audit --audit-level=high",
114+
);
115+
expect(packageJson.scripts?.check).toContain("npm run audit:dependencies");
110116
expect(packageJson.overrides?.next?.postcss).toBe("8.5.26");
117+
expect(packageLock.packages?.["node_modules/vinext"]?.version).toBe(
118+
"1.0.0-beta.8",
119+
);
120+
expect(
121+
packageLock.packages?.["node_modules/@vitejs/plugin-rsc"]?.version,
122+
).toBe("0.5.34");
111123
expect(packageLock.packages?.["node_modules/postcss"]?.version).toBe(
112124
"8.5.26",
113125
);
114126
expect(packageLock.packages?.["node_modules/nanoid"]?.version).toBe(
115127
"3.3.18",
116128
);
129+
expect(packageLock.packages?.["node_modules/image-size"]).toBeUndefined();
130+
expect(
131+
(
132+
Object.values(packageLock.packages ?? {}) as Array<{
133+
dependencies?: Record<string, string>;
134+
optionalDependencies?: Record<string, string>;
135+
}>
136+
).some(
137+
(entry) =>
138+
entry?.dependencies?.["image-size"] !== undefined ||
139+
entry?.optionalDependencies?.["image-size"] !== undefined,
140+
),
141+
).toBe(false);
117142

118143
const metadataImageRoute =
119144
/^(?:favicon|icon|apple-icon|opengraph-image|twitter-image)(?:\..+)?$/;

0 commit comments

Comments
 (0)