Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/@apphosting/adapter-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@types/tmp": "*",
"mocha": "*",
"next": "~14.0.0",
"semver": "*",
"semver": "^7.7.3",
"tmp": "*",
"ts-mocha": "*",
"ts-node": "*",
Expand Down
2 changes: 2 additions & 0 deletions packages/@apphosting/adapter-nextjs/src/bin/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
validateOutputDirectory,
getAdapterMetadata,
exists,
checkNextJSVersion,
} from "../utils.js";
import { join } from "path";
import { getBuildOptions, runBuild } from "@apphosting/common";
Expand All @@ -24,6 +25,7 @@
// Opt-out sending telemetry to Vercel
process.env.NEXT_TELEMETRY_DISABLED = "1";

checkNextJSVersion(process.env.FRAMEWORK_VERSION)

Check failure on line 28 in packages/@apphosting/adapter-nextjs/src/bin/build.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`
const nextConfig = await loadConfig(root, opts.projectDirectory);

/**
Expand Down
18 changes: 18 additions & 0 deletions packages/@apphosting/adapter-nextjs/src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ import path from "path";
import os from "os";
import { RoutesManifest, MiddlewareManifest } from "../src/interfaces.js";

describe("block vulnerable nextjs versions", () => {
it("should allow for unspecified", async () => {
const { checkNextJSVersion } = await importUtils;

assert.throws(() => {
checkNextJSVersion("15.0.0");
});

assert.ok(() => {
checkNextJSVersion(undefined);
});

assert.ok(() => {
checkNextJSVersion("15.0.5");
});
});
Comment thread
annajowang marked this conversation as resolved.
Outdated
});

describe("manifest utils", () => {
let tmpDir: string;
let distDir: string;
Expand Down
14 changes: 13 additions & 1 deletion packages/@apphosting/adapter-nextjs/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fsExtra from "fs-extra";
import semVer from "semver";
import { createRequire } from "node:module";
import { join, dirname, relative, normalize } from "path";
import { fileURLToPath } from "url";
Expand All @@ -16,7 +17,18 @@

// fs-extra is CJS, readJson can't be imported using shorthand
export const { copy, exists, writeFile, readJson, readdir, readFileSync, existsSync, ensureDir } =
fsExtra;
fsExtra;

Check failure on line 20 in packages/@apphosting/adapter-nextjs/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `↹···`
export const {satisfies} = semVer;

Check failure on line 21 in packages/@apphosting/adapter-nextjs/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `satisfies` with `·satisfies·`

export function checkNextJSVersion(version: string | undefined) {
if (version == undefined) {

Check failure on line 24 in packages/@apphosting/adapter-nextjs/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Expected '===' and instead saw '=='
Comment thread
annajowang marked this conversation as resolved.
Outdated
return

Check failure on line 25 in packages/@apphosting/adapter-nextjs/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`
}
if (!satisfies(version, '>=16.1.0 || ^16.0.7 || ^v15.5.7 || ^v15.4.8 || ^v15.3.6 || ^v15.2.6 || ^v15.1.9 || ^v15.0.5 || <14.3.0-canary.77')) {

Check failure on line 27 in packages/@apphosting/adapter-nextjs/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `!satisfies(version,·'>=16.1.0·||·^16.0.7·||·^v15.5.7·||·^v15.4.8·||·^v15.3.6·||·^v15.2.6·||·^v15.1.9·||·^v15.0.5·||·<14.3.0-canary.77')` with `⏎····!satisfies(⏎······version,⏎······">=16.1.0·||·^16.0.7·||·^v15.5.7·||·^v15.4.8·||·^v15.3.6·||·^v15.2.6·||·^v15.1.9·||·^v15.0.5·||·<14.3.0-canary.77",⏎····)⏎··`
Comment thread
annajowang marked this conversation as resolved.
Outdated
throw new Error(

Check failure on line 28 in packages/@apphosting/adapter-nextjs/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `⏎····`
`CVE-2025-55182: Vulnerable Next version ${version} detected. Build blocked`);
}
}

// Loads the user's next.config.js file.
export async function loadConfig(root: string, projectRoot: string): Promise<NextConfigComplete> {
Expand Down
96 changes: 53 additions & 43 deletions starters/nextjs/basic/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion starters/nextjs/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"next": "15.0.0",
"next": "15.0.5",
"react": "^18",
"react-dom": "^18"
},
Expand Down
Loading