From 76d7292ea2cf9272254f8be236b0ed873398f52a Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 7 Apr 2020 16:13:02 -0400 Subject: [PATCH 01/10] initial implementation --- .../textextractors/TextFileExtractor.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java index 4a89b74d3c..710a7d3508 100644 --- a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java @@ -25,8 +25,10 @@ import java.io.Reader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.logging.Level; +import org.apache.commons.lang.StringUtils; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.textutils.EncodingUtils; +import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.ReadContentInputStream; import org.sleuthkit.datamodel.TskCoreException; @@ -38,6 +40,7 @@ public final class TextFileExtractor implements TextExtractor { private static final Logger logger = Logger.getLogger(TextFileExtractor.class.getName()); private final AbstractFile file; + private static final String PLAIN_TEXT_MIME_TYPE = "text/plain"; private Charset encoding = null; @@ -74,6 +77,28 @@ public final class TextFileExtractor implements TextExtractor { @Override public boolean isSupported() { - return file.getMIMEType().equals("text/plain"); + // if file is null, it is not supported + if (file == null) + return false; + + // get the MIME type + String mimeType = file.getMIMEType(); + + // if it is not present, attempt to use the FileTypeDetector to determine + if (StringUtils.isEmpty(mimeType)) { + FileTypeDetector fileTypeDetector = null; + try { + fileTypeDetector = new FileTypeDetector(); + } catch (FileTypeDetector.FileTypeDetectorInitException ex) { + logger.log(Level.WARNING, "Unable to create file type detector for determining MIME type."); + } + mimeType = fileTypeDetector.getMIMEType(file); + + // if able to determine mime type, + if (!StringUtils.isEmpty(mimeType)) + file.setMIMEType(mimeType); + } + + return (StringUtils.isEmpty(mimeType)) ? false : mimeType.equals(PLAIN_TEXT_MIME_TYPE); } } From 3c47c8b5f69448f29f231b7370358c90e9eb0069 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 7 Apr 2020 16:13:20 -0400 Subject: [PATCH 02/10] initial implementation --- .../textextractors/TextFileExtractorTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Core/test/unit/src/org/sleuthkit/autopsy/textextractors/TextFileExtractorTest.java diff --git a/Core/test/unit/src/org/sleuthkit/autopsy/textextractors/TextFileExtractorTest.java b/Core/test/unit/src/org/sleuthkit/autopsy/textextractors/TextFileExtractorTest.java new file mode 100644 index 0000000000..9f9dc8493c --- /dev/null +++ b/Core/test/unit/src/org/sleuthkit/autopsy/textextractors/TextFileExtractorTest.java @@ -0,0 +1,23 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.textextractors; + +import junit.framework.Assert; +import org.junit.Test; + + +/** + * Tests methods present in the TextFileExtractor + */ +public class TextFileExtractorTest { + + @Test + public void testIsSupported() { + Assert.assertFalse(new TextFileExtractor(null).isSupported()); + } + + +} From 5a89c431a6ec1905fe20b359edc04edf8ddeca91 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 8 Apr 2020 09:13:02 -0400 Subject: [PATCH 03/10] updates to TextFileExtractor --- .../autopsy/textextractors/TextFileExtractor.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java index 710a7d3508..33c7c04a4e 100644 --- a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java @@ -76,11 +76,7 @@ public final class TextFileExtractor implements TextExtractor { } @Override - public boolean isSupported() { - // if file is null, it is not supported - if (file == null) - return false; - + public boolean isSupported() { // get the MIME type String mimeType = file.getMIMEType(); @@ -91,6 +87,7 @@ public final class TextFileExtractor implements TextExtractor { fileTypeDetector = new FileTypeDetector(); } catch (FileTypeDetector.FileTypeDetectorInitException ex) { logger.log(Level.WARNING, "Unable to create file type detector for determining MIME type."); + return false; } mimeType = fileTypeDetector.getMIMEType(file); @@ -99,6 +96,6 @@ public final class TextFileExtractor implements TextExtractor { file.setMIMEType(mimeType); } - return (StringUtils.isEmpty(mimeType)) ? false : mimeType.equals(PLAIN_TEXT_MIME_TYPE); + return PLAIN_TEXT_MIME_TYPE.equals(mimeType); } } From 98933985031dc8ad8759959b716fbb91f48bb76a Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 8 Apr 2020 11:02:29 -0400 Subject: [PATCH 04/10] cleanup --- .../textextractors/TextFileExtractorTest.java | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 Core/test/unit/src/org/sleuthkit/autopsy/textextractors/TextFileExtractorTest.java diff --git a/Core/test/unit/src/org/sleuthkit/autopsy/textextractors/TextFileExtractorTest.java b/Core/test/unit/src/org/sleuthkit/autopsy/textextractors/TextFileExtractorTest.java deleted file mode 100644 index 9f9dc8493c..0000000000 --- a/Core/test/unit/src/org/sleuthkit/autopsy/textextractors/TextFileExtractorTest.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.sleuthkit.autopsy.textextractors; - -import junit.framework.Assert; -import org.junit.Test; - - -/** - * Tests methods present in the TextFileExtractor - */ -public class TextFileExtractorTest { - - @Test - public void testIsSupported() { - Assert.assertFalse(new TextFileExtractor(null).isSupported()); - } - - -} From 1b238183046b0f25e83d7f4322e314076d59e4a8 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 8 Apr 2020 13:51:25 -0400 Subject: [PATCH 05/10] update log entry to severe --- .../org/sleuthkit/autopsy/textextractors/TextFileExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java index 33c7c04a4e..dda59cdcfd 100644 --- a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java @@ -86,7 +86,7 @@ public final class TextFileExtractor implements TextExtractor { try { fileTypeDetector = new FileTypeDetector(); } catch (FileTypeDetector.FileTypeDetectorInitException ex) { - logger.log(Level.WARNING, "Unable to create file type detector for determining MIME type."); + logger.log(Level.SEVERE, "Unable to create file type detector for determining MIME type."); return false; } mimeType = fileTypeDetector.getMIMEType(file); From cc46accfa2f79cc8e1bab1c40b8e48f50e64a448 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 8 Apr 2020 15:47:54 -0400 Subject: [PATCH 06/10] updated parent of ManageOrganizationsDialog when launching from OptionalCasePropertiesPanel --- .../OptionalCasePropertiesPanel.java | 4 +- .../ManageOrganizationsDialog.java | 37 +++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/OptionalCasePropertiesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/OptionalCasePropertiesPanel.java index b5706027a3..9b753900b1 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/OptionalCasePropertiesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/OptionalCasePropertiesPanel.java @@ -19,8 +19,10 @@ package org.sleuthkit.autopsy.casemodule; import java.awt.Cursor; +import java.awt.Dialog; import java.util.logging.Level; import javax.swing.JComboBox; +import javax.swing.SwingUtilities; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; @@ -516,7 +518,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { }//GEN-LAST:event_comboBoxOrgNameActionPerformed private void bnNewOrganizationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnNewOrganizationActionPerformed - ManageOrganizationsDialog dialog = new ManageOrganizationsDialog(); + ManageOrganizationsDialog dialog = new ManageOrganizationsDialog((Dialog) SwingUtilities.getWindowAncestor(this)); // update the combobox options and org data fields loadOrganizationData(); if (dialog.isChanged()) { diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.java index dff44aa0c5..85373c06d2 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.centralrepository.optionspanel; import java.awt.Component; +import java.awt.Dialog; import java.util.List; import java.util.logging.Level; import javax.swing.DefaultListCellRenderer; @@ -51,12 +52,41 @@ public final class ManageOrganizationsDialog extends JDialog { @Messages({"ManageOrganizationsDialog.title.text=Manage Organizations"}) /** - * Creates new form ManageOrganizationsPanel + * Creates new form ManageOrganizationsPanel. + * @param parent The dialog parent. */ - public ManageOrganizationsDialog() { - super((JFrame) WindowManager.getDefault().getMainWindow(), + public ManageOrganizationsDialog(Dialog parent) { + super(parent, Bundle.ManageOrganizationsDialog_title_text(), true); // NON-NLS + init(); + } + + + /** + * Creates new form ManageOrganizationsPanel. + * @param parent The JFrame parent. + */ + public ManageOrganizationsDialog(JFrame parent) { + super(parent, + Bundle.ManageOrganizationsDialog_title_text(), + true); // NON-NLS + init(); + } + + + /** + * Creates new form ManageOrganizationsPanel. + */ + public ManageOrganizationsDialog() { + this((JFrame) WindowManager.getDefault().getMainWindow()); + } + + + /** + * To be run as a part of constructor initialization. + */ + private void init() { initComponents(); try { this.dbManager = CentralRepository.getInstance(); @@ -85,6 +115,7 @@ public final class ManageOrganizationsDialog extends JDialog { private void display() { this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow()); setVisible(true); + toFront(); } private void populateListAndSelect(CentralRepoOrganization selected) throws CentralRepoException { From 797b4a99060ac555b8f0c09feb5af6b228fbe819 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Thu, 9 Apr 2020 07:54:25 -0400 Subject: [PATCH 07/10] remove in-memory mime type change --- .../sleuthkit/autopsy/textextractors/TextFileExtractor.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java index dda59cdcfd..af31797b52 100644 --- a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java @@ -90,10 +90,6 @@ public final class TextFileExtractor implements TextExtractor { return false; } mimeType = fileTypeDetector.getMIMEType(file); - - // if able to determine mime type, - if (!StringUtils.isEmpty(mimeType)) - file.setMIMEType(mimeType); } return PLAIN_TEXT_MIME_TYPE.equals(mimeType); From 61d8a05b64f96a46b314f8d1aa0ace566ad10f02 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Wed, 15 Apr 2020 12:49:31 -0400 Subject: [PATCH 08/10] Get stack trace in TextFileExtractor.isSupported --- .../org/sleuthkit/autopsy/textextractors/TextFileExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java index af31797b52..9c71b14ecc 100644 --- a/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/textextractors/TextFileExtractor.java @@ -86,7 +86,7 @@ public final class TextFileExtractor implements TextExtractor { try { fileTypeDetector = new FileTypeDetector(); } catch (FileTypeDetector.FileTypeDetectorInitException ex) { - logger.log(Level.SEVERE, "Unable to create file type detector for determining MIME type."); + logger.log(Level.SEVERE, "Unable to create file type detector for determining MIME type", ex); return false; } mimeType = fileTypeDetector.getMIMEType(file); From 02b2315ac0ef1f3234fdaaaa3a23f400ba0f9fc9 Mon Sep 17 00:00:00 2001 From: Mark McKinnon Date: Wed, 15 Apr 2020 09:17:14 -0400 Subject: [PATCH 09/10] Update Running_Linux_OSX.txt Add Gatekeper troubleshooting tip --- Running_Linux_OSX.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Running_Linux_OSX.txt b/Running_Linux_OSX.txt index 521fa6e9f1..39ea10441c 100644 --- a/Running_Linux_OSX.txt +++ b/Running_Linux_OSX.txt @@ -80,6 +80,11 @@ Autopsy depends on a specific version of The Sleuth Kit. You need the Java libr (a) confirm that you have a version of Java 8 installed and (b) confirm that your JAVA_HOME environment variable is set correctly: % echo $JAVA_HOME + +- If you see something like "cannot be opened because the developer cannot be verified." it is an indication + that Gatekeeper is running and is stopping a file from being executed. To fix this open a new terminal window + and enter the following command "sudo spctl --master-disable", you will be required to enter your password. + This will allow any program to be be downloaded from anywhere and executed. * Limitations (Updated May 2018) * - Timeline does not work on OS X From 47d6f83f6f1ad3545f87f548221341ddbdb4dc98 Mon Sep 17 00:00:00 2001 From: Andrea Lazzarotto Date: Sun, 12 Apr 2020 15:15:06 +0200 Subject: [PATCH 10/10] Update installation instructions for macOS On macOS one has to install the liberica-jdk8-full package in order to have OpenJFX. --- Running_Linux_OSX.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Running_Linux_OSX.txt b/Running_Linux_OSX.txt index 39ea10441c..60b81bc50a 100644 --- a/Running_Linux_OSX.txt +++ b/Running_Linux_OSX.txt @@ -27,7 +27,7 @@ The following need to be done at least once. They do not need to be repeated for -- OS X: 1. Install BellSoft Java 8. % brew tap bell-sw/liberica - % brew cask install liberica-jdk8 + % brew cask install liberica-jdk8-full 2. Set JAVA_HOME environment variable to location of JRE installation. e.g. add the following to ~/.bashrc export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)