Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from oleg-nenashev/bug/JENKINS-50339
[JENKINS-50339] - Whitelist SVNErrorMessage and introduce RemotableSVNErrorMessage
- Loading branch information
Showing
12 changed files
with
148 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
buildPlugin() | ||
buildPlugin(jenkinsVersions: [null, "2.107.1"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/jenkins/scm/impl/subversion/RemotableSVNErrorMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2018 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package jenkins.scm.impl.subversion; | ||
|
||
import hudson.remoting.ProxyException; | ||
import org.tmatesoft.svn.core.SVNErrorCode; | ||
import org.tmatesoft.svn.core.SVNErrorMessage; | ||
|
||
/** | ||
* Version of {@link SVNErrorMessage}, which can be serialized over the channel. | ||
* This version does not serialize random {@link Object} instances. | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
public class RemotableSVNErrorMessage extends SVNErrorMessage { | ||
|
||
public RemotableSVNErrorMessage(SVNErrorCode code) { | ||
super(code, null, null, null, 0); | ||
} | ||
|
||
public RemotableSVNErrorMessage(SVNErrorCode code, String message) { | ||
super(code, message, null, null, 0); | ||
} | ||
|
||
public RemotableSVNErrorMessage(SVNErrorCode code, Throwable cause) { | ||
super(code, null, null, new ProxyException(cause), 0); | ||
} | ||
|
||
public RemotableSVNErrorMessage(SVNErrorCode code, String message, Throwable cause) { | ||
super(code, message, null, new ProxyException(cause), 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Whitelist for error messaging (JENKINS-50339). | ||
# SVNErrorMessage supports "Object" fields in API in 'myObjects', | ||
# so it is not guaranteed to work with JEP-200 in all cases. | ||
org.tmatesoft.svn.core.SVNErrorMessage | ||
org.tmatesoft.svn.core.SVNErrorCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/test/java/jenkins/scm/impl/subversion/RemotableSVNErrorMessageStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2018 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package jenkins.scm.impl.subversion; | ||
|
||
import hudson.remoting.Callable; | ||
import hudson.slaves.DumbSlave; | ||
import jenkins.security.MasterToSlaveCallable; | ||
import org.jenkinsci.remoting.RoleChecker; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.For; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.tmatesoft.svn.core.SVNErrorCode; | ||
import org.tmatesoft.svn.core.SVNErrorMessage; | ||
import org.tmatesoft.svn.core.SVNException; | ||
|
||
/** | ||
* @author Oleg Nenashev | ||
*/ | ||
@For(SVNErrorMessage.class) | ||
public class RemotableSVNErrorMessageStepTest { | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Test | ||
@Issue("JENKINS-50339") | ||
public void shouldSerializeException() throws Exception { | ||
DumbSlave agent = j.createOnlineSlave(); | ||
try { | ||
agent.getChannel().call(new ErrorCallable()); | ||
} catch (SVNException e) { | ||
return; // fine | ||
} | ||
} | ||
|
||
private static class ErrorCallable extends MasterToSlaveCallable<Void, SVNException> { | ||
|
||
@Override | ||
public Void call() throws SVNException { | ||
SVNErrorMessage err = new RemotableSVNErrorMessage(SVNErrorCode.UNKNOWN, "Just a test exception", | ||
new IllegalStateException("foo")); | ||
throw new SVNException(err); | ||
} | ||
} | ||
} |