mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-14 16:08:41 +00:00
* fix(frontend): restore sanitization in custom streamdown rehype chains Streamdown 2.5 replaces its entire default rehype chain [rehype-raw, rehype-sanitize, rehype-harden] with whatever array the caller passes via the rehypePlugins prop. Every custom chain in this repo therefore rendered LLM/stored markdown without any sanitization: - Artifact markdown previews (markdown-preview-plugins.ts + artifact-file-detail.tsx) parse raw HTML via rehypeRaw, so a generated .md artifact could inject <style>/<iframe>/on* handlers into the workspace DOM (stored XSS; only javascript: anchors were blocked by the ArtifactLink component). - The memory settings summary (memory-settings-page.tsx) spread the shared preset without component overrides, so a hostile <a href="javascript:..."> in stored memory content rendered as a clickable anchor. Fix strategy: - Add rehype-sanitize (already resolved in the lockfile via streamdown) as a direct dependency and re-insert a [rehypeSanitize, schema] step in the shared preset (core/streamdown/plugins.ts). It runs after rehypeRaw (raw HTML must be parsed into hast before it can be cleaned) and before rehypeKatex/rehypeSlug (their output is trusted and would otherwise be filtered or clobbered) - the same raw -> sanitize -> math ordering streamdown itself uses. - The schema extends rehype-sanitize's GitHub-style defaultSchema (the base of streamdown's own sanitize schema) so legitimate authored artifact HTML (tables, details, images, alignment/size attributes) keeps working while script/iframe/style, on* handlers and non-allow-listed URL schemes (javascript:, data:, ...) are dropped. The only extensions are tel: hrefs and the math-inline/math-display class markers remark-math emits and rehype-katex detects. - Position rehypeSlug after the sanitize step in the artifact chain so sanitize's id clobbering (id="x" -> id="user-content-x") cannot break the heading anchors it creates. - Pass a: createMarkdownLinkComponent() on the memory settings page as defense in depth, matching the chat rendering path. Unit tests feed a hostile payload (<a href="javascript:...">, <img onerror>, <script>, <iframe>, <style>, ontoggle) through both render paths and assert no executable/clickable equivalent survives, plus regression guards for heading anchors, legitimate HTML and KaTeX math rendering. * fix(frontend): keep the sanitize clobber prefix on heading anchors; minimal lockfile Review follow-ups on the sanitization change: - Heading anchors: rehypeScopedSlug replaces rehype-slug in the artifact chain. It runs after the sanitize step (so raw-HTML headings are also anchored) but keeps rehype-sanitize's user-content- id prefix — an untrusted heading like "## current" cannot mint an unprefixed id="current" (the DOM-clobbering shape the sanitizer guards against). In-page fragment links are translated to the prefixed anchors so they still resolve; external URLs, bare "#", already-prefixed fragments and sanitize-prefixed raw-HTML ids are left untouched. - Lockfile: regenerated as a minimal diff — only the two direct-dependency importer entries (rehype-sanitize, github-slugger for the scoped slug) are added; the libc platform selectors on the 64 native package records are preserved byte-for-byte instead of being dropped by lockfile normalization. Full frontend suite: 1034 tests passing; tsc and prettier clean. * style: reorder github-slugger import ahead of the hast type import * test(e2e): expect the clobber-prefixed heading anchor in artifact preview The scoped slug plugin gives generated heading ids rehype-sanitize's user-content- prefix and translates fragment links to match, so the anchor-scroll test must locate the prefixed id. * fix(frontend): reset the scoped slugger per tree; keep footnote anchors single-prefixed Review follow-ups: - The scoped slug attacher holds one GithubSlugger, but streamdown caches the unified processor by plugin name, so the instance survived across parses and repeated renders of the same heading grew -1/-2 suffixes (the artifact-anchor e2e could not find the id on re-render). The transformer now resets the slugger per tree, as rehype-slug does; a regression test renders identical artifact markdown twice. - remark-rehype emits GFM footnote anchors already clobber-prefixed (user-content-fn-1); the sanitize step prefixed those ids again while their hrefs stayed single-prefixed, breaking footnote navigation in every chain built on the shared preset. A new rehypeClobberFragments step runs right after sanitize: double-prefixed ids are normalized back to one prefix, and unprefixed fragment hrefs are translated to the prefixed form (already-prefixed and external links untouched). The artifact slug now inserts after this step; covered by a footnote regression test on the shared render path. Unit suite 1036 passing; artifact-preview e2e verified locally (9/9, including the heading-anchor scroll test).
131 lines
4.1 KiB
JSON
131 lines
4.1 KiB
JSON
{
|
|
"name": "deer-flow-frontend",
|
|
"version": "2.1.0",
|
|
"private": true,
|
|
"type": "module",
|
|
"scripts": {
|
|
"demo:save": "node scripts/save-demo.js",
|
|
"build": "next build",
|
|
"check": "eslint . --ext .ts,.tsx && tsc --noEmit",
|
|
"dev": "next dev --turbo",
|
|
"format": "prettier --check .",
|
|
"format:write": "prettier --write .",
|
|
"lint": "eslint . --ext .ts,.tsx",
|
|
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
|
"perf:check": "node scripts/measure-route-assets.mjs --check",
|
|
"preview": "next build && next start",
|
|
"start": "next start",
|
|
"test": "rstest",
|
|
"test:e2e": "playwright test",
|
|
"typecheck": "tsc --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"@codemirror/lang-css": "^6.3.1",
|
|
"@codemirror/lang-html": "^6.4.11",
|
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
"@codemirror/lang-json": "^6.0.2",
|
|
"@codemirror/lang-markdown": "^6.5.0",
|
|
"@codemirror/lang-python": "^6.2.1",
|
|
"@codemirror/language-data": "^6.5.2",
|
|
"@langchain/core": "^1.1.15",
|
|
"@langchain/langgraph-sdk": "^1.5.3",
|
|
"@radix-ui/react-avatar": "^1.1.11",
|
|
"@radix-ui/react-collapsible": "^1.1.12",
|
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
"@radix-ui/react-hover-card": "^1.1.15",
|
|
"@radix-ui/react-icons": "^1.3.2",
|
|
"@radix-ui/react-progress": "^1.1.8",
|
|
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
"@radix-ui/react-select": "^2.2.6",
|
|
"@radix-ui/react-separator": "^1.1.8",
|
|
"@radix-ui/react-slot": "^1.2.4",
|
|
"@radix-ui/react-switch": "^1.2.6",
|
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
"@radix-ui/react-toggle": "^1.1.10",
|
|
"@radix-ui/react-toggle-group": "^1.1.11",
|
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
"@radix-ui/react-use-controllable-state": "^1.2.2",
|
|
"@streamdown/code": "1.1.1",
|
|
"@streamdown/mermaid": "1.0.2",
|
|
"@t3-oss/env-nextjs": "^0.12.0",
|
|
"@tanstack/react-query": "^5.90.17",
|
|
"@tanstack/react-virtual": "^3.13.23",
|
|
"@types/hast": "^3.0.4",
|
|
"@uiw/codemirror-theme-basic": "^4.25.4",
|
|
"@uiw/codemirror-theme-monokai": "^4.25.4",
|
|
"@uiw/react-codemirror": "^4.25.4",
|
|
"@xyflow/react": "^12.10.0",
|
|
"ai": "^6.0.33",
|
|
"best-effort-json-parser": "^1.2.1",
|
|
"canvas-confetti": "^1.9.4",
|
|
"class-variance-authority": "^0.7.1",
|
|
"clsx": "^2.1.1",
|
|
"cmdk": "^1.1.1",
|
|
"codemirror": "^6.0.2",
|
|
"date-fns": "^4.1.0",
|
|
"defu": "6.1.5",
|
|
"dotenv": "^17.2.3",
|
|
"embla-carousel-react": "^8.6.0",
|
|
"github-slugger": "^2.0.0",
|
|
"gsap": "^3.13.0",
|
|
"h3": "1.15.9",
|
|
"hast": "^1.0.0",
|
|
"katex": "^0.16.28",
|
|
"lucide-react": "^0.562.0",
|
|
"motion": "^12.26.2",
|
|
"nanoid": "^5.1.16",
|
|
"next": "^16.2.11",
|
|
"next-themes": "^0.4.6",
|
|
"nextra": "^4.6.1",
|
|
"nextra-theme-docs": "^4.6.1",
|
|
"nuxt-og-image": "^5.1.13",
|
|
"ogl": "^1.0.11",
|
|
"react": "^19.0.0",
|
|
"react-dom": "^19.0.0",
|
|
"react-resizable-panels": "^4.4.1",
|
|
"rehype-katex": "^7.0.1",
|
|
"rehype-raw": "^7.0.0",
|
|
"rehype-sanitize": "^6.0.0",
|
|
"rehype-slug": "^6.0.0",
|
|
"remark-gfm": "^4.0.1",
|
|
"remark-math": "^6.0.0",
|
|
"shiki": "3.23.0",
|
|
"sonner": "^2.0.7",
|
|
"streamdown": "2.5.0",
|
|
"tailwind-merge": "^3.4.0",
|
|
"tokenlens": "^1.3.1",
|
|
"unist-util-visit": "^5.0.0",
|
|
"use-stick-to-bottom": "^1.1.1",
|
|
"uuid": "^14.0.0",
|
|
"zod": "^3.24.2"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/eslintrc": "^3.3.1",
|
|
"@playwright/test": "^1.59.1",
|
|
"@rsbuild/plugin-react": "^2.1.0",
|
|
"@rstest/core": "^0.10.6",
|
|
"@tailwindcss/postcss": "^4.0.15",
|
|
"@testing-library/dom": "^10.4.1",
|
|
"@testing-library/react": "^16.3.2",
|
|
"@types/gsap": "^3.0.0",
|
|
"@types/node": "^20.14.10",
|
|
"@types/react": "^19.0.0",
|
|
"@types/react-dom": "^19.0.0",
|
|
"eslint": "^9.23.0",
|
|
"eslint-config-next": "^15.2.3",
|
|
"happy-dom": "^20.11.1",
|
|
"postcss": "^8.5.18",
|
|
"prettier": "^3.5.3",
|
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
"tailwindcss": "^4.0.15",
|
|
"tw-animate-css": "^1.4.0",
|
|
"typescript": "^5.8.2",
|
|
"typescript-eslint": "^8.27.0"
|
|
},
|
|
"ct3aMetadata": {
|
|
"initVersion": "7.40.0"
|
|
},
|
|
"packageManager": "pnpm@10.26.2"
|
|
}
|