feat: add nonce support to genStyleUtils for CSP compliance#38
feat: add nonce support to genStyleUtils for CSP compliance#38
Conversation
Pass CSP nonce to useCSSVarRegister when registering CSS variables. This ensures dynamically generated style tags include the nonce attribute when Content Security Policy is enabled. Also updated @ant-design/cssinjs dependency to ^2.1.2 and fixed React import. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #38 +/- ##
==========================================
+ Coverage 90.39% 90.46% +0.06%
==========================================
Files 11 11
Lines 302 304 +2
Branches 74 74
==========================================
+ Hits 273 275 +2
Misses 29 29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the styling utility by integrating Content Security Policy (CSP) nonce support, which is crucial for applications with strict security requirements. It ensures that all dynamically injected styles are compliant with CSP rules, thereby preventing potential cross-site scripting vulnerabilities. Additionally, it includes an update to a core styling dependency and a minor refactor of a React import. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request successfully adds nonce support to genStyleUtils for CSP compliance, which is a valuable security enhancement. The dependency update for @ant-design/cssinjs is minor and the change to type-only React import is a good practice. A comprehensive test case has been added to validate the nonce functionality.
| ignore, | ||
| token: realToken, | ||
| scope: rootCls, | ||
| nonce: () => csp.nonce!, |
There was a problem hiding this comment.
The non-null assertion operator ! on csp.nonce! can be misleading here. The useCSP hook, especially its default implementation useDefaultCSP, can return an object where nonce is undefined. While () => undefined might be handled gracefully by useCSSVarRegister, it's generally better to avoid ! when nullability is possible to improve type safety clarity. Consider passing csp.nonce directly or providing a default if useCSSVarRegister strictly expects a string when the nonce property is present.
| nonce: () => csp.nonce!, | |
| nonce: () => csp.nonce, |
Pass CSP nonce to useCSSVarRegister when registering CSS variables. This ensures dynamically generated style tags include the nonce attribute when Content Security Policy is enabled.
Also updated @ant-design/cssinjs dependency to ^2.1.2 and fixed React import.