fix: allow inline styles from angular-sanitize in CSP #316
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theform.gov.sg
landing page and all public forms:As well as problems due to the
jquery
package, which show up in theform.gov.sg
landing page:Solution
Allow inline styles from
angular-sanitize.js
by adding the relevant hash to the allowedstyle-src
list. This fixes the issue on public forms: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 addingunsafe-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 forangular-sanitize
will significantly reduce the errors, since that is the issue which appears on public forms.