diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/CTOptionsPanel.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/CTOptionsPanel.java index 83a4a9a51a3709bea181021c7881fb3a7254c39c..2b6cffe789eeeec9239401f070b0c4ba10ccec2f 100644 --- a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/CTOptionsPanel.java +++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/CTOptionsPanel.java @@ -26,12 +26,12 @@ import java.util.Collection; import java.util.Comparator; import java.util.List; -import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.swing.JPanel; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.Lookup; +import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.ingest.IngestModuleGlobalSettingsPanel; /** diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTMalwareScannerOptionsPanel.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTMalwareScannerOptionsPanel.java index 375943188cba85bcf23613c24c47848a37e30da7..3c71bd3cbacb53462d1b0325398c5e0b1f768a8f 100644 --- a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTMalwareScannerOptionsPanel.java +++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTMalwareScannerOptionsPanel.java @@ -40,7 +40,6 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; @@ -51,6 +50,7 @@ import org.openide.util.lookup.ServiceProvider; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.core.UserPreferences; +import org.sleuthkit.autopsy.coreutils.Logger; /** * Options panel to be displayed in the CTOptionsPanel for settings regarding diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTIncidentImportOptionsPanel.java b/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTIncidentImportOptionsPanel.java index bf018701ca70117d6b3f18107ab5c972c7664896..ef7aa5a67ef010c0a2fc6ea09d0cfcf197d091f3 100644 --- a/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTIncidentImportOptionsPanel.java +++ b/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTIncidentImportOptionsPanel.java @@ -1,16 +1,21 @@ -/** ************************************************************************* - ** This data and information is proprietary to, and a valuable trade secret - ** of, Sleuth Kit Labs. It is given in confidence by Sleuth Kit Labs - ** and may only be used as permitted under the license agreement under which - ** it has been distributed, and in no other way. - ** - ** Copyright (c) 2023 Sleuth Kit Labs, LLC. All rights reserved - ** - ** The technical data and information provided herein are provided with - ** `limited rights', and the computer software provided herein is provided - ** with `restricted rights' as those terms are defined in DAR and ASPR - ** 7-104.9(a). - ************************************************************************** */ +/* + * Autopsy Forensic Browser + * + * Copyright 2023 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 com.basistech.df.cybertriage.autopsy.incidentoptions; import com.basistech.df.cybertriage.autopsy.ctoptions.subpanel.CTOptionsSubPanel; @@ -21,7 +26,7 @@ import java.net.URISyntaxException; import java.util.Collections; import java.util.logging.Level; -import java.util.logging.Logger; +import org.sleuthkit.autopsy.coreutils.Logger; import javax.swing.JFileChooser; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTSettings.java b/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTSettings.java index 35e2d108eae0b1c5e7850e847a47cc8970c33baf..d6427a641ca494e2b496b34bed033d1ac19899e0 100644 --- a/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTSettings.java +++ b/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTSettings.java @@ -1,16 +1,21 @@ -/** ************************************************************************* - ** This data and information is proprietary to, and a valuable trade secret - ** of, Sleuth Kit Labs. It is given in confidence by Sleuth Kit Labs - ** and may only be used as permitted under the license agreement under which - ** it has been distributed, and in no other way. - ** - ** Copyright (c) 2023 Sleuth Kit Labs, LLC. All rights reserved - ** - ** The technical data and information provided herein are provided with - ** `limited rights', and the computer software provided herein is provided - ** with `restricted rights' as those terms are defined in DAR and ASPR - ** 7-104.9(a). - ************************************************************************** */ +/* + * Autopsy Forensic Browser + * + * Copyright 2023 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 com.basistech.df.cybertriage.autopsy.incidentoptions; import java.io.IOException; @@ -19,35 +24,60 @@ import java.nio.file.Paths; import java.util.Objects; import java.util.logging.Level; -import java.util.logging.Logger; +import org.sleuthkit.autopsy.coreutils.Logger; +import org.apache.commons.lang3.StringUtils; import org.openide.modules.Places; +import org.sleuthkit.autopsy.coreutils.PlatformUtil; /** - * CT settings that don't include license information. This code must be kept in-sync with code in - * CT Autopsy Importer NBM. + * CT settings that don't include license information. This code must be kept + * in-sync with code in CT Autopsy Importer NBM. */ public class CTSettings { + private static final Logger LOGGER = Logger.getLogger(CTSettings.class.getCanonicalName()); private static final String DEFAULT_FILE_REPO_PATH = getAppDataLocalDirectory(); - // taken from com.basistech.df.cybertriage.utils.SystemProperties - private static String getAppDataLocalDirectory() { + private static final String CYBERTRIAGE_FOLDER = "cybertriage"; + private static final String CYBERTRIAGE_DOT_FOLDER = "." + CYBERTRIAGE_FOLDER; - Logger LOGGER = java.util.logging.Logger.getLogger(CTSettings.class.getCanonicalName()); + // based on com.basistech.df.cybertriage.utils.SystemProperties + private static String getAppDataLocalDirectory() { if (Objects.nonNull(Places.getUserDirectory()) && Places.getUserDirectory().getAbsolutePath().endsWith("testuserdir")) { // APP is in testing .. this should return the test path LOGGER.log(Level.INFO, "Application Data (test mode) Path: " + Places.getUserDirectory().getAbsolutePath()); return Places.getUserDirectory().getAbsolutePath(); - } else { - Path localAppPath = Paths.get(System.getenv("LOCALAPPDATA"), "cybertriage"); + } + + // try to use LOCALAPPDATA on windows + String localDataStr = System.getenv("LOCALAPPDATA"); + if (StringUtils.isNotBlank(localDataStr)) { + Path localAppPath = Paths.get(localDataStr, CYBERTRIAGE_FOLDER); try { Files.createDirectories(localAppPath); LOGGER.log(Level.INFO, "Application Data Path: " + localAppPath.toString()); return localAppPath.toString(); } catch (IOException ex) { - LOGGER.log(Level.SEVERE, "IO Error, defaulting to user dir", ex); - return Places.getUserDirectory().getAbsolutePath(); // In case of an IO Error + LOGGER.log(Level.SEVERE, "IO Error using " + localAppPath.toString(), ex); } } + + // try to use ~/.cybertriage anywhere else + if (!PlatformUtil.isWindowsOS()) { + String homePathStr = System.getenv("HOME"); + if (StringUtils.isNotBlank(homePathStr)) { + Path localAppPath = Paths.get(homePathStr, CYBERTRIAGE_DOT_FOLDER); + try { + Files.createDirectories(localAppPath); + LOGGER.log(Level.INFO, "Non-windows Application Data Path: " + localAppPath.toString()); + return localAppPath.toString(); + } catch (IOException ex) { + LOGGER.log(Level.SEVERE, "IO Error using " + localAppPath.toString(), ex); + } + } + } + + // defer to user directory otherwise + return Places.getUserDirectory().getAbsolutePath(); // In case of an IO Error } public static String getDefaultFileRepoPath() { diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTSettingsPersistence.java b/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTSettingsPersistence.java index be60813edd89a61d497290316ee69e2f3472b27c..e5e5b6838fa40d0e4478ffca23a97c954881b000 100644 --- a/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTSettingsPersistence.java +++ b/Core/src/com/basistech/df/cybertriage/autopsy/incidentoptions/CTSettingsPersistence.java @@ -1,16 +1,21 @@ -/** ************************************************************************* - ** This data and information is proprietary to, and a valuable trade secret - ** of, Sleuth Kit Labs. It is given in confidence by Sleuth Kit Labs - ** and may only be used as permitted under the license agreement under which - ** it has been distributed, and in no other way. - ** - ** Copyright (c) 2023 Sleuth Kit Labs, LLC. All rights reserved - ** - ** The technical data and information provided herein are provided with - ** `limited rights', and the computer software provided herein is provided - ** with `restricted rights' as those terms are defined in DAR and ASPR - ** 7-104.9(a). - ************************************************************************** */ +/* + * Autopsy Forensic Browser + * + * Copyright 2023 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 com.basistech.df.cybertriage.autopsy.incidentoptions; import com.fasterxml.jackson.databind.ObjectMapper;