diff --git a/Core/nbproject/project.xml b/Core/nbproject/project.xml index 67e71c9b03457127307f6fb2c6878107e9b032a5..be742fc4ac6f537f928a0e6dbd3bc5623299521f 100644 --- a/Core/nbproject/project.xml +++ b/Core/nbproject/project.xml @@ -316,7 +316,6 @@ <package>org.sleuthkit.autopsy.casemodule.multiusercases</package> <package>org.sleuthkit.autopsy.casemodule.multiusercasesbrowser</package> <package>org.sleuthkit.autopsy.casemodule.services</package> - <package>org.sleuthkit.autopsy.centralrepository.settings</package> <package>org.sleuthkit.autopsy.contentviewers</package> <package>org.sleuthkit.autopsy.coordinationservice</package> <package>org.sleuthkit.autopsy.core</package> @@ -339,16 +338,13 @@ <package>org.sleuthkit.autopsy.modules.encryptiondetection</package> <package>org.sleuthkit.autopsy.modules.filetypeid</package> <package>org.sleuthkit.autopsy.modules.hashdatabase</package> - <package>org.sleuthkit.autopsy.modules.interestingitems</package> <package>org.sleuthkit.autopsy.modules.vmextractor</package> - <package>org.sleuthkit.autopsy.modules.yara.rules</package> <package>org.sleuthkit.autopsy.progress</package> <package>org.sleuthkit.autopsy.report</package> <package>org.sleuthkit.autopsy.textextractors</package> <package>org.sleuthkit.autopsy.textextractors.configs</package> <package>org.sleuthkit.autopsy.textsummarizer</package> <package>org.sleuthkit.autopsy.texttranslation</package> - <package>org.sleuthkit.autopsy.texttranslation.translators.settings</package> <package>org.sleuthkit.autopsy.url.analytics</package> <package>org.sleuthkit.datamodel</package> <package>org.sleuthkit.datamodel.blackboardutils</package> diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java index 60a38f3a84a8a63dd5e0cb665b3531e61c846487..24f208f4217c5ab8e6b3ddc3cc021d1d8365ad52 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java @@ -31,7 +31,7 @@ import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.CentralRepoSettings; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.datamodel.TagName; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/settings/CentralRepoSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/CentralRepoSettings.java similarity index 82% rename from Core/src/org/sleuthkit/autopsy/centralrepository/settings/CentralRepoSettings.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/CentralRepoSettings.java index 365d4620e2fbf1ec61a92d5bd04d580dfbe34d2f..751d294df6e889ef7d92f7d477c4a4ac22f88872 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/settings/CentralRepoSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/CentralRepoSettings.java @@ -16,16 +16,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.sleuthkit.autopsy.centralrepository.settings; +package org.sleuthkit.autopsy.centralrepository; -import com.google.common.annotations.Beta; import java.nio.file.Paths; -import org.sleuthkit.autopsy.coreutils.PlatformUtil; +import org.sleuthkit.autopsy.core.configpath.SharedConfigPath; /** * Location for central repo settings and paths. */ -@Beta public class CentralRepoSettings { private static final CentralRepoSettings instance = new CentralRepoSettings(); @@ -39,12 +37,21 @@ public static CentralRepoSettings getInstance() { private static final String CENTRAL_REPOSITORY_FOLDER = "CentralRepository"; private static final String CENTRAL_REPOSITORY_SETTINGS_NAME = "CentralRepository"; - private static final String CENTRAL_REPO_BASE_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), CENTRAL_REPOSITORY_FOLDER).toString(); + private static final String CENTRAL_REPO_BASE_PATH = Paths.get( + SharedConfigPath.getInstance().getSharedConfigPath(), + CENTRAL_REPOSITORY_FOLDER).toString(); + private static final String DEFAULT_DB_PARENT_PATH = Paths.get(CENTRAL_REPO_BASE_PATH, "LocalDatabase").toString(); private static final String DEFAULT_DB_NAME = "central_repository.db"; - private static final String MODULE_SETTINGS_KEY = Paths.get(CENTRAL_REPOSITORY_FOLDER, CENTRAL_REPOSITORY_SETTINGS_NAME).toString(); - private static final String MODULE_SETTINGS_PROPERTIES = Paths.get(CENTRAL_REPO_BASE_PATH, CENTRAL_REPOSITORY_SETTINGS_NAME + ".properties").toString(); - + private static final String MODULE_SETTINGS_KEY = Paths.get( + SharedConfigPath.getInstance().getSharedConfigFolder(), + CENTRAL_REPOSITORY_FOLDER, + CENTRAL_REPOSITORY_SETTINGS_NAME).toString(); + + private static final String MODULE_SETTINGS_PROPERTIES = Paths.get( + CENTRAL_REPO_BASE_PATH, + CENTRAL_REPOSITORY_SETTINGS_NAME + ".properties").toString(); + /** * @return The base path for central repository settings. */ @@ -59,7 +66,7 @@ public String getSettingsBaseFolder() { public String getModuleSettingsKey() { return MODULE_SETTINGS_KEY; } - + /** * @return The path to the central repo settings. */ diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java index 95bfeca2b5d920c35c729805016727e94e98ebb4..3f1e82e4643c0df14b5ac15efbe6985606099562 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java @@ -24,7 +24,7 @@ import java.sql.SQLException; import java.util.logging.Level; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.CentralRepoSettings; import org.sleuthkit.autopsy.coordinationservice.CoordinationService; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.Logger; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java index 4ff0cb7a2e8c8288e0cca0a5b02014eb6518f59b..410e78e52d15c8f08d63a891249e0ae68322de1f 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java @@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import static org.sleuthkit.autopsy.centralrepository.datamodel.RdbmsCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; -import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.CentralRepoSettings; /** * diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPostgresSettingsUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPostgresSettingsUtil.java index bf47d92e359f2f21dccb4dccff5e7ce4f19d48c3..4cce88245358f2e7c097b0b22482f67d14f8813f 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPostgresSettingsUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPostgresSettingsUtil.java @@ -25,7 +25,7 @@ import java.util.HashMap; import java.util.Map; import java.util.logging.Level; -import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.CentralRepoSettings; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.core.UserPreferencesException; import org.sleuthkit.autopsy.coreutils.Logger; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java index 3380e4a1e5878474802d5634fd60b8ac02eb845b..1e824ac33327ed8269f576df8eaf4d13656e81cf 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java @@ -29,7 +29,7 @@ import java.sql.SQLException; import java.util.logging.Level; import java.util.regex.Pattern; -import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.CentralRepoSettings; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PlatformUtil; @@ -62,22 +62,6 @@ public final class SqliteCentralRepoSettings implements CentralRepoDbConnectivit private String dbDirectory; private int bulkThreshold; - /** - * @return The settings key for the name of the database. - */ - public static String getDatabaseNameKey() { - return DATABASE_NAME; - } - - /** - * @return The settings key for the parent path of the database. - */ - public static String getDatabasePathKey() { - return DATABASE_PATH; - } - - - public SqliteCentralRepoSettings() { loadSettings(); } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java index f5f35ccc0e482fb49862db2c4d0f7466eebc5b3e..04e1defe4dc6908ce6c1f2ef09880c0904ee5ba1 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java @@ -33,7 +33,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbManager; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteCentralRepoSettings; -import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.CentralRepoSettings; import org.sleuthkit.autopsy.core.RuntimeProperties; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.Logger; @@ -49,7 +49,6 @@ public class Installer extends ModuleInstall { private static final String LEGACY_DEFAULT_FOLDER = "central_repository"; private static final String LEGACY_DEFAULT_DB_PARENT_PATH = Paths.get(PlatformUtil.getUserDirectory().getAbsolutePath(), LEGACY_DEFAULT_FOLDER).toAbsolutePath().toString(); - //private static final String LEGACY_DEFAULT_DB_NAME = "central_repository.db"; private static final String LEGACY_MODULE_SETTINGS_KEY = "CentralRepository"; private static final Logger logger = Logger.getLogger(Installer.class.getName()); diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index b848e19f92c31776eea7de79418f803aba1758dd..585902128537fc1fe3e5053c11653d687cef4a3f 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -216,7 +216,7 @@ public Installer() { packageInstallers.add(org.sleuthkit.autopsy.healthmonitor.Installer.getDefault()); packageInstallers.add(org.sleuthkit.autopsy.casemodule.Installer.getDefault()); packageInstallers.add(org.sleuthkit.autopsy.texttranslation.translators.Installer.getDefault()); - packageInstallers.add(org.sleuthkit.autopsy.modules.hashdatabase.installer.Installer.getDefault()); + packageInstallers.add(org.sleuthkit.autopsy.modules.hashdatabase.infrastructure.Installer.getDefault()); /** * This is a temporary workaround for the following bug in Tika that diff --git a/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java b/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java index 6136ff65940f8f049ba590238df9337d0b06b4d1..3310975ac19be5cd9da0e23ee25089206c0ac489 100644 --- a/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java +++ b/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.core; -import com.google.common.annotations.Beta; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -36,6 +35,7 @@ import org.openide.util.Lookup; import org.python.icu.util.TimeZone; import org.sleuthkit.autopsy.appservices.AutopsyService; +import org.sleuthkit.autopsy.core.configpath.SharedConfigPath; import org.sleuthkit.autopsy.machinesettings.UserMachinePreferences; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PlatformUtil; @@ -51,7 +51,8 @@ public final class UserPreferences { /** - * Returns the path to the preferences for the identifier. + * Returns the path to the preferences for the identifier in the user config + * directory. * * @param identifier The identifier. * @@ -61,42 +62,22 @@ private static String getConfigPreferencePath(String identifier) { return Paths.get(PlatformUtil.getUserConfigDirectory(), identifier + ".properties").toString(); } - private static final String VIEW_PREFERENCE_PATH = getConfigPreferencePath("ViewPreferences"); - private static final String MACHINE_SPECIFIC_PREFERENCE_PATH = getConfigPreferencePath("MachineSpecificPreferences"); - private static final String MODE_PREFERENCE_PATH = getConfigPreferencePath("ModePreferences"); - private static final String EXTERNAL_SERVICE_PREFERENCE_PATH = getConfigPreferencePath("ExternalServicePreferences"); - - /** - * @return The path to machine specific preferences. - */ - @Beta - public static String getMachineSpecificPreferencePath() { - return MACHINE_SPECIFIC_PREFERENCE_PATH; - } - - /** - * @return The path to mode preferences. - */ - @Beta - public static String getModePreferencePath() { - return MODE_PREFERENCE_PATH; - } - /** - * @return The path to external service preferences. - */ - @Beta - public static String getExternalServicePreferencePath() { - return EXTERNAL_SERVICE_PREFERENCE_PATH; - } - - /** - * @return The path to view preferences. + * Returns the path to the preferences for the identifier in the shared + * preference directory. + * + * @param identifier The identifier. + * + * @return The path to the preference file. */ - @Beta - public static String getViewPreferencePath() { - return VIEW_PREFERENCE_PATH; + private static String getSharedPreferencePath(String identifier) { + return Paths.get(SharedConfigPath.getInstance().getSharedConfigPath(), identifier + ".properties").toString(); } + + private static final String VIEW_PREFERENCE_PATH = getSharedPreferencePath("ViewPreferences"); + private static final String MACHINE_SPECIFIC_PREFERENCE_PATH = getConfigPreferencePath("MachineSpecificPreferences"); + private static final String MODE_PREFERENCE_PATH = getConfigPreferencePath("ModePreferences"); + private static final String EXTERNAL_SERVICE_PREFERENCE_PATH = getSharedPreferencePath("ExternalServicePreferences"); private static final ConfigProperties viewPreferences = new ConfigProperties(VIEW_PREFERENCE_PATH); private static final ConfigProperties machineSpecificPreferences = new ConfigProperties(MACHINE_SPECIFIC_PREFERENCE_PATH); diff --git a/Core/src/org/sleuthkit/autopsy/core/configpath/SharedConfigPath.java b/Core/src/org/sleuthkit/autopsy/core/configpath/SharedConfigPath.java new file mode 100644 index 0000000000000000000000000000000000000000..93401b648cbca1afffb21aca453ee0c5ef15bb11 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/core/configpath/SharedConfigPath.java @@ -0,0 +1,58 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2022 Basis Technology Corp. + * Contact: carrier <at> sleuthkit <dot> org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.core.configpath; + +import java.nio.file.Paths; +import org.sleuthkit.autopsy.coreutils.PlatformUtil; + +/** + * Path to sharable config. + */ +public class SharedConfigPath { + + private static final SharedConfigPath instance = new SharedConfigPath(); + + private static final String SHARED_FOLDER = "SharableConfig"; + private static final String SHARED_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), SHARED_FOLDER).toAbsolutePath().toString(); + + private SharedConfigPath() { + } + + /** + * @return An instance of this class. + */ + public static SharedConfigPath getInstance() { + return instance; + } + + /** + * @return The path to a folder for config items that can be shared between + * different instances. + */ + public String getSharedConfigPath() { + return SHARED_PATH; + } + + /** + * @return The folder in user config for shared config. + */ + public String getSharedConfigFolder() { + return SHARED_FOLDER; + } +} diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java b/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java index 4dcdaab20b4c708b63bbc9d29fdfcc8e7cc674b1..c20888ff8177233f0e3028e338dc878cdba0db77 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.coreutils; -import com.google.common.annotations.Beta; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -132,8 +131,7 @@ public static synchronized boolean settingExists(String moduleName, String setti * * @return The settings file path as a string. */ - @Beta - public static String getSettingsFilePath(String moduleName) { + static String getSettingsFilePath(String moduleName) { return Paths.get(MODULE_DIR_PATH, moduleName + SETTINGS_FILE_EXT).toString(); } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java index 5399ff1fb38b44a7c524dce6ace2d18cf454a9ed..96422fcac6402160ac66b0c3c6300a3d9242423d 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.ingest; -import com.google.common.annotations.Beta; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -37,9 +36,9 @@ import org.openide.util.NbBundle; import org.openide.util.io.NbObjectInputStream; import org.openide.util.io.NbObjectOutputStream; +import org.sleuthkit.autopsy.core.configpath.SharedConfigPath; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; -import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.modules.interestingitems.FilesSet; import org.sleuthkit.autopsy.modules.interestingitems.FilesSetsManager; import org.sleuthkit.autopsy.python.FactoryClassNameNormalizer; @@ -52,8 +51,18 @@ public final class IngestJobSettings { private static final String ENABLED_MODULES_PROPERTY = "Enabled_Ingest_Modules"; //NON-NLS private static final String DISABLED_MODULES_PROPERTY = "Disabled_Ingest_Modules"; //NON-NLS private static final String LAST_FILE_INGEST_FILTER_PROPERTY = "Last_File_Ingest_Filter"; //NON-NLS - private static final String MODULE_SETTINGS_FOLDER = "IngestSettings"; //NON-NLS - private static final String MODULE_SETTINGS_FOLDER_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), IngestJobSettings.MODULE_SETTINGS_FOLDER).toAbsolutePath().toString(); + private static final String MODULE_SETTINGS_FOLDER_NAME = "IngestSettings"; //NON-NLS + + private static final String MODULE_SETTINGS_FOLDER = Paths.get( + SharedConfigPath.getInstance().getSharedConfigFolder(), + MODULE_SETTINGS_FOLDER_NAME + ).toString(); + + private static final String MODULE_SETTINGS_FOLDER_PATH = Paths.get( + SharedConfigPath.getInstance().getSharedConfigPath(), + IngestJobSettings.MODULE_SETTINGS_FOLDER_NAME + ).toAbsolutePath().toString(); + private static final String MODULE_SETTINGS_FILE_EXT = ".settings"; //NON-NLS private static final CharSequence PYTHON_CLASS_PROXY_PREFIX = "org.python.proxies.".subSequence(0, "org.python.proxies.".length() - 1); //NON-NLS private static final Logger logger = Logger.getLogger(IngestJobSettings.class.getName()); @@ -63,29 +72,26 @@ public final class IngestJobSettings { private String executionContext; private FilesSet fileFilter; private String moduleSettingsFolderPath; - - + /** * @return The base path to module settings. */ - @Beta - public static String getBaseSettingsPath() { + static String getBaseSettingsPath() { return MODULE_SETTINGS_FOLDER_PATH; } - - /** - * Returns the string to use with ModuleSettings for resource identification. + * Returns the string to use with ModuleSettings for resource + * identification. + * * @param executionContext The execution context. - * @return + * + * @return */ static String getModuleSettingsResource(String executionContext) { return Paths.get(MODULE_SETTINGS_FOLDER, executionContext).toString(); } - - /** * Gets the path to the module settings folder for a given execution * context. @@ -95,7 +101,7 @@ static String getModuleSettingsResource(String executionContext) { * contexts may have different ingest job settings. * * @param executionContext The execution context identifier. - * + * * @return The path to the module settings folder */ static Path getSavedModuleSettingsFolder(String executionContext) { @@ -518,7 +524,7 @@ private static HashSet<String> getModulesNames(String executionContext, String p * specified context. * * @param context -the execution context (profile name) to check. - * + * * @return the names of the enabled modules */ static List<String> getEnabledModules(String context) { @@ -597,7 +603,7 @@ private void store() { disabledModuleNames.add(moduleName); } } - + String ingestModuleResource = getModuleSettingsResource(this.executionContext); ModuleSettings.setConfigSetting(ingestModuleResource, IngestJobSettings.ENABLED_MODULES_PROPERTY, makeCsvList(enabledModuleNames)); ModuleSettings.setConfigSetting(ingestModuleResource, IngestJobSettings.DISABLED_MODULES_PROPERTY, makeCsvList(disabledModuleNames)); diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestProfiles.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestProfiles.java index 0705fbcc633012cfb7ff65067f533b78fbd272d0..6303aebad5256b50f1fdfb67ad0f3184e675cf21 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestProfiles.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestProfiles.java @@ -45,8 +45,7 @@ public final class IngestProfiles { * @return Prefix to append to an ingest profile name when saving to disk or * using with ingest job settings. */ - @Beta - public static String getIngestProfilePrefix() { + static String getIngestProfilePrefix() { return SETTINGS_FILE_PREFIX; } diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettings.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettings.java index 5d45ee385a12b16e2651bdc9ee8964e3ba26c583..747293c50aa930680fc88b268664df66a48db4a1 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettings.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettings.java @@ -18,13 +18,11 @@ */ package org.sleuthkit.autopsy.modules.hashdatabase; -import com.google.common.annotations.Beta; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.Serializable; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -37,7 +35,6 @@ import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.core.RuntimeProperties; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.XMLUtil; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.CentralRepoHashSet; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.SleuthkitHashSet; @@ -46,16 +43,12 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb; +import org.sleuthkit.autopsy.modules.hashdatabase.infrastructure.HashConfigPaths; /** * Class to represent the settings to be serialized for hash lookup. */ -public final class HashLookupSettings implements Serializable { - - private static final String HASHSET_FOLDER = "HashLookup"; - private static final String HASHSET_CONFIG_DIR = Paths.get(PlatformUtil.getUserConfigDirectory(), HASHSET_FOLDER).toAbsolutePath().toString(); - private static final String SERIALIZATION_FILE_NAME = "hashLookup.settings"; //NON-NLS - private static final String SERIALIZATION_FILE_PATH = Paths.get(HASHSET_CONFIG_DIR, SERIALIZATION_FILE_NAME).toString(); //NON-NLS +final class HashLookupSettings implements Serializable { private static final String SET_ELEMENT = "hash_set"; //NON-NLS private static final String SET_NAME_ATTRIBUTE = "name"; //NON-NLS private static final String SET_TYPE_ATTRIBUTE = "type"; //NON-NLS @@ -63,11 +56,6 @@ public final class HashLookupSettings implements Serializable { private static final String SEND_INGEST_MESSAGES_ATTRIBUTE = "show_inbox_messages"; //NON-NLS private static final String PATH_ELEMENT = "hash_set_path"; //NON-NLS private static final String LEGACY_PATH_NUMBER_ATTRIBUTE = "number"; //NON-NLS - private static final String CONFIG_FILE_NAME = "hashsets.xml"; //NON-NLS - private static final String CONFIG_FILE_PATH = Paths.get(HASHSET_CONFIG_DIR, CONFIG_FILE_NAME).toString(); - private static final String HASH_DATABASE_DEFAULT_FOLDER = "HashDatabases"; - private static final String HASH_DATABASE_DEFAULT_PATH = Paths.get(HASHSET_CONFIG_DIR, HASH_DATABASE_DEFAULT_FOLDER).toString(); - private static final Logger logger = Logger.getLogger(HashDbManager.class.getName()); @@ -79,26 +67,23 @@ public final class HashLookupSettings implements Serializable { /** * @return The path to the hash db settings file. */ - @Beta - public static String getSettingsPath() { - return SERIALIZATION_FILE_PATH; + static String getSettingsPath() { + return HashConfigPaths.getInstance().getSettingsPath(); } /** * @return The default database folder path. */ - @Beta - public static String getDefaultDbPath() { - return HASH_DATABASE_DEFAULT_PATH; + static String getDefaultDbPath() { + return HashConfigPaths.getInstance().getDefaultDbPath(); } /** * @return The base path of the hashset config folder. */ - @Beta - public static String getBaseHashsetConfigPath() { - return HASHSET_CONFIG_DIR; + static String getBaseHashsetConfigPath() { + return HashConfigPaths.getInstance().getBasePath(); } /** @@ -140,7 +125,7 @@ List<HashDbInfo> getHashDbInfo() { * settings. */ static HashLookupSettings readSettings() throws HashLookupSettingsException { - File fileSetFile = new File(SERIALIZATION_FILE_PATH); + File fileSetFile = new File(HashConfigPaths.getInstance().getSettingsPath()); if (fileSetFile.exists()) { return readSerializedSettings(); } @@ -159,7 +144,7 @@ static HashLookupSettings readSettings() throws HashLookupSettingsException { */ private static HashLookupSettings readSerializedSettings() throws HashLookupSettingsException { try { - try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(SERIALIZATION_FILE_PATH))) { + try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(HashConfigPaths.getInstance().getSettingsPath()))) { HashLookupSettings filesSetsSettings = (HashLookupSettings) in.readObject(); /* NOTE: to support JIRA-4177, we need to check if any of the hash @@ -185,12 +170,12 @@ private static HashLookupSettings readSerializedSettings() throws HashLookupSett * settings */ private static HashLookupSettings readXmlSettings() throws HashLookupSettingsException { - File xmlFile = new File(CONFIG_FILE_PATH); + File xmlFile = new File(HashConfigPaths.getInstance().getXmlSettingsPath()); if (xmlFile.exists()) { boolean updatedSchema = false; // Open the XML document that implements the configuration file. - final Document doc = XMLUtil.loadDoc(HashDbManager.class, CONFIG_FILE_PATH); + final Document doc = XMLUtil.loadDoc(HashDbManager.class, HashConfigPaths.getInstance().getXmlSettingsPath()); if (doc == null) { throw new HashLookupSettingsException("Could not open xml document."); } @@ -285,13 +270,13 @@ private static HashLookupSettings readXmlSettings() throws HashLookupSettingsExc } if (updatedSchema) { - String backupFilePath = CONFIG_FILE_PATH + ".v1_backup"; //NON-NLS + String backupFilePath = HashConfigPaths.getInstance().getXmlSettingsPath() + ".v1_backup"; //NON-NLS String messageBoxTitle = NbBundle.getMessage(HashLookupSettings.class, "HashDbManager.msgBoxTitle.confFileFmtChanged"); String baseMessage = NbBundle.getMessage(HashLookupSettings.class, "HashDbManager.baseMessage.updatedFormatHashDbConfig"); try { - FileUtils.copyFile(new File(CONFIG_FILE_PATH), new File(backupFilePath)); + FileUtils.copyFile(new File(HashConfigPaths.getInstance().getXmlSettingsPath()), new File(backupFilePath)); logger.log(Level.INFO, "Updated the schema, backup saved at: " + backupFilePath); if (RuntimeProperties.runningWithGUI()) { JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), @@ -330,7 +315,7 @@ static boolean writeSettings(HashLookupSettings settings) { the current user directory path. */ convertPathToPlaceholder(settings); - try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(SERIALIZATION_FILE_PATH))) { + try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(HashConfigPaths.getInstance().getSettingsPath()))) { out.writeObject(settings); // restore the paths, in case they are going to be used somewhere convertPlaceholderToPath(settings); @@ -352,9 +337,9 @@ static void convertPathToPlaceholder(HashLookupSettings settings) { for (HashDbInfo hashDbInfo : settings.getHashDbInfo()) { if (hashDbInfo.isFileDatabaseType()) { String dbPath = hashDbInfo.getPath(); - if (dbPath.startsWith(HASHSET_CONFIG_DIR)) { + if (dbPath.startsWith(HashConfigPaths.getInstance().getBasePath())) { // replace the current user directory with place holder - String remainingPath = dbPath.substring(HASHSET_CONFIG_DIR.length()); + String remainingPath = dbPath.substring(HashConfigPaths.getInstance().getBasePath().length()); hashDbInfo.setPath(USER_DIR_PLACEHOLDER + remainingPath); } } @@ -375,7 +360,7 @@ static void convertPlaceholderToPath(HashLookupSettings settings) { if (dbPath.startsWith(USER_DIR_PLACEHOLDER)) { // replace the place holder with current user directory String remainingPath = dbPath.substring(USER_DIR_PLACEHOLDER.length()); - hashDbInfo.setPath(HASHSET_CONFIG_DIR + remainingPath); + hashDbInfo.setPath(HashConfigPaths.getInstance().getBasePath() + remainingPath); } } } diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/infrastructure/HashConfigPaths.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/infrastructure/HashConfigPaths.java new file mode 100644 index 0000000000000000000000000000000000000000..0e864b9fe62091b683208bb821a319838b6f49ca --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/infrastructure/HashConfigPaths.java @@ -0,0 +1,82 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2022 Basis Technology Corp. + * Contact: carrier <at> sleuthkit <dot> org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.modules.hashdatabase.infrastructure; + +import java.nio.file.Paths; +import org.sleuthkit.autopsy.core.configpath.SharedConfigPath; + +/** + * Paths for hash config files. + */ +public class HashConfigPaths { + + private static final HashConfigPaths instance = new HashConfigPaths(); + + private static final String HASHSET_FOLDER = "HashLookup"; + private static final String SERIALIZATION_FILE_NAME = "hashLookup.settings"; //NON-NLS + + private static final String HASH_CONFIG_PATH = Paths.get(SharedConfigPath.getInstance().getSharedConfigPath(), HASHSET_FOLDER).toAbsolutePath().toString(); + + private static final String XML_FILE_NAME = "hashsets.xml"; //NON-NLS + private static final String XML_FILE_PATH = Paths.get(HASH_CONFIG_PATH, XML_FILE_NAME).toAbsolutePath().toString(); + + private static final String HASH_DATABASE_DEFAULT_FOLDER = "HashDatabases"; + private static final String HASH_DATABASE_DEFAULT_PATH = Paths.get(HASH_CONFIG_PATH, HASH_DATABASE_DEFAULT_FOLDER).toString(); + + private static final String SERIALIZATION_FILE_PATH = Paths.get(HASH_CONFIG_PATH, SERIALIZATION_FILE_NAME).toString(); //NON-NLS + + + private HashConfigPaths() { + } + + /** + * @return Singleton instance of this class. + */ + public static HashConfigPaths getInstance() { + return instance; + } + + /** + * @return The base path to the config file. + */ + public String getBasePath() { + return HASH_CONFIG_PATH; + } + + /** + * @return The default hash database path. + */ + public String getDefaultDbPath() { + return HASH_DATABASE_DEFAULT_PATH; + } + + /** + * @return The path to the serialized settings file. + */ + public String getSettingsPath() { + return SERIALIZATION_FILE_PATH; + } + + /** + * @return The path to the xml settings file. + */ + public String getXmlSettingsPath() { + return XML_FILE_PATH; + } +} diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/installer/Installer.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/infrastructure/Installer.java similarity index 78% rename from Core/src/org/sleuthkit/autopsy/modules/hashdatabase/installer/Installer.java rename to Core/src/org/sleuthkit/autopsy/modules/hashdatabase/infrastructure/Installer.java index 0b7363785c4d6a48d490e0afdbba204b00fe43ce..55470e58d830071b588258fc34f33af5f6d56537 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/installer/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/infrastructure/Installer.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.sleuthkit.autopsy.modules.hashdatabase.installer; +package org.sleuthkit.autopsy.modules.hashdatabase.infrastructure; import java.io.File; import java.io.IOException; @@ -27,13 +27,13 @@ import org.python.icu.text.MessageFormat; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.PlatformUtil; -import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupSettings; /** * Installer for hash databases that copies legacy settings to new location. */ public class Installer extends ModuleInstall { + private static final String LEGACY_SERIALIZATION_XML_FILE_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), "hashsets.xml").toString(); private static final String LEGACY_SERIALIZATION_FILE_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), "hashLookup.settings").toString(); //NON-NLS private static final String LEGACY_HASH_DATABASE_DEFAULT_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), "HashDatabases").toString(); @@ -69,19 +69,18 @@ private Installer() { public void restored() { // copy user dir hash dbs from legacy to new if old path exists and new does not. File legacyDbPath = new File(LEGACY_HASH_DATABASE_DEFAULT_PATH); - File dbPath = new File(HashLookupSettings.getDefaultDbPath()); + File dbPath = new File(HashConfigPaths.getInstance().getDefaultDbPath()); if (legacyDbPath.exists() && !dbPath.exists()) { try { FileUtils.copyDirectory(legacyDbPath, dbPath); } catch (IOException ex) { logger.log(Level.WARNING, MessageFormat.format("There was an error copying legacy path hash dbs from {0} to {1}", legacyDbPath, dbPath), ex); } - } // copy hash db settings to new location. File legacySettingsFile = new File(LEGACY_SERIALIZATION_FILE_PATH); - File settingsFile = new File(HashLookupSettings.getSettingsPath()); + File settingsFile = new File(HashConfigPaths.getInstance().getSettingsPath()); if (legacySettingsFile.exists() && !settingsFile.exists()) { try { FileUtils.copyFile(legacySettingsFile, settingsFile); @@ -89,6 +88,17 @@ public void restored() { logger.log(Level.WARNING, MessageFormat.format("There was an error copying legacy hash db settings from {0} to {1}", legacySettingsFile, settingsFile), ex); } } + + File legacyXmlSettingsFile = new File(LEGACY_SERIALIZATION_XML_FILE_PATH); + File xmlSettingsFile = new File(HashConfigPaths.getInstance().getXmlSettingsPath()); + if (legacyXmlSettingsFile.exists() && !xmlSettingsFile.exists()) { + try { + FileUtils.copyFile(legacyXmlSettingsFile, xmlSettingsFile); + } catch (IOException ex) { + logger.log(Level.WARNING, MessageFormat.format("There was an error copying legacy xml hash db settings from {0} to {1}", legacyXmlSettingsFile, xmlSettingsFile), ex); + } + } + } } diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetsManager.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetsManager.java index 0d78bdffb6bd117ff9eebf720398a89b5461ef0f..a81c81bf06640bad265f5d21ceac857e6cf69636 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetsManager.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetsManager.java @@ -84,16 +84,14 @@ public synchronized static FilesSetsManager getInstance() { /** * @return The path to file filter settings. */ - @Beta - public static String getFileFilterPath() { + static String getFileFilterPath() { return FILE_FILTER_PATH; } /** * @return The path to interesting item settings. */ - @Beta - public static String getInterestingItemPath() { + static String getInterestingItemPath() { return INTERESTING_ITEM_PATH; } diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemsFilesSetSettings.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemsFilesSetSettings.java index e1655001321d413875aeb49c101ef64c71497eea..f081acdf63be0e0755c81f3361e12c4c05eb56ce 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemsFilesSetSettings.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemsFilesSetSettings.java @@ -89,8 +89,7 @@ class InterestingItemsFilesSetSettings implements Serializable { private static final String EXTENSION_RULE_TAG = "EXTENSION"; //NON-NLS private static final String STANDARD_SET = "standardSet"; private static final String VERSION_NUMBER = "versionNumber"; - - + private Map<String, FilesSet> filesSets; InterestingItemsFilesSetSettings(Map<String, FilesSet> filesSets) { diff --git a/Core/src/org/sleuthkit/autopsy/modules/leappanalyzers/LeappFileProcessor.java b/Core/src/org/sleuthkit/autopsy/modules/leappanalyzers/LeappFileProcessor.java index e482c29ebfa1125cd7f84e40faa97b190629c7b1..1e4e30a94473babfcd04684eba1bc9849da6aaf8 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/leappanalyzers/LeappFileProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/modules/leappanalyzers/LeappFileProcessor.java @@ -29,7 +29,6 @@ import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -197,20 +196,6 @@ boolean isRequired() { .put("call history.tsv", "calllog") .build(); - private static final String BASE_FOLDER = "LeappProcessor"; - private static final String BASE_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), BASE_FOLDER).toString(); - - /** - * The path to an xml file config file on disk. - * - * @param xmlFileName The xml file name. - * - * @return The path to the xml file. - */ - private static String getXmlPath(String xmlFileName) { - return Paths.get(BASE_PATH, xmlFileName).toString(); - } - private final Blackboard blkBoard; public LeappFileProcessor(String xmlFile, String moduleName, IngestJobContext context) throws IOException, IngestModuleException, NoCurrentCaseException { @@ -1093,7 +1078,7 @@ private BlackboardAttribute parseAttrValue(String value, BlackboardAttribute.Typ private void loadConfigFile() throws IngestModuleException { Document xmlinput; try { - String path = getXmlPath(xmlFile); + String path = PlatformUtil.getUserConfigDirectory() + File.separator + xmlFile; File f = new File(path); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); @@ -1278,18 +1263,8 @@ void postArtifacts(Collection<BlackboardArtifact> artifacts) { * @throws org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException */ private void configExtractor() throws IOException { - File curFileLoc = Paths.get(PlatformUtil.getUserConfigDirectory(), xmlFile).toFile(); - File newFileLoc = new File(getXmlPath(xmlFile)); - - if (!newFileLoc.exists()) { - PlatformUtil.extractResourceToUserConfigDir(LeappFileProcessor.class, - xmlFile, true); - - if (curFileLoc.exists()) { - newFileLoc.getParentFile().mkdirs(); - curFileLoc.renameTo(newFileLoc); - } - } + PlatformUtil.extractResourceToUserConfigDir(LeappFileProcessor.class, + xmlFile, true); } private static final Set<String> ALLOWED_EXTENSIONS = new HashSet<>(Arrays.asList("zip", "tar", "tgz")); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportingConfigPath.java b/Core/src/org/sleuthkit/autopsy/report/ReportingConfigPath.java deleted file mode 100644 index 16d03f710fb8c6d64974afa24c04b7eb6774c7b5..0000000000000000000000000000000000000000 --- a/Core/src/org/sleuthkit/autopsy/report/ReportingConfigPath.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2022 Basis Technology Corp. - * Contact: carrier <at> sleuthkit <dot> org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.report; - -import org.sleuthkit.autopsy.report.infrastructure.ReportingConfigLoader; -import com.google.common.annotations.Beta; - -/** - * Paths to report config. - */ -public class ReportingConfigPath { - - /** - * @return The base path for reports. - */ - @Beta - public static String getBaseReportPath() { - return ReportingConfigLoader.getBaseReportPath(); - } -} diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportingConfigLoader.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportingConfigLoader.java index def8c24afad44e74c7f262c55540b8ae08760f8f..8e06659c01fdd31d13ee465b247b8fb55a789e0a 100755 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportingConfigLoader.java +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportingConfigLoader.java @@ -36,8 +36,8 @@ import java.util.logging.Level; import org.openide.util.io.NbObjectInputStream; import org.openide.util.io.NbObjectOutputStream; +import org.sleuthkit.autopsy.core.configpath.SharedConfigPath; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.report.GeneralReportSettings; /** @@ -45,11 +45,15 @@ * all of the settings that make up a reporting configuration in an atomic, * thread safe way. */ -public final class ReportingConfigLoader { +final class ReportingConfigLoader { private static final Logger logger = Logger.getLogger(ReportingConfigLoader.class.getName()); private static final String REPORT_CONFIG_FOLDER = "ReportingConfigs"; //NON-NLS - private static final String REPORT_CONFIG_FOLDER_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), ReportingConfigLoader.REPORT_CONFIG_FOLDER).toAbsolutePath().toString(); + private static final String REPORT_CONFIG_FOLDER_PATH = Paths.get( + SharedConfigPath.getInstance().getSharedConfigPath(), + ReportingConfigLoader.REPORT_CONFIG_FOLDER + ).toAbsolutePath().toString(); + private static final String REPORT_SETTINGS_FILE_EXTENSION = ".settings"; private static final String TABLE_REPORT_CONFIG_FILE = "TableReportSettings.settings"; private static final String FILE_REPORT_CONFIG_FILE = "FileReportSettings.settings"; @@ -61,13 +65,6 @@ public final class ReportingConfigLoader { // existing in the configuration file. private static final List<String> DELETED_REPORT_MODULES = Arrays.asList("org.sleuthkit.autopsy.report.modules.stix.STIXReportModule"); - /** - * @return The base path for reports. - */ - public static String getBaseReportPath() { - return REPORT_CONFIG_FOLDER_PATH; - } - /** * Deserialize all of the settings that make up a reporting configuration in * an atomic, thread safe way. diff --git a/Core/src/org/sleuthkit/autopsy/texttranslation/translators/BingTranslatorSettings.java b/Core/src/org/sleuthkit/autopsy/texttranslation/translators/BingTranslatorSettings.java index 9a8414d548c046669bb9bfd503e9273cc6cf5072..c23d2938a9cc04a3df809f68fb2c7f224e722f31 100644 --- a/Core/src/org/sleuthkit/autopsy/texttranslation/translators/BingTranslatorSettings.java +++ b/Core/src/org/sleuthkit/autopsy/texttranslation/translators/BingTranslatorSettings.java @@ -20,7 +20,7 @@ import org.apache.commons.lang3.StringUtils; import org.sleuthkit.autopsy.coreutils.ModuleSettings; -import org.sleuthkit.autopsy.texttranslation.translators.settings.TranslatorSettings; +import org.sleuthkit.autopsy.texttranslation.translators.TranslatorSettings; /** * Class to handle the settings associated with the BingTranslator diff --git a/Core/src/org/sleuthkit/autopsy/texttranslation/translators/GoogleTranslatorSettings.java b/Core/src/org/sleuthkit/autopsy/texttranslation/translators/GoogleTranslatorSettings.java index f1d60c940712316b69112347459509fa966ca23a..55cb8b7e9c87a70aabc036007028381a3c0bc590 100644 --- a/Core/src/org/sleuthkit/autopsy/texttranslation/translators/GoogleTranslatorSettings.java +++ b/Core/src/org/sleuthkit/autopsy/texttranslation/translators/GoogleTranslatorSettings.java @@ -21,7 +21,7 @@ import com.google.cloud.translate.TranslateOptions; import org.apache.commons.lang3.StringUtils; import org.sleuthkit.autopsy.coreutils.ModuleSettings; -import org.sleuthkit.autopsy.texttranslation.translators.settings.TranslatorSettings; +import org.sleuthkit.autopsy.texttranslation.translators.TranslatorSettings; /** * Class to handle the settings associated with the GoogleTranslator diff --git a/Core/src/org/sleuthkit/autopsy/texttranslation/translators/settings/TranslatorSettings.java b/Core/src/org/sleuthkit/autopsy/texttranslation/translators/TranslatorSettings.java similarity index 83% rename from Core/src/org/sleuthkit/autopsy/texttranslation/translators/settings/TranslatorSettings.java rename to Core/src/org/sleuthkit/autopsy/texttranslation/translators/TranslatorSettings.java index 89ed9e2c81dccc13e9d8f4c474f49449f7318c17..3f17957593ec1b5736ada871a726ebaf653984d6 100644 --- a/Core/src/org/sleuthkit/autopsy/texttranslation/translators/settings/TranslatorSettings.java +++ b/Core/src/org/sleuthkit/autopsy/texttranslation/translators/TranslatorSettings.java @@ -16,17 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.sleuthkit.autopsy.texttranslation.translators.settings; +package org.sleuthkit.autopsy.texttranslation.translators; import java.nio.file.Paths; import org.sleuthkit.autopsy.coreutils.PlatformUtil; -import com.google.common.annotations.Beta; /** * ModuleSettings keys and paths for translator settings. */ - @Beta -public class TranslatorSettings { +class TranslatorSettings { private static final String TRANSLATION_FOLDER = "Translation"; private static final String TRANSLATION_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), TRANSLATION_FOLDER).toString(); @@ -36,7 +34,7 @@ public class TranslatorSettings { /** * @return The singular instance. */ - public static TranslatorSettings getInstance() { + static TranslatorSettings getInstance() { return instance; } @@ -51,14 +49,14 @@ private TranslatorSettings() { * * @return The resource name to use with ModuleSettings. */ - public String getModuleSettingsResource(String translationResource) { + String getModuleSettingsResource(String translationResource) { return Paths.get(TRANSLATION_FOLDER, translationResource).toString(); } /** * @return The base translation folder. */ - public String getBaseTranslationFolder() { + String getBaseTranslationFolder() { return TRANSLATION_PATH; } } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java index 4f7395bd4a4cf5ad20123643df2c210dbe1cb9cb..d4b188d7db59d212f58637712f19a1aa4a53bf27 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java @@ -43,7 +43,7 @@ import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.CentralRepoSettings; import org.sleuthkit.autopsy.coreutils.FileUtil; /** diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/SharedConfiguration.java b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/SharedConfiguration.java index 5b56e2b30ea2691fb442e5626110d44c5655732d..d8c5a560673e2704a6e44849003e5bb72e75d9d1 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/SharedConfiguration.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/SharedConfiguration.java @@ -38,7 +38,6 @@ import java.util.concurrent.TimeUnit; import java.util.prefs.BackingStoreException; import org.apache.commons.io.FileUtils; -import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.PlatformUtil; @@ -53,8 +52,6 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService.CategoryNode; import org.sleuthkit.autopsy.coordinationservice.CoordinationService.Lock; import org.sleuthkit.autopsy.coordinationservice.CoordinationService.CoordinationServiceException; -import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupSettings; -import org.sleuthkit.autopsy.modules.interestingitems.FilesSetsManager; /* * A utility class for loading and saving shared configuration data @@ -65,8 +62,8 @@ public class SharedConfiguration { private static final String AUTO_MODE_CONTEXT_FILE = "AutoModeContext.properties"; //NON-NLS private static final String USER_DEFINED_TYPE_DEFINITIONS_FILE = "UserFileTypeDefinitions.settings"; //NON-NLS private static final String USER_DEFINED_TYPE_DEFINITIONS_FILE_LEGACY = "UserFileTypeDefinitions.xml"; //NON-NLS + private static final String INTERESTING_FILES_SET_DEFS_FILE = "InterestingFileSets.settings"; //NON-NLS private static final String INTERESTING_FILES_SET_DEFS_FILE_LEGACY = "InterestingFilesSetDefs.xml"; //NON-NLS - private static final String KEYWORD_SEARCH_SETTINGS = "keywords.settings"; //NON-NLS private static final String KEYWORD_SEARCH_SETTINGS_LEGACY = "keywords.xml"; //NON-NLS private static final String KEYWORD_SEARCH_GENERAL_LEGACY = "KeywordSearch.properties"; //NON-NLS @@ -77,22 +74,30 @@ public class SharedConfiguration { private static final String FILE_EXT_MISMATCH_SETTINGS_LEGACY = "mismatch_config.xml"; //NON-NLS private static final String ANDROID_TRIAGE = "AndroidTriage_Options.properties"; //NON-NLS private static final String AUTO_INGEST_PROPERTIES = "AutoIngest.properties"; //NON-NLS - - private static final String REMOTE_HASH_FOLDER = "hashDb"; //NON-NLS - + private static final String HASHDB_CONFIG_FILE_NAME = "hashLookup.settings"; //NON-NLS private static final String HASHDB_CONFIG_FILE_NAME_LEGACY = "hashsets.xml"; //NON-NLS public static final String FILE_EXPORTER_SETTINGS_FILE = "fileexporter.settings"; //NON-NLS + private static final String CENTRAL_REPOSITORY_PROPERTIES_FILE = "CentralRepository.properties"; //NON-NLS private static final String SHARED_CONFIG_VERSIONS = "SharedConfigVersions.txt"; //NON-NLS // Folders private static final String AUTO_MODE_FOLDER = "AutoModeContext"; //NON-NLS + private static final String REMOTE_HASH_FOLDER = "hashDb"; //NON-NLS public static final String FILE_EXPORTER_FOLDER = "Automated File Exporter"; //NON-NLS + private static final String UPLOAD_IN_PROGRESS_FILE = "uploadInProgress"; // NON-NLS private static final String moduleDirPath = PlatformUtil.getUserConfigDirectory(); private static final String INGEST_MODULES_PATH = IngestJobSettings.getBaseSettingsPath(); private static final String INGEST_MODULES_REL_PATH = new File(moduleDirPath).toURI().relativize(new File(INGEST_MODULES_PATH).toURI()).getPath(); private static final Logger logger = Logger.getLogger(SharedConfiguration.class.getName()); - + private static final String SHARED_DIR_PATH = Paths.get(moduleDirPath, "SharableConfig").toAbsolutePath().toString(); + private static final String CENTRAL_REPO_DIR_PATH = Paths.get(SHARED_DIR_PATH, "CentralRepository").toAbsolutePath().toString(); + private static final String VIEW_PREFERENCE_FILE = Paths.get(SHARED_DIR_PATH, "ViewPreferences").toAbsolutePath().toString(); + private static final String MACHINE_SPECIFIC_PREFERENCE_FILE = Paths.get(moduleDirPath, "MachineSpecificPreferences").toAbsolutePath().toString(); + private static final String MODE_PREFERENCE_FILE = Paths.get(moduleDirPath, "ModePreferences").toAbsolutePath().toString(); + private static final String EXTERNAL_SERVICE_PREFERENCE_FILE = Paths.get(moduleDirPath, "ExternalServicePreferences").toAbsolutePath().toString(); + + private final UpdateConfigSwingWorker swingWorker; private UserPreferences.SelectedMode mode; private String sharedConfigFolder; @@ -106,6 +111,8 @@ public class SharedConfiguration { private boolean hideSlackFilesInViews; private boolean keepPreferredViewer; + + /** * Exception type thrown by shared configuration. */ @@ -444,24 +451,6 @@ private static boolean isConfigFolderPopulated(File folder, boolean isSharedFold File contextProperties = Paths.get(folder.getAbsolutePath(), INGEST_MODULES_REL_PATH, AUTO_MODE_CONTEXT_FILE).toFile(); return contextProperties.exists(); } - - /** - * Copy a local settings file to the remote folder. - * - * @param fullLocalPathStr Full local path. - * @param localFolder Local settings folder - * @param remoteFolder Shared settings folder - * @param missingFileOk True if it's not an error if the source file is - * not found - * - * @throws SharedConfigurationException - */ - private static void copyToRemoteFolder(String fullLocalPathStr, File remoteFolder, boolean missingFileOk) throws SharedConfigurationException { - Path fullLocalPath = Paths.get(fullLocalPathStr); - String fileName = fullLocalPath.toFile().getName(); - String parentPath = fullLocalPath.getParent().toString(); - copyToRemoteFolder(fileName, parentPath, remoteFolder, missingFileOk); - } /** * Copy a local settings file to the remote folder. @@ -502,23 +491,6 @@ private static void copyToRemoteFolder(String fileName, String localFolder, File throw new SharedConfigurationException(String.format("Failed to copy %s to %s", localFile.getAbsolutePath(), remoteFolder.getAbsolutePath()), ex); } } - - /** - * Copy a shared settings file to the local settings folder. - * - * @param fullLocalPathStr Full local path. - * @param remoteFolder Shared settings folder - * @param missingFileOk True if it's not an error if the source file is - * not found - * - * @throws SharedConfigurationException - */ - private static void copyToLocalFolder(String fullLocalPathStr, File remoteFolder, boolean missingFileOk) throws SharedConfigurationException { - Path fullLocalPath = Paths.get(fullLocalPathStr); - String fileName = fullLocalPath.toFile().getName(); - String parentPath = fullLocalPath.getParent().toString(); - copyToLocalFolder(fileName, parentPath, remoteFolder, missingFileOk); - } /** * Copy a shared settings file to the local settings folder. @@ -767,7 +739,7 @@ private void downloadFileTypeSettings(File remoteFolder) throws SharedConfigurat private void uploadInterestingFilesSettings(File remoteFolder) throws SharedConfigurationException { publishTask("Uploading InterestingFiles module configuration"); copyToRemoteFolder(INTERESTING_FILES_SET_DEFS_FILE_LEGACY, moduleDirPath, remoteFolder, true); - copyToRemoteFolder(FilesSetsManager.getInstance().getInterestingItemPath(), remoteFolder, true); + copyToRemoteFolder(INTERESTING_FILES_SET_DEFS_FILE, SHARED_DIR_PATH, remoteFolder, true); } /** @@ -780,7 +752,7 @@ private void uploadInterestingFilesSettings(File remoteFolder) throws SharedConf private void downloadInterestingFilesSettings(File remoteFolder) throws SharedConfigurationException { publishTask("Downloading InterestingFiles module configuration"); copyToLocalFolder(INTERESTING_FILES_SET_DEFS_FILE_LEGACY, moduleDirPath, remoteFolder, true); - copyToLocalFolder(FilesSetsManager.getInstance().getInterestingItemPath(), remoteFolder, true); + copyToLocalFolder(INTERESTING_FILES_SET_DEFS_FILE, SHARED_DIR_PATH, remoteFolder, true); } /** @@ -903,15 +875,7 @@ private void downloadFileExporterSettings(File remoteFolder) throws SharedConfig */ private void uploadCentralRepositorySettings(File remoteFolder) throws SharedConfigurationException { publishTask("Uploading central repository configuration"); - - // get relative cr path to config path. - String centralRepoRelPath = new File(moduleDirPath).toURI().relativize( - new File(CentralRepoSettings.getInstance().getModuleSettingsFile()).getParentFile().toURI()).getPath(); - - copyToRemoteFolder( - CentralRepoSettings.getInstance().getModuleSettingsFile(), - Paths.get(remoteFolder.getAbsolutePath(), centralRepoRelPath).toFile(), - true); + copyToRemoteFolder(CENTRAL_REPOSITORY_PROPERTIES_FILE, CENTRAL_REPO_DIR_PATH, remoteFolder, true); } /** @@ -923,12 +887,7 @@ private void uploadCentralRepositorySettings(File remoteFolder) throws SharedCon */ private void downloadCentralRepositorySettings(File remoteFolder) throws SharedConfigurationException { publishTask("Downloading central repository configuration"); - - // get relative cr path to config path. - String centralRepoRelPath = new File(moduleDirPath).toURI().relativize( - new File(CentralRepoSettings.getInstance().getModuleSettingsFile()).getParentFile().toURI()).getPath(); - - copyToLocalFolder(CentralRepoSettings.getInstance().getModuleSettingsFile(), Paths.get(remoteFolder.getAbsolutePath(), centralRepoRelPath).toFile(), true); + copyToLocalFolder(CENTRAL_REPOSITORY_PROPERTIES_FILE, CENTRAL_REPO_DIR_PATH, remoteFolder, true); } /** @@ -941,11 +900,11 @@ private void downloadCentralRepositorySettings(File remoteFolder) throws SharedC private void uploadMultiUserAndGeneralSettings(File remoteFolder) throws SharedConfigurationException { publishTask("Uploading multi user configuration"); - copyToRemoteFolder(UserPreferences.getViewPreferencePath(), remoteFolder, false); - copyToRemoteFolder(UserPreferences.getMachineSpecificPreferencePath(), remoteFolder, false); - copyToRemoteFolder(UserPreferences.getModePreferencePath(), remoteFolder, false); - copyToRemoteFolder(UserPreferences.getExternalServicePreferencePath(), remoteFolder, false); - + copyToRemoteFolder(VIEW_PREFERENCE_FILE, SHARED_DIR_PATH, remoteFolder, false); + copyToRemoteFolder(MACHINE_SPECIFIC_PREFERENCE_FILE, moduleDirPath, remoteFolder, false); + copyToRemoteFolder(MODE_PREFERENCE_FILE, moduleDirPath, remoteFolder, false); + copyToRemoteFolder(EXTERNAL_SERVICE_PREFERENCE_FILE, SHARED_DIR_PATH, remoteFolder, false); + copyToRemoteFolder(AUTO_INGEST_PROPERTIES, moduleDirPath, remoteFolder, false); } @@ -959,10 +918,10 @@ private void uploadMultiUserAndGeneralSettings(File remoteFolder) throws SharedC private void downloadMultiUserAndGeneralSettings(File remoteFolder) throws SharedConfigurationException { publishTask("Downloading multi user configuration"); - copyToLocalFolder(UserPreferences.getViewPreferencePath(), remoteFolder, false); - copyToLocalFolder(UserPreferences.getMachineSpecificPreferencePath(), remoteFolder, false); - copyToLocalFolder(UserPreferences.getModePreferencePath(), remoteFolder, false); - copyToLocalFolder(UserPreferences.getExternalServicePreferencePath(), remoteFolder, false); + copyToLocalFolder(VIEW_PREFERENCE_FILE, SHARED_DIR_PATH, remoteFolder, false); + copyToLocalFolder(MACHINE_SPECIFIC_PREFERENCE_FILE, moduleDirPath, remoteFolder, false); + copyToLocalFolder(MODE_PREFERENCE_FILE, moduleDirPath, remoteFolder, false); + copyToLocalFolder(EXTERNAL_SERVICE_PREFERENCE_FILE, SHARED_DIR_PATH, remoteFolder, false); copyToLocalFolder(AUTO_INGEST_PROPERTIES, moduleDirPath, remoteFolder, false); } @@ -1041,7 +1000,7 @@ private void uploadHashDbSettings(File remoteFolder) throws SharedConfigurationE Map<String, String> sharedVersions = readVersionsFromFile(sharedVersionFile); // Copy the settings file - copyToRemoteFolder(HashLookupSettings.getSettingsPath(), remoteFolder, true); + copyToRemoteFolder(HASHDB_CONFIG_FILE_NAME, SHARED_DIR_PATH, remoteFolder, true); copyToRemoteFolder(HASHDB_CONFIG_FILE_NAME_LEGACY, moduleDirPath, remoteFolder, true); // Get the list of databases from the file @@ -1290,7 +1249,7 @@ private void downloadHashDbSettings(File remoteFolder) throws SharedConfiguratio } // Copy the settings filey - copyToLocalFolder(HashLookupSettings.getSettingsPath(), remoteFolder, true); + copyToLocalFolder(HASHDB_CONFIG_FILE_NAME, SHARED_DIR_PATH, remoteFolder, true); copyToLocalFolder(HASHDB_CONFIG_FILE_NAME_LEGACY, moduleDirPath, remoteFolder, true); copyToLocalFolder(SHARED_CONFIG_VERSIONS, moduleDirPath, remoteFolder, true);