Skip to content

Commit

Permalink
Fix XSS vulnerability (#3230)
Browse files Browse the repository at this point in the history
* Fix XSS vulnerability
  • Loading branch information
honnix authored Mar 14, 2023
1 parent e1d5161 commit 29887c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions luigi/static/visualiser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<script src="lib/d3/d3.min.js" charset="utf-8"></script>
<script src="lib/d3/dagre-d3.min.js"></script>
<script src="lib/mustache.js"></script>
<script src="js/util.js"></script>
<script src="js/luigi.js"></script>
<script src="js/graph.js"></script>
<script src="js/visualiserApp.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions luigi/static/visualiser/js/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Graph = (function() {
$(svgLink(node.trackingUrl))
.append(
$(svgElement("text"))
.text(node.name)
.text(escapeHtml(node.name))
.attr("y", 3))
.attr("class","graph-node-a")
.attr("data-task-status", node.status)
Expand All @@ -284,7 +284,7 @@ Graph = (function() {
container: 'body',
html: true,
placement: 'top',
content: content
content: escapeHtml(content)
});
});

Expand Down Expand Up @@ -313,7 +313,7 @@ Graph = (function() {
.appendTo(legend);

$(svgElement("text"))
.text(key.charAt(0).toUpperCase() + key.substring(1).toLowerCase().replace(/_./gi, function (x) { return " " + x[1].toUpperCase(); }))
.text(escapeHtml(key.charAt(0).toUpperCase() + key.substring(1).toLowerCase().replace(/_./gi, function (x) { return " " + x[1].toUpperCase(); })))
.attr("x", legendLineHeight + 14)
.attr("y", legendLineHeight+(x*legendLineHeight))
.appendTo(legend);
Expand Down
8 changes: 8 additions & 0 deletions luigi/static/visualiser/js/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
4 changes: 2 additions & 2 deletions luigi/static/visualiser/js/visualiserApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,8 @@ function visualiserApp(luigi) {
function renderParams(params) {
var htmls = [];
for (var key in params) {
htmls.push('<span class="param-name">' + key +
'</span>=<span class="param-value">' + params[key] + '</span>');
htmls.push('<span class="param-name">' + escapeHtml(key) +
'</span>=<span class="param-value">' + escapeHtml(params[key]) + '</span>');
}
return htmls.join(', ');
}
Expand Down

0 comments on commit 29887c0

Please sign in to comment.