Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/17686#discussion_r112225087
--- Diff: core/src/main/scala/org/apache/spark/ui/UIUtils.scala ---
@@ -527,4 +528,27 @@ private[spark] object UIUtils extends Logging {
origHref
}
}
+
+ /**
+ * Remove suspicious characters of user input to prevent Cross-Site
scripting (XSS) attacks
+ *
+ * For more information about XSS testing:
+ * https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet and
+ *
https://www.owasp.org/index.php/Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)
+ */
+ def stripXSS(url: String): String = {
+ var strippedXSSUrl = url
+ if (strippedXSSUrl != null) {
+ // Avoid null characters or single quote
+ strippedXSSUrl =
strippedXSSUrl.replaceAll("(\r\n|\n|\r|%0D%0A|%0A|%0D|'|%27)", "")
+ strippedXSSUrl = StringEscapeUtils.escapeHtml4(strippedXSSUrl)
+ }
+ strippedXSSUrl
+ }
+
+ def stripXSSMap(url: Array[String]): Array[String] = {
--- End diff --
Not sure what this method is trying to do but it just returns its argument.
Do you just mean `url.map(stripXSS)`? why Map, why url as names?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]