Skip to content

Commit

Permalink
fix #948 NPE due to TskServers not started when reading items from index
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed Jan 28, 2022
1 parent 37124e4 commit 0c724c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public class SleuthkitReader extends DataSourceReader {
// via referência interna ao JNI para acessar os itens do caso
public static volatile SleuthkitCase sleuthCase;

public static File getSleuthkitDB(File output) {
return new File(output.getParent(), DB_NAME);
}

public SleuthkitReader(boolean embeddedDisk, ICaseData caseData, File output) {
this(caseData, output, false);
this.embeddedDisk = embeddedDisk;
Expand Down Expand Up @@ -352,7 +356,7 @@ public void read(File image, Item parent) throws Exception {
}
}

String dbPath = output.getParent() + File.separator + DB_NAME;
String dbPath = getSleuthkitDB(output).getAbsolutePath();

if (listOnly || embeddedDisk) {

Expand All @@ -373,10 +377,8 @@ public void read(File image, Item parent) throws Exception {
}
}

FileSystemConfig fsConfig = ConfigurationManager.get().findObject(FileSystemConfig.class);
if (fsConfig.isRobustImageReading()) {
Manager.getInstance().initSleuthkitServers(sleuthCase.getDbDirPath());
}
Manager.getInstance().initSleuthkitServers();

Long[] range = getDecodedRangeId(image, output);
if (range != null && args.isContinue()) {
synchronized (idRangeMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@
import dpf.sp.gpinf.indexer.analysis.AppAnalyzer;
import dpf.sp.gpinf.indexer.config.AnalysisConfig;
import dpf.sp.gpinf.indexer.config.ConfigurationManager;
import dpf.sp.gpinf.indexer.config.FileSystemConfig;
import dpf.sp.gpinf.indexer.config.IndexTaskConfig;
import dpf.sp.gpinf.indexer.config.LocalConfig;
import dpf.sp.gpinf.indexer.datasource.ItemProducer;
import dpf.sp.gpinf.indexer.datasource.SleuthkitReader;
import dpf.sp.gpinf.indexer.io.ParsingReader;
import dpf.sp.gpinf.indexer.localization.Messages;
import dpf.sp.gpinf.indexer.process.task.ElasticSearchIndexTask;
Expand Down Expand Up @@ -235,6 +237,8 @@ public void process() throws Exception {
if (!iniciarIndexacao())
return;

initSleuthkitServers();

// apenas conta o número de arquivos a indexar
counter = new ItemProducer(this, caseData, true, sources, output);
counter.start();
Expand Down Expand Up @@ -323,9 +327,13 @@ private void interromperIndexacao() throws Exception {
}
}

public synchronized void initSleuthkitServers(final String dbPath) throws InterruptedException {
if (!initSleuthkitServers.getAndSet(true)) {
SleuthkitClient.initSleuthkitServers(dbPath);
public synchronized void initSleuthkitServers() throws InterruptedException {
File tskDB = SleuthkitReader.getSleuthkitDB(output);
FileSystemConfig fsConfig = ConfigurationManager.get().findObject(FileSystemConfig.class);
if (tskDB.exists() && fsConfig.isRobustImageReading()) {
if (!initSleuthkitServers.getAndSet(true)) {
SleuthkitClient.initSleuthkitServers(tskDB.getParent());
}
}
}

Expand Down

0 comments on commit 0c724c8

Please sign in to comment.