From 4e8e7fa3dda23c782b3a7c70c88ed24c7db11ce0 Mon Sep 17 00:00:00 2001 From: Nick Davis Date: Thu, 29 May 2014 14:28:50 -0400 Subject: [PATCH 01/11] Tagged hard coded strings with \\NON-NLS --- .../CoreComponentControl.java | 2 +- .../hashdatabase/HashLookupModuleSettingsPanel.java | 2 +- .../keywordsearch/DropdownListSearchPanel.java | 2 +- .../autopsy/keywordsearch/DropdownToolbar.java | 12 ++++++------ .../keywordsearch/GlobalListsManagementPanel.java | 4 ++-- .../keywordsearch/KeywordSearchJobSettingsPanel.java | 2 +- .../org/sleuthkit/autopsy/keywordsearch/Server.java | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/CoreComponentControl.java b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/CoreComponentControl.java index 3f93665b11..ba6e172b7d 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/CoreComponentControl.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/CoreComponentControl.java @@ -66,7 +66,7 @@ public class CoreComponentControl { // find the data content top component TopComponent contentWin = DataContentTopComponent.findInstance(); - Mode m = WindowManager.getDefault().findMode("output"); + Mode m = WindowManager.getDefault().findMode("output"); //NON-NLS if (m != null) { m.dockInto(contentWin); // redock into the output mode } else { diff --git a/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashLookupModuleSettingsPanel.java b/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashLookupModuleSettingsPanel.java index 510a908461..1a81c13403 100644 --- a/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashLookupModuleSettingsPanel.java +++ b/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashLookupModuleSettingsPanel.java @@ -70,7 +70,7 @@ public final class HashLookupModuleSettingsPanel extends IngestModuleIngestJobSe customizeHashSetsTable(jScrollPane2, knownBadHashTable, knownBadHashSetsTableModel); alwaysCalcHashesCheckbox.setSelected(settings.shouldCalculateHashes()); hashDbManager.addPropertyChangeListener(this); - alwaysCalcHashesCheckbox.setText("" + org.openide.util.NbBundle.getMessage(HashLookupModuleSettingsPanel.class, "HashLookupModuleSettingsPanel.alwaysCalcHashesCheckbox.text") + ""); // NOI18N + alwaysCalcHashesCheckbox.setText("" + org.openide.util.NbBundle.getMessage(HashLookupModuleSettingsPanel.class, "HashLookupModuleSettingsPanel.alwaysCalcHashesCheckbox.text") + ""); // NOI18N NON-NLS } private void customizeHashSetsTable(JScrollPane scrollPane, JTable table, HashSetsTableModel tableModel) { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java index 714748602c..89e993c50e 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java @@ -238,7 +238,7 @@ class DropdownListSearchPanel extends KeywordSearchPanel { } }); - ingestIndexLabel.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N + ingestIndexLabel.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N NON-NLS ingestIndexLabel.setText(org.openide.util.NbBundle.getMessage(DropdownListSearchPanel.class, "KeywordSearchListsViewerPanel.ingestIndexLabel.text")); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownToolbar.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownToolbar.java index f2516ec817..748896e292 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownToolbar.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownToolbar.java @@ -143,13 +143,13 @@ class DropdownToolbar extends javax.swing.JPanel { setOpaque(false); - listsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon.png"))); // NOI18N + listsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon.png"))); // NOI18N NON-NLS listsButton.setText(org.openide.util.NbBundle.getMessage(DropdownToolbar.class, "ListBundleName")); // NOI18N listsButton.setBorderPainted(false); listsButton.setContentAreaFilled(false); listsButton.setEnabled(false); - listsButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-rollover.png"))); // NOI18N - listsButton.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-pressed.png"))); // NOI18N + listsButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-rollover.png"))); // NOI18N NON-NLS + listsButton.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-pressed.png"))); // NOI18N NON-NLS listsButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { listsButtonMousePressed(evt); @@ -161,7 +161,7 @@ class DropdownToolbar extends javax.swing.JPanel { } }); - searchDropButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon.png"))); // NOI18N + searchDropButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon.png"))); // NOI18N NON-NLS searchDropButton.setText(org.openide.util.NbBundle.getMessage(DropdownToolbar.class, "KeywordSearchPanel.searchDropButton.text")); // NOI18N searchDropButton.setBorderPainted(false); searchDropButton.setContentAreaFilled(false); @@ -169,8 +169,8 @@ class DropdownToolbar extends javax.swing.JPanel { searchDropButton.setMaximumSize(new java.awt.Dimension(146, 27)); searchDropButton.setMinimumSize(new java.awt.Dimension(146, 27)); searchDropButton.setPreferredSize(new java.awt.Dimension(146, 27)); - searchDropButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon-rollover.png"))); // NOI18N - searchDropButton.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon-pressed.png"))); // NOI18N + searchDropButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon-rollover.png"))); // NOI18N NON-NLS + searchDropButton.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon-pressed.png"))); // NOI18N NON-NLS searchDropButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { searchDropButtonMousePressed(evt); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListsManagementPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListsManagementPanel.java index a4ad3641ad..4059394305 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListsManagementPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListsManagementPanel.java @@ -113,7 +113,7 @@ class GlobalListsManagementPanel extends javax.swing.JPanel implements OptionsPa }); jScrollPane1.setViewportView(listsTable); - newListButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/new16.png"))); // NOI18N + newListButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/new16.png"))); // NOI18N NON-NLS newListButton.setText(org.openide.util.NbBundle.getMessage(GlobalListsManagementPanel.class, "KeywordSearchListsManagementPanel.newListButton.text")); // NOI18N newListButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -121,7 +121,7 @@ class GlobalListsManagementPanel extends javax.swing.JPanel implements OptionsPa } }); - importButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/import16.png"))); // NOI18N + importButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/import16.png"))); // NOI18N NON-NLS importButton.setText(org.openide.util.NbBundle.getMessage(GlobalListsManagementPanel.class, "KeywordSearchListsManagementPanel.importButton.text")); // NOI18N importButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchJobSettingsPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchJobSettingsPanel.java index 90b3aa7701..99b27ac0a2 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchJobSettingsPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchJobSettingsPanel.java @@ -64,7 +64,7 @@ public final class KeywordSearchJobSettingsPanel extends IngestModuleIngestJobSe displayLanguages(); displayEncodings(); keywordListsManager.addPropertyChangeListener(this); - languagesLabel.setText("" + org.openide.util.NbBundle.getMessage(KeywordSearchJobSettingsPanel.class, "KeywordSearchJobSettingsPanel.languagesLabel.text") + ""); // NOI18N + languagesLabel.setText("" + org.openide.util.NbBundle.getMessage(KeywordSearchJobSettingsPanel.class, "KeywordSearchJobSettingsPanel.languagesLabel.text") + ""); // NOI18N NON-NLS } private void customizeKeywordListsTable() { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java index 701017788b..1aacc4d1bb 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java @@ -91,7 +91,7 @@ public class Server { TEXT { @Override public String toString() { - return "text"; + return "text"; //NON-NLS } }, CONTENT_WS { From 1d3b1dab674cbca0b740d36efb2ccfeaa086bf22 Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Fri, 30 May 2014 00:20:51 -0400 Subject: [PATCH 02/11] USB device parser adds vendor name when product code isn't known --- .../recentactivity/ExtractRegistry.java | 6 +++-- .../recentactivity/UsbDeviceIdMapper.java | 23 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractRegistry.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractRegistry.java index 81049cb211..1fb0b83d8a 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractRegistry.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractRegistry.java @@ -446,12 +446,14 @@ class ExtractRegistry extends Extract { String model = dev; if (dev.toLowerCase().contains("vid")) { //NON-NLS USBInfo info = extrctr.parseAndLookup(dev); - if(info.getVendor()!=null) + if (info.getVendor() != null) { bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MAKE.getTypeID(), NbBundle.getMessage(this.getClass(), "ExtractRegistry.parentModuleName.noSpace"), info.getVendor())); - if(info.getProduct() != null) + } + if (info.getProduct() != null) { model = info.getProduct(); + } } bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MODEL.getTypeID(), NbBundle.getMessage(this.getClass(), diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/UsbDeviceIdMapper.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/UsbDeviceIdMapper.java index 5f889d439e..5cdc517fe0 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/UsbDeviceIdMapper.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/UsbDeviceIdMapper.java @@ -63,20 +63,29 @@ class UsbDeviceIdMapper { */ public USBInfo parseAndLookup(String dev) { String[] dtokens = dev.split("[_&]"); - String vID = dtokens[1]; + String vID = dtokens[1].toUpperCase(); String pID; if (dtokens.length < 4 || dtokens[3].length() < 4) { pID = "0000"; } else { pID = dtokens[3]; } + pID = pID.toUpperCase(); + + // first try the full key String key = vID + pID; - key = key.toUpperCase(); - if (!devices.containsKey(key)) { - return new USBInfo(null, null); - } else { + if (devices.containsKey(key)) { return devices.get(key); } + + // try just the vendor ID -> In case database doesn't know about this specific product + key = vID + "0000"; + if (devices.containsKey(key)) { + USBInfo info = devices.get(key); + return new USBInfo(info.getVendor(), "Product: " + pID); + } + + return new USBInfo(null, null); } /** @@ -152,8 +161,8 @@ class UsbDeviceIdMapper { * Stores the vendor information about a USB device */ public class USBInfo { - private String vendor; - private String product; + private final String vendor; + private final String product; private USBInfo(String vend, String prod) { vendor = vend; From 9e07e6f78b73781e1887b4962e9b4cdfafb54cad Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Fri, 30 May 2014 00:28:51 -0400 Subject: [PATCH 03/11] Added more extensions to config file --- .../autopsy/modules/fileextmismatch/mismatch_config.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/mismatch_config.xml b/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/mismatch_config.xml index 3294584539..59bccd5f57 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/mismatch_config.xml +++ b/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/mismatch_config.xml @@ -223,7 +223,9 @@ jpe jpeg jpg + jpg:ms-thumbnail png + tile gif @@ -264,6 +266,7 @@ adm admx aff + appcontent-ms arff ashx asp @@ -300,6 +303,7 @@ dun ecf elm + eml eng ent enu @@ -398,6 +402,7 @@ sql std stp + strings sve sve svg From 2767542a1ade02bd67db612ad29564597386e4ec Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Fri, 30 May 2014 00:29:37 -0400 Subject: [PATCH 04/11] Restored default behavior to ignore text files --- .../fileextmismatch/FileExtMismatchDetectorModuleSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchDetectorModuleSettings.java b/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchDetectorModuleSettings.java index a894fe60a6..12a5bfa154 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchDetectorModuleSettings.java +++ b/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchDetectorModuleSettings.java @@ -27,7 +27,7 @@ final class FileExtMismatchDetectorModuleSettings implements IngestModuleIngestJ private static final long serialVersionUID = 1L; private boolean skipFilesWithNoExtension = true; - private boolean skipFilesWithTextPlainMimeType = false; + private boolean skipFilesWithTextPlainMimeType = true; FileExtMismatchDetectorModuleSettings() { } From 93bcdaebd20910cf23ddd2c488cbba1c53e95254 Mon Sep 17 00:00:00 2001 From: alexjacks92 Date: Fri, 30 May 2014 14:17:31 -0400 Subject: [PATCH 05/11] Dropping tsk_files obj_id istead of replacing. --- test/script/tskdbdiff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/script/tskdbdiff.py b/test/script/tskdbdiff.py index 067e7205d2..dfe0d06b28 100755 --- a/test/script/tskdbdiff.py +++ b/test/script/tskdbdiff.py @@ -289,7 +289,7 @@ def replace_id(line, table): if (files_index != -1): obj_id = fields_list[0] path = table[int(obj_id)] - newLine = ('INSERT INTO "tsk_files" VALUES(' + path + ', '.join(fields_list[1:]) + ');') + newLine = ('INSERT INTO "tsk_files" VALUES(' + ', '.join(fields_list[1:]) + ');') return newLine elif (path_index != -1): From 1c7d72b053569959cbbd618a6695c89d13c20594 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Fri, 30 May 2014 19:27:53 -0400 Subject: [PATCH 06/11] Write to log files in case log directory --- .../sleuthkit/autopsy/casemodule/Case.java | 17 ++++++- .../sleuthkit/autopsy/coreutils/Logger.java | 47 ++++++++++++++++--- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 0cb1b2e24b..e050a8859a 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -345,7 +345,7 @@ public class Case implements SleuthkitCase.ErrorObserver { } static Map getImagePaths(SleuthkitCase db) { //TODO: clean this up - Map imgPaths = new HashMap(); + Map imgPaths = new HashMap<>(); try { Map> imgPathsList = db.getImagePaths(); for (Map.Entry> entry : imgPathsList.entrySet()) { @@ -721,7 +721,20 @@ public class Case implements SleuthkitCase.ErrorObserver { return xmlcm.getExportDir(); } } - + + /** + * Gets the full path to the log directory for this case. + * + * @return The log directory path. + */ + public String getLogDirectoryPath() { + if (xmlcm == null) { + return ""; + } else { + return xmlcm.getLogDir(); + } + } + /** * get the created date of this case * diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java b/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java index 6f58f1df01..da29925272 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java @@ -18,8 +18,12 @@ */ package org.sleuthkit.autopsy.coreutils; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; import java.io.IOException; import java.util.logging.*; +import org.sleuthkit.autopsy.casemodule.Case; /** * Autopsy specialization of the Java Logger class with custom file handlers. @@ -27,18 +31,47 @@ import java.util.logging.*; public final class Logger extends java.util.logging.Logger { private static final String LOG_ENCODING = PlatformUtil.getLogFileEncoding(); - private static final String LOG_DIR = PlatformUtil.getLogDirectory(); private static final int LOG_SIZE = 0; // In bytes, zero is unlimited private static final int LOG_FILE_COUNT = 10; private static final String LOG_WITHOUT_STACK_TRACES = "autopsy.log"; //NON-NLS private static final String LOG_WITH_STACK_TRACES = "autopsy_traces.log"; //NON-NLS - private static final FileHandler userFriendlyLogFile = createFileHandler(LOG_WITHOUT_STACK_TRACES); - private static final FileHandler developersLogFile = createFileHandler(LOG_WITH_STACK_TRACES); + private static final CaseChangeListener caseChangeListener = new CaseChangeListener(); private static final Handler console = new java.util.logging.ConsoleHandler(); + private static FileHandler userFriendlyLogFile = createFileHandler(PlatformUtil.getLogDirectory(), LOG_WITHOUT_STACK_TRACES); + private static FileHandler developersLogFile = createFileHandler(PlatformUtil.getLogDirectory(), LOG_WITH_STACK_TRACES); - private static FileHandler createFileHandler(String fileName) { + static { + Case.addPropertyChangeListener(caseChangeListener); + } + + private static class CaseChangeListener implements PropertyChangeListener { + + @Override + public void propertyChange(PropertyChangeEvent event) { + if (event.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) { + // Write to logs in the Logs directory of the current case, or + // to logs in the user directory when there is no case. + if (event.getNewValue() != null) { + String logDirectoryPath = ((Case) event.getNewValue()).getLogDirectoryPath(); + if (!logDirectoryPath.isEmpty()) { + userFriendlyLogFile.close(); + userFriendlyLogFile = createFileHandler(logDirectoryPath, LOG_WITHOUT_STACK_TRACES); + developersLogFile.close(); + developersLogFile = createFileHandler(logDirectoryPath, LOG_WITH_STACK_TRACES); + } + } else { + userFriendlyLogFile.close(); + userFriendlyLogFile = createFileHandler(PlatformUtil.getLogDirectory(), LOG_WITHOUT_STACK_TRACES); + developersLogFile.close(); + developersLogFile = createFileHandler(PlatformUtil.getLogDirectory(), LOG_WITH_STACK_TRACES); + } + } + } + } + + private static FileHandler createFileHandler(String logDirectory, String fileName) { try { - FileHandler f = new FileHandler(LOG_DIR + fileName, LOG_SIZE, LOG_FILE_COUNT); + FileHandler f = new FileHandler(logDirectory + File.separator + fileName, LOG_SIZE, LOG_FILE_COUNT); f.setEncoding(LOG_ENCODING); f.setFormatter(new SimpleFormatter()); return f; @@ -113,9 +146,9 @@ public final class Logger extends java.util.logging.Logger { private void logUserFriendlyOnly(Level level, String message, Throwable thrown) { removeHandler(developersLogFile); super.log(level, "{0}\nException: {1}", new Object[]{message, thrown.toString()}); //NON-NLS - addHandler(developersLogFile); + addHandler(developersLogFile); } - + @Override public void throwing(String sourceClass, String sourceMethod, Throwable thrown) { removeHandler(userFriendlyLogFile); From de063b995782065e92cb023aed7bc4a8ab04a6b8 Mon Sep 17 00:00:00 2001 From: alexjacks92 Date: Mon, 2 Jun 2014 16:38:32 -0400 Subject: [PATCH 07/11] Working towards moving both sets of logs for testing. --- .../sleuthkit/autopsy/coreutils/Logger.java | 4 +- test/script/regression.py | 41 ++++++++++++++----- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java b/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java index da29925272..6b2f5c474b 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java @@ -33,8 +33,8 @@ public final class Logger extends java.util.logging.Logger { private static final String LOG_ENCODING = PlatformUtil.getLogFileEncoding(); private static final int LOG_SIZE = 0; // In bytes, zero is unlimited private static final int LOG_FILE_COUNT = 10; - private static final String LOG_WITHOUT_STACK_TRACES = "autopsy.log"; //NON-NLS - private static final String LOG_WITH_STACK_TRACES = "autopsy_traces.log"; //NON-NLS + private static final String LOG_WITHOUT_STACK_TRACES = "autopsy_case.log"; //NON-NLS + private static final String LOG_WITH_STACK_TRACES = "autopsy_case_traces.log"; //NON-NLS private static final CaseChangeListener caseChangeListener = new CaseChangeListener(); private static final Handler console = new java.util.logging.ConsoleHandler(); private static FileHandler userFriendlyLogFile = createFileHandler(PlatformUtil.getLogDirectory(), LOG_WITHOUT_STACK_TRACES); diff --git a/test/script/regression.py b/test/script/regression.py index 6cc3dd9917..ce289edbb4 100755 --- a/test/script/regression.py +++ b/test/script/regression.py @@ -142,7 +142,7 @@ class TestRunner(object): test_data.printerror = Errors.printerror # give solr process time to die. time.sleep(10) - + print("Total ingest time was " + test_data.total_ingest_time) Reports.write_html_foot(test_config.html_log) if test_config.jenkins: @@ -1200,17 +1200,18 @@ class Logs(object): test_data: the TestData to modify """ try: - # Open autopsy.log.0 - log_path = make_path(test_data.logs_dir, "autopsy.log.0") + # Open autopsy_case.log.0 + log_path = make_path(test_data.logs_dir, "autopsy_case.log.0") log = open(log_path) - # Set the TestData start time based off the first line of autopsy.log.0 + # Set the TestData start time based off the first line of autopsy_case.log.0 # *** If logging time format ever changes this will break *** test_data.start_date = log.readline().split(" org.")[0] + print("1210") # Set the test_data ending time based off the "create" time (when the file was copied) test_data.end_date = time.ctime(os.path.getmtime(log_path)) except IOError as e: - Errors.print_error("Error: Unable to open autopsy.log.0.") + Errors.print_error("Error: Unable to open autopsy_case.log.0.") Errors.print_error(str(e) + "\n") logging.warning(traceback.format_exc()) # Start date must look like: "Jul 16, 2012 12:57:53 PM" @@ -1224,9 +1225,10 @@ class Logs(object): # Set Autopsy version, heap space, ingest time, and service times version_line = search_logs("INFO: Application name: Autopsy, version:", test_data)[0] + print("1228") test_data.autopsy_version = get_word_at(version_line, 5).rstrip(",") test_data.heap_space = search_logs("Heap memory usage:", test_data)[0].rstrip().split(": ")[1] - + print("1231") ingest_line = search_logs("Ingest (including enqueue)", test_data)[0] test_data.total_ingest_time = get_word_at(ingest_line, 6).rstrip() @@ -1245,7 +1247,7 @@ class Logs(object): logging.critical(traceback.format_exc()) print(traceback.format_exc()) try: - service_lines = find_msg_in_log("autopsy.log.0", "to process()", test_data) + service_lines = find_msg_in_log("autopsy_case.log.0", "to process()", test_data) service_list = [] for line in service_lines: words = line.split(" ") @@ -1253,11 +1255,16 @@ class Logs(object): # If this format changes, the tester will break i = words.index("secs.") times = words[i-4] + " " + print("1") times += words[i-3] + " " + print("2") times += words[i-2] + " " + print("3") times += words[i-1] + " " + print("4") times += words[i] service_list.append(times) + print("5") test_data.service_times = "; ".join(service_list) except (OSError, IOError) as e: Errors.print_error("Error: Unknown fatal error when finding service times.") @@ -1361,11 +1368,22 @@ def copy_logs(test_data): test_data: the TestData whose logs will be copied """ try: - log_dir = os.path.join("..", "..", "Testing","build","test","qa-functional","work","userdir0","var","log") + # copy logs from autopsy case's Log folder + log_dir = os.path.join(test_data.output_path, AUTOPSY_TEST_CASE, "Log") shutil.copytree(log_dir, test_data.logs_dir) + + # copy logs from userdir0 + log_dir = os.path.join("..", "..", "Testing","build","test","qa-functional","work","userdir0","var","log/") + print("log_dir is " + log_dir) + for log in log_dir: + new_name = "userdir0." + log + os.rename(log, new_name) + print("a log name is " + log) + print("log_dir is " + log_dir) + shutil.copytree(log_dir, test_data.logs_dir) except OSError as e: - printerror(test_data,"Error: Failed to copy the logs.") - printerror(test_data,str(e) + "\n") + print(test_data,"Error: Failed to copy the logs.") + print(test_data,str(e) + "\n") logging.warning(traceback.format_exc()) def setDay(): @@ -1655,6 +1673,7 @@ def search_logs(string, test_data): logs_path = test_data.logs_dir results = [] for file in os.listdir(logs_path): + print(file) log = codecs.open(make_path(logs_path, file), "r", "utf_8") for line in log: if string in line: @@ -1739,7 +1758,7 @@ def find_msg_in_log(log, string, test_data): """ lines = [] try: - lines = search_log("autopsy.log.0", string, test_data)[0] + lines = search_log("autopsy_case.log.0", string, test_data)[0] except (Exception) as e: # there weren't any matching messages found pass From 2382a3c023e284086ae22775833523863c502bd1 Mon Sep 17 00:00:00 2001 From: alexjacks92 Date: Tue, 3 Jun 2014 12:51:10 -0400 Subject: [PATCH 08/11] Tests now pull in both sets of logs for diffing. --- test/script/regression.py | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/test/script/regression.py b/test/script/regression.py index ce289edbb4..628ba10538 100755 --- a/test/script/regression.py +++ b/test/script/regression.py @@ -1207,7 +1207,6 @@ class Logs(object): # Set the TestData start time based off the first line of autopsy_case.log.0 # *** If logging time format ever changes this will break *** test_data.start_date = log.readline().split(" org.")[0] - print("1210") # Set the test_data ending time based off the "create" time (when the file was copied) test_data.end_date = time.ctime(os.path.getmtime(log_path)) except IOError as e: @@ -1225,10 +1224,8 @@ class Logs(object): # Set Autopsy version, heap space, ingest time, and service times version_line = search_logs("INFO: Application name: Autopsy, version:", test_data)[0] - print("1228") test_data.autopsy_version = get_word_at(version_line, 5).rstrip(",") test_data.heap_space = search_logs("Heap memory usage:", test_data)[0].rstrip().split(": ")[1] - print("1231") ingest_line = search_logs("Ingest (including enqueue)", test_data)[0] test_data.total_ingest_time = get_word_at(ingest_line, 6).rstrip() @@ -1255,15 +1252,10 @@ class Logs(object): # If this format changes, the tester will break i = words.index("secs.") times = words[i-4] + " " - print("1") times += words[i-3] + " " - print("2") times += words[i-2] + " " - print("3") times += words[i-1] + " " - print("4") times += words[i] - service_list.append(times) print("5") test_data.service_times = "; ".join(service_list) except (OSError, IOError) as e: @@ -1374,13 +1366,12 @@ def copy_logs(test_data): # copy logs from userdir0 log_dir = os.path.join("..", "..", "Testing","build","test","qa-functional","work","userdir0","var","log/") - print("log_dir is " + log_dir) - for log in log_dir: - new_name = "userdir0." + log - os.rename(log, new_name) - print("a log name is " + log) - print("log_dir is " + log_dir) - shutil.copytree(log_dir, test_data.logs_dir) + for log in os.listdir(log_dir): + if log.find("log"): + new_name = log_dir + "userdir0." + log + log = log_dir + log + shutil.move(log, new_name) + shutil.copy(new_name, test_data.logs_dir) except OSError as e: print(test_data,"Error: Failed to copy the logs.") print(test_data,str(e) + "\n") @@ -1574,15 +1565,11 @@ class Args(object): arg = sys.argv.pop(0) nxtproc.append(arg) if(arg == "-f"): - #try: @@@ Commented out until a more specific except statement is added arg = sys.argv.pop(0) print("Running on a single file:") print(path_fix(arg) + "\n") self.single = True self.single_file = path_fix(arg) - #except: - # print("Error: No single file given.\n") - # return False elif(arg == "-r" or arg == "--rebuild"): print("Running in rebuild mode.\n") self.rebuild = True @@ -1673,7 +1660,6 @@ def search_logs(string, test_data): logs_path = test_data.logs_dir results = [] for file in os.listdir(logs_path): - print(file) log = codecs.open(make_path(logs_path, file), "r", "utf_8") for line in log: if string in line: @@ -1776,8 +1762,8 @@ def clear_dir(dir): os.makedirs(dir) return True; except OSError as e: - printerror(test_data,"Error: Cannot clear the given directory:") - printerror(test_data,dir + "\n") + print_error(test_data,"Error: Cannot clear the given directory:") + print_error(test_data,dir + "\n") print(str(e)) return False; @@ -1792,8 +1778,8 @@ def del_dir(dir): shutil.rmtree(dir) return True; except: - printerror(test_data,"Error: Cannot delete the given directory:") - printerror(test_data,dir + "\n") + print_error(test_data,"Error: Cannot delete the given directory:") + print_error(test_data,dir + "\n") return False; def get_file_in_dir(dir, ext): From 977d34b07bc9c33472402856e373501e6643e9ff Mon Sep 17 00:00:00 2001 From: alexjacks92 Date: Tue, 3 Jun 2014 13:30:50 -0400 Subject: [PATCH 09/11] Documentation and code clean up. --- test/script/regression.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/script/regression.py b/test/script/regression.py index 628ba10538..a4276bc9a6 100755 --- a/test/script/regression.py +++ b/test/script/regression.py @@ -1256,7 +1256,7 @@ class Logs(object): times += words[i-2] + " " times += words[i-1] + " " times += words[i] - print("5") + service_list.append(times) test_data.service_times = "; ".join(service_list) except (OSError, IOError) as e: Errors.print_error("Error: Unknown fatal error when finding service times.") @@ -1364,7 +1364,7 @@ def copy_logs(test_data): log_dir = os.path.join(test_data.output_path, AUTOPSY_TEST_CASE, "Log") shutil.copytree(log_dir, test_data.logs_dir) - # copy logs from userdir0 + # copy logs from userdir0/var/log log_dir = os.path.join("..", "..", "Testing","build","test","qa-functional","work","userdir0","var","log/") for log in os.listdir(log_dir): if log.find("log"): @@ -1373,8 +1373,8 @@ def copy_logs(test_data): shutil.move(log, new_name) shutil.copy(new_name, test_data.logs_dir) except OSError as e: - print(test_data,"Error: Failed to copy the logs.") - print(test_data,str(e) + "\n") + print_error(test_data,"Error: Failed to copy the logs.") + print_error(test_data,str(e) + "\n") logging.warning(traceback.format_exc()) def setDay(): From a3dfd9c4b5bec827bf247c554140b4af362968c8 Mon Sep 17 00:00:00 2001 From: alexjacks92 Date: Thu, 5 Jun 2014 10:04:59 -0400 Subject: [PATCH 10/11] Reverting to old log naming conventions. --- Core/src/org/sleuthkit/autopsy/coreutils/Logger.java | 4 ++-- test/script/regression.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java b/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java index 6b2f5c474b..da29925272 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/Logger.java @@ -33,8 +33,8 @@ public final class Logger extends java.util.logging.Logger { private static final String LOG_ENCODING = PlatformUtil.getLogFileEncoding(); private static final int LOG_SIZE = 0; // In bytes, zero is unlimited private static final int LOG_FILE_COUNT = 10; - private static final String LOG_WITHOUT_STACK_TRACES = "autopsy_case.log"; //NON-NLS - private static final String LOG_WITH_STACK_TRACES = "autopsy_case_traces.log"; //NON-NLS + private static final String LOG_WITHOUT_STACK_TRACES = "autopsy.log"; //NON-NLS + private static final String LOG_WITH_STACK_TRACES = "autopsy_traces.log"; //NON-NLS private static final CaseChangeListener caseChangeListener = new CaseChangeListener(); private static final Handler console = new java.util.logging.ConsoleHandler(); private static FileHandler userFriendlyLogFile = createFileHandler(PlatformUtil.getLogDirectory(), LOG_WITHOUT_STACK_TRACES); diff --git a/test/script/regression.py b/test/script/regression.py index a4276bc9a6..dafc239a1c 100755 --- a/test/script/regression.py +++ b/test/script/regression.py @@ -1200,17 +1200,17 @@ class Logs(object): test_data: the TestData to modify """ try: - # Open autopsy_case.log.0 - log_path = make_path(test_data.logs_dir, "autopsy_case.log.0") + # Open autopsy.log.0 + log_path = make_path(test_data.logs_dir, "autopsy.log.0") log = open(log_path) - # Set the TestData start time based off the first line of autopsy_case.log.0 + # Set the TestData start time based off the first line of autopsy.log.0 # *** If logging time format ever changes this will break *** test_data.start_date = log.readline().split(" org.")[0] # Set the test_data ending time based off the "create" time (when the file was copied) test_data.end_date = time.ctime(os.path.getmtime(log_path)) except IOError as e: - Errors.print_error("Error: Unable to open autopsy_case.log.0.") + Errors.print_error("Error: Unable to open autopsy.log.0.") Errors.print_error(str(e) + "\n") logging.warning(traceback.format_exc()) # Start date must look like: "Jul 16, 2012 12:57:53 PM" @@ -1244,7 +1244,7 @@ class Logs(object): logging.critical(traceback.format_exc()) print(traceback.format_exc()) try: - service_lines = find_msg_in_log("autopsy_case.log.0", "to process()", test_data) + service_lines = find_msg_in_log("autopsy.log.0", "to process()", test_data) service_list = [] for line in service_lines: words = line.split(" ") @@ -1744,7 +1744,7 @@ def find_msg_in_log(log, string, test_data): """ lines = [] try: - lines = search_log("autopsy_case.log.0", string, test_data)[0] + lines = search_log("autopsy.log.0", string, test_data)[0] except (Exception) as e: # there weren't any matching messages found pass From 7f4d2ac75f35661901471be25b8f7585f3c6f4ae Mon Sep 17 00:00:00 2001 From: alexjacks92 Date: Thu, 5 Jun 2014 10:23:06 -0400 Subject: [PATCH 11/11] Bug with moving userdir logs fixed. --- test/script/regression.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/script/regression.py b/test/script/regression.py index dafc239a1c..c36dcefc00 100755 --- a/test/script/regression.py +++ b/test/script/regression.py @@ -1371,7 +1371,8 @@ def copy_logs(test_data): new_name = log_dir + "userdir0." + log log = log_dir + log shutil.move(log, new_name) - shutil.copy(new_name, test_data.logs_dir) + shutil.copy(new_name, test_data.logs_dir) + shutil.move(new_name, log) except OSError as e: print_error(test_data,"Error: Failed to copy the logs.") print_error(test_data,str(e) + "\n")