-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: Fix CSP eval violation and add a test to protect against future violations #32291
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
Conversation
|
Size Change: +4.99 kB (+0.14%) Total Size: 3.66 MB
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR addresses a Content Security Policy (CSP) violation caused by eval() usage in a third-party dependency, upgrading @microlink/react-json-view and implementing preventive measures.
- Added
frontend/bin/check-toolbar-csp-eval.mjsto detect potential CSP violations by scanning foreval(),Functionconstructors, and unsafe timer patterns - Updated
@microlink/react-json-viewfrom v1.21.3 to v1.26.2 to resolve CSP violation - Added new CI step in
.github/workflows/ci-frontend.ymlto run CSP violation checks - Added
@babel/parserand@babel/traverseas dev dependencies for AST parsing
3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
I wasn't able to run it locally so far but lgtm
| # we only care if the toolbar will increase a lot | ||
| minimum-change-threshold: 1000 | ||
|
|
||
| - name: Check toolbar for CSP eval violations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Important
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Problem
We accidentally broke people's CSP rules with a 3rd party library where were webpack was including an
eval()It'd be good to fix this! I made a PR in the library, and the maintainer was super-responsive. microlinkhq/react-json-view#77
Changes
Let's bump the dependency and add a script to protect against this kind of thing in the future
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
The script fails with the old dep, passes with the new