Skip to content

Commit c39b88b

Browse files
authored
fix: harden cookie flags, sanitize Genie markdown output, fix remote tunnel (#216)
* fix: harden cookie flags and sanitize Genie markdown output - Set httpOnly and secure flags on dev-tunnel-id cookie - Add DOMPurify sanitization to Genie chat message markdown rendering Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com> * fix: copy remote tunnel HTML files to dist during build Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com> * fix(ci): use npm install for PR template artifact step prepare-pr-template.ts rewrites dependencies to file: tarballs, which will never match the lockfile copied from template/ — npm ci will always fail here, so npm install is required. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com> --------- Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
1 parent 1d4eee5 commit c39b88b

7 files changed

Lines changed: 26 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ jobs:
155155

156156
- name: Install template dependencies
157157
working-directory: pr-template
158-
run: npm ci
158+
run: npm install
159159

160160
- name: Create zip artifact
161161
working-directory: pr-template

apps/dev-playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "npm run build:app",
1111
"build:app": "tsdown --out-dir build server/index.ts && cd client && npm run build",
1212
"build:server": "tsdown --out-dir build server/index.ts",
13-
"install": "cd client && npm ci && cd ..",
13+
"install": "cd client && npm install && cd ..",
1414
"preview": "vite preview",
1515
"check": "tsc",
1616
"clean": "rm -rf build && cd client && rm -rf dist",

packages/appkit-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"class-variance-authority": "0.7.1",
7878
"clsx": "2.1.1",
7979
"cmdk": "1.1.1",
80+
"dompurify": "3.3.3",
8081
"echarts": "6.0.0",
8182
"echarts-for-react": "3.0.5",
8283
"embla-carousel-react": "8.6.0",

packages/appkit-ui/src/react/genie/genie-chat-message.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import DOMPurify from "dompurify";
12
import { marked } from "marked";
23
import { useMemo } from "react";
34
import { cn } from "../lib/utils";
@@ -9,7 +10,7 @@ import type { GenieAttachmentResponse, GenieMessageItem } from "./types";
910
/**
1011
* Using `marked` instead of `react-markdown` because `react-markdown` depends on
1112
* `micromark-util-symbol` which has broken ESM exports with `rolldown-vite`.
12-
* Content comes from our own Genie API so `dangerouslySetInnerHTML` is safe.
13+
* Output is sanitized with DOMPurify before being passed to `dangerouslySetInnerHTML`.
1314
*/
1415
marked.setOptions({ breaks: true, gfm: true });
1516

@@ -43,7 +44,10 @@ export function GenieChatMessage({
4344
const isUser = message.role === "user";
4445
const queryAttachments = message.attachments.filter(isQueryAttachment);
4546
const html = useMemo(
46-
() => (message.content ? (marked.parse(message.content) as string) : ""),
47+
() =>
48+
message.content
49+
? DOMPurify.sanitize(marked.parse(message.content) as string)
50+
: "",
4751
[message.content],
4852
);
4953

packages/appkit/src/plugins/server/remote-tunnel/remote-tunnel-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ export class RemoteTunnelManager {
208208
}
209209

210210
res.cookie("dev-tunnel-id", tunnelId, {
211-
httpOnly: false,
211+
httpOnly: true,
212+
secure: true,
212213
sameSite: "lax",
213214
});
214215

packages/appkit/tsdown.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,12 @@ export default defineConfig([
2727
return /^[^./]/.test(id) || id.includes("/node_modules/");
2828
},
2929
tsconfig: "./tsconfig.json",
30+
copy: [
31+
{
32+
from: "src/plugins/server/remote-tunnel/*.html",
33+
to: "dist/plugins/server/remote-tunnel",
34+
flatten: true,
35+
},
36+
],
3037
},
3138
]);

pnpm-lock.yaml

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)