From 2bb8ce29fb828ab6664ebad5fd1a68b25467054d Mon Sep 17 00:00:00 2001 From: Oliver Spohngellert Date: Wed, 9 Mar 2016 16:18:35 -0500 Subject: [PATCH] Made changes as per pr notes --- Core/nbproject/project.xml | 9 -- .../interestingitems/Bundle.properties | 6 +- ...FilesIdentifierIngestJobSettingsPanel.java | 16 +- .../FilesIdentifierIngestModule.java | 11 +- .../modules/interestingitems/FilesSet.java | 65 ++++---- .../interestingitems/FilesSetRulePanel.form | 36 ++--- .../interestingitems/FilesSetRulePanel.java | 149 +++++++++--------- .../InterestingItemDefsManager.java | 56 +++---- .../InterestingItemDefsPanel.java | 22 ++- .../InterestingItemsIngestModuleFactory.java | 10 +- 10 files changed, 202 insertions(+), 178 deletions(-) diff --git a/Core/nbproject/project.xml b/Core/nbproject/project.xml index 9e144a3a62..a2ddc46460 100644 --- a/Core/nbproject/project.xml +++ b/Core/nbproject/project.xml @@ -6,15 +6,6 @@ org.sleuthkit.autopsy.core - - org.jdesktop.beansbinding - - - - 1 - 1.24.1.121 - - org.netbeans.api.progress diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties index 85403fb1d2..3a1ced09a3 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties @@ -62,6 +62,6 @@ FilesSetRulePanel.nameCheck.text=Name Pattern: FilesSetRulePanel.pathCheck.text=Path Pattern: FilesSetRulePanel.mimeCheck.text=MIME Type: FilesSetRulePanel.fileSizeCheck.text=File Size: -FilesSetRulePanel.filesRadio.text=Files -FilesSetRulePanel.dirsRadio.text=Directories -FilesSetRulePanel.filesAndDirsRadio.text=Files and Directories +FilesSetRulePanel.filesRadioButton.text=Files +FilesSetRulePanel.dirsRadioButton.text=Directories +FilesSetRulePanel.filesAndDirsRadioButton.text=Files and Directories diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestJobSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestJobSettingsPanel.java index a9a17c984e..6af0110956 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestJobSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestJobSettingsPanel.java @@ -26,6 +26,8 @@ import java.util.TreeMap; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; +import org.openide.util.Exceptions; +import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettingsPanel; @@ -75,7 +77,11 @@ final class FilesIdentifierIngestJobSettingsPanel extends IngestModuleIngestJobS * Observer.update(). */ List filesSetRows = new ArrayList<>(); - this.filesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets()); + try { + this.filesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets()); + } catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) { + MessageNotifyUtil.Message.error("Test Error"); + } for (FilesSet set : this.filesSetSnapshot.values()) { filesSetRows.add(new FilesSetRow(set, settings.interestingFilesSetIsEnabled(set.getName()))); } @@ -130,7 +136,13 @@ final class FilesIdentifierIngestJobSettingsPanel extends IngestModuleIngestJobS // Refresh the view of the interesting files set definitions. List rowModels = new ArrayList<>(); - TreeMap newFilesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets()); + TreeMap newFilesSetSnapshot; + try { + newFilesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets()); + } catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) { + MessageNotifyUtil.Message.error("Test error"); + return; + } for (FilesSet set : newFilesSetSnapshot.values()) { if (this.filesSetSnapshot.keySet().contains(set.getName())) { // Preserve the current enabled/diabled state of the set. diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestModule.java index ae93cbbc74..dfa7763ff7 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestModule.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.services.Blackboard; @@ -77,10 +78,14 @@ final class FilesIdentifierIngestModule implements FileIngestModule { // synchronized definitions manager method eliminates the need // to disable the interesting files set definition UI during ingest. List filesSets = new ArrayList<>(); - for (FilesSet set : InterestingItemDefsManager.getInstance().getInterestingFilesSets().values()) { - if (settings.interestingFilesSetIsEnabled(set.getName())) { - filesSets.add(set); + try { + for (FilesSet set : InterestingItemDefsManager.getInstance().getInterestingFilesSets().values()) { + if (settings.interestingFilesSetIsEnabled(set.getName())) { + filesSets.add(set); + } } + } catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) { + throw new IngestModuleException("Test"); } FilesIdentifierIngestModule.interestingFileSetsByJob.put(context.getJobId(), filesSets); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSet.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSet.java index 6c95ccbe2b..de807b0672 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSet.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSet.java @@ -153,9 +153,11 @@ final class FilesSet implements Serializable { * Construct an interesting files set membership rule. * * @param ruleName The name of the rule. Can be empty string. - * @param fileNameCondition A file name condition. + * @param fileNameCondition A file name condition, may be null. * @param metaTypeCondition A file meta-type condition. * @param pathCondition A file path condition, may be null. + * @param mimeTypeCondition A file mime type condition, may be null. + * @param fileSizeCondition A file size condition, may be null. */ Rule(String ruleName, FileNameCondition fileNameCondition, MetaTypeCondition metaTypeCondition, ParentPathCondition pathCondition, MimeTypeCondition mimeTypeCondition, FileSizeCondition fileSizeCondition) { // since ruleName is optional, ruleUUID can be used to uniquely identify a rule. @@ -227,7 +229,7 @@ final class FilesSet implements Serializable { /** * Get the path condition for the rule. * - * @return A path condition, may be null. Can be null. + * @return A path condition, may be null. */ ParentPathCondition getPathCondition() { return this.pathCondition; @@ -299,8 +301,7 @@ final class FilesSet implements Serializable { static interface FileAttributeCondition extends Serializable { /** - * Tests whether or not a file satisfies the conditions of a - * condition. + * Tests whether or not a file satisfies the condition. * * @param file The file to test. * @@ -353,33 +354,7 @@ final class FilesSet implements Serializable { private static final long serialVersionUID = 1L; - /** - * Gets the comparator of this condition - * - * @return the comparator - */ - COMPARATOR getComparator() { - return comparator; - } - - /** - * Gets the unit for the size of this condition - * - * @return the unit - */ - SIZE_UNIT getUnit() { - return unit; - } - - /** - * Gets the size value of this condition - * - * @return the size value - */ - int getSizeValue() { - return sizeValue; - } - + /** * Represents a comparison item for file size */ @@ -467,6 +442,34 @@ final class FilesSet implements Serializable { this.unit = unit; this.sizeValue = sizeValue; } + + /** + * Gets the comparator of this condition + * + * @return the comparator + */ + COMPARATOR getComparator() { + return comparator; + } + + /** + * Gets the unit for the size of this condition + * + * @return the unit + */ + SIZE_UNIT getUnit() { + return unit; + } + + /** + * Gets the size value of this condition + * + * @return the size value + */ + int getSizeValue() { + return sizeValue; + } + @Override public boolean passes(AbstractFile file) { diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetRulePanel.form b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetRulePanel.form index 82bdad5213..72b506199a 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetRulePanel.form +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetRulePanel.form @@ -38,11 +38,11 @@ - + - + - + @@ -109,9 +109,9 @@ - - - + + + @@ -199,6 +199,9 @@ + + + @@ -261,9 +264,6 @@ - - - @@ -344,43 +344,43 @@ - + - + - + - + - + - + - + - + - + diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetRulePanel.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetRulePanel.java index 8779f7eb16..efbc2197c8 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetRulePanel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetRulePanel.java @@ -69,10 +69,11 @@ final class FilesSetRulePanel extends javax.swing.JPanel { /** * Constructs a files set rule panel in create rule mode. */ - FilesSetRulePanel() { + FilesSetRulePanel(JButton okButton, JButton cancelButton) { initComponents(); + populateMimeTypesComboBox(); populateComponentsWithDefaultValues(); - customInit(); + this.setButtons(okButton, cancelButton); } /** @@ -80,26 +81,29 @@ final class FilesSetRulePanel extends javax.swing.JPanel { * * @param rule The files set rule to be edited. */ - FilesSetRulePanel(FilesSet.Rule rule) { + FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton) { initComponents(); + populateMimeTypesComboBox(); populateRuleNameComponent(rule); populateTypeConditionComponents(rule); populateNameConditionComponents(rule); populatePathConditionComponents(rule); - customInit(); + populateMimeConditionComponents(rule); + this.setButtons(okButton, cancelButton); } /** * Populates the UI components with default values. */ private void populateComponentsWithDefaultValues() { - this.filesRadio.setSelected(true); + this.filesRadioButton.setSelected(true); this.fullNameRadioButton.setSelected(true); - this.equalitySymbolComboBox.setSelectedIndex(2); - this.fileSizeComboBox.setSelectedIndex(1); + this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol()); + this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName()); + this.mimeTypeComboBox.setSelectedIndex(0); } - private void customInit() { + private void populateMimeTypesComboBox() { Set fileTypesCollated = new HashSet<>(); for (MediaType mediaType : mediaTypes) { fileTypesCollated.add(mediaType.toString()); @@ -139,18 +143,21 @@ final class FilesSetRulePanel extends javax.swing.JPanel { this.ruleNameTextField.setText(rule.getName()); } + private void populateMimeConditionComponents(FilesSet.Rule rule) { + FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition(); + if (mimeTypeCondition != null) { + this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType()); + } + } + /** * Sets whether or not the OK button should be enabled based upon other UI * elements */ private void setOkButton() { if (this.okButton != null) { - if (!(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected() - || this.nameCheck.isSelected() || this.pathCheck.isSelected())) { - this.okButton.setEnabled(false); - } else { - this.okButton.setEnabled(true); - } + this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected() + || this.nameCheck.isSelected() || this.pathCheck.isSelected()); } } @@ -177,7 +184,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel { * @param ok The ok button * @param cancel The cancel button */ - public void setButtons(JButton ok, JButton cancel) { + private void setButtons(JButton ok, JButton cancel) { this.okButton = ok; this.cancelButton = cancel; okButton.addActionListener(new ActionListener() { @@ -207,13 +214,13 @@ final class FilesSetRulePanel extends javax.swing.JPanel { FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition(); switch (typeCondition.getMetaType()) { case FILES: - this.filesRadio.setSelected(true); + this.filesRadioButton.setSelected(true); break; case DIRECTORIES: - this.dirsRadio.setSelected(true); + this.dirsRadioButton.setSelected(true); break; case FILES_AND_DIRECTORIES: - this.filesAndDirsRadio.setSelected(true); + this.filesAndDirsRadioButton.setSelected(true); break; } } @@ -418,14 +425,10 @@ final class FilesSetRulePanel extends javax.swing.JPanel { FilesSet.Rule.FileSizeCondition getFileSizeCondition() { FilesSet.Rule.FileSizeCondition condition = null; if ((Integer) this.fileSizeSpinner.getValue() != 0) { - try { - FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem()); - FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem()); - int fileSizeValue = (Integer) this.fileSizeSpinner.getValue(); - condition = new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue); - } catch (IllegalArgumentException ex) { - //Swallowing up exception because if invalid data is given, this should return null - } + FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem()); + FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem()); + int fileSizeValue = (Integer) this.fileSizeSpinner.getValue(); + condition = new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue); } return condition; } @@ -437,9 +440,9 @@ final class FilesSetRulePanel extends javax.swing.JPanel { * @return A type condition. */ FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() { - if (this.filesRadio.isSelected()) { + if (this.filesRadioButton.isSelected()) { return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES); - } else if (this.dirsRadio.isSelected()) { + } else if (this.dirsRadioButton.isSelected()) { return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES); } else { return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES); @@ -509,7 +512,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel { * state of the UI components in the type button group. */ private void setComponentsForSearchType() { - if (!this.filesRadio.isSelected()) { + if (!this.filesRadioButton.isSelected()) { this.fullNameRadioButton.setSelected(true); this.extensionRadioButton.setEnabled(false); this.mimeTypeComboBox.setEnabled(false); @@ -560,9 +563,9 @@ final class FilesSetRulePanel extends javax.swing.JPanel { pathCheck = new javax.swing.JCheckBox(); mimeCheck = new javax.swing.JCheckBox(); fileSizeCheck = new javax.swing.JCheckBox(); - filesRadio = new javax.swing.JRadioButton(); - dirsRadio = new javax.swing.JRadioButton(); - filesAndDirsRadio = new javax.swing.JRadioButton(); + filesRadioButton = new javax.swing.JRadioButton(); + dirsRadioButton = new javax.swing.JRadioButton(); + filesAndDirsRadioButton = new javax.swing.JRadioButton(); org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameLabel.text")); // NOI18N @@ -581,6 +584,11 @@ final class FilesSetRulePanel extends javax.swing.JPanel { nameButtonGroup.add(fullNameRadioButton); org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fullNameRadioButton.text")); // NOI18N fullNameRadioButton.setEnabled(false); + fullNameRadioButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + fullNameRadioButtonActionPerformed(evt); + } + }); nameButtonGroup.add(extensionRadioButton); org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.extensionRadioButton.text")); // NOI18N @@ -604,11 +612,6 @@ final class FilesSetRulePanel extends javax.swing.JPanel { mimeTypeComboBox.setEditable(true); mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] {""})); mimeTypeComboBox.setEnabled(false); - mimeTypeComboBox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - mimeTypeComboBoxActionPerformed(evt); - } - }); equalitySymbolComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "=", ">", "≥", "<", "≤" })); equalitySymbolComboBox.setEnabled(false); @@ -647,27 +650,27 @@ final class FilesSetRulePanel extends javax.swing.JPanel { } }); - typeButtonGroup.add(filesRadio); - org.openide.awt.Mnemonics.setLocalizedText(filesRadio, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesRadio.text")); // NOI18N - filesRadio.addActionListener(new java.awt.event.ActionListener() { + typeButtonGroup.add(filesRadioButton); + org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesRadioButton.text")); // NOI18N + filesRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - filesRadioActionPerformed(evt); + filesRadioButtonActionPerformed(evt); } }); - typeButtonGroup.add(dirsRadio); - org.openide.awt.Mnemonics.setLocalizedText(dirsRadio, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dirsRadio.text")); // NOI18N - dirsRadio.addActionListener(new java.awt.event.ActionListener() { + typeButtonGroup.add(dirsRadioButton); + org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dirsRadioButton.text")); // NOI18N + dirsRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - dirsRadioActionPerformed(evt); + dirsRadioButtonActionPerformed(evt); } }); - typeButtonGroup.add(filesAndDirsRadio); - org.openide.awt.Mnemonics.setLocalizedText(filesAndDirsRadio, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesAndDirsRadio.text")); // NOI18N - filesAndDirsRadio.addActionListener(new java.awt.event.ActionListener() { + typeButtonGroup.add(filesAndDirsRadioButton); + org.openide.awt.Mnemonics.setLocalizedText(filesAndDirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesAndDirsRadioButton.text")); // NOI18N + filesAndDirsRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - filesAndDirsRadioActionPerformed(evt); + filesAndDirsRadioButtonActionPerformed(evt); } }); @@ -690,11 +693,11 @@ final class FilesSetRulePanel extends javax.swing.JPanel { .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addGap(65, 65, 65) - .addComponent(filesRadio) + .addComponent(filesRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(dirsRadio) + .addComponent(dirsRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(filesAndDirsRadio))) + .addComponent(filesAndDirsRadioButton))) .addGap(0, 0, Short.MAX_VALUE)))) .addGroup(layout.createSequentialGroup() .addContainerGap() @@ -743,9 +746,9 @@ final class FilesSetRulePanel extends javax.swing.JPanel { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) - .addComponent(filesRadio) - .addComponent(dirsRadio) - .addComponent(filesAndDirsRadio)) + .addComponent(filesRadioButton) + .addComponent(dirsRadioButton) + .addComponent(filesAndDirsRadioButton)) .addGap(5, 5, 5) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -839,32 +842,32 @@ final class FilesSetRulePanel extends javax.swing.JPanel { this.setOkButton(); }//GEN-LAST:event_fileSizeCheckActionPerformed - private void mimeTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mimeTypeComboBoxActionPerformed + private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesRadioButtonActionPerformed + + this.setComponentsForSearchType(); + }//GEN-LAST:event_filesRadioButtonActionPerformed + + private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioButtonActionPerformed + this.setComponentsForSearchType(); + }//GEN-LAST:event_dirsRadioButtonActionPerformed + + private void filesAndDirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesAndDirsRadioButtonActionPerformed + this.setComponentsForSearchType(); + }//GEN-LAST:event_filesAndDirsRadioButtonActionPerformed + + private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fullNameRadioButtonActionPerformed // TODO add your handling code here: - }//GEN-LAST:event_mimeTypeComboBoxActionPerformed - - private void filesRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesRadioActionPerformed - - this.setComponentsForSearchType(); - }//GEN-LAST:event_filesRadioActionPerformed - - private void dirsRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioActionPerformed - this.setComponentsForSearchType(); - }//GEN-LAST:event_dirsRadioActionPerformed - - private void filesAndDirsRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesAndDirsRadioActionPerformed - this.setComponentsForSearchType(); - }//GEN-LAST:event_filesAndDirsRadioActionPerformed + }//GEN-LAST:event_fullNameRadioButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JRadioButton dirsRadio; + private javax.swing.JRadioButton dirsRadioButton; private javax.swing.JComboBox equalitySymbolComboBox; private javax.swing.JRadioButton extensionRadioButton; private javax.swing.JCheckBox fileSizeCheck; private javax.swing.JComboBox fileSizeComboBox; private javax.swing.JSpinner fileSizeSpinner; - private javax.swing.JRadioButton filesAndDirsRadio; - private javax.swing.JRadioButton filesRadio; + private javax.swing.JRadioButton filesAndDirsRadioButton; + private javax.swing.JRadioButton filesRadioButton; private javax.swing.JRadioButton fullNameRadioButton; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel5; diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsManager.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsManager.java index 6f5afbce86..db558a9f13 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsManager.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsManager.java @@ -32,11 +32,6 @@ import java.util.Observable; import java.util.logging.Level; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import javax.persistence.PersistenceException; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.openide.util.Exceptions; import org.openide.util.io.NbObjectInputStream; import org.openide.util.io.NbObjectOutputStream; import org.sleuthkit.autopsy.coreutils.Logger; @@ -97,7 +92,7 @@ final class InterestingItemDefsManager extends Observable { * @return A map of interesting files set names to interesting file sets, * possibly empty. */ - synchronized Map getInterestingFilesSets() { + synchronized Map getInterestingFilesSets() throws InterestingItemDefsManagerException { return FilesSetXML.readDefinitionsFile(DEFAULT_FILE_SET_DEFS_PATH); } @@ -108,7 +103,7 @@ final class InterestingItemDefsManager extends Observable { * @param filesSets A mapping of interesting files set names to files sets, * used to enforce unique files set names. */ - synchronized void setInterestingFilesSets(Map filesSets) { + synchronized void setInterestingFilesSets(Map filesSets) throws InterestingItemDefsManagerException { FilesSetXML.writeDefinitionsFile(INTERESTING_FILES_SET_DEFS_SERIALIZATION_PATH, filesSets); this.setChanged(); this.notifyObservers(); @@ -139,21 +134,6 @@ final class InterestingItemDefsManager extends Observable { private static final String TYPE_FILTER_VALUE_FILES = "file"; //NON-NLS private static final String TYPE_FILTER_VALUE_DIRS = "dir"; //NON-NLS - // The following tags and attributes are currently specific to the - // Autopsy implementation of interesting files set definitions. Autopsy - // definitions that use these will not be able to be used by TSK - // Framework. However, Autopsy can accept TSK Framework definitions: - // - // 1. Rules do not have names in the TSK Framework schema, but rules do - // have names in the Autopsy schema. Names will be synthesized as needed - // to allow Autopsy to use TSK Framework interesting files set - // definitions. - // 2. The TSK Framework has an interesting files module that supports - // simple globbing with "*" characters. Name rules and path conditions with - // "*" characters will be converted to regexes to allow Autopsy to use - // TSK Framework interesting files set definitions. - // 3. Type conditions are required by Autopsy, but not by TSK Frmaework. - // Missing type conditions will defualt to "files" conditions. private static final String REGEX_ATTR = "regex"; //NON-NLS private static final String PATH_REGEX_ATTR = "pathRegex"; //NON-NLS private static final String TYPE_FILTER_VALUE_FILES_AND_DIRS = "files_and_dirs"; //NON-NLS @@ -170,10 +150,10 @@ final class InterestingItemDefsManager extends Observable { // Note: This method takes a file path to support the possibility of // multiple intersting files set definition files, e.g., one for // definitions that ship with Autopsy and one for user definitions. - static Map readDefinitionsFile(String filePath) { + static Map readDefinitionsFile(String filePath) throws InterestingItemDefsManagerException { Map filesSets = new HashMap<>(); - // Check if the file exists. + // Check if the legacy xml file exists. File defsFile = new File(filePath); if (!defsFile.exists()) { return readSerializedDefinitions(); @@ -207,8 +187,9 @@ final class InterestingItemDefsManager extends Observable { return filesSets; } - private static Map readSerializedDefinitions() { - String filePath = INTERESTING_FILES_SET_DEFS_SERIALIZATION_PATH; + private static Map readSerializedDefinitions() throws InterestingItemDefsManagerException { + throw new InterestingItemDefsManagerException("Test"); + /*String filePath = INTERESTING_FILES_SET_DEFS_SERIALIZATION_PATH; File fileSetFile = new File(filePath); if (fileSetFile.exists()) { try { @@ -217,11 +198,11 @@ final class InterestingItemDefsManager extends Observable { return filesSetsSettings.getFilesSets(); } } catch (IOException | ClassNotFoundException ex) { - throw new PersistenceException(String.format("Failed to read settings from %s", filePath), ex); + throw new InterestingItemDefsManagerException(String.format("Failed to read settings from %s", filePath), ex); } } else { return new HashMap(); - } + }*/ } /** @@ -524,11 +505,11 @@ final class InterestingItemDefsManager extends Observable { // Note: This method takes a file path to support the possibility of // multiple intersting files set definition files, e.g., one for // definitions that ship with Autopsy and one for user definitions. - static boolean writeDefinitionsFile(String filePath, Map interestingFilesSets) { + static boolean writeDefinitionsFile(String filePath, Map interestingFilesSets) throws InterestingItemDefsManagerException { try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) { out.writeObject(new InterestingItemsFilesSetSettings(interestingFilesSets)); } catch (IOException ex) { - throw new PersistenceException(String.format("Failed to write settings to %s", filePath), ex); + throw new InterestingItemDefsManagerException(String.format("Failed to write settings to %s", filePath), ex); } File xmlFile = new File(DEFAULT_FILE_SET_DEFS_PATH); if (xmlFile.exists()) { @@ -537,5 +518,20 @@ final class InterestingItemDefsManager extends Observable { return true; } } + + static class InterestingItemDefsManagerException extends Exception { + InterestingItemDefsManagerException() { + + } + InterestingItemDefsManagerException(String message) { + super(message); + } + InterestingItemDefsManagerException(String message, Throwable cause) { + super(message, cause); + } + InterestingItemDefsManagerException(Throwable cause) { + super(cause); + } + } } diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsPanel.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsPanel.java index 83301b6239..f45056e489 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsPanel.java @@ -42,6 +42,7 @@ import org.sleuthkit.autopsy.ingest.IngestModuleGlobalSettingsPanel; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.apache.tika.mime.MediaType; import org.apache.tika.mime.MimeTypes; +import org.openide.util.Exceptions; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -121,7 +122,11 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp */ @Override public void saveSettings() { - InterestingItemDefsManager.getInstance().setInterestingFilesSets(this.filesSets); + try { + InterestingItemDefsManager.getInstance().setInterestingFilesSets(this.filesSets); + } catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) { + MessageNotifyUtil.Message.error("Test Error"); + } } /** @@ -139,9 +144,13 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp public void load() { this.resetComponents(); - // Get a working copy of the interesting files set definitions and sort - // by set name. - this.filesSets = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets()); + try { + // Get a working copy of the interesting files set definitions and sort + // by set name. + this.filesSets = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets()); + } catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) { + MessageNotifyUtil.Message.error("Test error"); + } // Populate the list model for the interesting files sets list // component. @@ -369,12 +378,11 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp FilesSetRulePanel panel; if (selectedRule != null) { // Editing an existing rule definition. - panel = new FilesSetRulePanel(selectedRule); + panel = new FilesSetRulePanel(selectedRule, okButton, cancelButton); } else { // Creating a new rule definition. - panel = new FilesSetRulePanel(); + panel = new FilesSetRulePanel(okButton, cancelButton); } - panel.setButtons(okButton, cancelButton); // Do a dialog box with the files set panel until the user either enters // a valid definition or cancels. Note that the panel gives the user // feedback when isValidDefinition() is called. diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemsIngestModuleFactory.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemsIngestModuleFactory.java index 549e75c963..410e366bd2 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemsIngestModuleFactory.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemsIngestModuleFactory.java @@ -20,8 +20,10 @@ package org.sleuthkit.autopsy.modules.interestingitems; import java.util.ArrayList; import java.util.List; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; +import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.Version; import org.sleuthkit.autopsy.ingest.FileIngestModule; import org.sleuthkit.autopsy.ingest.IngestModuleFactory; @@ -76,8 +78,12 @@ final public class InterestingItemsIngestModuleFactory extends IngestModuleFacto // definitions independent of the rules that make up the defintions. // Doing so also keeps the serialization simple. List enabledFilesSetNames = new ArrayList<>(); - for (String name : InterestingItemDefsManager.getInstance().getInterestingFilesSets().keySet()) { - enabledFilesSetNames.add(name); + try { + for (String name : InterestingItemDefsManager.getInstance().getInterestingFilesSets().keySet()) { + enabledFilesSetNames.add(name); + } + } catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) { + MessageNotifyUtil.Message.error("Test Error"); } return new FilesIdentifierIngestJobSettings(enabledFilesSetNames); }