Merge branch 'develop' of github.com:sleuthkit/autopsy into 7276_hostPersonEvents

This commit is contained in:
Greg DiCristofaro 2021-03-03 19:08:38 -05:00
commit cde9ab3d5a
7 changed files with 153 additions and 242 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2013-2018 Basis Technology Corp. * Copyright 2013-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -51,8 +51,7 @@ import org.sleuthkit.datamodel.TskCoreException;
* independently of the wizard. * independently of the wizard.
*/ */
@ServiceProviders(value = { @ServiceProviders(value = {
@ServiceProvider(service = DataSourceProcessor.class) @ServiceProvider(service = DataSourceProcessor.class),
,
@ServiceProvider(service = AutoIngestDataSourceProcessor.class)} @ServiceProvider(service = AutoIngestDataSourceProcessor.class)}
) )
public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSourceProcessor { public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSourceProcessor {
@ -83,7 +82,6 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
private String sha1; private String sha1;
private String sha256; private String sha256;
private Host host = null; private Host host = null;
private boolean setDataSourceOptionsCalled;
static { static {
filtersList.add(allFilter); filtersList.add(allFilter);
@ -184,8 +182,8 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
@Override @Override
public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) { public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
run(null, progressMonitor, callback); run(null, progressMonitor, callback);
} }
/** /**
* Adds a data source to the case database using a background task in a * Adds a data source to the case database using a background task in a
* separate thread and the settings provided by the selection and * separate thread and the settings provided by the selection and
@ -208,71 +206,71 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
this.host = host; this.host = host;
try { try {
image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(), image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, this.host); new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, this.host);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex); logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
errors.add(ex.getMessage()); errors.add(ex.getMessage());
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return; return;
} }
doAddImageProcess(deviceId, imagePath, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, progressMonitor, callback); doAddImageProcess(deviceId, imagePath, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, progressMonitor, callback);
} }
/** /**
* Adds a data source to the case database using a background task in a * Adds a data source to the case database using a background task in a
* separate thread and the settings provided by the selection and * separate thread and the settings provided by the selection and
* configuration panel. Files found during ingest will be sent directly to the * configuration panel. Files found during ingest will be sent directly to
* IngestStream provided. Returns as soon as the background task is started. * the IngestStream provided. Returns as soon as the background task is
* The background task uses a callback object to signal task completion and * started. The background task uses a callback object to signal task
* return results. * completion and return results.
* *
* This method should not be called unless isPanelValid returns true, and * This method should not be called unless isPanelValid returns true, and
* should only be called for DSPs that support ingest streams. * should only be called for DSPs that support ingest streams.
* *
* @param settings The ingest job settings. * @param settings The ingest job settings.
* @param progress Progress monitor that will be used by the * @param progress Progress monitor that will be used by the background task
* background task to report progress. * to report progress.
* @param callBack Callback that will be used by the background task * @param callBack Callback that will be used by the background task to
* to return results. * return results.
*/ */
@Override @Override
public void runWithIngestStream(IngestJobSettings settings, DataSourceProcessorProgressMonitor progress, public void runWithIngestStream(IngestJobSettings settings, DataSourceProcessorProgressMonitor progress,
DataSourceProcessorCallback callBack) { DataSourceProcessorCallback callBack) {
runWithIngestStream(null, settings, progress, callBack); runWithIngestStream(null, settings, progress, callBack);
} }
/** /**
* Adds a data source to the case database using a background task in a * Adds a data source to the case database using a background task in a
* separate thread and the settings provided by the selection and * separate thread and the settings provided by the selection and
* configuration panel. Files found during ingest will be sent directly to the * configuration panel. Files found during ingest will be sent directly to
* IngestStream provided. Returns as soon as the background task is started. * the IngestStream provided. Returns as soon as the background task is
* The background task uses a callback object to signal task completion and * started. The background task uses a callback object to signal task
* return results. * completion and return results.
* *
* This method should not be called unless isPanelValid returns true, and * This method should not be called unless isPanelValid returns true, and
* should only be called for DSPs that support ingest streams. * should only be called for DSPs that support ingest streams.
* *
* @param host The host for this data source. * @param host The host for this data source.
* @param settings The ingest job settings. * @param settings The ingest job settings.
* @param progress Progress monitor that will be used by the * @param progress Progress monitor that will be used by the background task
* background task to report progress. * to report progress.
* @param callBack Callback that will be used by the background task * @param callBack Callback that will be used by the background task to
* to return results. * return results.
*/ */
@Override @Override
public void runWithIngestStream(Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progress, public void runWithIngestStream(Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progress,
DataSourceProcessorCallback callBack) { DataSourceProcessorCallback callBack) {
// Read the settings from the wizard // Read the settings from the wizard
readConfigSettings(); readConfigSettings();
this.host = host; this.host = host;
// Set up the data source before creating the ingest stream // Set up the data source before creating the ingest stream
try { try {
image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(), image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, this.host); new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, this.host);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex); logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
@ -291,46 +289,43 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
callBack.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callBack.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return; return;
} }
doAddImageProcess(deviceId, imagePath, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, progress, callBack); doAddImageProcess(deviceId, imagePath, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, progress, callBack);
} }
/** /**
* Store the options from the config panel. * Store the options from the config panel.
*/ */
private void readConfigSettings() { private void readConfigSettings() {
if (!setDataSourceOptionsCalled) { configPanel.storeSettings();
configPanel.storeSettings(); deviceId = UUID.randomUUID().toString();
deviceId = UUID.randomUUID().toString(); imagePath = configPanel.getContentPaths();
imagePath = configPanel.getContentPaths(); sectorSize = configPanel.getSectorSize();
sectorSize = configPanel.getSectorSize(); timeZone = configPanel.getTimeZone();
timeZone = configPanel.getTimeZone(); ignoreFatOrphanFiles = configPanel.getNoFatOrphans();
ignoreFatOrphanFiles = configPanel.getNoFatOrphans(); md5 = configPanel.getMd5();
md5 = configPanel.getMd5(); if (md5.isEmpty()) {
if (md5.isEmpty()) { md5 = null;
md5 = null; }
} sha1 = configPanel.getSha1();
sha1 = configPanel.getSha1(); if (sha1.isEmpty()) {
if (sha1.isEmpty()) { sha1 = null;
sha1 = null; }
} sha256 = configPanel.getSha256();
sha256 = configPanel.getSha256(); if (sha256.isEmpty()) {
if (sha256.isEmpty()) { sha256 = null;
sha256 = null;
}
} }
} }
/** /**
* Check if this DSP supports ingest streams. * Check if this DSP supports ingest streams.
* *
* @return True if this DSP supports an ingest stream, false otherwise. * @return True if this DSP supports an ingest stream, false otherwise.
*/ */
@Override @Override
public boolean supportsIngestStream() { public boolean supportsIngestStream() {
return true; return true;
} }
/** /**
* Adds a data source to the case database using a background task in a * Adds a data source to the case database using a background task in a
@ -357,11 +352,11 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
ingestStream = new DefaultIngestStream(); ingestStream = new DefaultIngestStream();
try { try {
image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(), image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
new String[]{imagePath}, sectorSize, timeZone, "", "", "", deviceId); new String[]{imagePath}, sectorSize, timeZone, "", "", "", deviceId);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex); logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
errors.add(ex.getMessage()); errors.add(ex.getMessage());
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return; return;
} }
@ -375,10 +370,10 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
* selection and configuration panel. Returns as soon as the background task * selection and configuration panel. Returns as soon as the background task
* is started and uses the callback object to signal task completion and * is started and uses the callback object to signal task completion and
* return results. * return results.
* *
* The image should be loaded in the database and stored in "image" * The image should be loaded in the database and stored in "image" before
* before calling this method. Additionally, an ingest stream should be initialized * calling this method. Additionally, an ingest stream should be initialized
* and stored in "ingestStream". * and stored in "ingestStream".
* *
* @param deviceId An ASCII-printable identifier for the device * @param deviceId An ASCII-printable identifier for the device
* associated with the data source that is * associated with the data source that is
@ -400,28 +395,28 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
*/ */
private void doAddImageProcess(String deviceId, String imagePath, int sectorSize, String timeZone, boolean ignoreFatOrphanFiles, String md5, String sha1, String sha256, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) { private void doAddImageProcess(String deviceId, String imagePath, int sectorSize, String timeZone, boolean ignoreFatOrphanFiles, String md5, String sha1, String sha256, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
// If the data source or ingest stream haven't been initialized, stop processing // If the data source or ingest stream haven't been initialized, stop processing
if (ingestStream == null) { if (ingestStream == null) {
String message = "Ingest stream was not initialized before running the add image process on " + imagePath; String message = "Ingest stream was not initialized before running the add image process on " + imagePath;
logger.log(Level.SEVERE, message); logger.log(Level.SEVERE, message);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
errors.add(message); errors.add(message);
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return; return;
} }
if (image == null) { if (image == null) {
String message = "Image was not added to database before running the add image process on " + imagePath; String message = "Image was not added to database before running the add image process on " + imagePath;
logger.log(Level.SEVERE, message); logger.log(Level.SEVERE, message);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
errors.add(message); errors.add(message);
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return; return;
} }
AddImageTask.ImageDetails imageDetails = new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, null); AddImageTask.ImageDetails imageDetails = new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, null);
addImageTask = new AddImageTask(imageDetails, addImageTask = new AddImageTask(imageDetails,
progressMonitor, progressMonitor,
new StreamingAddDataSourceCallbacks(ingestStream), new StreamingAddDataSourceCallbacks(ingestStream),
new StreamingAddImageTaskCallback(ingestStream, callback)); new StreamingAddImageTaskCallback(ingestStream, callback));
new Thread(addImageTask).start(); new Thread(addImageTask).start();
} }
@ -455,7 +450,6 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
ignoreFatOrphanFiles = false; ignoreFatOrphanFiles = false;
host = null; host = null;
configPanel.reset(); configPanel.reset();
setDataSourceOptionsCalled = false;
} }
private static boolean isAcceptedByFiler(File file, List<FileFilter> filters) { private static boolean isAcceptedByFiler(File file, List<FileFilter> filters) {
@ -488,56 +482,56 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
// able to process the data source // able to process the data source
return 100; return 100;
} }
@Override @Override
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) { public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
process(deviceId, dataSourcePath, null, progressMonitor, callBack); process(deviceId, dataSourcePath, null, progressMonitor, callBack);
} }
@Override @Override
public void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) { public void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
// this method does not use the config panel
this.deviceId = deviceId; this.deviceId = deviceId;
this.imagePath = dataSourcePath.toString(); this.imagePath = dataSourcePath.toString();
this.sectorSize = 0; this.sectorSize = 0;
this.timeZone = Calendar.getInstance().getTimeZone().getID(); this.timeZone = Calendar.getInstance().getTimeZone().getID();
this.host = host; this.host = host;
this.ignoreFatOrphanFiles = false; this.ignoreFatOrphanFiles = false;
setDataSourceOptionsCalled = true;
ingestStream = new DefaultIngestStream(); ingestStream = new DefaultIngestStream();
try { try {
image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(), image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
new String[]{imagePath}, sectorSize, timeZone, "", "", "", deviceId, host); new String[]{imagePath}, sectorSize, timeZone, "", "", "", deviceId, host);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex); logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
errors.add(ex.getMessage()); errors.add(ex.getMessage());
callBack.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callBack.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return; return;
} }
doAddImageProcess(deviceId, dataSourcePath.toString(), sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, progressMonitor, callBack); doAddImageProcess(deviceId, dataSourcePath.toString(), sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, progressMonitor, callBack);
} }
@Override @Override
public IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) { public IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
return processWithIngestStream(deviceId, dataSourcePath, null, settings, progressMonitor, callBack); return processWithIngestStream(deviceId, dataSourcePath, null, settings, progressMonitor, callBack);
} }
@Override @Override
public IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) { public IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
// this method does not use the config panel
this.deviceId = deviceId; this.deviceId = deviceId;
this.imagePath = dataSourcePath.toString(); this.imagePath = dataSourcePath.toString();
this.sectorSize = 0; this.sectorSize = 0;
this.timeZone = Calendar.getInstance().getTimeZone().getID(); this.timeZone = Calendar.getInstance().getTimeZone().getID();
this.host = host; this.host = host;
this.ignoreFatOrphanFiles = false; this.ignoreFatOrphanFiles = false;
setDataSourceOptionsCalled = true;
// Set up the data source before creating the ingest stream // Set up the data source before creating the ingest stream
try { try {
image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(), image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, host); new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, host);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex); logger.log(Level.SEVERE, "Error adding data source with path " + imagePath + " to database", ex);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
@ -555,34 +549,10 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
errors.add(ex.getMessage()); errors.add(ex.getMessage());
callBack.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callBack.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return null; return null;
} }
doAddImageProcess(deviceId, dataSourcePath.toString(), sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, progressMonitor, callBack); doAddImageProcess(deviceId, dataSourcePath.toString(), sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, progressMonitor, callBack);
return ingestStream; return ingestStream;
} }
/**
* Sets the configuration of the data source processor without using the
* selection and configuration panel.
*
* @param imagePath Path to the image file.
* @param timeZone The time zone to use when processing dates
* and times for the image, obtained from
* java.util.TimeZone.getID.
* @param ignoreFatOrphanFiles Whether to parse orphans if the image has a
* FAT filesystem.
*
* @deprecated Use the provided overload of the run method instead.
*/
@Deprecated
public void setDataSourceOptions(String imagePath, String timeZone, boolean ignoreFatOrphanFiles) {
this.deviceId = UUID.randomUUID().toString();
this.imagePath = imagePath;
this.sectorSize = 0;
this.timeZone = Calendar.getInstance().getTimeZone().getID();
this.ignoreFatOrphanFiles = ignoreFatOrphanFiles;
this.host = null;
setDataSourceOptionsCalled = true;
}
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2013-2018 Basis Technology Corp. * Copyright 2013-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -19,7 +19,6 @@
package org.sleuthkit.autopsy.casemodule; package org.sleuthkit.autopsy.casemodule;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
@ -60,7 +59,6 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
private Host host; private Host host;
private ImageWriterSettings imageWriterSettings; private ImageWriterSettings imageWriterSettings;
private boolean ignoreFatOrphanFiles; private boolean ignoreFatOrphanFiles;
private boolean setDataSourceOptionsCalled;
/** /**
* Constructs a local drive data source processor that implements the * Constructs a local drive data source processor that implements the
@ -139,7 +137,7 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) { public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
run(null, progressMonitor, callback); run(null, progressMonitor, callback);
} }
/** /**
* Adds a data source to the case database using a background task in a * Adds a data source to the case database using a background task in a
* separate thread and the settings provided by the selection and * separate thread and the settings provided by the selection and
@ -157,38 +155,36 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
*/ */
@Override @Override
public void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) { public void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
if (!setDataSourceOptionsCalled) { deviceId = UUID.randomUUID().toString();
deviceId = UUID.randomUUID().toString(); drivePath = configPanel.getContentPath();
drivePath = configPanel.getContentPath(); sectorSize = configPanel.getSectorSize();
sectorSize = configPanel.getSectorSize(); timeZone = configPanel.getTimeZone();
timeZone = configPanel.getTimeZone(); ignoreFatOrphanFiles = configPanel.getNoFatOrphans();
ignoreFatOrphanFiles = configPanel.getNoFatOrphans(); if (configPanel.getImageWriterEnabled()) {
if (configPanel.getImageWriterEnabled()) { imageWriterSettings = configPanel.getImageWriterSettings();
imageWriterSettings = configPanel.getImageWriterSettings(); } else {
} else { imageWriterSettings = null;
imageWriterSettings = null;
}
} }
this.host = host; this.host = host;
Image image; Image image;
try { try {
image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(), image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
new String[]{drivePath}, sectorSize, new String[]{drivePath}, sectorSize,
timeZone, null, null, null, deviceId, this.host); timeZone, null, null, null, deviceId, this.host);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error adding local disk with path " + drivePath + " to database", ex); logger.log(Level.SEVERE, "Error adding local disk with path " + drivePath + " to database", ex);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
errors.add(ex.getMessage()); errors.add(ex.getMessage());
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return; return;
} }
addDiskTask = new AddImageTask( addDiskTask = new AddImageTask(
new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, imageWriterSettings), new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, imageWriterSettings),
progressMonitor, progressMonitor,
new StreamingAddDataSourceCallbacks(new DefaultIngestStream()), new StreamingAddDataSourceCallbacks(new DefaultIngestStream()),
new StreamingAddImageTaskCallback(new DefaultIngestStream(), callback)); new StreamingAddImageTaskCallback(new DefaultIngestStream(), callback));
new Thread(addDiskTask).start(); new Thread(addDiskTask).start();
} }
@ -244,19 +240,19 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
Image image; Image image;
try { try {
image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(), image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
new String[]{drivePath}, sectorSize, new String[]{drivePath}, sectorSize,
timeZone, null, null, null, deviceId); timeZone, null, null, null, deviceId);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error adding local disk with path " + drivePath + " to database", ex); logger.log(Level.SEVERE, "Error adding local disk with path " + drivePath + " to database", ex);
final List<String> errors = new ArrayList<>(); final List<String> errors = new ArrayList<>();
errors.add(ex.getMessage()); errors.add(ex.getMessage());
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return; return;
} }
addDiskTask = new AddImageTask(new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, imageWriterSettings), addDiskTask = new AddImageTask(new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, imageWriterSettings),
progressMonitor, progressMonitor,
new StreamingAddDataSourceCallbacks(new DefaultIngestStream()), new StreamingAddDataSourceCallbacks(new DefaultIngestStream()),
new StreamingAddImageTaskCallback(new DefaultIngestStream(), callback)); new StreamingAddImageTaskCallback(new DefaultIngestStream(), callback));
new Thread(addDiskTask).start(); new Thread(addDiskTask).start();
} }
@ -285,30 +281,5 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
drivePath = null; drivePath = null;
timeZone = null; timeZone = null;
ignoreFatOrphanFiles = false; ignoreFatOrphanFiles = false;
setDataSourceOptionsCalled = false;
} }
/**
* Sets the configuration of the data source processor without using the
* configuration panel.
*
* @param drivePath Path to the local drive.
* @param timeZone The time zone to use when processing dates
* and times for the local drive, obtained from
* java.util.TimeZone.getID.
* @param ignoreFatOrphanFiles Whether to parse orphans if the image has a
* FAT filesystem.
*
* @deprecated Use the provided overload of the run method instead.
*/
@Deprecated
public void setDataSourceOptions(String drivePath, String timeZone, boolean ignoreFatOrphanFiles) {
this.deviceId = UUID.randomUUID().toString();
this.drivePath = drivePath;
this.sectorSize = 0;
this.timeZone = Calendar.getInstance().getTimeZone().getID();
this.ignoreFatOrphanFiles = ignoreFatOrphanFiles;
setDataSourceOptionsCalled = true;
}
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -78,7 +78,6 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
* when the deprecated method setDataSourceOptions is removed. * when the deprecated method setDataSourceOptions is removed.
*/ */
private List<String> localFilePaths; private List<String> localFilePaths;
private boolean setDataSourceOptionsCalled;
/** /**
* Constructs a local/logical files and/or directories data source processor * Constructs a local/logical files and/or directories data source processor
@ -139,7 +138,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
return configPanel.validatePanel(); return configPanel.validatePanel();
} }
/** /**
* Adds a data source to the case database using a background task in a * Adds a data source to the case database using a background task in a
* separate thread and the settings provided by the selection and * separate thread and the settings provided by the selection and
* configuration panel. Returns as soon as the background task is started. * configuration panel. Returns as soon as the background task is started.
@ -156,8 +155,8 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
@Override @Override
public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) { public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
run(null, progressMonitor, callback); run(null, progressMonitor, callback);
} }
/** /**
* Adds a data source to the case database using a background task in a * Adds a data source to the case database using a background task in a
* separate thread and the settings provided by the selection and * separate thread and the settings provided by the selection and
@ -175,23 +174,21 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
*/ */
@Override @Override
public void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) { public void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
if (!setDataSourceOptionsCalled) {
localFilePaths = configPanel.getContentPaths();
localFilePaths = configPanel.getContentPaths(); if (configPanel.subTypeIsLogicalEvidencePanel()) {
if (configPanel.subTypeIsLogicalEvidencePanel()) { try {
try { //if the L01 option was chosen
//if the L01 option was chosen localFilePaths = extractLogicalEvidenceFileContents(localFilePaths);
localFilePaths = extractLogicalEvidenceFileContents(localFilePaths); } catch (L01Exception ex) {
} catch (L01Exception ex) { //contents of l01 could not be extracted don't add data source or run ingest
//contents of l01 could not be extracted don't add data source or run ingest final List<String> errors = new ArrayList<>();
final List<String> errors = new ArrayList<>(); errors.add(ex.getMessage());
errors.add(ex.getMessage()); callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>()); return;
return; } catch (NoCurrentCaseException ex) {
} catch (NoCurrentCaseException ex) { logger.log(Level.WARNING, "Exception while getting open case.", ex);
logger.log(Level.WARNING, "Exception while getting open case.", ex); return;
return;
}
} }
} }
run(UUID.randomUUID().toString(), configPanel.getFileSetName(), localFilePaths, host, progressMonitor, callback); run(UUID.randomUUID().toString(), configPanel.getFileSetName(), localFilePaths, host, progressMonitor, callback);
@ -220,7 +217,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
command.add("-f"); command.add("-f");
command.add("files"); command.add("files");
command.add("-t"); command.add("-t");
File l01Dir = new File(Case.getCurrentCaseThrows().getModuleDirectory(), L01_EXTRACTION_DIR); File l01Dir = new File(Case.getCurrentCaseThrows().getModuleDirectory(), L01_EXTRACTION_DIR);
if (!l01Dir.exists()) { if (!l01Dir.exists()) {
l01Dir.mkdirs(); l01Dir.mkdirs();
} }
@ -307,7 +304,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
return executablePath; return executablePath;
} }
/** /**
* Adds a data source to the case database using a background task in a * Adds a data source to the case database using a background task in a
* separate thread and the given settings instead of those provided by the * separate thread and the given settings instead of those provided by the
@ -385,7 +382,6 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
public void reset() { public void reset() {
configPanel.select(); configPanel.select();
localFilePaths = null; localFilePaths = null;
setDataSourceOptionsCalled = false;
} }
@Override @Override
@ -421,34 +417,13 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) { public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
process(deviceId, dataSourcePath, null, progressMonitor, callBack); process(deviceId, dataSourcePath, null, progressMonitor, callBack);
} }
@Override @Override
public void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) { public void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
List<String> filePaths = Arrays.asList(new String[]{dataSourcePath.toString()}); List<String> filePaths = Arrays.asList(new String[]{dataSourcePath.toString()});
run(deviceId, "", filePaths, host, progressMonitor, callBack); run(deviceId, "", filePaths, host, progressMonitor, callBack);
} }
/**
* Sets the configuration of the data source processor without using the
* configuration panel. The data source processor will assign a UUID to the
* data source and will use the time zone of the machine executing this code
* when when processing dates and times for the image.
*
* @param paths A list of local/logical file and/or directory
* localFilePaths.
*
* @deprecated Use the provided overload of the run method instead.
*/
@Deprecated
public void setDataSourceOptions(String paths) {
// The LocalFilesPanel used to separate file paths with a comma and pass
// them as a string, but because file names are allowed to contain
// commas, this approach was buggy and replaced. We now pass a list of
// String paths.
this.localFilePaths = Arrays.asList(paths.split(","));
setDataSourceOptionsCalled = true;
}
/** /**
* A custom exception for the L01 processing. * A custom exception for the L01 processing.
*/ */

View File

@ -29,7 +29,6 @@ import javax.swing.filechooser.FileFilter;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.ServiceProvider; import org.openide.util.lookup.ServiceProvider;
import org.openide.util.lookup.ServiceProviders; import org.openide.util.lookup.ServiceProviders;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.GeneralFilter; import org.sleuthkit.autopsy.casemodule.GeneralFilter;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;

View File

@ -93,16 +93,12 @@ public class DomainSummaryViewer extends javax.swing.JPanel {
* reflect the currently selected domain. Will populate the list with * reflect the currently selected domain. Will populate the list with
* nothing when a domain is not used. * nothing when a domain is not used.
* *
* @param useDomain If the currently selected domain should be used to
* retrieve a list.
*/ */
@ThreadConfined(type = ThreadConfined.ThreadType.AWT) @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
void sendPopulateEvent(boolean useDomain) { void sendPopulateEvent() {
String domain = ""; String domain = "";
if (useDomain) { if (domainList.getSelectedIndex() != -1) {
if (domainList.getSelectedIndex() != -1) { domain = domainListModel.getElementAt(domainList.getSelectedIndex()).getResultDomain().getDomain();
domain = domainListModel.getElementAt(domainList.getSelectedIndex()).getResultDomain().getDomain();
}
} }
//send populateMesage //send populateMesage
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.PopulateDomainTabsEvent(domain)); DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.PopulateDomainTabsEvent(domain));

View File

@ -128,8 +128,8 @@ final class ResultsPanel extends javax.swing.JPanel {
} }
}); });
domainSummaryViewer.addListSelectionListener((e) -> { domainSummaryViewer.addListSelectionListener((e) -> {
if (resultType == SearchData.Type.DOMAIN) { if (resultType == SearchData.Type.DOMAIN && !e.getValueIsAdjusting()) {
domainSummaryViewer.sendPopulateEvent(!e.getValueIsAdjusting()); domainSummaryViewer.sendPopulateEvent();
} }
}); });
} }

View File

@ -34,7 +34,7 @@ public class DomainSearchTestUtils {
long totalVisits, long visits, long filesDownloaded, long dataSourceId) { long totalVisits, long visits, long filesDownloaded, long dataSourceId) {
Content dataSource = TskMockUtils.getDataSource(dataSourceId); Content dataSource = TskMockUtils.getDataSource(dataSourceId);
return new ResultDomain(domain, start, end, totalVisits, return new ResultDomain(domain, start, end, totalVisits,
visits, filesDownloaded, 0L, dataSource); visits, filesDownloaded, 0L, "", dataSource);
} }
public static ResultDomain mockDomainResult(String domain) { public static ResultDomain mockDomainResult(String domain) {