Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏷️ type: add Conversation type export #258

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Binary file modified bun.lockb
Binary file not shown.
15 changes: 9 additions & 6 deletions components/bubble/demo/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ const text = `
Link: [Ant Design X](https://x.ant.design)
`.trim();

const renderMarkdown: BubbleProps['messageRender'] = (content) => (
<Typography>
{/* biome-ignore lint/security/noDangerouslySetInnerHtml: used in demo */}
<div dangerouslySetInnerHTML={{ __html: md.render(content) }} />
</Typography>
);
const renderMarkdown: BubbleProps['messageRender'] = (content) => {
console.log('content', content);
return (
<Typography>
{/* biome-ignore lint/security/noDangerouslySetInnerHtml: used in demo */}
<div dangerouslySetInnerHTML={{ __html: md.render(content) }} />
</Typography>
);
};
Comment on lines +17 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

需要添加安全警告注释

代码中已经包含了 biome-ignore 注释说明这是演示用途,但建议在 markdown-it 的初始化配置处也添加相应的安全警告注释。具体需要:

  • const md = markdownit({ html: true, breaks: true }); 这行代码前添加注释,说明启用 HTML 渲染可能存在 XSS 风险,仅用于演示目的。
🔗 Analysis chain

注意 XSS 安全风险

当前 markdown-it 配置允许渲染 HTML(html: true),这可能带来潜在的 XSS 风险。虽然这是演示代码,但建议添加注释说明安全考虑。

运行以下脚本检查是否有其他使用 markdown-it 的实例:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:检查 markdown-it 的配置和使用情况

# 搜索 markdown-it 的配置
rg "markdownit\({" -A 3

Length of output: 115


Script:

#!/bin/bash
# 搜索 markdown-it 的配置和使用
rg "markdown-it" -A 3

# 搜索 dangerouslySetInnerHTML 的使用
rg "dangerouslySetInnerHTML" -A 3

Length of output: 1630


Script:

#!/bin/bash
# 搜索 markdown-it 的初始化配置
rg "const\s+\w+\s*=\s*(?:new\s+)?markdownit" -A 5

# 查找 markdown.tsx 文件中的完整配置
cat components/bubble/demo/markdown.tsx

Length of output: 1779


const App = () => {
const [renderKey, setRenderKey] = React.useState(0);
Expand Down
2 changes: 1 addition & 1 deletion components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export { default as Bubble } from './bubble';
export type { BubbleProps } from './bubble';

export { default as Conversations } from './conversations';
export type { ConversationsProps } from './conversations';
export type { ConversationsProps, Conversation } from './conversations';

export { default as Prompts } from './prompts';
export type { PromptsProps, PromptProps } from './prompts';
Expand Down