From 328df23d33b3fadebb3a0cf40cc1c564657dfe08 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Sat, 4 Jul 2026 18:24:35 +0000
Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=92=20harden=20CSP=20by=20removing?=
=?UTF-8?q?=20unsafe-eval=20and=20synchronizing=20policies?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Removed 'unsafe-eval' from script-src in next.config.ts and docs layout.
- Synchronized connect-src and script-src domains across main app and docs.
- Verified that 'unsafe-inline' remains necessary for framework hydration.
---
docs/app/[[...mdxPath]]/layout.tsx | 2 +-
next.config.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/app/[[...mdxPath]]/layout.tsx b/docs/app/[[...mdxPath]]/layout.tsx
index 046b710..b60765e 100644
--- a/docs/app/[[...mdxPath]]/layout.tsx
+++ b/docs/app/[[...mdxPath]]/layout.tsx
@@ -30,7 +30,7 @@ export default async function RootLayout({ children }: { children: ReactNode })
diff --git a/next.config.ts b/next.config.ts
index 881e2c2..647836f 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -8,7 +8,7 @@ const nextConfig: NextConfig = {
headers: [
{
key: "Content-Security-Policy",
- value: "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' va.vercel-scripts.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' vitals.vercel-insights.com; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; upgrade-insecure-requests;",
+ value: "default-src 'self'; script-src 'self' 'unsafe-inline' va.vercel-scripts.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' vitals.vercel-insights.com; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; upgrade-insecure-requests;",
},
{
key: "X-Content-Type-Options",
From 2f8ae4a4047ba6349db6af2731ae841a82fdf4c8 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Sat, 4 Jul 2026 18:32:06 +0000
Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=92=20harden=20CSP=20and=20fix=20s?=
=?UTF-8?q?itemap=20test=20types?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Removed 'unsafe-eval' from CSP in next.config.ts and docs layout.
- Synchronized allowed domains in CSP for analytics and speed insights.
- Fixed TypeScript errors in docs sitemap tests by updating mocks to support async readdir.
- Rebased on main and verified all tests pass locally.
---
docs/app/sitemap.ts | 1 -
tests/unit/docs/app/sitemap.test.ts | 21 +++++++++++----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/docs/app/sitemap.ts b/docs/app/sitemap.ts
index edacb07..b17ecb2 100644
--- a/docs/app/sitemap.ts
+++ b/docs/app/sitemap.ts
@@ -45,7 +45,6 @@ export default async function sitemap(): Promise {
if (!fs.existsSync(CONTENT_DIR)) {
return [];
}
-
const paths = await getMdxFiles(CONTENT_DIR, CONTENT_DIR);
return paths.map((p) => ({
diff --git a/tests/unit/docs/app/sitemap.test.ts b/tests/unit/docs/app/sitemap.test.ts
index a44b0b3..f89893a 100644
--- a/tests/unit/docs/app/sitemap.test.ts
+++ b/tests/unit/docs/app/sitemap.test.ts
@@ -28,21 +28,22 @@ describe("Docs Sitemap", () => {
});
it("returns correct sitemap based on MDX files", async () => {
- (fs.existsSync as any).mockReturnValue(true);
- (fs.promises.readdir as any).mockImplementation((dir: string) => {
- if (dir === CONTENT_DIR) {
- return Promise.resolve([
+ vi.mocked(fs.existsSync).mockReturnValue(true);
+ vi.mocked(fs.promises.readdir).mockImplementation(async (dir: string | Buffer | URL) => {
+ const dirStr = dir.toString();
+ if (dirStr === CONTENT_DIR) {
+ return [
{ name: "index.mdx", isDirectory: () => false, isFile: () => true },
{ name: "about.md", isDirectory: () => false, isFile: () => true },
{ name: "nested", isDirectory: () => true, isFile: () => false },
- ]);
+ ] as any;
}
- if (dir === path.join(CONTENT_DIR, "nested")) {
- return Promise.resolve([
+ if (dirStr === path.join(CONTENT_DIR, "nested")) {
+ return [
{ name: "page.mdx", isDirectory: () => false, isFile: () => true },
- ]);
+ ] as any;
}
- return Promise.resolve([]);
+ return [];
});
const result = await sitemap();
@@ -72,7 +73,7 @@ describe("Docs Sitemap", () => {
});
it("returns empty array if content directory does not exist", async () => {
- (fs.existsSync as any).mockReturnValue(false);
+ vi.mocked(fs.existsSync).mockReturnValue(false);
const result = await sitemap();
expect(result).toEqual([]);
});
From be73ac5ad0c04e4ef3fab9b656924b53536798fc Mon Sep 17 00:00:00 2001
From: Amr Abed <3361565+amrabed@users.noreply.github.com>
Date: Sat, 4 Jul 2026 16:55:51 -0400
Subject: [PATCH 3/3] revert changes to sitemap file and sitemap unit tests
---
docs/app/sitemap.ts | 1 +
tests/unit/docs/app/sitemap.test.ts | 21 ++++++++++-----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/docs/app/sitemap.ts b/docs/app/sitemap.ts
index b17ecb2..edacb07 100644
--- a/docs/app/sitemap.ts
+++ b/docs/app/sitemap.ts
@@ -45,6 +45,7 @@ export default async function sitemap(): Promise {
if (!fs.existsSync(CONTENT_DIR)) {
return [];
}
+
const paths = await getMdxFiles(CONTENT_DIR, CONTENT_DIR);
return paths.map((p) => ({
diff --git a/tests/unit/docs/app/sitemap.test.ts b/tests/unit/docs/app/sitemap.test.ts
index f89893a..a44b0b3 100644
--- a/tests/unit/docs/app/sitemap.test.ts
+++ b/tests/unit/docs/app/sitemap.test.ts
@@ -28,22 +28,21 @@ describe("Docs Sitemap", () => {
});
it("returns correct sitemap based on MDX files", async () => {
- vi.mocked(fs.existsSync).mockReturnValue(true);
- vi.mocked(fs.promises.readdir).mockImplementation(async (dir: string | Buffer | URL) => {
- const dirStr = dir.toString();
- if (dirStr === CONTENT_DIR) {
- return [
+ (fs.existsSync as any).mockReturnValue(true);
+ (fs.promises.readdir as any).mockImplementation((dir: string) => {
+ if (dir === CONTENT_DIR) {
+ return Promise.resolve([
{ name: "index.mdx", isDirectory: () => false, isFile: () => true },
{ name: "about.md", isDirectory: () => false, isFile: () => true },
{ name: "nested", isDirectory: () => true, isFile: () => false },
- ] as any;
+ ]);
}
- if (dirStr === path.join(CONTENT_DIR, "nested")) {
- return [
+ if (dir === path.join(CONTENT_DIR, "nested")) {
+ return Promise.resolve([
{ name: "page.mdx", isDirectory: () => false, isFile: () => true },
- ] as any;
+ ]);
}
- return [];
+ return Promise.resolve([]);
});
const result = await sitemap();
@@ -73,7 +72,7 @@ describe("Docs Sitemap", () => {
});
it("returns empty array if content directory does not exist", async () => {
- vi.mocked(fs.existsSync).mockReturnValue(false);
+ (fs.existsSync as any).mockReturnValue(false);
const result = await sitemap();
expect(result).toEqual([]);
});