-
Notifications
You must be signed in to change notification settings - Fork 193
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
Add base tag to html attachments view #5764
Conversation
d784b5f
to
d1ea6f0
Compare
Super, this looks like a good approach. Nice one working this out. Have you tried it on integration? Might also be worth checking it works ok on draft stack, but I assume Plek is fine for that. Implementation wise I'd suggest moving this from setting it on all html_publications (as the vast majority of them don't need it) and localising this to just csv_preview since that is the quirky bit of the stack. You could do that by setting |
Makes sense, thanks @kevindew. Haven't tested on integration yet as I'm waiting on the tests to pass before deploying the branch. I wasn't sure how wide to scope this change originally, which is why I added it into |
cool cool - probably worth giving it a spin on integration as is anyway just to verify it does fix the problem |
7a13849
to
5a36a48
Compare
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.
Looks good, nice one Karl
5a36a48
to
84f246d
Compare
This commit fixes a long-standing bug with Whitehall, where links in the header and footer of the CSV preview page (rendered by the `CsvPreviewController`) contain relative links that point to the incorrect site root (`assets.publishing.service.gov.uk` rather than `www.gov.uk`), resulting in `404`s to any of those links which are followed. The footer itself is obtained through Slimmer, using the `chromeless` view that's part of `Static` where most URLs in the footer are set as relative. The fix is achieved through adding a `base` tag to the `frontend_base` partial, which is set from the `CsvPreviewController` and rendered via the `html_attachments` view. By adding a `base` tag, all relative URLs on the page will be prefixed with the `href` attribute specified, which is the GOV.UK website root. The `base` tag can only appear in the `head` of a page, which is the reason for adding it into the partial `frontend_base`.
84f246d
to
5b96d9f
Compare
A base element can be used to change the destination of relative paths, this can be used as part of XSS to include a script file on a host an attacker controls. To prevent this we disable all uses of the base element as it is not used on all GOV.UK views, bar one exception. The exception is for CSV previews which are rendered by Whitehall [1] on a different hostname (assets). As this is only for one app the convention would be to modify the CSP in app. It is also unclear at this point in time when or whether we will enable the CSP on Whitehall frontend. [1]: alphagov/whitehall#5764
A base element can be used to change the destination of relative paths, this can be used as part of XSS to include a script file on a host an attacker controls. To prevent this we disable all uses of the base element as it is not used on all GOV.UK views, bar one exception. The exception is for CSV previews which are rendered by Whitehall [1] on a different hostname (assets). As this is only for one app the convention would be to modify the CSP in app. It is also unclear at this point in time when or whether we will enable the CSP on Whitehall frontend. [1]: alphagov/whitehall#5764
A base element can be used to change the destination of relative paths, this can be used as part of XSS to include a script file on a host an attacker controls. To prevent this we disable all uses of the base element as it is not used on all GOV.UK views, bar one exception. The exception is for CSV previews which are rendered by Whitehall [1] on a different hostname (assets). As this is only for one app the convention would be to modify the CSP in app. It is also unclear at this point in time when or whether we will enable the CSP on Whitehall frontend. [1]: alphagov/whitehall#5764
A base element can be used to change the destination of relative paths, this can be used as part of XSS to include a script file on a host an attacker controls. To prevent this we disable all uses of the base element as it is not used on all GOV.UK views, bar one exception. The exception is for CSV previews which are rendered by Whitehall [1] on a different hostname (assets). As this is only for one app the convention would be to modify the CSP in app. It is also unclear at this point in time when or whether we will enable the CSP on Whitehall frontend. [1]: alphagov/whitehall#5764
A base element can be used to change the destination of relative paths, this can be used as part of XSS to include a script file on a host an attacker controls. To prevent this we disable all uses of the base element as it is not used on all GOV.UK views, bar one exception. The exception is for CSV previews which are rendered by Whitehall [1] on a different hostname (assets). As this is only for one app the convention would be to modify the CSP in app. It is also unclear at this point in time when or whether we will enable the CSP on Whitehall frontend. [1]: alphagov/whitehall#5764
A base element can be used to change the destination of relative paths, this can be used as part of XSS to include a script file on a host an attacker controls. To prevent this we disable all uses of the base element as it is not used on all GOV.UK views, bar one exception. The exception is for CSV previews which are rendered by Whitehall [1] on a different hostname (assets). As this is only for one app the convention would be to modify the CSP in app. It is also unclear at this point in time when or whether we will enable the CSP on Whitehall frontend. [1]: alphagov/whitehall#5764
A base element can be used to change the destination of relative paths, this can be used as part of XSS to include a script file on a host an attacker controls. To prevent this we disable all uses of the base element as it is not used on all GOV.UK views, bar one exception. The exception is for CSV previews which are rendered by Whitehall [1] on a different hostname (assets). As this is only for one app the convention would be to modify the CSP in app. It is also unclear at this point in time when or whether we will enable the CSP on Whitehall frontend. [1]: alphagov/whitehall#5764
This PR adds a
base
tag to thehtml_attachments
view. This view is used by thecsv_preview
controller and links currently rendered in the footer on this page currently point to the wrong URL (assets rather than GOV.UK); as a result, they return 404s. The footer itself is obtained through Slimmer, using thechromeless
view that's part ofStatic
where most URLs in the footer are relative.By adding a
base
tag, all relative URLs on the page will be prefixed with thehref
attribute specified, which is the GOV.UK website root. Thebase
tag can only appear in thehead
of a page, which is the reason for adding it into the partialfrontend_base
.