File tree Expand file tree Collapse file tree 7 files changed +22
-6
lines changed
Expand file tree Collapse file tree 7 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -4165,6 +4165,7 @@ public synchronized HttpRedirect doCancelQuietDown() {
41654165 return new HttpRedirect ("." );
41664166 }
41674167
4168+ @ POST
41684169 public HttpResponse doToggleCollapse () throws ServletException , IOException {
41694170 final StaplerRequest2 request = Stapler .getCurrentRequest2 ();
41704171 final String paneId = request .getParameter ("paneId" );
Original file line number Diff line number Diff line change @@ -174,7 +174,9 @@ THE SOFTWARE.
174174 ${executorDetails}
175175 </span >
176176 </j : if >
177- <a class =" collapse" href =" ${rootURL}/toggleCollapse?paneId=executors"
177+ <st : adjunct includes =" lib.form.link.link" />
178+ <!-- TODO improve l:link so the `a` can be changed to `l:link`. -->
179+ <a class =" collapse post" href =" ${rootURL}/toggleCollapse?paneId=executors"
178180 tooltip =" ${paneIsCollapsed ? '%Expand' : '%Collapse'}" data-tooltip-append-to-parent =" true" >
179181 <j : set var =" svgIconId" value =" ${paneIsCollapsed ? 'chevron-up' : 'chevron-down'}" />
180182 <l : icon src =" symbol-${svgIconId}" />
Original file line number Diff line number Diff line change @@ -59,7 +59,9 @@ THE SOFTWARE.
5959 </span >
6060
6161 <j : if test =" ${attrs.id != null}" >
62- <a class =" collapse" href =" ${rootURL}/toggleCollapse?paneId=${attrs.id}"
62+ <st : adjunct includes =" lib.form.link.link" />
63+ <!-- TODO improve l:link so the `a` can be changed to `l:link`. -->
64+ <a class =" collapse post" href =" ${rootURL}/toggleCollapse?paneId=${attrs.id}"
6365 title =" ${paneIsCollapsed ? '%expand' : '%collapse'}" >
6466
6567 <j : set var =" svgIconId" value =" ${paneIsCollapsed ? 'chevron-up' : 'chevron-down'}" />
Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ public void testTerminatedNodeAjaxExecutorsDoesNotShowTrace() throws Exception {
173173 new OfflineCause .ChannelTermination (new RuntimeException (message ))
174174 );
175175
176- WebClient wc = j .createWebClient ();
176+ WebClient wc = j .createWebClient (). withJavaScriptEnabled ( false ) ;
177177 Page page = wc .getPage (wc .createCrumbedUrl (HasWidgetHelper .getWidget (j .jenkins .getComputer (), ExecutorsWidget .class ).orElseThrow ().getUrl () + "ajax" ));
178178 String content = page .getWebResponse ().getContentAsString ();
179179 assertThat (content , not (containsString (message )));
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ public void testTerminatedNodeAjaxExecutorsDoesNotShowTrace() throws Exception {
285285 new OfflineCause .ChannelTermination (new RuntimeException (message ))
286286 );
287287
288- WebClient wc = j .createWebClient ();
288+ WebClient wc = j .createWebClient (). withJavaScriptEnabled ( false ) ;
289289 Page page = wc .getPage (wc .createCrumbedUrl (HasWidgetHelper .getWidget (agent .toComputer (), ExecutorsWidget .class ).orElseThrow ().getUrl () + "ajax" ));
290290 String content = page .getWebResponse ().getContentAsString ();
291291 assertThat (content , not (containsString (message )));
Original file line number Diff line number Diff line change 7272import hudson .util .FormValidation ;
7373import hudson .util .HttpResponses ;
7474import hudson .util .VersionNumber ;
75+ import jakarta .servlet .http .HttpServletResponse ;
7576import java .io .File ;
7677import java .io .IOException ;
7778import java .net .HttpURLConnection ;
@@ -130,6 +131,16 @@ public class JenkinsTest {
130131 @ Rule
131132 public TemporaryFolder tmp = new TemporaryFolder ();
132133
134+ @ Test
135+ @ Issue ("SECURITY-3498" )
136+ public void testPaneToggleCollapse () throws Exception {
137+ try (WebClient wc = j .createWebClient ()) {
138+ final FailingHttpStatusCodeException ex = assertThrows (FailingHttpStatusCodeException .class , () -> wc .goTo ("toggleCollapse?paneId=foo" ));
139+ // @POST responds 404 when the verb is wrong; @RequirePOST would respond 405.
140+ assertThat (ex .getStatusCode (), is (HttpServletResponse .SC_NOT_FOUND ));
141+ }
142+ }
143+
133144 @ Test
134145 @ Issue ("SECURITY-3073" )
135146 public void verifyUploadedFingerprintFilePermission () throws Exception {
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public class AjaxTest {
6161 @ Test
6262 @ Issue ("JENKINS-65288" )
6363 public void ajaxPageRenderingPossibleWithoutJellyTrace () throws Exception {
64- JenkinsRule .WebClient wc = r .createWebClient ();
64+ JenkinsRule .WebClient wc = r .createWebClient (). withJavaScriptEnabled ( false ) ;
6565 HtmlPage htmlPage = wc .goTo (getExecutorsWidgetAjaxViewUrl ());
6666 r .assertGoodStatus (htmlPage );
6767 }
@@ -76,7 +76,7 @@ public void ajaxPageRenderingPossibleWithJellyTrace() throws Exception {
7676 try {
7777 JellyFacet .TRACE = true ;
7878
79- JenkinsRule .WebClient wc = r .createWebClient ();
79+ JenkinsRule .WebClient wc = r .createWebClient (). withJavaScriptEnabled ( false ) ;
8080 HtmlPage htmlPage = wc .goTo (getExecutorsWidgetAjaxViewUrl ());
8181 r .assertGoodStatus (htmlPage );
8282 } finally {
You can’t perform that action at this time.
0 commit comments