Skip to content

Conversation

@zzcr
Copy link
Member

@zzcr zzcr commented Mar 18, 2025

添加配置xss白名单FAQ

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Documentation
    • Introduced a new FAQ section that outlines best practices for configuring safe content filtering. The guide provides a clear example to help configure a whitelist for trusted HTML elements, ensuring enhanced security in rich text scenarios.
    • Added details on configuring an XSS whitelist using the @opentiny/utils package, including recommended practices and a code example for setting custom XSS options.

@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2025

Walkthrough

A new section has been added to the FAQ documentation that explains how to configure an XSS whitelist using the @opentiny/utils package (supported from version 3.21.0). The update includes a code example demonstrating the use of the setXssOption method to configure safe HTML tags (e.g., a and img) and their attributes. No changes were made to any exported or public entities.

Changes

File(s) Change Summary
examples/.../faq.md Added a new section detailing XSS whitelist configuration using @opentiny/utils with a code example covering the setup of safe HTML tags and attributes.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Doc as Documentation
    participant Util as @opentiny/utils

    Dev->>Doc: Read XSS whitelist configuration section
    Doc-->>Dev: Display setXssOption usage example
    Dev->>Util: Call setXssOption(options)
    Util-->>Dev: Return configured XSS options
Loading

Possibly related PRs

  • feat(utils): add a whitelist for xss in rich text components #2879: The changes in the main PR regarding the configuration of an XSS whitelist using the @opentiny/utils package are directly related to the modifications in the retrieved PR that also focus on enhancing the XSS whitelist for specific HTML tags.
  • fix(fluent-editor): fix link and img render error #2142: The changes in the main PR regarding the configuration of an XSS whitelist using the @opentiny/utils package are directly related to the modifications in the retrieved PR that enhance the allowed attributes for HTML elements in the context of XSS protection.
  • fix(fluent-editor): fix link img render error #2156: The changes in the main PR introduce a new section on configuring an XSS whitelist using the @opentiny/utils package, while the retrieved PR modifies the xssOptions configuration to enhance XSS protection.

Suggested reviewers

  • kagol

Poem

I’m a little rabbit, hopping through the code,
Found a guide on XSS, on the documentation road.
With setXssOption in my burrow, I calibrate each tag,
Ensuring safe HTML snuggles, with no room for bug.
Hop along with me – our code’s secure and never drab! 🐇✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the documentation 对文档的改进或补充 label Mar 18, 2025
@petercat-assistant
Copy link

Walkthrough

This pull request adds a new FAQ section to the documentation, detailing how to configure an XSS whitelist using @opentiny/utils. This feature is supported from version 3.21.0 and allows developers to manually configure a whitelist for HTML tags deemed safe in rich text scenarios.

Changes

File Summary
examples/sites/demos/pc/webdoc/faq.md Added a new section explaining how to configure an XSS whitelist using @opentiny/utils, including a code example for setting custom whitelist options.

html: {
whiteList: {
a: ['class', 'style', 'contenteditable', 'data-id', 'data-title', 'data-size', 'href', 'data-last-modified'],
img: ['class', 'style', 'devui-editorx-image', 'style', 'data-image-id', 'src']

Choose a reason for hiding this comment

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

The style attribute is listed twice for the img tag in the XSS whitelist configuration. This redundancy should be removed to avoid confusion.

@github-actions
Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
examples/sites/demos/pc/webdoc/faq.md (1)

88-113: Enhance FAQ Clarity and Remove Duplicate Attribute

The new section on configuring an XSS whitelist is clear and helpful. The code example demonstrates how to use setXssOption from @opentiny/utils effectively. One minor nitpick: in the whitelist for the img tag, the attribute "style" appears twice. Consider removing the duplicate entry to avoid confusion. Additionally, you might add a reference or link to the official JS-XSS documentation for users seeking further details.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae5066a and 8d50b9b.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/webdoc/faq.md (1 hunks)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
examples/sites/demos/pc/webdoc/faq.md (1)

101-102: 🛠️ Refactor suggestion

Remove Duplicate 'style' Attribute in the Whitelist

The configuration for the img tag currently lists the style attribute twice. This redundancy could cause confusion. Please remove the duplicate entry. For example:

-      img: ['class', 'style', 'style', 'data-image-id', 'src']
+      img: ['class', 'style', 'data-image-id', 'src']
🧹 Nitpick comments (1)
examples/sites/demos/pc/webdoc/faq.md (1)

88-108: Enhance FAQ Clarity on XSS Whitelist Configuration

The new section is a valuable addition and clearly explains how to configure an XSS whitelist using the @opentiny/utils package (supported from v3.21.0). For further clarity, consider adding a brief explanation of when and why developers might need to manually adjust the whitelist for particular rich text scenarios.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d50b9b and 470b503.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/webdoc/faq.md (1 hunks)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
examples/sites/demos/pc/webdoc/faq.md (1)

88-112: XSS Whitelist FAQ Section: Clarity and Security Consideration

The new section on configuring the XSS whitelist using @opentiny/utils is clear and well-structured. The code example effectively demonstrates how to set custom XSS options and the accompanying explanation is concise. One minor suggestion:

  • Consider adding a brief note on security implications: Enabling attributes like style can sometimes introduce risks if unexpected CSS or inline style vulnerabilities are exploited. A short note or warning may help ensure developers are making an informed choice when customizing the whitelist.

Overall, the changes directly address the PR objective, and the documentation update enhances clarity regarding XSS configuration.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 470b503 and 35e2917.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/webdoc/faq.md (1 hunks)

@kagol kagol merged commit 4517ede into dev Mar 19, 2025
5 checks passed
@kagol kagol deleted the add-xss-docs-0318 branch April 14, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 对文档的改进或补充

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants