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

[PPP-5199][Update XSS Vulnerabilities] #854

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
*
*/
define(["dojo/_base/declare", "dijit/_WidgetBase", "dijit/_Templated", "dojo/on", "dojo/query",
"pentaho/common/button", "pentaho/common/Dialog", "dojo/text!pentaho/reportviewer/GlassPane.html"],
function(declare, _WidgetBase, _Templated, on, query, button, Dialog, templateStr){
"pentaho/common/button", "pentaho/common/Dialog", "dojo/text!pentaho/reportviewer/GlassPane.html", "common-ui/dompurify"],
function(declare, _WidgetBase, _Templated, on, query, button, Dialog, templateStr, DOMPurify){
return declare("pentaho.reportviewer.GlassPane", [Dialog],
{
buttons: ['ok'],
imagePath: '',
hasTitleBar: false,

setTitle: function(title) {
this.glasspanetitle.innerHTML = title;
this.glasspanetitle.innerHTML = DOMPurify.sanitize(title);
},

setText: function(text) {
this.glasspanemessage.innerHTML = text;
this.glasspanemessage.innerHTML = DOMPurify.sanitize(text);
},

setButtonText: function(text) {
this.buttons[0] = text;
query("#button"+0, this.domNode).forEach(function(node, index, arr){
node.innerHTML = text;
node.innerHTML = DOMPurify.sanitize(text);
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ define(function() {
if(!enabled) { return null; }

// May be null in case popups blocked
var logWin = window.open('', options.winname || 'report_viewer_log');
/* noopener and noreferrer: These attributes mitigate the risk of tabnabbing and
prevent the new page from accessing the original window’s properties. */
var logWin = window.open('', options.winname || 'report_viewer_log', 'noopener,noreferrer');
if(!logWin) { return null; }

var logDoc = logWin.document;
Expand Down
16 changes: 9 additions & 7 deletions core/src/main/javascript/reportviewer/reportviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ define([ 'common-ui/util/util', 'common-ui/util/timeutil', 'common-ui/util/forma
"dojo/dom", "dojo/on", "dojo/_base/lang", "dijit/registry", "dojo/has", "dojo/sniff", "dojo/dom-class",
'pentaho/reportviewer/ReportDialog', "dojo/dom-style",
"dojo/query", "common-ui/util/_a11y", "dojo/dom-geometry", "dojo/parser", "dojo/window", "dojo/_base/window",
'cdf/lib/jquery', 'amd!cdf/lib/jquery.ui', "common-repo/pentaho-ajax", "dijit/ProgressBar", "common-data/xhr"],
'cdf/lib/jquery', 'amd!cdf/lib/jquery.ui', "common-repo/pentaho-ajax", "dijit/ProgressBar", "common-data/xhr", "common-ui/dompurify"],
function(util, _timeutil, _formatting, _Messages, dom, on, lang, registry, has, sniff, domClass, ReportDialog,
domStyle, query, a11yUtil, geometry, parser, win, win2, $) {
domStyle, query, a11yUtil, geometry, parser, win, win2, $, DOMPurify) {
return function(reportPrompt) {
if (!reportPrompt) {
alert("report prompt is required");
Expand Down Expand Up @@ -822,7 +822,9 @@ define([ 'common-ui/util/util', 'common-ui/util/timeutil', 'common-ui/util/forma
if(isRunningIFrameInSameOrigin) {
if (!top.mantle_initialized) {
this._topMantleOpenTabRegistration = top.mantle_openTab = function(name, title, url) {
window.open(url, '_blank');
/* noopener and noreferrer: These attributes mitigate the risk of tabnabbing and
prevent the new page from accessing the original window’s properties. */
window.open(DOMPurify.sanitize(url), '_blank', 'noopener,noreferrer');
};
}

Expand Down Expand Up @@ -1193,7 +1195,7 @@ define([ 'common-ui/util/util', 'common-ui/util/timeutil', 'common-ui/util/forma
hideDlgAndPane(registry.byId('feedbackScreen'));

//Show loading screen
$('#notification-message').html(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages);
$('#notification-message').html(DOMPurify.sanitize(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages));
$('#notification-screen').css("z-index", 100);
if (me._currentReportStatus == 'CONTENT_AVAILABLE') {
domClass.remove('notification-screen', 'hidden');
Expand Down Expand Up @@ -1236,7 +1238,7 @@ define([ 'common-ui/util/util', 'common-ui/util/timeutil', 'common-ui/util/forma
isPageCountUpdated = true;
}

$('#notification-message').html(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages);
$('#notification-message').html(DOMPurify.sanitize(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages));
registry.byId('reportGlassPane').setText(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages);

me._keepPolling(mainJobStatus.uuid, url, mainReportGeneration);
Expand All @@ -1246,13 +1248,13 @@ define([ 'common-ui/util/util', 'common-ui/util/timeutil', 'common-ui/util/forma
case "QUEUED":
case "WORKING":
// Although we are hiding the screen latter, update the label anyway;
$('#notification-message').html(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages);
$('#notification-message').html(DOMPurify.sanitize(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages));
me._hideAsyncScreens();
me._keepPolling(mainJobStatus.uuid, url, mainReportGeneration);
break;
case "FINISHED":
// Although we are hiding the screen latter, update the label anyway;
$('#notification-message').html(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages);
$('#notification-message').html(DOMPurify.sanitize(_Messages.getString('LoadingPage') + " " + mainJobStatus.page + " " + _Messages.getString('Of') + " " + mainJobStatus.totalPages));
me._isFinished = true;

hideDlgAndPane(registry.byId('feedbackScreen'));
Expand Down