Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/17686#discussion_r113133641
--- Diff: core/src/main/scala/org/apache/spark/ui/UIUtils.scala ---
@@ -527,4 +530,24 @@ 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(requestParameter: String): String = {
+ if (requestParameter == null) {
+ null
+ } else {
+ // Remove new lines and single quotes, followed by escaping HTML
version 4.0
+ StringEscapeUtils.escapeHtml4(
+ requestParameter.replaceAll(NEWLINE_AND_SINGLE_QUOTE_REGEX, ""))
+ }
+
+ def stripXSSArray(requestParameter: Array[String]): Array[String] = {
--- End diff --
I'm on the fence about whether it's worth including this as you can just
write `_.map(stripXSS)` in the two places it's used.
---
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]