File tree Expand file tree Collapse file tree 4 files changed +35
-7
lines changed
main/scala/org/apache/spark/ui
test/scala/org/apache/spark/ui Expand file tree Collapse file tree 4 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ private[spark] object UIUtils extends Logging {
35
35
val TABLE_CLASS_STRIPED = TABLE_CLASS_NOT_STRIPED + " table-striped"
36
36
val TABLE_CLASS_STRIPED_SORTABLE = TABLE_CLASS_STRIPED + " sortable"
37
37
38
- val NEWLINE_AND_SINGLE_QUOTE_REGEX = " (\r\n |\n |\r |%0D%0A|%0A|%0D|'|%27)"
38
+ private val NEWLINE_AND_SINGLE_QUOTE_REGEX = " (\r\n |\n |\r |%0D%0A|%0A|%0D|'|%27)"
39
39
40
40
// SimpleDateFormat is not thread-safe. Don't expose it to avoid improper use.
41
41
private val dateFormat = new ThreadLocal [SimpleDateFormat ]() {
@@ -546,8 +546,4 @@ private[spark] object UIUtils extends Logging {
546
546
StringEscapeUtils .escapeHtml4(
547
547
requestParameter.replaceAll(NEWLINE_AND_SINGLE_QUOTE_REGEX , " " ))
548
548
}
549
-
550
- def stripXSSArray (requestParameter : Array [String ]): Array [String ] = {
551
- requestParameter.map(stripXSS)
552
- }
553
549
}
Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ private[ui] class AllJobsPage(parent: JobsTab) extends WebUIPage("") {
221
221
jobs : Seq [JobUIData ],
222
222
killEnabled : Boolean ): Seq [Node ] = {
223
223
// stripXSS is called to remove suspicious characters used in XSS attacks
224
- val allParameters = request.getParameterMap.asScala.toMap.mapValues(UIUtils .stripXSSArray )
224
+ val allParameters = request.getParameterMap.asScala.toMap.mapValues(_.map( UIUtils .stripXSS) )
225
225
val parameterOtherTable = allParameters.filterNot(_._1.startsWith(jobTag))
226
226
.map(para => para._1 + " =" + para._2(0 ))
227
227
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ private[ui] class StageTableBase(
43
43
killEnabled : Boolean ,
44
44
isFailedStage : Boolean ) {
45
45
// stripXSS is called to remove suspicious characters used in XSS attacks
46
- val allParameters = request.getParameterMap.asScala.toMap.mapValues(UIUtils .stripXSSArray )
46
+ val allParameters = request.getParameterMap.asScala.toMap.mapValues(_.map( UIUtils .stripXSS) )
47
47
val parameterOtherTable = allParameters.filterNot(_._1.startsWith(stageTag))
48
48
.map(para => para._1 + " =" + para._2(0 ))
49
49
Original file line number Diff line number Diff line change @@ -133,6 +133,38 @@ class UIUtilsSuite extends SparkFunSuite {
133
133
assert(decoded2 === decodeURLParameter(decoded2))
134
134
}
135
135
136
+ test(" SPARK-20393: Prevent script from parameters running on page." ) {
137
+ val scriptAlert = """ >"'><script>alert(401)<%2Fscript>"""
138
+ val stripScriptAlert = " >"><script>alert(401)<%2Fscript>"
139
+
140
+ assert(stripScriptAlert === stripXSS(scriptAlert))
141
+ }
142
+
143
+ test(" SPARK-20393: Prevent javascript from parameters running on page." ) {
144
+ val javascriptAlert =
145
+ """ app-20161208133404-0002<iframe+src%3Djavascript%3Aalert(1705)>"""
146
+ val stripJavascriptAlert =
147
+ " app-20161208133404-0002<iframe+src%3Djavascript%3Aalert(1705)>"
148
+
149
+ assert(stripJavascriptAlert === stripXSS(javascriptAlert))
150
+ }
151
+
152
+ test(" SPARK-20393: Prevent links from parameters on page." ) {
153
+ val link =
154
+ """ stdout'"><iframe+id%3D1131+src%3Dhttp%3A%2F%2Fdemo.testfire.net%2Fphishing.html>"""
155
+ val stripLink =
156
+ " stdout"><iframe+id%3D1131+src%3Dhttp%3A%2F%2Fdemo.testfire.net%2Fphishing.html>"
157
+
158
+ assert(stripLink === stripXSS(link))
159
+ }
160
+
161
+ test(" SPARK-20393: Prevent popups from parameters on page." ) {
162
+ val popup = """ stdout'%2Balert(60)%2B'"""
163
+ val stripPopup = " stdout%2Balert(60)%2B"
164
+
165
+ assert(stripPopup === stripXSS(popup))
166
+ }
167
+
136
168
private def verify (
137
169
desc : String ,
138
170
expected : Node ,
You can’t perform that action at this time.
0 commit comments