Uh oh!
There was an error while loading. Please reload this page.
[SPARK-31534][WEBUI] Text for tooltip should be escaped. - #28317
Conversation
dongjoon-hyun
commented
Apr 23, 2020
Thank you, @sarutak . I'll take a look. |
| // extra layers of escaping in order to embed this in a Javascript string literal. | ||
| val escapedDesc = Utility.escape(jobDescription) | ||
| val jsEscapedDesc = StringEscapeUtils.escapeEcmaScript(escapedDesc) | ||
| val jsEscapedDescForTooltip = StringEscapeUtils.escapeEcmaScript(Utility.escape(escapedDesc)) |
There was a problem hiding this comment.
Ur, this is triple escaping since we are using escapedDesc?
Technically, this is equivalent StringEscapeUtils.escapeEcmaScript(Utility.escape(Utility.escape(jobDescription))).
There was a problem hiding this comment.
If we'd like to get a tooltip text <console>, the value of the corresponding attribute data-title should be <console>.
With single Utility.escape, the value of attribute will be <console> so additional Utility.escape is needed.
| .replace(/>/g, ">") | ||
| .replace(/"/g, "\""); | ||
| var g = graphlibDot.read(escaped_dot); | ||
| var g = graphlibDot.read(dot); |
There was a problem hiding this comment.
So, did we handle all callers of renderDot in this PR?
There was a problem hiding this comment.
Ah, I've noticed StagePage needs those escaping.
There was a problem hiding this comment.
In the current implementation, a source text is used for tooltip text as HTML and used for node label as plain text for DAG Viz.
I changed the usage of the source text for node label to interpret it as HTML.
So, I believe these escaping I remove from renderDot are not needed.
SparkQA
commented
Apr 23, 2020
Test build #121692 has finished for PR 28317 at commit
|
SparkQA
commented
Apr 24, 2020
Test build #121698 has finished for PR 28317 at commit
|
sarutak
commented
Apr 24, 2020
retest this please. |
SparkQA
commented
Apr 24, 2020
Test build #121709 has finished for PR 28317 at commit
|
sarutak
commented
Apr 24, 2020
retest this please. |
SparkQA
commented
Apr 24, 2020
Test build #121740 has finished for PR 28317 at commit
|
SparkQA
commented
Apr 24, 2020
Test build #121755 has finished for PR 28317 at commit
|
dongjoon-hyun
commented
Apr 24, 2020
Retest this please. |
| } | ||
| } | ||
| test("SPARK-31534: text for tooltip should be escaped") { |
SparkQA
commented
Apr 24, 2020
Test build #121767 has finished for PR 28317 at commit
|
sarutak
commented
Apr 24, 2020
retest this please. |
SparkQA
commented
Apr 24, 2020
Test build #121781 has finished for PR 28317 at commit
|
sarutak
commented
Apr 25, 2020
retest this please. |
dongjoon-hyun
commented
Apr 25, 2020
Wow. The current Jenkins environment is really flaky. |
SparkQA
commented
Apr 25, 2020
Test build #121788 has finished for PR 28317 at commit
|
dongjoon-hyun
commented
Apr 25, 2020
We reverted 9faad07 from the master. Let's trigger once more tomorrow. |
sarutak
commented
Apr 25, 2020
retest this please. |
SparkQA
commented
Apr 25, 2020
Test build #121803 has finished for PR 28317 at commit
|
@sarutak . I've been digging the following error message, but didn't find a clue. Do you have any idea about this ERROR message in your new test case? It's not a failure, but I just want to understand the reason why this complains. |
@dongjoon-hyun I inspected the error message by replacing Then, I found the reason was the type of |
dongjoon-hyun
commented
Apr 26, 2020
Oh, thank you for the instruction, @sarutak . It's helpful. |
dongjoon-hyun
commented
Apr 26, 2020
So, it sounds like we are good to go. |
dongjoon-hyun
commented
Apr 26, 2020
Feel free to proceed to merge, @sarutak ! Thanks. |
sarutak
commented
Apr 26, 2020
dongjoon-hyun
commented
Apr 27, 2020
I merged #28352 now. Could you reconsider about backporting? |
### What changes were proposed in this pull request? This PR escapes text for tooltip for DAG Viz and Timeline View. ### Why are the changes needed? This is a bug. Normally, DAG Viz and Timeline View show tooltip like as follows. <img width="278" alt="dag-viz-tooltip" src="https://user-images.githubusercontent.com/4736016/80127481-5a6c6880-85cf-11ea-8daf-cfd59aa3ba09.png"> <img width="477" alt="timeline-tooltip" src="https://user-images.githubusercontent.com/4736016/80127500-60624980-85cf-11ea-9b0f-cce301019e3a.png"> They contain a callsite properly. However, if a callsite contains characters which should be escaped for HTML without escaping , the corresponding tooltips wouldn't show the callsite and its following text properly. <img width="179" alt="dag-viz-tooltip-before-fixed" src="https://user-images.githubusercontent.com/4736016/80128480-b1267200-85d0-11ea-8035-ad68ae5fbcab.png"> <img width="261" alt="timeline-tooltip-before-fixed" src="https://user-images.githubusercontent.com/4736016/80128492-b5eb2600-85d0-11ea-9556-c48490110244.png"> The reason of this issue is that the source texts of the tooltip texts are not escaped. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? I tested manually. First, I ran a job `sc.parallelize(1 to 10).collect` in Spark Shell then, visited AllJobsPage and JobPage and confirmed tooltip texts. <img width="196" alt="dag-viz-tooltip-fixed" src="https://user-images.githubusercontent.com/4736016/80128813-2db95080-85d1-11ea-82f8-90a1f4547f30.png"> <img width="363" alt="timeline-tooltip-fixed" src="https://user-images.githubusercontent.com/4736016/80128824-31e56e00-85d1-11ea-9818-492b72b1c56e.png"> I also added a testcase. Closesapache#28317 from sarutak/fix-tooltip. Authored-by: Kousuke Saruta <sarutak@oss.nttdata.com> Signed-off-by: Kousuke Saruta <sarutak@oss.nttdata.com>
gengliangwang
commented
Apr 27, 2020
Late LGTM, nice catch! |
### What changes were proposed in this pull request? This PR backports #28317 which escapes text for tooltip for DAG Viz and Timeline View. ### Why are the changes needed? This is a bug. Normally, DAG Viz and Timeline View show tooltip like as follows. <img width="278" alt="dag-viz-tooltip" src="https://user-images.githubusercontent.com/4736016/80127481-5a6c6880-85cf-11ea-8daf-cfd59aa3ba09.png"> <img width="477" alt="timeline-tooltip" src="https://user-images.githubusercontent.com/4736016/80127500-60624980-85cf-11ea-9b0f-cce301019e3a.png"> They contain a callsite properly. However, if a callsite contains characters which should be escaped for HTML without escaping , the corresponding tooltips wouldn't show the callsite and its following text properly. <img width="179" alt="dag-viz-tooltip-before-fixed" src="https://user-images.githubusercontent.com/4736016/80128480-b1267200-85d0-11ea-8035-ad68ae5fbcab.png"> <img width="261" alt="timeline-tooltip-before-fixed" src="https://user-images.githubusercontent.com/4736016/80128492-b5eb2600-85d0-11ea-9556-c48490110244.png"> The reason of this issue is that the source texts of the tooltip texts are not escaped. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? I tested manually. First, I ran a job `sc.parallelize(1 to 10).collect` in Spark Shell then, visited AllJobsPage and JobPage and confirmed tooltip texts. <img width="277" alt="timeline-tooltip-fixed-3 0" src="https://user-images.githubusercontent.com/4736016/80332616-41411180-8886-11ea-8d93-28e1c5265115.png"> <img width="191" alt="dag-tooltip-fixed-3 0" src="https://user-images.githubusercontent.com/4736016/80332625-44d49880-8886-11ea-8f2e-de8df1369e62.png"> And I confirmed that the appearance of the label of DAG-viz in StagePage is not changed. <img width="313" alt="stage-page-dag" src="https://user-images.githubusercontent.com/4736016/80332725-9b41d700-8886-11ea-9adb-40d50ad29f86.png"> I also added a testcase. With this testcase, an error message related to JavaScript is shown. `TypeError: Cannot call method "indexOf" of undefined (http://192.168.1.209:59376/static/spark-dag-viz.js#378)` This is thrown from `interpretLineBreak` in `spark-dag-viz.js`. HtmlUnit seems not to support `innerHTML` for text content (I tried replacing it with `textContent` and the error message is not shown). But DOMs which is needed by the testcase added is already rendered before `interpretLineBreak` is called. So the testcase successfully passes. Closes#28359 from sarutak/fix-tooltip-branch-3.0. Authored-by: Kousuke Saruta <sarutak@oss.nttdata.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…eline tooltip ### What changes were proposed in this pull request? This PR HTML-escapes the executor removal reason before embedding it into the executor event timeline tooltip, in both `AllJobsPage` and `JobPage`. `Utility.escape` is applied twice, matching the adjacent job description and stage name handling (`jsEscapedDescForTooltip` / `jsEscapedNameForTooltip`): the value is parsed once as the `data-bs-title` attribute value, and once more when Bootstrap assigns it as the tooltip `innerHTML`. https://github.com/apache/spark/blob/a4dc5d9499fa8d40b02a42d5d54dfbc1a1986f37/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala#L80-L81 This is similar to the following. - #28317 ### Why are the changes needed? `removeReason` was the only value in the tooltip escaped with `StringEscapeUtils.escapeEcmaScript` alone, without HTML escaping. That is a JavaScript string literal escape, so `\"` evaluates back to `"` at runtime. Since the timeline library treats the content as HTML, a reason like `"><img src=x onerror=alert(1)>` closes the `data-bs-title` attribute and injects a tag. The reason is not a fixed literal: it carries executor-side exception messages, YARN container diagnostics, and Kubernetes pod status messages verbatim. ### Does this PR introduce _any_ user-facing change? No behavior change. Only a UI hardening. ### How was this patch tested? Pass the CIs with the newly added test suite. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes#57288 from dongjoon-hyun/SPARK-58156. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…eline tooltip ### What changes were proposed in this pull request? This PR HTML-escapes the executor removal reason before embedding it into the executor event timeline tooltip, in both `AllJobsPage` and `JobPage`. `Utility.escape` is applied twice, matching the adjacent job description and stage name handling (`jsEscapedDescForTooltip` / `jsEscapedNameForTooltip`): the value is parsed once as the `data-bs-title` attribute value, and once more when Bootstrap assigns it as the tooltip `innerHTML`. https://github.com/apache/spark/blob/a4dc5d9499fa8d40b02a42d5d54dfbc1a1986f37/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala#L80-L81 This is similar to the following. - #28317 ### Why are the changes needed? `removeReason` was the only value in the tooltip escaped with `StringEscapeUtils.escapeEcmaScript` alone, without HTML escaping. That is a JavaScript string literal escape, so `\"` evaluates back to `"` at runtime. Since the timeline library treats the content as HTML, a reason like `"><img src=x onerror=alert(1)>` closes the `data-bs-title` attribute and injects a tag. The reason is not a fixed literal: it carries executor-side exception messages, YARN container diagnostics, and Kubernetes pod status messages verbatim. ### Does this PR introduce _any_ user-facing change? No behavior change. Only a UI hardening. ### How was this patch tested? Pass the CIs with the newly added test suite. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes#57288 from dongjoon-hyun/SPARK-58156. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 6b24038) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…eline tooltip ### What changes were proposed in this pull request? This PR HTML-escapes the executor removal reason before embedding it into the executor event timeline tooltip, in both `AllJobsPage` and `JobPage`. `Utility.escape` is applied twice, matching the adjacent job description and stage name handling (`jsEscapedDescForTooltip` / `jsEscapedNameForTooltip`): the value is parsed once as the `data-bs-title` attribute value, and once more when Bootstrap assigns it as the tooltip `innerHTML`. https://github.com/apache/spark/blob/a4dc5d9499fa8d40b02a42d5d54dfbc1a1986f37/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala#L80-L81 This is similar to the following. - #28317 ### Why are the changes needed? `removeReason` was the only value in the tooltip escaped with `StringEscapeUtils.escapeEcmaScript` alone, without HTML escaping. That is a JavaScript string literal escape, so `\"` evaluates back to `"` at runtime. Since the timeline library treats the content as HTML, a reason like `"><img src=x onerror=alert(1)>` closes the `data-bs-title` attribute and injects a tag. The reason is not a fixed literal: it carries executor-side exception messages, YARN container diagnostics, and Kubernetes pod status messages verbatim. ### Does this PR introduce _any_ user-facing change? No behavior change. Only a UI hardening. ### How was this patch tested? Pass the CIs with the newly added test suite. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes#57288 from dongjoon-hyun/SPARK-58156. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 6b24038) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…eline tooltip ### What changes were proposed in this pull request? This PR HTML-escapes the executor removal reason before embedding it into the executor event timeline tooltip, in both `AllJobsPage` and `JobPage`. `Utility.escape` is applied twice, matching the adjacent job description and stage name handling (`jsEscapedDescForTooltip` / `jsEscapedNameForTooltip`): the value is parsed once as the `data-bs-title` attribute value, and once more when Bootstrap assigns it as the tooltip `innerHTML`. https://github.com/apache/spark/blob/a4dc5d9499fa8d40b02a42d5d54dfbc1a1986f37/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala#L80-L81 This is similar to the following. - #28317 ### Why are the changes needed? `removeReason` was the only value in the tooltip escaped with `StringEscapeUtils.escapeEcmaScript` alone, without HTML escaping. That is a JavaScript string literal escape, so `\"` evaluates back to `"` at runtime. Since the timeline library treats the content as HTML, a reason like `"><img src=x onerror=alert(1)>` closes the `data-bs-title` attribute and injects a tag. The reason is not a fixed literal: it carries executor-side exception messages, YARN container diagnostics, and Kubernetes pod status messages verbatim. ### Does this PR introduce _any_ user-facing change? No behavior change. Only a UI hardening. ### How was this patch tested? Pass the CIs with the newly added test suite. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes#57288 from dongjoon-hyun/SPARK-58156. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 6b24038) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…eline tooltip ### What changes were proposed in this pull request? This PR HTML-escapes the executor removal reason before embedding it into the executor event timeline tooltip, in both `AllJobsPage` and `JobPage`. `Utility.escape` is applied twice, matching the adjacent job description and stage name handling (`jsEscapedDescForTooltip` / `jsEscapedNameForTooltip`): the value is parsed once as the `data-bs-title` attribute value, and once more when Bootstrap assigns it as the tooltip `innerHTML`. https://github.com/apache/spark/blob/a4dc5d9499fa8d40b02a42d5d54dfbc1a1986f37/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala#L80-L81 This is similar to the following. - #28317 ### Why are the changes needed? `removeReason` was the only value in the tooltip escaped with `StringEscapeUtils.escapeEcmaScript` alone, without HTML escaping. That is a JavaScript string literal escape, so `\"` evaluates back to `"` at runtime. Since the timeline library treats the content as HTML, a reason like `"><img src=x onerror=alert(1)>` closes the `data-bs-title` attribute and injects a tag. The reason is not a fixed literal: it carries executor-side exception messages, YARN container diagnostics, and Kubernetes pod status messages verbatim. ### Does this PR introduce _any_ user-facing change? No behavior change. Only a UI hardening. ### How was this patch tested? Pass the CIs with the newly added test suite. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes#57288 from dongjoon-hyun/SPARK-58156. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 6b24038) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…eline tooltip ### What changes were proposed in this pull request? This PR HTML-escapes the executor removal reason before embedding it into the executor event timeline tooltip, in both `AllJobsPage` and `JobPage`. `Utility.escape` is applied twice, matching the adjacent job description and stage name handling (`jsEscapedDescForTooltip` / `jsEscapedNameForTooltip`): the value is parsed once as the `data-bs-title` attribute value, and once more when Bootstrap assigns it as the tooltip `innerHTML`. https://github.com/apache/spark/blob/a4dc5d9499fa8d40b02a42d5d54dfbc1a1986f37/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala#L80-L81 This is similar to the following. - #28317 ### Why are the changes needed? `removeReason` was the only value in the tooltip escaped with `StringEscapeUtils.escapeEcmaScript` alone, without HTML escaping. That is a JavaScript string literal escape, so `\"` evaluates back to `"` at runtime. Since the timeline library treats the content as HTML, a reason like `"><img src=x onerror=alert(1)>` closes the `data-bs-title` attribute and injects a tag. The reason is not a fixed literal: it carries executor-side exception messages, YARN container diagnostics, and Kubernetes pod status messages verbatim. ### Does this PR introduce _any_ user-facing change? No behavior change. Only a UI hardening. ### How was this patch tested? Pass the CIs with the newly added test suite. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes#57288 from dongjoon-hyun/SPARK-58156. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 6b24038) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>

What changes were proposed in this pull request?
This PR escapes text for tooltip for DAG Viz and Timeline View.
Why are the changes needed?
This is a bug.
Normally, DAG Viz and Timeline View show tooltip like as follows.
They contain a callsite properly.


However, if a callsite contains characters which should be escaped for HTML without escaping , the corresponding tooltips wouldn't show the callsite and its following text properly.
The reason of this issue is that the source texts of the tooltip texts are not escaped.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
I tested manually.


First, I ran a job
sc.parallelize(1 to 10).collectin Spark Shell then, visited AllJobsPage and JobPage and confirmed tooltip texts.I also added a testcase.