From d2ed8f55723a7f53daf58d998aa5f711917aea72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:21:46 +0000 Subject: [PATCH 1/4] Bump plugin from 4.37 to 4.38 (#61) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0d94cdc..4cca77c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.jenkins-ci.plugins plugin - 4.37 + 4.38 From 6d7012276ca283ad0d332c3346874e6959401844 Mon Sep 17 00:00:00 2001 From: offa Date: Tue, 5 Apr 2022 08:50:11 +0000 Subject: [PATCH 2/4] Remove some deprecated API calls (#57) * Simplify assertions * Remove unused import * Replace deprecated APIs --- .../main/modules/sshd/AsynchronousCommand.java | 6 +++--- .../main/modules/sshd/CLICommandAdapter.java | 4 +++- .../jenkinsci/main/modules/sshd/PortAdvertiser.java | 5 +---- .../main/modules/sshd/UserAuthNamedFactory.java | 4 ++-- .../main/modules/cli/auth/ssh/CLITest.java | 13 +++++++------ .../modules/cli/auth/ssh/UserPropertyImplTest.java | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/jenkinsci/main/modules/sshd/AsynchronousCommand.java b/src/main/java/org/jenkinsci/main/modules/sshd/AsynchronousCommand.java index a6debb3..efe3b01 100644 --- a/src/main/java/org/jenkinsci/main/modules/sshd/AsynchronousCommand.java +++ b/src/main/java/org/jenkinsci/main/modules/sshd/AsynchronousCommand.java @@ -81,9 +81,9 @@ public void setSession(ServerSession session) { @CheckForNull protected User getCurrentUser() { - final Jenkins jenkins = Jenkins.getInstance(); - if (jenkins != null && jenkins.isUseSecurity()) { - return User.get(getSession().getUsername()); // then UserAuthNamedFactory must have done public key auth + final Jenkins jenkins = Jenkins.get(); + if (jenkins.isUseSecurity()) { + return User.getById(getSession().getUsername(), true); // then UserAuthNamedFactory must have done public key auth } else { return null; // not authenticated. anonymous. } diff --git a/src/main/java/org/jenkinsci/main/modules/sshd/CLICommandAdapter.java b/src/main/java/org/jenkinsci/main/modules/sshd/CLICommandAdapter.java index cd88324..b02594e 100644 --- a/src/main/java/org/jenkinsci/main/modules/sshd/CLICommandAdapter.java +++ b/src/main/java/org/jenkinsci/main/modules/sshd/CLICommandAdapter.java @@ -26,7 +26,9 @@ public Command create(CommandLine commandLine) { @Override public int runCommand() throws IOException { User u = getCurrentUser(); - if (u!=null) c.setTransportAuth(u.impersonate()); + if (u != null) { + c.setTransportAuth2(u.impersonate2()); + } CommandLine cmds = getCmdLine(); diff --git a/src/main/java/org/jenkinsci/main/modules/sshd/PortAdvertiser.java b/src/main/java/org/jenkinsci/main/modules/sshd/PortAdvertiser.java index 7df8afd..851d905 100644 --- a/src/main/java/org/jenkinsci/main/modules/sshd/PortAdvertiser.java +++ b/src/main/java/org/jenkinsci/main/modules/sshd/PortAdvertiser.java @@ -25,10 +25,7 @@ public String getEndpoint() { try { int p = sshd.getActualPort(); if (p>0) { - final Jenkins jenkins = Jenkins.getInstance(); - if (jenkins == null) { - throw new IllegalStateException("Jenkins has not been started, or was already shut down"); - } + final Jenkins jenkins = Jenkins.get(); return (host != null ? host : new URL(jenkins.getRootUrl()).getHost()) + ":" + p; } } catch (Exception e) { diff --git a/src/main/java/org/jenkinsci/main/modules/sshd/UserAuthNamedFactory.java b/src/main/java/org/jenkinsci/main/modules/sshd/UserAuthNamedFactory.java index 29ee8da..990f5bd 100644 --- a/src/main/java/org/jenkinsci/main/modules/sshd/UserAuthNamedFactory.java +++ b/src/main/java/org/jenkinsci/main/modules/sshd/UserAuthNamedFactory.java @@ -18,8 +18,8 @@ class UserAuthNamedFactory implements UserAuthFactory { UserAuthFactory none = UserAuthNoneFactory.INSTANCE; private UserAuthFactory select() { - final Jenkins jenkins = Jenkins.getInstance(); - return (jenkins != null && jenkins.isUseSecurity()) ? publicKey : none; + final Jenkins jenkins = Jenkins.get(); + return jenkins.isUseSecurity() ? publicKey : none; } public String getName() { diff --git a/src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/CLITest.java b/src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/CLITest.java index f16b43d..2660936 100644 --- a/src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/CLITest.java +++ b/src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/CLITest.java @@ -64,17 +64,18 @@ import java.io.IOException; import java.io.PrintWriter; import java.net.HttpURLConnection; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; -import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertNull; import static org.junit.Assume.assumeNoException; import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; @@ -130,7 +131,7 @@ public void strictHostKey() throws Exception { SSHD.get().setPort(0); File privkey = tmp.newFile("id_rsa"); FileUtils.copyURLToFile(CLITest.class.getResource("id_rsa"), privkey); - User.get("admin").addProperty(new UserPropertyImpl(IOUtils.toString(CLITest.class.getResource("id_rsa.pub")))); + User.getById("admin", true).addProperty(new UserPropertyImpl(IOUtils.toString(CLITest.class.getResource("id_rsa.pub"), StandardCharsets.UTF_8))); assertNotEquals(0, new Launcher.LocalLauncher(StreamTaskListener.fromStderr()).launch().cmds( "java", "-Duser.home=" + home, "-jar", jar.getAbsolutePath(), "-s", r.getURL().toString(), "-ssh", "-user", "admin", "-i", privkey.getAbsolutePath(), "-strictHostKey", "who-am-i" ).stdout(System.out).stderr(System.err).join()); @@ -162,7 +163,7 @@ public void interrupt() throws Exception { SSHD.get().setPort(0); File privkey = tmp.newFile("id_rsa"); FileUtils.copyURLToFile(CLITest.class.getResource("id_rsa"), privkey); - User.get("admin").addProperty(new UserPropertyImpl(IOUtils.toString(CLITest.class.getResource("id_rsa.pub")))); + User.getById("admin", true).addProperty(new UserPropertyImpl(IOUtils.toString(CLITest.class.getResource("id_rsa.pub"), StandardCharsets.UTF_8))); FreeStyleProject p = r.createFreeStyleProject("p"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); p.getBuildersList().add(new SleepBuilder(TimeUnit.MINUTES.toMillis(2))); @@ -241,9 +242,9 @@ public void redirectToEndpointShouldBeFollowed() throws Exception { WebResponse rsp = wc.goTo("cli-proxy/").getWebResponse(); assertEquals(rsp.getContentAsString(), HttpURLConnection.HTTP_MOVED_TEMP, rsp.getStatusCode()); - assertEquals(rsp.getContentAsString(), null, rsp.getResponseHeaderValue("X-Jenkins")); - assertEquals(rsp.getContentAsString(), null, rsp.getResponseHeaderValue("X-Jenkins-CLI-Port")); - assertEquals(rsp.getContentAsString(), null, rsp.getResponseHeaderValue("X-SSH-Endpoint")); + assertNull(rsp.getContentAsString(), rsp.getResponseHeaderValue("X-Jenkins")); + assertNull(rsp.getContentAsString(), rsp.getResponseHeaderValue("X-Jenkins-CLI-Port")); + assertNull(rsp.getContentAsString(), rsp.getResponseHeaderValue("X-SSH-Endpoint")); String url = r.getURL().toString() + "cli-proxy/"; ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/UserPropertyImplTest.java b/src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/UserPropertyImplTest.java index 8ece9f5..cf41908 100644 --- a/src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/UserPropertyImplTest.java +++ b/src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/UserPropertyImplTest.java @@ -25,7 +25,7 @@ public void dsa() throws Exception { private void testRoundtrip(String publicKey) throws Exception { r.jenkins.setSecurityRealm(r.createDummySecurityRealm()); - User foo = User.get("foo"); + User foo = User.getById("foo", true); foo.addProperty(new UserPropertyImpl(publicKey)); r.configRoundtrip(foo); assertEquals(publicKey, foo.getProperty(UserPropertyImpl.class).authorizedKeys); From 251d59011530b4d3a4db4a3e6ee8f076c61c3bfe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 10:00:03 +0200 Subject: [PATCH 3/4] Bump sshd-core from 2.7.0 to 2.8.0 (#55) * Bump sshd-core from 2.7.0 to 2.8.0 Bumps [sshd-core](https://github.com/apache/mina-sshd) from 2.7.0 to 2.8.0. - [Release notes](https://github.com/apache/mina-sshd/releases) - [Changelog](https://github.com/apache/mina-sshd/blob/master/CHANGES.md) - [Commits](https://github.com/apache/mina-sshd/compare/sshd-2.7.0...sshd-2.8.0) --- updated-dependencies: - dependency-name: org.apache.sshd:sshd-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Fix upper bounds check Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Vincent Latombe --- pom.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4cca77c..21f341d 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ -SNAPSHOT 2.289.1 8 + 1.7.32 @@ -44,6 +45,16 @@ pom import + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + @@ -51,7 +62,7 @@ org.apache.sshd sshd-core - 2.7.0 + 2.8.0 net.i2p.crypto From fb0796a9df6cec2a0e11553f6f17c829dc8271ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:31:51 +0000 Subject: [PATCH 4/4] Bump plugin from 4.38 to 4.40 Bumps [plugin](https://github.com/jenkinsci/plugin-pom) from 4.38 to 4.40. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.38...plugin-4.40) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 21f341d..b3da8d2 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.jenkins-ci.plugins plugin - 4.38 + 4.40