dongjoon-hyun commented on code in PR #60591:
URL: https://github.com/apache/spark/pull/60591#discussion_r4595183821


##########
core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala:
##########
@@ -354,6 +354,25 @@ abstract class HistoryServerSuite extends SparkFunSuite 
with BeforeAndAfter with
     holdStatus._3 should be (Some("Hold status not available through the 
history server."))
   }
 
+  test("SPARK-61841: app UI action endpoints are not attached at global 
paths") {
+    // Start with no app loaded, so that the codes below come from the history 
server itself.
+    stop()
+    init()
+
+    // The paths the UI's forms post to. The trailing slash matters: without 
it, a handler
+    // attached at the path only redirects to add the slash, which hides the 
leak.
+    val actionPaths = Seq("/jobs/job/kill/", "/stages/stage/kill/", 
"/jobs/hold/", "/jobs/resume/")
+    def postCodes(): Seq[Int] = actionPaths.map { path =>
+      TestUtils.httpResponseCode(new 
URI(s"http://$localhost:$port$path";).toURL, "POST")
+    }
+    val codesWithoutApp = postCodes()
+
+    // Loading an app attaches its UI handlers to the history server.
+    HistoryServerSuite.getUrl(
+      new 
URI(s"http://$localhost:$port/history/local-1422981780767/jobs/";).toURL)
+    assert(postCodes() === codesWithoutApp)

Review Comment:
   Good point, thanks. Addressed in d1cba160a04: after loading the app, the 
test now also POSTs to all four paths under `/history/local-1422981780767` and 
asserts they return 403 (missing CSRF token). Without the fix, that assertion 
alone fails with `List(405, 405, 405, 405) did not equal List(403, 403, 403, 
403)`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to