From 24379c7cca40f6f08999c8280cd127bc146646fc Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 20 Sep 2019 17:39:33 -0400 Subject: [PATCH] Fixes to Save Tagged Hashes module --- .../modules/hashdatabase/HashDbManager.java | 4 +-- .../HashesReportModuleSettings.java | 17 ++++++----- .../SaveTaggedHashesToHashDbConfigPanel.form | 2 +- .../SaveTaggedHashesToHashDbConfigPanel.java | 30 ++++++++++++------- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java index 9c7e536f01..3b90240ebc 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java @@ -693,9 +693,7 @@ public class HashDbManager implements PropertyChangeListener { return filePath; } - public static abstract class HashDb implements Serializable { - - private static final long serialVersionUID = 1L; + public static abstract class HashDb { /** * Indicates how files with hashes stored in a particular hash database diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/HashesReportModuleSettings.java b/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/HashesReportModuleSettings.java index 097e141ee3..77ca2894ff 100755 --- a/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/HashesReportModuleSettings.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/HashesReportModuleSettings.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.report.modules.taggedhashes; -import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb; import org.sleuthkit.autopsy.report.ReportModuleSettings; /** @@ -28,7 +27,7 @@ class HashesReportModuleSettings implements ReportModuleSettings { private static final long serialVersionUID = 1L; private final boolean exportAllTags; - private final HashDb hashDb; + private final String hashDbName; @Override public long getVersionNumber() { @@ -40,18 +39,18 @@ class HashesReportModuleSettings implements ReportModuleSettings { */ HashesReportModuleSettings() { exportAllTags = true; - hashDb = null; + hashDbName = ""; } /** * Configuration for the Tagged Hashes report module. * * @param exportAllTags Flag whether to export all tags. - * @param hashDb Selected HashDb object to export to + * @param hashDbName Name of selected hash database to export to */ - HashesReportModuleSettings(boolean exportAllTags, HashDb hashDb) { + HashesReportModuleSettings(boolean exportAllTags, String hashDbName) { this.exportAllTags = exportAllTags; - this.hashDb = hashDb; + this.hashDbName = hashDbName; } /** @@ -64,9 +63,11 @@ class HashesReportModuleSettings implements ReportModuleSettings { } /** + * Get name of the selected hash database. + * * @return the hashDb */ - public HashDb getHashDb() { - return hashDb; + public String getHashDbName() { + return hashDbName; } } diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDbConfigPanel.form b/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDbConfigPanel.form index ae76eeb26d..6047a7a789 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDbConfigPanel.form +++ b/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDbConfigPanel.form @@ -129,7 +129,7 @@ - + diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDbConfigPanel.java b/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDbConfigPanel.java index 3ad9990f06..d86b0f184a 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDbConfigPanel.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDbConfigPanel.java @@ -56,7 +56,8 @@ class SaveTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel { private Map tagNameSelections = new LinkedHashMap<>(); private TagNamesListModel tagsNamesListModel = new TagNamesListModel(); private TagsNamesListCellRenderer tagsNamesRenderer = new TagsNamesListCellRenderer(); - private HashDb selectedHashSet = null; + private String selectedHashSetName; + private List updateableHashSets = new ArrayList<>(); SaveTaggedHashesToHashDbConfigPanel() { initComponents(); @@ -74,7 +75,7 @@ class SaveTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel { } HashesReportModuleSettings getConfiguration() { - return new HashesReportModuleSettings(jAllTagsCheckBox.isSelected(), selectedHashSet); + return new HashesReportModuleSettings(jAllTagsCheckBox.isSelected(), selectedHashSetName); } void setConfiguration(HashesReportModuleSettings settings) { @@ -84,11 +85,14 @@ class SaveTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel { // update tag selection jAllTagsCheckBox.setSelected(settings.isExportAllTags()); + if (settings.isExportAllTags()) { + selectAllTags(true); + } // update hash database selection - if (settings.getHashDb() != null) { + if (settings.getHashDbName() != null) { populateHashSetComponents(); - hashSetsComboBox.setSelectedItem(settings.getHashDb()); + hashSetsComboBox.setSelectedItem(settings.getHashDbName()); } } @@ -147,13 +151,14 @@ class SaveTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel { // Clear the components because this method is called both during construction // and when the user changes the hash set configuration. hashSetsComboBox.removeAllItems(); - + selectedHashSetName = ""; + // Get the updateable hash databases and add their hash set names to the // JComboBox component. - List updateableHashSets = HashDbManager.getInstance().getUpdateableHashSets(); + updateableHashSets = HashDbManager.getInstance().getUpdateableHashSets(); if (!updateableHashSets.isEmpty()) { for (HashDb hashDb : updateableHashSets) { - hashSetsComboBox.addItem(hashDb); + hashSetsComboBox.addItem(hashDb.getHashSetName()); } hashSetsComboBox.setEnabled(true); } else { @@ -182,7 +187,12 @@ class SaveTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel { * @return A HashDb object representing the database or null. */ HashDb getSelectedHashDatabase() { - return selectedHashSet; + for (HashDb hashDb : updateableHashSets) { + if (hashDb.getHashSetName().equals(selectedHashSetName)) { + return hashDb; + } + } + return null; } // This class is a list model for the tag names JList component. @@ -341,7 +351,7 @@ class SaveTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel { }//GEN-LAST:event_selectAllButtonActionPerformed private void hashSetsComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hashSetsComboBoxActionPerformed - selectedHashSet = (HashDb)hashSetsComboBox.getSelectedItem(); + selectedHashSetName = (String)hashSetsComboBox.getSelectedItem(); }//GEN-LAST:event_hashSetsComboBoxActionPerformed private void deselectAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deselectAllButtonActionPerformed @@ -377,7 +387,7 @@ class SaveTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton configureHashDatabasesButton; private javax.swing.JButton deselectAllButton; - private javax.swing.JComboBox hashSetsComboBox; + private javax.swing.JComboBox hashSetsComboBox; private javax.swing.JCheckBox jAllTagsCheckBox; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2;