From f5b1f7b4c9ed8afdba25174a775a44c10ec48352 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Thu, 15 Aug 2019 12:32:07 -0400 Subject: [PATCH] Changed ReportingConfig to use a Map, wizard configuration changes --- .../autopsy/report/Bundle.properties-MERGED | 5 ++-- .../autopsy/report/ReportVisualPanel1.java | 5 +++- .../autopsy/report/ReportWizardAction.java | 5 +++- .../report/ReportWizardFileOptionsPanel.java | 2 +- .../autopsy/report/ReportWizardIterator.java | 28 +++++++++++++++---- .../autopsy/report/ReportWizardPanel1.java | 8 ++++-- .../autopsy/report/ReportWizardPanel2.java | 2 +- .../ReportWizardPortableCaseOptionsPanel.java | 3 +- .../autopsy/report/ReportingConfig.java | 11 +++++--- .../autopsy/report/ReportingConfigLoader.java | 17 +++++++---- 10 files changed, 62 insertions(+), 24 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED index f642928717..b6dd050066 100755 --- a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED @@ -1,6 +1,6 @@ OpenIDE-Module-Name=Report CTL_ReportWizardAction=Run Report -ArtifactSelectionDialog.titleLabel.text=Select which artifacts you would like to report on: +ArtifactSelectionDialog.titleLabel.text=Select which result types you would like to report on: ArtifactSelectionDialog.okButton.text=OK PortableCaseInterestingItemsListPanel.error.errorLoadingTags=Error loading interesting item set names PortableCaseInterestingItemsListPanel.error.errorTitle=Error getting intesting item set names for case @@ -77,7 +77,7 @@ ReportVisualPanel2.allResultsRadioButton.text=All Results ReportWizardFileOptionsVisualPanel.selectAllButton.text=Select All ReportWizardFileOptionsVisualPanel.deselectAllButton.text=Deselect All ReportWizardFileOptionsVisualPanel.jLabel1.text=Select items to include in File Report: -ArtifactSelectionDialog.dlgTitle.text=Advanced Artifact Selection +ArtifactSelectionDialog.dlgTitle.text=Result Type Selection FileReportDataTypes.filename.text=Name FileReportDataTypes.fileExt.text=File Extension FileReportDataTypes.fileType.text=File Type @@ -331,5 +331,6 @@ ReportProgressDialog.reportLabel.text=reportLabel ReportProgressDialog.statusMessageLabel.text=processingLabel ReportVisualPanel2.specificTaggedResultsRadioButton.text=Specific Tagged Results ReportVisualPanel2.allTaggedResultsRadioButton.text=All Tagged Results +ArtifactSelectionDialog.titleLabel.toolTipText= ReportWizardPortableCaseOptionsVisualPanel.getName.title=Choose Portable Case settings TableReportGenerator.StatusColumn.Header=Review Status diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel1.java index d5c434a198..5763198e01 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel1.java @@ -23,6 +23,7 @@ import java.awt.Component; import java.util.ArrayList; import static java.util.Collections.swap; import java.util.List; +import java.util.Map; import java.util.logging.Level; import javax.swing.JList; import javax.swing.JPanel; @@ -49,13 +50,15 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener { private List tableModules = new ArrayList<>(); private List fileModules = new ArrayList<>(); private PortableCaseReportModule portableCaseModule; + private Map moduleConfigs; private Integer selectedIndex; /** * Creates new form ReportVisualPanel1 */ - public ReportVisualPanel1(ReportWizardPanel1 wizPanel) { + public ReportVisualPanel1(ReportWizardPanel1 wizPanel, Map moduleConfigs) { this.wizPanel = wizPanel; + this.moduleConfigs = moduleConfigs; initComponents(); configurationPanel.setLayout(new BorderLayout()); descriptionTextPane.setEditable(false); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java index 8fa03fd68b..58882fa4e7 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java @@ -54,6 +54,9 @@ import org.sleuthkit.datamodel.BlackboardArtifact; @ActionReference(path = "Toolbars/Case", position = 105)}) public final class ReportWizardAction extends CallableSystemAction implements Presenter.Toolbar, ActionListener { + private static final String REPORTING_CONFIGURATION_NAME = "EXAMINER_MODE"; + private static final boolean DISPLAY_CASE_SPECIFIC_DATA = true; + private static final boolean RUN_REPORTS = true; private final JButton toolbarButton = new JButton(); private static final String ACTION_NAME = NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.actionName.text"); @@ -64,7 +67,7 @@ public final class ReportWizardAction extends CallableSystemAction implements Pr */ @SuppressWarnings("unchecked") public static void doReportWizard() { - WizardDescriptor wiz = new WizardDescriptor(new ReportWizardIterator()); + WizardDescriptor wiz = new WizardDescriptor(new ReportWizardIterator(REPORTING_CONFIGURATION_NAME, DISPLAY_CASE_SPECIFIC_DATA, RUN_REPORTS)); wiz.setTitleFormat(new MessageFormat("{0} {1}")); wiz.setTitle(NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.reportWiz.title")); if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) { diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardFileOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardFileOptionsPanel.java index eec784ff50..a41d2ce3d7 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardFileOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardFileOptionsPanel.java @@ -37,7 +37,7 @@ class ReportWizardFileOptionsPanel implements WizardDescriptor.FinishablePanel { + private static final Logger logger = Logger.getLogger(ReportWizardIterator.class.getName()); private int index; private final ReportWizardPanel1 firstPanel; @@ -55,11 +58,26 @@ final class ReportWizardIterator implements WizardDescriptor.Iterator[] portableCaseConfigPanels; @SuppressWarnings({"rawtypes", "unchecked"}) - ReportWizardIterator() { - firstPanel = new ReportWizardPanel1(); - tableConfigPanel = new ReportWizardPanel2(); - fileConfigPanel = new ReportWizardFileOptionsPanel(); - portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(); + ReportWizardIterator(String reportingConfigurationName, boolean displayCaseSpecificData, boolean runReports) { + + ReportingConfig config = null; + try { + config = ReportingConfigLoader.loadConfig(reportingConfigurationName); + } catch (ReportConfigException ex) { + logger.log(Level.SEVERE, "Unable to load reporting configuration " + reportingConfigurationName + ". Using default settings", ex); + } + + if (config != null) { + firstPanel = new ReportWizardPanel1(config.getModuleConfigs()); + tableConfigPanel = new ReportWizardPanel2(config.getTableReportSettings()); + fileConfigPanel = new ReportWizardFileOptionsPanel(config.getFileReportSettings()); + portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(config.getModuleConfigs()); + } else { + firstPanel = new ReportWizardPanel1(null); + tableConfigPanel = new ReportWizardPanel2(null); + fileConfigPanel = new ReportWizardFileOptionsPanel(null); + portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(null); + } allConfigPanels = new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel, fileConfigPanel, portableCaseConfigPanel}; tableConfigPanels = new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel}; diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardPanel1.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardPanel1.java index d400497a4f..d6736ab1f8 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardPanel1.java @@ -21,6 +21,8 @@ package org.sleuthkit.autopsy.report; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Collection; +import java.util.List; +import java.util.Map; import java.util.prefs.Preferences; import javax.swing.JButton; import javax.swing.event.ChangeListener; @@ -33,10 +35,12 @@ class ReportWizardPanel1 implements WizardDescriptor.FinishablePanel moduleConfigs; private final JButton nextButton; private final JButton finishButton; - ReportWizardPanel1() { + ReportWizardPanel1(Map moduleConfigs) { + this.moduleConfigs = moduleConfigs; nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.nextButton.text")); finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.finishButton.text")); finishButton.setEnabled(false); @@ -60,7 +64,7 @@ class ReportWizardPanel1 implements WizardDescriptor.FinishablePanel { private final JButton nextButton; private WizardDescriptor wiz; - ReportWizardPanel2() { + ReportWizardPanel2(TableReportSettings tableReportSettings) { finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.finishButton.text")); nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.nextButton.text")); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardPortableCaseOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardPortableCaseOptionsPanel.java index afc36b6887..7367b868f5 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardPortableCaseOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardPortableCaseOptionsPanel.java @@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.report; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Map; import javax.swing.JButton; import javax.swing.event.ChangeListener; import org.openide.WizardDescriptor; @@ -36,7 +37,7 @@ class ReportWizardPortableCaseOptionsPanel implements WizardDescriptor.Finishabl private ReportWizardPortableCaseOptionsVisualPanel component; private final JButton finishButton; - ReportWizardPortableCaseOptionsPanel() { + ReportWizardPortableCaseOptionsPanel(Map moduleConfigs) { finishButton = new JButton( NbBundle.getMessage(this.getClass(), "ReportWizardFileOptionsPanel.finishButton.text")); finishButton.setEnabled(false); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportingConfig.java b/Core/src/org/sleuthkit/autopsy/report/ReportingConfig.java index 07ee700342..fb17f919cf 100755 --- a/Core/src/org/sleuthkit/autopsy/report/ReportingConfig.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportingConfig.java @@ -19,8 +19,9 @@ package org.sleuthkit.autopsy.report; import java.io.Serializable; -import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * A bundling of all the settings objects that define a report configuration. @@ -29,7 +30,7 @@ final class ReportingConfig implements Serializable { private static final long serialVersionUID = 1L; private String configName; - private List moduleConfigs = new ArrayList<>(); + private Map moduleConfigs = new HashMap<>(); private TableReportSettings tableReportSettings; private FileReportSettings fileReportSettings; @@ -51,10 +52,12 @@ final class ReportingConfig implements Serializable { } void setModuleConfigs(List moduleConfigs) { - this.moduleConfigs = moduleConfigs; + for (ReportModuleConfig config : moduleConfigs) { + this.moduleConfigs.put(config.getModuleClassName(), config); + } } - List getModuleConfigs() { + Map getModuleConfigs() { return this.moduleConfigs; } diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportingConfigLoader.java b/Core/src/org/sleuthkit/autopsy/report/ReportingConfigLoader.java index 4c9b99bbae..99d3b7d06a 100755 --- a/Core/src/org/sleuthkit/autopsy/report/ReportingConfigLoader.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportingConfigLoader.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.logging.Level; @@ -129,14 +130,14 @@ final class ReportingConfigLoader { * Serialize all of the settings that make up a reporting configuration in * an atomic, thread safe way. * - * @param config ReportingConfig object to serialize to disk + * @param reportConfig ReportingConfig object to serialize to disk * @throws ReportConfigException if an error occurred while saving the * configuration */ - static synchronized void saveConfig(ReportingConfig config) throws ReportConfigException { + static synchronized void saveConfig(ReportingConfig reportConfig) throws ReportConfigException { // construct the configuration directory path - Path pathToConfigDir = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, config.getName()); + Path pathToConfigDir = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, reportConfig.getName()); // create configuration directory try { @@ -148,7 +149,7 @@ final class ReportingConfigLoader { // save table report settings String filePath = pathToConfigDir.toString() + File.separator + TABLE_REPORT_CONFIG_FILE; try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) { - out.writeObject(config.getTableReportSettings()); + out.writeObject(reportConfig.getTableReportSettings()); } catch (IOException ex) { throw new ReportConfigException("Unable to save table report configuration " + filePath, ex); } @@ -156,14 +157,18 @@ final class ReportingConfigLoader { // save file report settings filePath = pathToConfigDir.toString() + File.separator + FILE_REPORT_CONFIG_FILE; try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) { - out.writeObject(config.getFileReportSettings()); + out.writeObject(reportConfig.getFileReportSettings()); } catch (IOException ex) { throw new ReportConfigException("Unable to save file report configuration " + filePath, ex); } // save list of module configuration objects filePath = pathToConfigDir.toString() + File.separator + MODULE_CONFIG_FILE; - List moduleConfigs = config.getModuleConfigs(); + List moduleConfigs = new ArrayList<>(); + for (ReportModuleConfig config : reportConfig.getModuleConfigs().values()) { + moduleConfigs.add(config); + } + try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) { out.writeObject(moduleConfigs); } catch (IOException ex) {