mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Add support to upload and download yara settings from remote dir
This commit is contained in:
parent
6becccafc6
commit
78f516170f
@ -205,7 +205,9 @@ DeleteCaseTask.progress.parsingManifest=Parsing manifest file {0}...
|
|||||||
DeleteCaseTask.progress.releasingManifestLock=Releasing lock on the manifest file {0}...
|
DeleteCaseTask.progress.releasingManifestLock=Releasing lock on the manifest file {0}...
|
||||||
DeleteCaseTask.progress.startMessage=Starting deletion...
|
DeleteCaseTask.progress.startMessage=Starting deletion...
|
||||||
DeleteOrphanCaseNodesAction.progressDisplayName=Cleanup Case Znodes
|
DeleteOrphanCaseNodesAction.progressDisplayName=Cleanup Case Znodes
|
||||||
|
# {0} - item count
|
||||||
DeleteOrphanCaseNodesDialog.additionalInit.lblNodeCount.text=Znodes found: {0}
|
DeleteOrphanCaseNodesDialog.additionalInit.lblNodeCount.text=Znodes found: {0}
|
||||||
|
# {0} - item count
|
||||||
DeleteOrphanCaseNodesDialog.additionalInit.znodesTextArea.countMessage=ZNODES FOUND: {0}
|
DeleteOrphanCaseNodesDialog.additionalInit.znodesTextArea.countMessage=ZNODES FOUND: {0}
|
||||||
DeleteOrphanCaseNodesTask.progress.connectingToCoordSvc=Connecting to the coordination service
|
DeleteOrphanCaseNodesTask.progress.connectingToCoordSvc=Connecting to the coordination service
|
||||||
# {0} - node path
|
# {0} - node path
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2015 Basis Technology Corp.
|
* Copyright 2015 - 2020 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");
|
||||||
@ -151,6 +151,8 @@ public class SharedConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Upload the current multi-user ingest settings to a shared folder.
|
* Upload the current multi-user ingest settings to a shared folder.
|
||||||
*
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
* @throws SharedConfigurationException
|
* @throws SharedConfigurationException
|
||||||
* @throws CoordinationServiceException
|
* @throws CoordinationServiceException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
@ -208,6 +210,7 @@ public class SharedConfiguration {
|
|||||||
uploadCentralRepositorySettings(remoteFolder);
|
uploadCentralRepositorySettings(remoteFolder);
|
||||||
uploadObjectDetectionClassifiers(remoteFolder);
|
uploadObjectDetectionClassifiers(remoteFolder);
|
||||||
uploadPythonModules(remoteFolder);
|
uploadPythonModules(remoteFolder);
|
||||||
|
uploadYARASetting(remoteFolder);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Files.deleteIfExists(uploadInProgress.toPath());
|
Files.deleteIfExists(uploadInProgress.toPath());
|
||||||
@ -222,6 +225,8 @@ public class SharedConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Download the multi-user settings from a shared folder.
|
* Download the multi-user settings from a shared folder.
|
||||||
*
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
* @throws SharedConfigurationException
|
* @throws SharedConfigurationException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
@ -252,13 +257,16 @@ public class SharedConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Make sure all recent changes are saved to the preference file.
|
/*
|
||||||
This also releases open file handles to the preference files. If this
|
* Make sure all recent changes are saved to the preference
|
||||||
is not done, then occasionally downloading of shared configuration
|
* file. This also releases open file handles to the preference
|
||||||
fails silently, likely because Java/OS is still holding the file handle.
|
* files. If this is not done, then occasionally downloading of
|
||||||
The problem manifests itself by some of the old/original configuration files
|
* shared configuration fails silently, likely because Java/OS
|
||||||
sticking around after shared configuration has seemingly been successfully
|
* is still holding the file handle. The problem manifests
|
||||||
updated. */
|
* itself by some of the old/original configuration files
|
||||||
|
* sticking around after shared configuration has seemingly been
|
||||||
|
* successfully updated.
|
||||||
|
*/
|
||||||
UserPreferences.saveToStorage();
|
UserPreferences.saveToStorage();
|
||||||
} catch (BackingStoreException ex) {
|
} catch (BackingStoreException ex) {
|
||||||
throw new SharedConfigurationException("Failed to save shared configuration settings", ex);
|
throw new SharedConfigurationException("Failed to save shared configuration settings", ex);
|
||||||
@ -275,6 +283,7 @@ public class SharedConfiguration {
|
|||||||
downloadCentralRepositorySettings(remoteFolder);
|
downloadCentralRepositorySettings(remoteFolder);
|
||||||
downloadObjectDetectionClassifiers(remoteFolder);
|
downloadObjectDetectionClassifiers(remoteFolder);
|
||||||
downloadPythonModules(remoteFolder);
|
downloadPythonModules(remoteFolder);
|
||||||
|
downloadYARASettings(remoteFolder);
|
||||||
|
|
||||||
// Download general settings, then restore the current
|
// Download general settings, then restore the current
|
||||||
// values for the unshared fields
|
// values for the unshared fields
|
||||||
@ -344,7 +353,7 @@ public class SharedConfiguration {
|
|||||||
private void saveNonSharedSettings() {
|
private void saveNonSharedSettings() {
|
||||||
sharedConfigMaster = AutoIngestUserPreferences.getSharedConfigMaster();
|
sharedConfigMaster = AutoIngestUserPreferences.getSharedConfigMaster();
|
||||||
sharedConfigFolder = AutoIngestUserPreferences.getSharedConfigFolder();
|
sharedConfigFolder = AutoIngestUserPreferences.getSharedConfigFolder();
|
||||||
showToolsWarning = AutoIngestUserPreferences.getShowToolsWarning();
|
showToolsWarning = AutoIngestUserPreferences.getShowToolsWarning();
|
||||||
displayLocalTime = UserPreferences.displayTimesInLocalTime();
|
displayLocalTime = UserPreferences.displayTimesInLocalTime();
|
||||||
hideKnownFilesInDataSource = UserPreferences.hideKnownFilesInDataSourcesTree();
|
hideKnownFilesInDataSource = UserPreferences.hideKnownFilesInDataSourcesTree();
|
||||||
hideKnownFilesInViews = UserPreferences.hideKnownFilesInViewsTree();
|
hideKnownFilesInViews = UserPreferences.hideKnownFilesInViewsTree();
|
||||||
@ -360,7 +369,7 @@ public class SharedConfiguration {
|
|||||||
private void restoreNonSharedSettings() {
|
private void restoreNonSharedSettings() {
|
||||||
AutoIngestUserPreferences.setSharedConfigFolder(sharedConfigFolder);
|
AutoIngestUserPreferences.setSharedConfigFolder(sharedConfigFolder);
|
||||||
AutoIngestUserPreferences.setSharedConfigMaster(sharedConfigMaster);
|
AutoIngestUserPreferences.setSharedConfigMaster(sharedConfigMaster);
|
||||||
AutoIngestUserPreferences.setShowToolsWarning(showToolsWarning);
|
AutoIngestUserPreferences.setShowToolsWarning(showToolsWarning);
|
||||||
UserPreferences.setDisplayTimesInLocalTime(displayLocalTime);
|
UserPreferences.setDisplayTimesInLocalTime(displayLocalTime);
|
||||||
UserPreferences.setHideKnownFilesInDataSourcesTree(hideKnownFilesInDataSource);
|
UserPreferences.setHideKnownFilesInDataSourcesTree(hideKnownFilesInDataSource);
|
||||||
UserPreferences.setHideKnownFilesInViewsTree(hideKnownFilesInViews);
|
UserPreferences.setHideKnownFilesInViewsTree(hideKnownFilesInViews);
|
||||||
@ -515,21 +524,23 @@ public class SharedConfiguration {
|
|||||||
throw new SharedConfigurationException(String.format("Failed to copy %s to %s", remoteFile.getAbsolutePath(), localSettingsFolder.getAbsolutePath()), ex);
|
throw new SharedConfigurationException(String.format("Failed to copy %s to %s", remoteFile.getAbsolutePath(), localSettingsFolder.getAbsolutePath()), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy an entire local settings folder to the remote folder, deleting any existing files.
|
* Copy an entire local settings folder to the remote folder, deleting any
|
||||||
*
|
* existing files.
|
||||||
|
*
|
||||||
* @param localFolder The local folder to copy
|
* @param localFolder The local folder to copy
|
||||||
* @param remoteBaseFolder The remote folder that will hold a copy of the original folder
|
* @param remoteBaseFolder The remote folder that will hold a copy of the
|
||||||
*
|
* original folder
|
||||||
* @throws SharedConfigurationException
|
*
|
||||||
|
* @throws SharedConfigurationException
|
||||||
*/
|
*/
|
||||||
private void copyLocalFolderToRemoteFolder(File localFolder, File remoteBaseFolder) throws SharedConfigurationException {
|
private void copyLocalFolderToRemoteFolder(File localFolder, File remoteBaseFolder) throws SharedConfigurationException {
|
||||||
logger.log(Level.INFO, "Uploading {0} to {1}", new Object[]{localFolder.getAbsolutePath(), remoteBaseFolder.getAbsolutePath()});
|
logger.log(Level.INFO, "Uploading {0} to {1}", new Object[]{localFolder.getAbsolutePath(), remoteBaseFolder.getAbsolutePath()});
|
||||||
|
|
||||||
File newRemoteFolder = new File(remoteBaseFolder, localFolder.getName());
|
File newRemoteFolder = new File(remoteBaseFolder, localFolder.getName());
|
||||||
|
|
||||||
if(newRemoteFolder.exists()) {
|
if (newRemoteFolder.exists()) {
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(newRemoteFolder);
|
FileUtils.deleteDirectory(newRemoteFolder);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -537,29 +548,30 @@ public class SharedConfiguration {
|
|||||||
throw new SharedConfigurationException(String.format("Failed to delete remote folder {0}", newRemoteFolder.getAbsolutePath()), ex);
|
throw new SharedConfigurationException(String.format("Failed to delete remote folder {0}", newRemoteFolder.getAbsolutePath()), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileUtils.copyDirectoryToDirectory(localFolder, remoteBaseFolder);
|
FileUtils.copyDirectoryToDirectory(localFolder, remoteBaseFolder);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new SharedConfigurationException(String.format("Failed to copy %s to %s", localFolder, remoteBaseFolder.getAbsolutePath()), ex);
|
throw new SharedConfigurationException(String.format("Failed to copy %s to %s", localFolder, remoteBaseFolder.getAbsolutePath()), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy an entire remote settings folder to the local folder, deleting any existing files.
|
* Copy an entire remote settings folder to the local folder, deleting any
|
||||||
* No error if the remote folder does not exist.
|
* existing files. No error if the remote folder does not exist.
|
||||||
*
|
*
|
||||||
* @param localFolder The local folder that will be overwritten.
|
* @param localFolder The local folder that will be overwritten.
|
||||||
* @param remoteBaseFolder The remote folder holding the folder that will be copied
|
* @param remoteBaseFolder The remote folder holding the folder that will be
|
||||||
*
|
* copied
|
||||||
* @throws SharedConfigurationException
|
*
|
||||||
|
* @throws SharedConfigurationException
|
||||||
*/
|
*/
|
||||||
private void copyRemoteFolderToLocalFolder(File localFolder, File remoteBaseFolder) throws SharedConfigurationException {
|
private void copyRemoteFolderToLocalFolder(File localFolder, File remoteBaseFolder) throws SharedConfigurationException {
|
||||||
logger.log(Level.INFO, "Downloading {0} from {1}", new Object[]{localFolder.getAbsolutePath(), remoteBaseFolder.getAbsolutePath()});
|
logger.log(Level.INFO, "Downloading {0} from {1}", new Object[]{localFolder.getAbsolutePath(), remoteBaseFolder.getAbsolutePath()});
|
||||||
|
|
||||||
// Clean out the local folder regardless of whether the remote version exists. leave the
|
// Clean out the local folder regardless of whether the remote version exists. leave the
|
||||||
// folder in place since Autopsy expects it to exist.
|
// folder in place since Autopsy expects it to exist.
|
||||||
if(localFolder.exists()) {
|
if (localFolder.exists()) {
|
||||||
try {
|
try {
|
||||||
FileUtils.cleanDirectory(localFolder);
|
FileUtils.cleanDirectory(localFolder);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -567,19 +579,19 @@ public class SharedConfiguration {
|
|||||||
throw new SharedConfigurationException(String.format("Failed to delete files from local folder {0}", localFolder.getAbsolutePath()), ex);
|
throw new SharedConfigurationException(String.format("Failed to delete files from local folder {0}", localFolder.getAbsolutePath()), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File remoteSubFolder = new File(remoteBaseFolder, localFolder.getName());
|
File remoteSubFolder = new File(remoteBaseFolder, localFolder.getName());
|
||||||
if(! remoteSubFolder.exists()) {
|
if (!remoteSubFolder.exists()) {
|
||||||
logger.log(Level.INFO, "{0} does not exist", remoteSubFolder.getAbsolutePath());
|
logger.log(Level.INFO, "{0} does not exist", remoteSubFolder.getAbsolutePath());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileUtils.copyDirectory(remoteSubFolder, localFolder);
|
FileUtils.copyDirectory(remoteSubFolder, localFolder);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new SharedConfigurationException(String.format("Failed to copy %s from %s", localFolder, remoteBaseFolder.getAbsolutePath()), ex);
|
throw new SharedConfigurationException(String.format("Failed to copy %s from %s", localFolder, remoteBaseFolder.getAbsolutePath()), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload the basic set of auto-ingest settings to the shared folder.
|
* Upload the basic set of auto-ingest settings to the shared folder.
|
||||||
@ -899,56 +911,56 @@ public class SharedConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload the object detection classifiers.
|
* Upload the object detection classifiers.
|
||||||
*
|
*
|
||||||
* @param remoteFolder Shared settings folder
|
* @param remoteFolder Shared settings folder
|
||||||
*
|
*
|
||||||
* @throws SharedConfigurationException
|
* @throws SharedConfigurationException
|
||||||
*/
|
*/
|
||||||
private void uploadObjectDetectionClassifiers(File remoteFolder) throws SharedConfigurationException {
|
private void uploadObjectDetectionClassifiers(File remoteFolder) throws SharedConfigurationException {
|
||||||
publishTask("Uploading object detection classfiers");
|
publishTask("Uploading object detection classfiers");
|
||||||
File classifiersFolder = new File(PlatformUtil.getObjectDetectionClassifierPath());
|
File classifiersFolder = new File(PlatformUtil.getObjectDetectionClassifierPath());
|
||||||
copyLocalFolderToRemoteFolder(classifiersFolder, remoteFolder);
|
copyLocalFolderToRemoteFolder(classifiersFolder, remoteFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download the object detection classifiers.
|
* Download the object detection classifiers.
|
||||||
*
|
*
|
||||||
* @param remoteFolder Shared settings folder
|
* @param remoteFolder Shared settings folder
|
||||||
*
|
*
|
||||||
* @throws SharedConfigurationException
|
* @throws SharedConfigurationException
|
||||||
*/
|
*/
|
||||||
private void downloadObjectDetectionClassifiers(File remoteFolder) throws SharedConfigurationException {
|
private void downloadObjectDetectionClassifiers(File remoteFolder) throws SharedConfigurationException {
|
||||||
publishTask("Downloading object detection classfiers");
|
publishTask("Downloading object detection classfiers");
|
||||||
File classifiersFolder = new File(PlatformUtil.getObjectDetectionClassifierPath());
|
File classifiersFolder = new File(PlatformUtil.getObjectDetectionClassifierPath());
|
||||||
copyRemoteFolderToLocalFolder(classifiersFolder, remoteFolder);
|
copyRemoteFolderToLocalFolder(classifiersFolder, remoteFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload the Python modules.
|
* Upload the Python modules.
|
||||||
*
|
*
|
||||||
* @param remoteFolder Shared settings folder
|
* @param remoteFolder Shared settings folder
|
||||||
*
|
*
|
||||||
* @throws SharedConfigurationException
|
* @throws SharedConfigurationException
|
||||||
*/
|
*/
|
||||||
private void uploadPythonModules(File remoteFolder) throws SharedConfigurationException {
|
private void uploadPythonModules(File remoteFolder) throws SharedConfigurationException {
|
||||||
publishTask("Uploading python modules");
|
publishTask("Uploading python modules");
|
||||||
File classifiersFolder = new File(PlatformUtil.getUserPythonModulesPath());
|
File classifiersFolder = new File(PlatformUtil.getUserPythonModulesPath());
|
||||||
copyLocalFolderToRemoteFolder(classifiersFolder, remoteFolder);
|
copyLocalFolderToRemoteFolder(classifiersFolder, remoteFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download the Python modules.
|
* Download the Python modules.
|
||||||
*
|
*
|
||||||
* @param remoteFolder Shared settings folder
|
* @param remoteFolder Shared settings folder
|
||||||
*
|
*
|
||||||
* @throws SharedConfigurationException
|
* @throws SharedConfigurationException
|
||||||
*/
|
*/
|
||||||
private void downloadPythonModules(File remoteFolder) throws SharedConfigurationException {
|
private void downloadPythonModules(File remoteFolder) throws SharedConfigurationException {
|
||||||
publishTask("Downloading python modules");
|
publishTask("Downloading python modules");
|
||||||
File classifiersFolder = new File(PlatformUtil.getUserPythonModulesPath());
|
File classifiersFolder = new File(PlatformUtil.getUserPythonModulesPath());
|
||||||
copyRemoteFolderToLocalFolder(classifiersFolder, remoteFolder);
|
copyRemoteFolderToLocalFolder(classifiersFolder, remoteFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload settings and hash databases to the shared folder. The general
|
* Upload settings and hash databases to the shared folder. The general
|
||||||
* algorithm is: - Copy the general settings in hashsets.xml - For each hash
|
* algorithm is: - Copy the general settings in hashsets.xml - For each hash
|
||||||
@ -1093,12 +1105,10 @@ public class SharedConfiguration {
|
|||||||
Map<String, String> remoteVersions = readVersionsFromFile(remoteVersionFile);
|
Map<String, String> remoteVersions = readVersionsFromFile(remoteVersionFile);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Iterate through remote list
|
* Iterate through remote list If local needs it, download
|
||||||
If local needs it, download
|
*
|
||||||
|
* Download remote settings files to local Download remote versions file
|
||||||
Download remote settings files to local
|
* to local HashDbManager reload
|
||||||
Download remote versions file to local
|
|
||||||
HashDbManager reload
|
|
||||||
*/
|
*/
|
||||||
File localDb = new File("");
|
File localDb = new File("");
|
||||||
File sharedDb = new File("");
|
File sharedDb = new File("");
|
||||||
@ -1247,7 +1257,7 @@ public class SharedConfiguration {
|
|||||||
if (hashDb.getIndexPath().isEmpty() && hashDb.getDatabasePath().isEmpty()) {
|
if (hashDb.getIndexPath().isEmpty() && hashDb.getDatabasePath().isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hashDb.hasIndexOnly()) {
|
if (hashDb.hasIndexOnly()) {
|
||||||
results.add(hashDb.getIndexPath());
|
results.add(hashDb.getIndexPath());
|
||||||
} else {
|
} else {
|
||||||
@ -1356,4 +1366,41 @@ public class SharedConfiguration {
|
|||||||
throw new SharedConfigurationException(String.format("Failed to calculate CRC for %s", file.getAbsolutePath()), ex);
|
throw new SharedConfigurationException(String.format("Failed to calculate CRC for %s", file.getAbsolutePath()), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the YARA settings directory from the local directory to the remote
|
||||||
|
* directory.
|
||||||
|
*
|
||||||
|
* @param remoteFolder Shared settings folder
|
||||||
|
*
|
||||||
|
* @throws
|
||||||
|
* org.sleuthkit.autopsy.experimental.configuration.SharedConfiguration.SharedConfigurationException
|
||||||
|
*/
|
||||||
|
private void uploadYARASetting(File remoteFolder) throws SharedConfigurationException {
|
||||||
|
publishTask("Uploading YARA module configuration");
|
||||||
|
|
||||||
|
File localYara = Paths.get(PlatformUtil.getUserDirectory().getAbsolutePath(), "yara").toFile();
|
||||||
|
|
||||||
|
if (!localYara.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
copyLocalFolderToRemoteFolder(localYara, remoteFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads the YARA settings folder from the remote directory to the local
|
||||||
|
* one.
|
||||||
|
*
|
||||||
|
* @param remoteFolder Shared settings folder
|
||||||
|
*
|
||||||
|
* @throws
|
||||||
|
* org.sleuthkit.autopsy.experimental.configuration.SharedConfiguration.SharedConfigurationException
|
||||||
|
*/
|
||||||
|
private void downloadYARASettings(File remoteFolder) throws SharedConfigurationException {
|
||||||
|
publishTask("Downloading YARA module configuration");
|
||||||
|
File localYara = Paths.get(PlatformUtil.getUserDirectory().getAbsolutePath(), "yara").toFile();
|
||||||
|
|
||||||
|
copyRemoteFolderToLocalFolder(localYara, remoteFolder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user