mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
Address PR comments
This commit is contained in:
parent
ec82b0785c
commit
28aac6ca11
@ -37,7 +37,7 @@ import org.sleuthkit.datamodel.TskDataException;
|
|||||||
* case database, grouped under a virtual directory that serves as the data
|
* case database, grouped under a virtual directory that serves as the data
|
||||||
* source.
|
* source.
|
||||||
*/
|
*/
|
||||||
public class AddLocalFilesTask implements Runnable {
|
class AddLocalFilesTask implements Runnable {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(AddLocalFilesTask.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(AddLocalFilesTask.class.getName());
|
||||||
private final String deviceId;
|
private final String deviceId;
|
||||||
@ -68,7 +68,7 @@ public class AddLocalFilesTask implements Runnable {
|
|||||||
* during processing.
|
* during processing.
|
||||||
* @param callback Callback to call when processing is done.
|
* @param callback Callback to call when processing is done.
|
||||||
*/
|
*/
|
||||||
public AddLocalFilesTask(String deviceId, String rootVirtualDirectoryName, List<String> localFilePaths, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
|
AddLocalFilesTask(String deviceId, String rootVirtualDirectoryName, List<String> localFilePaths, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
this.rootVirtualDirectoryName = rootVirtualDirectoryName;
|
this.rootVirtualDirectoryName = rootVirtualDirectoryName;
|
||||||
this.localFilePaths = localFilePaths;
|
this.localFilePaths = localFilePaths;
|
||||||
@ -88,7 +88,7 @@ public class AddLocalFilesTask implements Runnable {
|
|||||||
try {
|
try {
|
||||||
progress.setIndeterminate(true);
|
progress.setIndeterminate(true);
|
||||||
FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
|
FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
|
||||||
LocalFilesDataSource newDataSource = fileManager.addLocalFilesDataSource(deviceId, "", "", localFilePaths, new ProgressUpdater());
|
LocalFilesDataSource newDataSource = fileManager.addLocalFilesDataSource(deviceId, rootVirtualDirectoryName, "", localFilePaths, new ProgressUpdater());
|
||||||
newDataSources.add(newDataSource);
|
newDataSources.add(newDataSource);
|
||||||
} catch (TskDataException | TskCoreException | NoCurrentCaseException ex) {
|
} catch (TskDataException | TskCoreException | NoCurrentCaseException ex) {
|
||||||
errors.add(ex.getMessage());
|
errors.add(ex.getMessage());
|
||||||
|
@ -85,13 +85,13 @@ class LogicalImagerConfig {
|
|||||||
String version,
|
String version,
|
||||||
boolean finalizeImageWriter,
|
boolean finalizeImageWriter,
|
||||||
boolean promptBeforeExit,
|
boolean promptBeforeExit,
|
||||||
boolean creatVHD,
|
boolean createVHD,
|
||||||
List<LogicalImagerRuleSet> ruleSets
|
List<LogicalImagerRuleSet> ruleSets
|
||||||
) {
|
) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.finalizeImageWriter = finalizeImageWriter;
|
this.finalizeImageWriter = finalizeImageWriter;
|
||||||
this.promptBeforeExit = promptBeforeExit;
|
this.promptBeforeExit = promptBeforeExit;
|
||||||
this.createVHD = creatVHD;
|
this.createVHD = createVHD;
|
||||||
this.ruleSets = ruleSets;
|
this.ruleSets = ruleSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
import org.sleuthkit.autopsy.casemodule.services.FileManager;
|
|
||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;
|
||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
@ -107,7 +106,9 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
"AddLogicalImageTask.addingInterestingFiles=Adding search results as interesting files",
|
"AddLogicalImageTask.addingInterestingFiles=Adding search results as interesting files",
|
||||||
"AddLogicalImageTask.doneAddingInterestingFiles=Done adding search results as interesting files",
|
"AddLogicalImageTask.doneAddingInterestingFiles=Done adding search results as interesting files",
|
||||||
"# {0} - SearchResults.txt", "# {1} - directory", "AddLogicalImageTask.cannotFindFiles=Cannot find {0} in {1}",
|
"# {0} - SearchResults.txt", "# {1} - directory", "AddLogicalImageTask.cannotFindFiles=Cannot find {0} in {1}",
|
||||||
"# {0} - reason", "AddLogicalImageTask.failedToAddInterestingFiles=Failed to add interesting files: {0}"
|
"# {0} - reason", "AddLogicalImageTask.failedToAddInterestingFiles=Failed to add interesting files: {0}",
|
||||||
|
"AddLogicalImageTask.addingExtractedFiles=Adding extracted files",
|
||||||
|
"AddLogicalImageTask.doneAddingExtractedFiles=Done adding extracted files",
|
||||||
})
|
})
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -189,11 +190,14 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
progressMonitor.setProgressText(Bundle.AddLogicalImageTask_addingExtractedFiles());
|
||||||
addExtractedFiles(dest, Paths.get(dest.toString(), resultsFilename), newDataSources);
|
addExtractedFiles(dest, Paths.get(dest.toString(), resultsFilename), newDataSources);
|
||||||
|
progressMonitor.setProgressText(Bundle.AddLogicalImageTask_doneAddingExtractedFiles());
|
||||||
} catch (TskCoreException | IOException ex) {
|
} catch (TskCoreException | IOException ex) {
|
||||||
errorList.add(ex.getMessage());
|
errorList.add(ex.getMessage());
|
||||||
LOGGER.log(Level.SEVERE, String.format("Failed to add datasource: %s", ex.getMessage()), ex); // NON-NLS
|
LOGGER.log(Level.SEVERE, String.format("Failed to add datasource: %s", ex.getMessage()), ex); // NON-NLS
|
||||||
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errorList, emptyDataSources);
|
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errorList, emptyDataSources);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
createVHD = true;
|
createVHD = true;
|
||||||
@ -209,6 +213,7 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
String msg = Bundle.AddLogicalImageTask_noCurrentCase();
|
String msg = Bundle.AddLogicalImageTask_noCurrentCase();
|
||||||
errorList.add(msg);
|
errorList.add(msg);
|
||||||
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errorList, emptyDataSources);
|
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errorList, emptyDataSources);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,10 +295,13 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
br.readLine(); // skip the header line
|
br.readLine(); // skip the header line
|
||||||
int lineNumber = 2;
|
int lineNumber = 2;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
|
if (cancelled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String[] fields = line.split("\t", -1); // NON-NLS
|
String[] fields = line.split("\t", -1); // NON-NLS
|
||||||
// if (fields.length != 9) {
|
if (fields.length != 14) {
|
||||||
// throw new IOException(Bundle.AddLogicalImageTask_notEnoughFields(lineNumber, fields.length, 9));
|
throw new IOException(Bundle.AddLogicalImageTask_notEnoughFields(lineNumber, fields.length, 9));
|
||||||
// }
|
}
|
||||||
String vhdFilename = fields[0];
|
String vhdFilename = fields[0];
|
||||||
// String fileSystemOffsetStr = fields[1];
|
// String fileSystemOffsetStr = fields[1];
|
||||||
String fileMetaAddressStr = fields[2];
|
String fileMetaAddressStr = fields[2];
|
||||||
@ -344,14 +352,13 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
BlackboardAttribute ruleNameAttribute = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, MODULE_NAME, ruleName);
|
BlackboardAttribute ruleNameAttribute = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, MODULE_NAME, ruleName);
|
||||||
attributes.add(ruleNameAttribute);
|
attributes.add(ruleNameAttribute);
|
||||||
if (!blackboard.artifactExists(file, BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, attributes)) {
|
if (!blackboard.artifactExists(file, BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, attributes)) {
|
||||||
BlackboardArtifact artifact = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
|
BlackboardArtifact artifact = this.currentCase.getSleuthkitCase().newBlackboardArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, file.getId());
|
||||||
artifact.addAttributes(attributes);
|
artifact.addAttributes(attributes);
|
||||||
artifacts.add(artifact);
|
artifacts.add(artifact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addExtractedFiles(File src, Path resultsPath, List<Content> newDataSources) throws TskCoreException, UnsupportedEncodingException, IOException {
|
private void addExtractedFiles(File src, Path resultsPath, List<Content> newDataSources) throws TskCoreException, UnsupportedEncodingException, IOException {
|
||||||
|
|
||||||
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
|
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
|
||||||
SleuthkitCase.CaseDbTransaction trans = null;
|
SleuthkitCase.CaseDbTransaction trans = null;
|
||||||
try {
|
try {
|
||||||
@ -365,16 +372,20 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
br.readLine(); // skip the header line
|
br.readLine(); // skip the header line
|
||||||
int lineNumber = 2;
|
int lineNumber = 2;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
|
if (cancelled) {
|
||||||
|
rollbackTransaction(trans);
|
||||||
|
return;
|
||||||
|
}
|
||||||
String[] fields = line.split("\t", -1); // NON-NLS
|
String[] fields = line.split("\t", -1); // NON-NLS
|
||||||
if (fields.length != 14) {
|
if (fields.length != 14) {
|
||||||
throw new IOException(Bundle.AddLogicalImageTask_notEnoughFields(lineNumber, fields.length, 14));
|
throw new IOException(Bundle.AddLogicalImageTask_notEnoughFields(lineNumber, fields.length, 14));
|
||||||
}
|
}
|
||||||
String vhdFilename = fields[0];
|
String vhdFilename = fields[0];
|
||||||
// String fileSystemOffsetStr = fields[1];
|
// String fileSystemOffsetStr = fields[1];
|
||||||
// String fileMetaAddressStr = fields[2];
|
// String fileMetaAddressStr = fields[2];
|
||||||
// String extractStatusStr = fields[3];
|
// String extractStatusStr = fields[3];
|
||||||
// String ruleSetName = fields[4];
|
// String ruleSetName = fields[4];
|
||||||
// String ruleName = fields[5];
|
// String ruleName = fields[5];
|
||||||
// String description = fields[6];
|
// String description = fields[6];
|
||||||
String filename = fields[7];
|
String filename = fields[7];
|
||||||
String parentPath = fields[8];
|
String parentPath = fields[8];
|
||||||
@ -398,48 +409,26 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
|
|
||||||
lineNumber++;
|
lineNumber++;
|
||||||
} // end reading file
|
} // end reading file
|
||||||
|
|
||||||
trans.commit();
|
|
||||||
newDataSources.add(localFilesDataSource);
|
|
||||||
}
|
}
|
||||||
} catch (TskCoreException ex) {
|
trans.commit();
|
||||||
LOGGER.log(Level.SEVERE, "Error adding local files", ex); // NON-NLS
|
newDataSources.add(localFilesDataSource);
|
||||||
if (null != trans) {
|
|
||||||
try {
|
} catch (IOException | NumberFormatException | TskCoreException ex) {
|
||||||
trans.rollback();
|
LOGGER.log(Level.SEVERE, "Error adding extracted files", ex); // NON-NLS
|
||||||
} catch (TskCoreException ex2) {
|
rollbackTransaction(trans);
|
||||||
LOGGER.log(Level.SEVERE, String.format("Failed to rollback transaction after exception: %s", ex.getMessage()), ex2); // NON-NLS
|
throw new TskCoreException("Error adding extracted files", ex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rollbackTransaction(SleuthkitCase.CaseDbTransaction trans) throws TskCoreException {
|
||||||
|
if (null != trans) {
|
||||||
|
try {
|
||||||
|
trans.rollback();
|
||||||
|
} catch (TskCoreException ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, String.format("Failed to rollback transaction: %s", ex.getMessage()), ex); // NON-NLS
|
||||||
|
throw new TskCoreException("Error cancelling", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates task progress as the file manager adds the local/logical files
|
|
||||||
* and/or directories to the case database.
|
|
||||||
*/
|
|
||||||
@Messages({
|
|
||||||
"# {0} - parent path", "# {1} - filename", "AddLogicalImageTask.localFileAddProgress=Adding: {0}/{1}",
|
|
||||||
})
|
|
||||||
private class ProgressUpdater implements FileManager.FileAddProgressUpdater {
|
|
||||||
|
|
||||||
private int count;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates task progress (called by the file manager after it adds each
|
|
||||||
* local file/directory to the case database).
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void fileAdded(final AbstractFile file) {
|
|
||||||
++count;
|
|
||||||
if (count % 10 == 0) {
|
|
||||||
progressMonitor.setProgressText(
|
|
||||||
Bundle.AddLogicalImageTask_localFileAddProgress(
|
|
||||||
file.getParentPath(),
|
|
||||||
file.getName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# To change this template file, choose Tools | Templates
|
# To change this template file, choose Tools | Templates
|
||||||
# and open the template in the editor.
|
# and open the template in the editor.
|
||||||
|
|
||||||
|
AddLogicalImageTask.addingExtractedFiles=Adding extracted files
|
||||||
AddLogicalImageTask.addingInterestingFiles=Adding search results as interesting files
|
AddLogicalImageTask.addingInterestingFiles=Adding search results as interesting files
|
||||||
# {0} - file
|
# {0} - file
|
||||||
AddLogicalImageTask.addingToReport=Adding {0} to report
|
AddLogicalImageTask.addingToReport=Adding {0} to report
|
||||||
@ -15,6 +16,7 @@ AddLogicalImageTask.cannotFindFiles=Cannot find {0} in {1}
|
|||||||
AddLogicalImageTask.copyingImageFromTo=Copying image from {0} to {1}
|
AddLogicalImageTask.copyingImageFromTo=Copying image from {0} to {1}
|
||||||
# {0} - sparseImageDirectory
|
# {0} - sparseImageDirectory
|
||||||
AddLogicalImageTask.directoryDoesNotContainSparseImage=Directory {0} does not contain any images
|
AddLogicalImageTask.directoryDoesNotContainSparseImage=Directory {0} does not contain any images
|
||||||
|
AddLogicalImageTask.doneAddingExtractedFiles=Done adding extracted files
|
||||||
AddLogicalImageTask.doneAddingInterestingFiles=Done adding search results as interesting files
|
AddLogicalImageTask.doneAddingInterestingFiles=Done adding search results as interesting files
|
||||||
# {0} - file
|
# {0} - file
|
||||||
AddLogicalImageTask.doneAddingToReport=Done adding {0} to report
|
AddLogicalImageTask.doneAddingToReport=Done adding {0} to report
|
||||||
@ -30,9 +32,6 @@ AddLogicalImageTask.failedToCopyDirectory=Failed to copy directory {0} to {1}
|
|||||||
# {0} - file
|
# {0} - file
|
||||||
AddLogicalImageTask.failToGetCanonicalPath=Fail to get canonical path for {0}
|
AddLogicalImageTask.failToGetCanonicalPath=Fail to get canonical path for {0}
|
||||||
AddLogicalImageTask.ingestionCancelled=Ingestion cancelled
|
AddLogicalImageTask.ingestionCancelled=Ingestion cancelled
|
||||||
# {0} - parent path
|
|
||||||
# {1} - filename
|
|
||||||
AddLogicalImageTask.localFileAddProgress=Adding: {0}/{1}
|
|
||||||
AddLogicalImageTask.noCurrentCase=No current case
|
AddLogicalImageTask.noCurrentCase=No current case
|
||||||
# {0} - line number
|
# {0} - line number
|
||||||
# {1} - fields length
|
# {1} - fields length
|
||||||
|
Loading…
x
Reference in New Issue
Block a user