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

Provide helpful terminal messages to fix web component CSP errors #724

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

wwwillchen
Copy link
Collaborator

@wwwillchen wwwillchen commented Aug 3, 2024

Fixes #566. This makes it a lot easier to fix CSP errors by printing a helpful message in the terminal. Particularly helpful with #723.

Screenshot:

image

Copy link
Collaborator

@richard-to richard-to left a comment

Choose a reason for hiding this comment

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

Looks like report-uri is deprecated (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-uri).

Seems like the newer way is report-to, however not all browsers support it yet (Firefox) https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-to.


One thing that could be helpful is to also include the full url that got blocked since there could be multiple files that got blocked from the same domain. So I think it could be important to verify that all the urls were expected ones.

@wwwillchen
Copy link
Collaborator Author

Looks like report-uri is deprecated (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-uri).

Seems like the newer way is report-to, however not all browsers support it yet (Firefox) https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-to.

Yeah, I looked into this a little bit, but the lack of Firefox support made me not go down the route. There's also some trickier aspects where it's unclear whether it'll work locally and there may be a delay. For now, I think report-uri is OK (I think lots of Google sites use it exclusively and not report-to) and if it does break eventually, we can switch over to report-to.

One thing that could be helpful is to also include the full url that got blocked since there could be multiple files that got blocked from the same domain. So I think it could be important to verify that all the urls were expected ones.

Good idea. I've included the full blocked URL.

@wwwillchen wwwillchen merged commit 6ca5d85 into google:main Aug 4, 2024
2 checks passed
@wwwillchen wwwillchen deleted the csp_autofix branch August 4, 2024 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it easier to debug & fix CSP (e.g. script-src, Trusted Type) errors
2 participants