Add support to upload and download yara settings from remote dir

This commit is contained in:
Kelly Kelly 2020-11-05 13:45:29 -05:00
parent 6becccafc6
commit 78f516170f
2 changed files with 108 additions and 59 deletions

View File

@ -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

View File

@ -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
@ -517,10 +526,12 @@ public class SharedConfiguration {
} }
/** /**
* 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
*/ */
@ -546,11 +557,12 @@ public class SharedConfiguration {
} }
/** /**
* 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
*/ */
@ -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("");
@ -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);
}
} }