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

fix: allow inline styles from angular-sanitize in CSP #316

Merged
merged 1 commit into from
Sep 14, 2020

Conversation

mantariksh
Copy link
Contributor

Problem

Since the last release a week ago, Sentry has had 1.2m events due to CSP errors. While the errors do not seem to affect any functionality, they are likely to cause us to burst our Sentry limits again.

In particular, there are problems caused by the angular-sanitize package, which show up in both the form.gov.sg landing page and all public forms:
image

As well as problems due to the jquery package, which show up in the form.gov.sg landing page:
image

Solution

Allow inline styles from angular-sanitize.js by adding the relevant hash to the allowed style-src list. This fixes the issue on public forms:
Screenshot 2020-09-14 at 9 08 48 AM

However, the issue with jquery is less straightforward because it sets attributes rather than inline style tags, so we cannot use a hash. Since we don't want to introduce security vulnerabilities by adding unsafe-inline, it seems we have to put up with our Sentry being somewhat polluted by CSP errors until we move to React. Hopefully fixing the issue for angular-sanitize will significantly reduce the errors, since that is the issue which appears on public forms.

Copy link
Contributor

@liangyuanruo liangyuanruo left a comment

Choose a reason for hiding this comment

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

lgtm. Could you also configure sentry to block the event to preserve our quota? The option is under the project settings somewhere.

@mantariksh mantariksh merged commit 77b5b94 into develop Sep 14, 2020
@tshuli tshuli mentioned this pull request Sep 15, 2020
@karrui karrui deleted the fix-sentry branch November 18, 2020 07:25
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.

2 participants