From 5ea8cf2fa5b4f1d5df84a987f2c2add889fdca7a Mon Sep 17 00:00:00 2001 From: Jan Faracik <43062514+janfaracik@users.noreply.github.com> Date: Sat, 22 Apr 2023 10:30:10 +0100 Subject: [PATCH] Small tidy up for the Tools page (#7716) * Init * Update global.jelly * Update config.jelly * Restore top button * Change form-label to section__title * Add comment suggestion by daniel-beck Co-authored-by: Daniel Beck <1831569+daniel-beck@users.noreply.github.com> * Remove test * Update HeteroListTest.java --------- Co-authored-by: Daniel Beck <1831569+daniel-beck@users.noreply.github.com> --- .../tools/ToolInstallation/global.jelly | 15 ++++----- .../jenkins/model/Jenkins/configure.jelly | 2 +- .../config.jelly | 4 +-- .../GlobalToolConfiguration/index.groovy | 2 +- core/src/main/resources/lib/form/rowSet.jelly | 14 ++------- .../src/main/resources/lib/form/section.jelly | 6 ++-- .../test/java/lib/form/HeteroListTest.java | 31 ------------------- 7 files changed, 16 insertions(+), 58 deletions(-) diff --git a/core/src/main/resources/hudson/tools/ToolInstallation/global.jelly b/core/src/main/resources/hudson/tools/ToolInstallation/global.jelly index f675d081ee..317b0dd481 100644 --- a/core/src/main/resources/hudson/tools/ToolInstallation/global.jelly +++ b/core/src/main/resources/hudson/tools/ToolInstallation/global.jelly @@ -23,13 +23,14 @@ THE SOFTWARE. --> - + + - - + @@ -37,11 +38,7 @@ THE SOFTWARE. - -
- -
-
+
diff --git a/core/src/main/resources/jenkins/model/Jenkins/configure.jelly b/core/src/main/resources/jenkins/model/Jenkins/configure.jelly index 18fdc9f6a7..34b067bec9 100644 --- a/core/src/main/resources/jenkins/model/Jenkins/configure.jelly +++ b/core/src/main/resources/jenkins/model/Jenkins/configure.jelly @@ -56,7 +56,7 @@ THE SOFTWARE. - + diff --git a/core/src/main/resources/jenkins/model/experimentalflags/UserExperimentalFlagsProperty/config.jelly b/core/src/main/resources/jenkins/model/experimentalflags/UserExperimentalFlagsProperty/config.jelly index 8e572d06c9..4fe6097089 100644 --- a/core/src/main/resources/jenkins/model/experimentalflags/UserExperimentalFlagsProperty/config.jelly +++ b/core/src/main/resources/jenkins/model/experimentalflags/UserExperimentalFlagsProperty/config.jelly @@ -35,7 +35,7 @@ THE SOFTWARE. - + @@ -64,4 +64,4 @@ THE SOFTWARE. - \ No newline at end of file + diff --git a/core/src/main/resources/jenkins/tools/GlobalToolConfiguration/index.groovy b/core/src/main/resources/jenkins/tools/GlobalToolConfiguration/index.groovy index d57a1033e6..c123d58a8a 100644 --- a/core/src/main/resources/jenkins/tools/GlobalToolConfiguration/index.groovy +++ b/core/src/main/resources/jenkins/tools/GlobalToolConfiguration/index.groovy @@ -20,7 +20,7 @@ l.layout(permission:app.SYSTEM_READ, title:my.displayName, type:"one-column") { Functions.getSortedDescriptorsForGlobalConfigByDescriptor(my.FILTER).each { Descriptor descriptor -> set("descriptor",descriptor) set("instance",descriptor) - f.rowSet(name:descriptor.jsonSafeClassName, class: "jenkins-!-margin-bottom-0") { + f.rowSet(name:descriptor.jsonSafeClassName) { st.include(from:descriptor, page:descriptor.globalConfigPage) } } diff --git a/core/src/main/resources/lib/form/rowSet.jelly b/core/src/main/resources/lib/form/rowSet.jelly index 586d8f6ff2..80706fd06b 100644 --- a/core/src/main/resources/lib/form/rowSet.jelly +++ b/core/src/main/resources/lib/form/rowSet.jelly @@ -35,12 +35,6 @@ THE SOFTWARE. id of the thing that serves as the group head, if that's available separately - - Removes the "jenkins-form-item" class if false - - - Classes to apply to the container (this will be the form item if 'isFormItem' is true) - @@ -53,11 +47,9 @@ THE SOFTWARE. -
- - -
-
+ + +
diff --git a/core/src/main/resources/lib/form/section.jelly b/core/src/main/resources/lib/form/section.jelly index 6e7f115d13..7a4383f27e 100644 --- a/core/src/main/resources/lib/form/section.jelly +++ b/core/src/main/resources/lib/form/section.jelly @@ -27,7 +27,7 @@ THE SOFTWARE. Section header in the form table. - tag becomes no-op. ]]> @@ -43,7 +43,7 @@ THE SOFTWARE. -
+
@@ -53,6 +53,6 @@ THE SOFTWARE.
-
+
diff --git a/test/src/test/java/lib/form/HeteroListTest.java b/test/src/test/java/lib/form/HeteroListTest.java index 43715655e9..3c4efcad0c 100644 --- a/test/src/test/java/lib/form/HeteroListTest.java +++ b/test/src/test/java/lib/form/HeteroListTest.java @@ -28,7 +28,6 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.gargoylesoftware.htmlunit.html.DomElement; @@ -51,7 +50,6 @@ import java.io.File; import java.util.Collections; import java.util.List; import java.util.Optional; -import net.sourceforge.htmlunit.corejs.javascript.NativeArray; import org.jenkinsci.Symbol; import org.junit.Rule; import org.junit.Test; @@ -84,35 +82,6 @@ public class HeteroListTest { assertThat(menuItemContent, not(containsString("<"))); } - // correspond to the hardening of escapeEntryTitleAndDescription - @Test - @Issue("SECURITY-2035") - public void xssPrevented_usingToolInstallation_withJustDisplayName() throws Exception { - JenkinsRule.WebClient wc = j.createWebClient(); - - HtmlPage page = wc.goTo("configureTools/"); - - // check the displayName - Object resultDN = page.executeJavaScript( - "var settingFields = document.querySelectorAll('.jenkins-form-label');" + - "var children = Array.from(settingFields).filter(b => b.textContent.indexOf('XSS:') !== -1)[0].children;" + - "Array.from(children).filter(c => c.tagName === 'IMG')" - ).getJavaScriptResult(); - assertThat(resultDN, instanceOf(NativeArray.class)); - NativeArray resultDNNA = (NativeArray) resultDN; - assertEquals(0, resultDNNA.size()); - - // check the description - Object resultDesc = page.executeJavaScript( - "var settingFields = document.querySelectorAll('.jenkins-form-description');" + - "var children = Array.from(settingFields).filter(b => b.textContent.indexOf('XSS:') !== -1)[0].children;" + - "Array.from(children).filter(c => c.tagName === 'IMG')" - ).getJavaScriptResult(); - assertThat(resultDesc, instanceOf(NativeArray.class)); - NativeArray resultDescNA = (NativeArray) resultDesc; - assertEquals(0, resultDescNA.size()); - } - @Test @Issue("SECURITY-2035") public void xssPrevented_usingToolInstallation_repeatableAddExisting() throws Exception {