-
Notifications
You must be signed in to change notification settings - Fork 56
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
IBX-5852: Created a new layout for error pages to prevent leak data #2106
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
src/bundle/Resources/public/js/scripts/admin.error.page.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(function(doc) { | ||
const notificationsContainer = doc.querySelector('.ez-notifications-container'); | ||
const notifications = JSON.parse(notificationsContainer.dataset.notifications); | ||
const template = notificationsContainer.dataset.template; | ||
|
||
const escapeHTML = (string) => { | ||
const stringTempNode = doc.createElement('div'); | ||
|
||
stringTempNode.appendChild(doc.createTextNode(string)); | ||
|
||
return stringTempNode.innerHTML; | ||
}; | ||
|
||
const addNotification = ({ detail }) => { | ||
const { label, message } = detail; | ||
const templateLabel = label === 'error' ? 'danger' : label; | ||
const container = doc.createElement('div'); | ||
let finalMessage = escapeHTML(message); | ||
|
||
const notification = template | ||
.replace('{{ label }}', templateLabel) | ||
.replace('{{ message }}', finalMessage) | ||
.replace('{{ badge }}', label); | ||
|
||
container.insertAdjacentHTML('beforeend', notification); | ||
|
||
const notificationNode = container.querySelector('.alert'); | ||
|
||
notificationsContainer.append(notificationNode); | ||
}; | ||
|
||
Object.entries(notifications).forEach(([label, messages]) => { | ||
messages.forEach((message) => addNotification({ detail: { label, message } })); | ||
}); | ||
})(window.document); |
4 changes: 1 addition & 3 deletions
4
src/bundle/Resources/views/themes/admin/ui/error_page/403.html.twig
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
8 changes: 1 addition & 7 deletions
8
src/bundle/Resources/views/themes/admin/ui/error_page/404.html.twig
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
4 changes: 1 addition & 3 deletions
4
src/bundle/Resources/views/themes/admin/ui/error_page/unknown.html.twig
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
47 changes: 47 additions & 0 deletions
47
src/bundle/Resources/views/themes/admin/ui/layout_error.html.twig
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html lang="{{ app.request.locale }}"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
{% block meta %} | ||
{% endblock %} | ||
{% if app.request.locale == 'ach_UG' %} | ||
<script type="text/javascript"> | ||
var _jipt = []; | ||
_jipt.push(['project', 'ezplatform']); | ||
</script> | ||
<script type="text/javascript" src="//cdn.crowdin.com/jipt/jipt.js"></script> | ||
{% endif %} | ||
<title>{% block title %}Ibexa DXP{% endblock %}</title> | ||
{{ encore_entry_link_tags('ezplatform-admin-ui-layout-css', null, 'ezplatform') }} | ||
<script src="{{ asset('bundles/ezplatformadminuiassets/vendors/jquery/dist/jquery.min.js') }}"></script> | ||
<script src="{{ asset('bundles/ezplatformadminuiassets/vendors/bootstrap/dist/js/bootstrap.min.js') }}"></script> | ||
|
||
{% block stylesheets %}{% endblock %} | ||
<link rel="icon" type="image/x-icon" href="{{ asset('bundles/ezplatformadminui/img/favicon.ico') }}" /> | ||
<link rel="icon" type="image/png" sizes="16x16" href="{{ asset('bundles/ezplatformadminui/img/favicon-16x16.png') }}" /> | ||
<link rel="icon" type="image/png" sizes="32x32" href="{{ asset('bundles/ezplatformadminui/img/favicon-32x32.png') }}" /> | ||
|
||
</head> | ||
<body class="{% block body_class %}{% endblock %}"> | ||
<div class="container-fluid ez-main-container"> | ||
{% block content %} | ||
{% endblock content %} | ||
</div> | ||
|
||
{% block footer %} | ||
{% include '@ezdesign/ui/footer.html.twig' %} | ||
{% endblock %} | ||
|
||
<div | ||
class="ez-notifications-container" | ||
data-notifications="{{ app.flashes|json_encode() }}" | ||
data-template="{{ include('@ezdesign/ui/notification.html.twig', { | ||
label: '{{ label }}', | ||
message: '{{ message }}', | ||
badge: '{{ badge }}' | ||
})|e('html_attr') }}"></div> | ||
|
||
{{ encore_entry_script_tags('ezplatform-admin-ui-error-page-js', null, 'ezplatform') }} | ||
{{ ez_render_component_group('stylesheet-body') }} | ||
</body> | ||
</html> |
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.
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.
Comment on the security hotspot alert for this? https://sonarcloud.io/project/security_hotspots?id=ezsystems_ezplatform-admin-ui&pullRequest=2106&resolved=false&types=SECURITY_HOTSPOT
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.
If this integrity check can be used, it would be good: https://sonarcloud.io/organizations/ezsystems/rules?open=Web%3AS5725&rule_key=Web%3AS5725&tab=how_to_fix
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.
this code was from our default layout: https://github.com/ezsystems/ezplatform-admin-ui/blob/2.3/src/bundle/Resources/views/themes/admin/ui/layout.html.twig#L88
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.
DO NOT COMMIT, just an example
So this alert is not from this PR, but I'm trying to resolve it anyway. The subresource integrity check makes sense here. Making the hash is easy. But we need to lock it to a specific version of the JS code, so it doesn't break on the next update. I haven't yet found how crowdin would specify the version.
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#tools_for_generating_sri_hashes
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.
NB: This should not hold up this PR - but please look into it as a follow-up, if merged without a fix for this.
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.
@glye I asked Crowdin about this and here is an answer:
"The team told me that we don’t have versions of jipt.js. Bug fixes or new features may be introduced to the file"
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.
Thanks. That's unfortunate. The only way to secure it is to bundle it, then, and ensure we update it during release cycles.
Anyway, this problem should not block this PR since it's pre-existing.