-
Notifications
You must be signed in to change notification settings - Fork 3
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
Forbid unsafe-inline for style attributes in CSP #291
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kevindew
force-pushed
the
forbid-inline-styles
branch
from
April 27, 2023 15:58
8e81376
to
55b2547
Compare
kevindew
added a commit
to alphagov/govuk_publishing_components
that referenced
this pull request
May 23, 2023
This removes setting list-style on ordered lists to instead allow the use of the type attribute on an ordered list to specify the list-style. I couldn't determine why this style was needed. Current browsers style this as list-style decimal by default and I can't find any code this undoes. It could be that previously this was to undo an earlier override, but it would be very unconventional for current GOV.UK to style an `ol` without a class so this seems unlikely. The motivation for making this change is to support some niche behaviour used by publishers that will become disabled. Currently some advanced published have managed to published ordered lists that are alphabetical or roman numeral prefixed by use of an `ol` element with a style attribute. This will not be available with the role out of the GOV.UK Content Security Policy which forbids unsafe inline styles [1]. [1]: alphagov/govuk_app_config#291
kevindew
added a commit
to alphagov/govuk_publishing_components
that referenced
this pull request
May 23, 2023
This removes setting list-style on ordered lists to instead allow the use of the type attribute on an ordered list to specify the list-style. I couldn't determine why this style was needed. Current browsers style this as list-style decimal by default and I can't find any code this undoes. It could be that previously this was to undo an earlier override, but it would be very unconventional for current GOV.UK to style an `ol` without a class so this seems unlikely. The motivation for making this change is to support some niche behaviour used by publishers that will become disabled. Currently some advanced published have managed to published ordered lists that are alphabetical or roman numeral prefixed by use of an `ol` element with a style attribute. This will not be available with the role out of the GOV.UK Content Security Policy which forbids unsafe inline styles [1]. [1]: alphagov/govuk_app_config#291
kevindew
added a commit
to alphagov/govuk_publishing_components
that referenced
this pull request
Jun 2, 2023
This removes setting list-style on ordered lists to instead allow the use of the type attribute on an ordered list to specify the list-style. I couldn't determine why this style was needed. Current browsers style this as list-style decimal by default and I can't find any code this undoes. It could be that previously this was to undo an earlier override, but it would be very unconventional for current GOV.UK to style an `ol` without a class so this seems unlikely. The motivation for making this change is to support some niche behaviour used by publishers that will become disabled. Currently some advanced published have managed to published ordered lists that are alphabetical or roman numeral prefixed by use of an `ol` element with a style attribute. This will not be available with the role out of the GOV.UK Content Security Policy which forbids unsafe inline styles [1]. [1]: alphagov/govuk_app_config#291
This continues the work from #279 to remove risky properties from our Content Security Policy (CSP) by removing unsafe-inline from style properties. We have been able to resolve the need for this property by updating Govspeak [1] [1]: alphagov/govspeak#268
kevindew
force-pushed
the
forbid-inline-styles
branch
from
June 2, 2023 08:24
55b2547
to
864b3e8
Compare
ChrisBAshton
approved these changes
Jun 2, 2023
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.
LGTM 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This continues the work from #279 to remove risky properties from our Content Security Policy (CSP) by removing unsafe-inline from style properties.
We have been able to resolve the need for this property by updating Govspeak 1.
I've marked this as a breaking change as it forbids something fundamental, however this is really quite a soft breaking change as a) there has been lots of prep work across GOV.UK to prepare for it and b) the CSP is in report only mode across GOV.UK so won't actually block any usages.
Prior to merging this we need to represent any content that uses tables with text alignment to the Publishing API to remove their inline styles. I've opened this as a draft while this is completed.Edit: 2 June, I've been through and removed nearly all usages of style. I'm now going to utilise the CSP reports to catch other ones.