Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.15 changes #461

Merged
merged 6 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,19 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
<version>3.6</version>
<configuration>
<bundledSignatures>
<bundledSignature>jdk-unsafe</bundledSignature>
<bundledSignature>jdk-deprecated</bundledSignature>
<bundledSignature>jdk-non-portable</bundledSignature>
<bundledSignature>jdk-reflection</bundledSignature>
</bundledSignatures>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand Down Expand Up @@ -805,5 +818,46 @@
</plugins>
</build>
</profile>
<profile>
<id>forbiddenapis</id>
<activation>
<jdk>[16,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
<configuration>
<releaseVersion>16</releaseVersion>
</configuration>
<executions>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<bundledSignatures combine.children="append">
<bundledSignature>jdk-system-out</bundledSignature>
</bundledSignatures>
</configuration>
</execution>
<execution>
<id>testCheck</id>
<goals>
<goal>testCheck</goal>
</goals>
<configuration>
<bundledSignatures combine.children="append">
<bundledSignature>commons-io-unsafe-2.14.0</bundledSignature>
</bundledSignatures>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
4 changes: 3 additions & 1 deletion src/main/java/com/jcraft/jsch/HostKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

package com.jcraft.jsch;

import java.util.Locale;

public class HostKey {

private static final byte[][] names =
Expand Down Expand Up @@ -118,7 +120,7 @@ public String getKey() {
public String getFingerPrint(JSch jsch) {
HASH hash = null;
try {
String _c = JSch.getConfig("FingerprintHash").toLowerCase();
String _c = JSch.getConfig("FingerprintHash").toLowerCase(Locale.ROOT);
Class<? extends HASH> c = Class.forName(JSch.getConfig(_c)).asSubclass(HASH.class);
hash = c.getDeclaredConstructor().newInstance();
} catch (Exception e) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/jcraft/jsch/JSch.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class JSch {
"ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256"));
config.put("prefer_known_host_key_types",
Util.getSystemProperty("jsch.prefer_known_host_key_types", "yes"));
config.put("enable_strict_kex", Util.getSystemProperty("jsch.enable_strict_kex", "yes"));
config.put("require_strict_kex", Util.getSystemProperty("jsch.require_strict_kex", "no"));
config.put("enable_server_sig_algs",
Util.getSystemProperty("jsch.enable_server_sig_algs", "yes"));
config.put("cipher.s2c", Util.getSystemProperty("jsch.cipher",
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/jcraft/jsch/JSchAlgoNegoFailException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jcraft.jsch;

import java.util.Locale;

/**
* Extension of {@link JSchException} to indicate when a connection fails during algorithm
* negotiation.
Expand Down Expand Up @@ -35,7 +37,7 @@ public String getServerProposal() {
}

private static String failString(int algorithmIndex, String jschProposal, String serverProposal) {
return String.format(
return String.format(Locale.ROOT,
"Algorithm negotiation fail: algorithmName=\"%s\" jschProposal=\"%s\" serverProposal=\"%s\"",
algorithmNameFromIndex(algorithmIndex), jschProposal, serverProposal);
}
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/jcraft/jsch/JSchStrictKexException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided with
* the distribution.
*
* 3. The names of the authors may not be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.jcraft.jsch;

public class JSchStrictKexException extends JSchException {
private static final long serialVersionUID = -1L;

JSchStrictKexException() {
super();
}

JSchStrictKexException(String s) {
super(s);
}
}
4 changes: 3 additions & 1 deletion src/main/java/com/jcraft/jsch/KeyExchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

package com.jcraft.jsch;

import java.util.Locale;

public abstract class KeyExchange {

static final int PROPOSAL_KEX_ALGS = 0;
Expand Down Expand Up @@ -198,7 +200,7 @@ protected static String[] guess(Session session, byte[] I_S, byte[] I_C) throws
public String getFingerPrint() {
HASH hash = null;
try {
String _c = session.getConfig("FingerprintHash").toLowerCase();
String _c = session.getConfig("FingerprintHash").toLowerCase(Locale.ROOT);
Class<? extends HASH> c = Class.forName(session.getConfig(_c)).asSubclass(HASH.class);
hash = c.getDeclaredConstructor().newInstance();
} catch (Exception e) {
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/jcraft/jsch/OpenSSHConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.Vector;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -75,9 +76,10 @@
*/
public class OpenSSHConfig implements ConfigRepository {

private static final Set<String> keysWithListAdoption =
Stream.of("KexAlgorithms", "Ciphers", "HostKeyAlgorithms", "MACs", "PubkeyAcceptedAlgorithms",
"PubkeyAcceptedKeyTypes").map(String::toUpperCase).collect(Collectors.toSet());
private static final Set<String> keysWithListAdoption = Stream
.of("KexAlgorithms", "Ciphers", "HostKeyAlgorithms", "MACs", "PubkeyAcceptedAlgorithms",
"PubkeyAcceptedKeyTypes")
.map(string -> string.toUpperCase(Locale.ROOT)).collect(Collectors.toSet());

/**
* Parses the given string, and returns an instance of ConfigRepository.
Expand Down Expand Up @@ -209,13 +211,13 @@ private String find(String key) {
if (keymap.get(key) != null) {
key = keymap.get(key);
}
key = key.toUpperCase();
key = key.toUpperCase(Locale.ROOT);
String value = null;
for (int i = 0; i < _configs.size(); i++) {
Vector<String[]> v = _configs.elementAt(i);
for (int j = 0; j < v.size(); j++) {
String[] kv = v.elementAt(j);
if (kv[0].toUpperCase().equals(key)) {
if (kv[0].toUpperCase(Locale.ROOT).equals(key)) {
value = kv[1];
break;
}
Expand Down Expand Up @@ -255,13 +257,13 @@ private String find(String key) {
}

private String[] multiFind(String key) {
key = key.toUpperCase();
key = key.toUpperCase(Locale.ROOT);
Vector<String> value = new Vector<>();
for (int i = 0; i < _configs.size(); i++) {
Vector<String[]> v = _configs.elementAt(i);
for (int j = 0; j < v.size(); j++) {
String[] kv = v.elementAt(j);
if (kv[0].toUpperCase().equals(key)) {
if (kv[0].toUpperCase(Locale.ROOT).equals(key)) {
String foo = kv[1];
if (foo != null) {
value.remove(foo);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/jcraft/jsch/PageantConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinUser;
import com.sun.jna.platform.win32.WinUser.COPYDATASTRUCT;
import java.util.Locale;

public class PageantConnector implements AgentConnector {

Expand Down Expand Up @@ -84,7 +85,8 @@ public void query(Buffer buffer) throws AgentProxyException {
throw new AgentProxyException("Pageant is not runnning.");
}

String mapname = String.format("PageantRequest%08x", kernel32.GetCurrentThreadId());
String mapname =
String.format(Locale.ROOT, "PageantRequest%08x", kernel32.GetCurrentThreadId());

HANDLE sharedFile = null;
Pointer sharedMemory = null;
Expand Down
Loading