Merge pull request #5239 from eugene7646/tagged_hashes_bugs

Tagged hashes bugs (5554)
This commit is contained in:
Richard Cordovano 2019-09-23 12:44:48 -04:00 committed by GitHub
commit 54da8ed11f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 22 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -129,7 +129,7 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="hashSetsComboBoxActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;HashDb&gt;"/>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="configureHashDatabasesButton">

View File

@ -56,7 +56,8 @@ class SaveTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel {
private Map<String, Boolean> tagNameSelections = new LinkedHashMap<>();
private TagNamesListModel tagsNamesListModel = new TagNamesListModel();
private TagsNamesListCellRenderer tagsNamesRenderer = new TagsNamesListCellRenderer();
private HashDb selectedHashSet = null;
private String selectedHashSetName;
private List<HashDb> 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<HashDb> 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<HashDb> hashSetsComboBox;
private javax.swing.JComboBox<String> hashSetsComboBox;
private javax.swing.JCheckBox jAllTagsCheckBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;