[PR #10] [MERGED] Fix crypto API, XSS, CSS import order, heading regex, installer, Workbox pattern, and timer leak #4390

Closed
opened 2026-10-22 04:07:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/10
Author: @Copilot
Created: 3/10/2026
Status: ✅ Merged
Merged: 3/10/2026
Merged by: @SpicyMarinara

Base: release/1.3.0 ← Head: copilot/sub-pr-9


📝 Commits (2)

  • 8283e3b Initial plan
  • 6116f41 Fix all review issues: crypto, XSS, CSS import, heading regex, bat installer, Workbox pattern, timer cleanup

📊 Changes

6 files changed (+69 additions, -14 deletions)

View changed files

📝 installer/install.bat (+25 -1)
📝 packages/client/src/components/agents/AgentEditor.tsx (+27 -5)
📝 packages/client/src/styles/globals.css (+1 -1)
📝 packages/client/vite.config.ts (+1 -1)
📝 packages/server/src/routes/generate.routes.ts (+2 -2)
📝 packages/server/src/routes/spotify-auth.routes.ts (+13 -4)

📄 Description

Addresses 8 issues flagged in code review across the Spotify OAuth flow, prompt injection dedup, PWA config, and the Windows installer.

Security

  • crypto.randomBytes instead of crypto.getRandomValues — getRandomValues is WebCrypto; unavailable on the Node crypto module and would throw at runtime.
  • Reflected XSS in Spotify OAuth callback — all values interpolated into HTML error responses (error, tokenRes.status, body, err.message) are now passed through htmlEscape().

Correctness

  • Markdown heading dedup regex — wrapContent(…, depth=1) emits ### Name but the duplicate check was testing `# ${name}`. Replaced with new RegExp(^#{1,6} ${escapedName}, "m") to match any heading level and names with special chars.
  • Workbox urlPattern — regex /^\/api\// never matches absolute URLs in the service worker context. Replaced with a function matcher:
    urlPattern: ({ url }) => url.pathname.startsWith("/api/"),
    
  • CSS @import ordering — @import "./themes/sillytavern.css" was at line ~1303, after thousands of style rules, making it invalid/ignored. Moved to the top, immediately after @import "tailwindcss".

Installer (install.bat)

  • Preserve default install path on Enter — set /p INSTALL_DIR=… clears the variable when the user presses Enter. Fixed using a temp USER_INPUT variable.
  • Enforce Node.js 20+ — NODE_MAJOR was extracted but never checked. Added an explicit < 20 guard with a descriptive error and early exit.

React timer leak (AgentEditor)

  • Spotify "Connect" polling used bare setInterval/setTimeout with no cleanup. Timer IDs are now stored in useRef, cleared in a useEffect return, and reset before starting a new poll to prevent stale callbacks after unmount or repeated clicks.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/10 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 3/10/2026 **Status:** ✅ Merged **Merged:** 3/10/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `release/1.3.0` ← **Head:** `copilot/sub-pr-9` --- ### 📝 Commits (2) - [`8283e3b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8283e3bfb67db2dcb718b72f9e9b3c8e6b609372) Initial plan - [`6116f41`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6116f410a6e15226f38c07960a97f091e5faab7a) Fix all review issues: crypto, XSS, CSS import, heading regex, bat installer, Workbox pattern, timer cleanup ### 📊 Changes **6 files changed** (+69 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `installer/install.bat` (+25 -1) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+27 -5) 📝 `packages/client/src/styles/globals.css` (+1 -1) 📝 `packages/client/vite.config.ts` (+1 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+2 -2) 📝 `packages/server/src/routes/spotify-auth.routes.ts` (+13 -4) </details> ### 📄 Description Addresses 8 issues flagged in code review across the Spotify OAuth flow, prompt injection dedup, PWA config, and the Windows installer. ## Security - **`crypto.randomBytes` instead of `crypto.getRandomValues`** — `getRandomValues` is WebCrypto; unavailable on the Node `crypto` module and would throw at runtime. - **Reflected XSS in Spotify OAuth callback** — all values interpolated into HTML error responses (`error`, `tokenRes.status`, `body`, `err.message`) are now passed through `htmlEscape()`. ## Correctness - **Markdown heading dedup regex** — `wrapContent(…, depth=1)` emits `### Name` but the duplicate check was testing `` `# ${name}` ``. Replaced with `new RegExp(`^#{1,6} ${escapedName}`, "m")` to match any heading level and names with special chars. - **Workbox `urlPattern`** — regex `/^\/api\//` never matches absolute URLs in the service worker context. Replaced with a function matcher: ```ts urlPattern: ({ url }) => url.pathname.startsWith("/api/"), ``` - **CSS `@import` ordering** — `@import "./themes/sillytavern.css"` was at line ~1303, after thousands of style rules, making it invalid/ignored. Moved to the top, immediately after `@import "tailwindcss"`. ## Installer (`install.bat`) - **Preserve default install path on Enter** — `set /p INSTALL_DIR=…` clears the variable when the user presses Enter. Fixed using a temp `USER_INPUT` variable. - **Enforce Node.js 20+** — `NODE_MAJOR` was extracted but never checked. Added an explicit `< 20` guard with a descriptive error and early exit. ## React timer leak (`AgentEditor`) - Spotify "Connect" polling used bare `setInterval`/`setTimeout` with no cleanup. Timer IDs are now stored in `useRef`, cleared in a `useEffect` return, and reset before starting a new poll to prevent stale callbacks after unmount or repeated clicks. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:07:10 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4390
No description provided.