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.startMessage=Starting deletion...
|
||||
DeleteOrphanCaseNodesAction.progressDisplayName=Cleanup Case Znodes
|
||||
# {0} - item count
|
||||
DeleteOrphanCaseNodesDialog.additionalInit.lblNodeCount.text=Znodes found: {0}
|
||||
# {0} - item count
|
||||
DeleteOrphanCaseNodesDialog.additionalInit.znodesTextArea.countMessage=ZNODES FOUND: {0}
|
||||
DeleteOrphanCaseNodesTask.progress.connectingToCoordSvc=Connecting to the coordination service
|
||||
# {0} - node path
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2015 Basis Technology Corp.
|
||||
* Copyright 2015 - 2020 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws SharedConfigurationException
|
||||
* @throws CoordinationServiceException
|
||||
* @throws InterruptedException
|
||||
@ -208,6 +210,7 @@ public class SharedConfiguration {
|
||||
uploadCentralRepositorySettings(remoteFolder);
|
||||
uploadObjectDetectionClassifiers(remoteFolder);
|
||||
uploadPythonModules(remoteFolder);
|
||||
uploadYARASetting(remoteFolder);
|
||||
|
||||
try {
|
||||
Files.deleteIfExists(uploadInProgress.toPath());
|
||||
@ -222,6 +225,8 @@ public class SharedConfiguration {
|
||||
/**
|
||||
* Download the multi-user settings from a shared folder.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws SharedConfigurationException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@ -252,13 +257,16 @@ public class SharedConfiguration {
|
||||
}
|
||||
|
||||
try {
|
||||
/* Make sure all recent changes are saved to the preference file.
|
||||
This also releases open file handles to the preference files. If this
|
||||
is not done, then occasionally downloading of shared configuration
|
||||
fails silently, likely because Java/OS is still holding the file handle.
|
||||
The problem manifests itself by some of the old/original configuration files
|
||||
sticking around after shared configuration has seemingly been successfully
|
||||
updated. */
|
||||
/*
|
||||
* Make sure all recent changes are saved to the preference
|
||||
* file. This also releases open file handles to the preference
|
||||
* files. If this is not done, then occasionally downloading of
|
||||
* shared configuration fails silently, likely because Java/OS
|
||||
* is still holding the file handle. The problem manifests
|
||||
* itself by some of the old/original configuration files
|
||||
* sticking around after shared configuration has seemingly been
|
||||
* successfully updated.
|
||||
*/
|
||||
UserPreferences.saveToStorage();
|
||||
} catch (BackingStoreException ex) {
|
||||
throw new SharedConfigurationException("Failed to save shared configuration settings", ex);
|
||||
@ -275,6 +283,7 @@ public class SharedConfiguration {
|
||||
downloadCentralRepositorySettings(remoteFolder);
|
||||
downloadObjectDetectionClassifiers(remoteFolder);
|
||||
downloadPythonModules(remoteFolder);
|
||||
downloadYARASettings(remoteFolder);
|
||||
|
||||
// Download general settings, then restore the current
|
||||
// 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 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
|
||||
*/
|
||||
@ -529,7 +540,7 @@ public class SharedConfiguration {
|
||||
|
||||
File newRemoteFolder = new File(remoteBaseFolder, localFolder.getName());
|
||||
|
||||
if(newRemoteFolder.exists()) {
|
||||
if (newRemoteFolder.exists()) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(newRemoteFolder);
|
||||
} catch (IOException ex) {
|
||||
@ -546,11 +557,12 @@ public class SharedConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy an entire remote settings folder to the local folder, deleting any existing files.
|
||||
* No error if the remote folder does not exist.
|
||||
* Copy an entire remote settings folder to the local folder, deleting any
|
||||
* existing files. No error if the remote folder does not exist.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@ -559,7 +571,7 @@ public class SharedConfiguration {
|
||||
|
||||
// Clean out the local folder regardless of whether the remote version exists. leave the
|
||||
// folder in place since Autopsy expects it to exist.
|
||||
if(localFolder.exists()) {
|
||||
if (localFolder.exists()) {
|
||||
try {
|
||||
FileUtils.cleanDirectory(localFolder);
|
||||
} catch (IOException ex) {
|
||||
@ -569,7 +581,7 @@ public class SharedConfiguration {
|
||||
}
|
||||
|
||||
File remoteSubFolder = new File(remoteBaseFolder, localFolder.getName());
|
||||
if(! remoteSubFolder.exists()) {
|
||||
if (!remoteSubFolder.exists()) {
|
||||
logger.log(Level.INFO, "{0} does not exist", remoteSubFolder.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
@ -1093,12 +1105,10 @@ public class SharedConfiguration {
|
||||
Map<String, String> remoteVersions = readVersionsFromFile(remoteVersionFile);
|
||||
|
||||
/*
|
||||
Iterate through remote list
|
||||
If local needs it, download
|
||||
|
||||
Download remote settings files to local
|
||||
Download remote versions file to local
|
||||
HashDbManager reload
|
||||
* Iterate through remote list If local needs it, download
|
||||
*
|
||||
* Download remote settings files to local Download remote versions file
|
||||
* to local HashDbManager reload
|
||||
*/
|
||||
File localDb = 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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