Skip to content

Commit

Permalink
DBACLD-145641: upgrade jgit to address important CVEs
Browse files Browse the repository at this point in the history
  • Loading branch information
porcelli committed Jul 25, 2024
1 parent f574261 commit 415ea98
Show file tree
Hide file tree
Showing 27 changed files with 17 additions and 799 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@

import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.internal.ketch.KetchLeaderCache;
import org.eclipse.jgit.internal.ketch.KetchSystem;
import org.eclipse.jgit.internal.storage.file.WindowCache;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
Expand Down Expand Up @@ -140,14 +138,7 @@
import org.uberfire.java.nio.fs.jgit.util.ProxyAuthenticator;
import org.uberfire.java.nio.fs.jgit.util.commands.Clone;
import org.uberfire.java.nio.fs.jgit.util.commands.PathUtil;
import org.uberfire.java.nio.fs.jgit.util.model.CommitContent;
import org.uberfire.java.nio.fs.jgit.util.model.CommitInfo;
import org.uberfire.java.nio.fs.jgit.util.model.CopyCommitContent;
import org.uberfire.java.nio.fs.jgit.util.model.DefaultCommitContent;
import org.uberfire.java.nio.fs.jgit.util.model.MoveCommitContent;
import org.uberfire.java.nio.fs.jgit.util.model.PathInfo;
import org.uberfire.java.nio.fs.jgit.util.model.PathType;
import org.uberfire.java.nio.fs.jgit.util.model.RevertCommitContent;
import org.uberfire.java.nio.fs.jgit.util.model.*;
import org.uberfire.java.nio.fs.jgit.ws.JGitFileSystemsEventsManager;
import org.uberfire.java.nio.fs.jgit.ws.JGitWatchEvent;
import org.uberfire.java.nio.security.FileSystemAuthorizer;
Expand Down Expand Up @@ -185,8 +176,6 @@ public class JGitFileSystemProvider implements SecuredFileSystemProvider,
private static final Logger LOG = LoggerFactory.getLogger(JGitFileSystemProvider.class);
private static final TimeUnit LOCK_LAST_ACCESS_TIME_UNIT = TimeUnit.SECONDS;
private static final long LOCK_LAST_ACCESS_THRESHOLD = 10;
final KetchSystem system = new KetchSystem();
final KetchLeaderCache leaders = new KetchLeaderCache(system);
private final Map<String, String> fullHostNames = new HashMap<>();
private final Object postponedEventsLock = new Object();
private final ExecutorService executorService;
Expand Down Expand Up @@ -511,8 +500,7 @@ void buildAndStartDaemon() {
daemonService = new Daemon(new InetSocketAddress(config.getDaemonHostAddr(),
config.getDaemonPort()),
new ExecutorWrapper(executorService),
executorService,
config.isEnableKetch() ? leaders : null);
executorService);
daemonService.setRepositoryResolver(new RepositoryResolverImpl<>());
try {
daemonService.start();
Expand Down Expand Up @@ -632,11 +620,6 @@ public FileSystem newFileSystem(final URI uri,
}
}

if (config.isEnableKetch()) {
createNewGitRepo(env,
fsName).enableKetch();
}

if (config.isDaemonEnabled() && daemonService != null && !daemonService.isRunning()) {
buildAndStartDaemon();
}
Expand Down Expand Up @@ -728,7 +711,6 @@ protected Git createNewGitRepo(Map<String, ?> env,
fsName,
branches,
credential,
config.isEnableKetch() ? leaders : null,
config.getHookDir(),
config.isSslVerify());
} else if (subdirectory != null) {
Expand All @@ -740,7 +722,6 @@ protected Git createNewGitRepo(Map<String, ?> env,
subdirectory,
branches,
credential,
leaders,
config.getHookDir(),
config.isSslVerify());
} else {
Expand All @@ -749,7 +730,6 @@ protected Git createNewGitRepo(Map<String, ?> env,
isMirror,
branches,
credential,
config.isEnableKetch() ? leaders : null,
config.getHookDir(),
config.isSslVerify());
}
Expand All @@ -760,7 +740,6 @@ protected Git createNewGitRepo(Map<String, ?> env,
} else {
git = Git.createRepository(repoDest,
config.getHookDir(),
config.isEnableKetch() ? leaders : null,
config.isSslVerify());
}
return git;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class JGitFileSystemProviderConfiguration {

public static final String GIT_NIO_DIR = "org.uberfire.nio.git.dir";
public static final String GIT_NIO_DIR_NAME = "org.uberfire.nio.git.dirname";
public static final String ENABLE_GIT_KETCH = "org.uberfire.nio.git.ketch";
public static final String HOOK_DIR = "org.uberfire.nio.git.hooks";

public static final String GIT_HTTP_HOST = "org.uberfire.nio.git.http.host";
Expand Down Expand Up @@ -149,7 +148,6 @@ public class JGitFileSystemProviderConfiguration {

private File hookDir;

boolean enableKetch = false;
private String proxyType;
private boolean sshOverHttpProxy;
private String httpProxyHost;
Expand Down Expand Up @@ -177,8 +175,6 @@ public void load(ConfigProperties systemConfig) {
LOG.debug("Configuring from properties:");

final String currentDirectory = System.getProperty(USER_DIR);
final ConfigProperties.ConfigProperty enableKetchProp = systemConfig.get(ENABLE_GIT_KETCH,
DEFAULT_ENABLE_GIT_KETCH);
final ConfigProperties.ConfigProperty hookDirProp = systemConfig.get(HOOK_DIR,
null);
final ConfigProperties.ConfigProperty bareReposDirProp = systemConfig.get(GIT_NIO_DIR,
Expand Down Expand Up @@ -294,10 +290,6 @@ public void load(ConfigProperties systemConfig) {
LOG.debug(systemConfig.getConfigurationSummary("Summary of JGit configuration:"));
}

if (enableKetchProp != null && enableKetchProp.getValue() != null) {
enableKetch = enableKetchProp.getBooleanValue();
}

if (hookDirProp != null && hookDirProp.getValue() != null) {
hookDir = new File(hookDirProp.getValue());
if (!hookDir.exists()) {
Expand Down Expand Up @@ -455,10 +447,6 @@ public File getHookDir() {
return hookDir;
}

public boolean isEnableKetch() {
return enableKetch;
}

public String getProxyType() {
return proxyType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
import org.eclipse.jgit.errors.UnsupportedCredentialItem;
import org.eclipse.jgit.internal.transport.ssh.jsch.CredentialsProviderUserInfo;
import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.CredentialsProviderUserInfo;
import org.eclipse.jgit.transport.OpenSshConfig;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory;
import org.eclipse.jgit.transport.ssh.jsch.OpenSshConfig;

public class JGitSSHConfigSessionFactory extends org.eclipse.jgit.transport.JschConfigSessionFactory {
public class JGitSSHConfigSessionFactory extends JschConfigSessionFactory {

private final JGitFileSystemProviderConfiguration config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.ketch.KetchLeaderCache;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.pack.PackConfig;
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
Expand Down Expand Up @@ -76,15 +75,6 @@ public class Daemon {

private final Executor acceptThreadPool;

public Daemon(final InetSocketAddress addr,
final Executor acceptThreadPool,
final ExecutorService executorService) {
this(addr,
acceptThreadPool,
executorService,
null);
}

/**
* Configures a new daemon for the specified network address. The daemon will not attempt to bind to an address or
* accept connections until a call to {@link #start()}.
Expand All @@ -95,8 +85,7 @@ public Daemon(final InetSocketAddress addr,
*/
public Daemon(final InetSocketAddress addr,
final Executor acceptThreadPool,
final ExecutorService executorService,
final KetchLeaderCache leaders) {
final ExecutorService executorService) {
myAddress = addr;
this.acceptThreadPool = checkNotNull("acceptThreadPool",
acceptThreadPool);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@

package org.uberfire.java.nio.fs.jgit.daemon.ssh;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.ExecutorService;

import org.apache.sshd.server.Environment;
import org.apache.sshd.server.channel.ChannelSession;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.ReceivePack;
Expand Down
Loading

0 comments on commit 415ea98

Please sign in to comment.