Merge pull request #2123 from BasisOlivers/aut-2100

Cleaned up reports code to only allow one report module at a time.
This commit is contained in:
Richard Cordovano 2016-06-09 13:00:13 -04:00 committed by GitHub
commit f2103cc289
7 changed files with 1842 additions and 1988 deletions

View File

@ -18,48 +18,45 @@
*/ */
package org.sleuthkit.autopsy.modules.stix; package org.sleuthkit.autopsy.modules.stix;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.logging.Level;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.mitre.cybox.cybox_2.ObjectType; import org.mitre.cybox.cybox_2.ObjectType;
import org.mitre.cybox.cybox_2.Observable; import org.mitre.cybox.cybox_2.Observable;
import org.mitre.cybox.cybox_2.ObservableCompositionType; import org.mitre.cybox.cybox_2.ObservableCompositionType;
import org.mitre.cybox.cybox_2.OperatorTypeEnum;
import org.mitre.cybox.objects.AccountObjectType;
import org.mitre.cybox.objects.Address;
import org.mitre.cybox.objects.DomainName;
import org.mitre.cybox.objects.EmailMessage;
import org.mitre.cybox.objects.FileObjectType;
import org.mitre.cybox.objects.SystemObjectType;
import org.mitre.cybox.objects.URIObjectType;
import org.mitre.cybox.objects.URLHistory;
import org.mitre.cybox.objects.WindowsNetworkShare;
import org.mitre.cybox.objects.WindowsRegistryKey;
import org.mitre.stix.common_1.IndicatorBaseType; import org.mitre.stix.common_1.IndicatorBaseType;
import org.mitre.stix.indicator_2.Indicator; import org.mitre.stix.indicator_2.Indicator;
import org.mitre.stix.stix_1.STIXPackage; import org.mitre.stix.stix_1.STIXPackage;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.report.GeneralReportModule;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.TskCoreException;
import org.mitre.cybox.cybox_2.OperatorTypeEnum;
import org.mitre.cybox.objects.Address;
import org.mitre.cybox.objects.FileObjectType;
import org.mitre.cybox.objects.URIObjectType;
import org.mitre.cybox.objects.EmailMessage;
import org.mitre.cybox.objects.WindowsNetworkShare;
import org.mitre.cybox.objects.AccountObjectType;
import org.mitre.cybox.objects.SystemObjectType;
import org.mitre.cybox.objects.URLHistory;
import org.mitre.cybox.objects.DomainName;
import org.mitre.cybox.objects.WindowsRegistryKey;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.report.GeneralReportModule;
import org.sleuthkit.autopsy.report.ReportProgressPanel;
import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus; import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus;
import org.sleuthkit.datamodel.TskCoreException;
/** /**
* *
@ -180,6 +177,9 @@ public class STIXReportModule implements GeneralReportModule {
// Process each STIX file // Process each STIX file
for (File file : stixFiles) { for (File file : stixFiles) {
if (progressPanel.getStatus() == ReportStatus.CANCELED) {
return;
}
try { try {
processFile(file.getAbsolutePath(), progressPanel); processFile(file.getAbsolutePath(), progressPanel);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {

File diff suppressed because it is too large Load Diff

0
Core/src/org/sleuthkit/autopsy/report/ReportKML.java Normal file → Executable file
View File

View File

@ -24,9 +24,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import static java.util.Collections.swap; import static java.util.Collections.swap;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -137,8 +135,8 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
// Make sure that the report module has a valid non-null name. // Make sure that the report module has a valid non-null name.
private boolean moduleIsValid(ReportModule module) { private boolean moduleIsValid(ReportModule module) {
return module.getName() != null && !module.getName().isEmpty() return module.getName() != null && !module.getName().isEmpty()
&& module.getRelativeFilePath() != null; && module.getRelativeFilePath() != null;
} }
private void popupWarning(ReportModule module) { private void popupWarning(ReportModule module) {
@ -163,13 +161,12 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
* *
* @return * @return
*/ */
Map<TableReportModule, Boolean> getTableModuleStates() { TableReportModule getTableModule() {
Map<TableReportModule, Boolean> reportModuleStates = new LinkedHashMap<>();
ReportModule mod = getSelectedModule(); ReportModule mod = getSelectedModule();
if (tableModules.contains(mod)) { if (tableModules.contains(mod)) {
reportModuleStates.put((TableReportModule) mod, Boolean.TRUE); return (TableReportModule) mod;
} }
return reportModuleStates; return null;
} }
/** /**
@ -177,13 +174,12 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
* *
* @return * @return
*/ */
Map<GeneralReportModule, Boolean> getGeneralModuleStates() { GeneralReportModule getGeneralModule() {
Map<GeneralReportModule, Boolean> reportModuleStates = new LinkedHashMap<>();
ReportModule mod = getSelectedModule(); ReportModule mod = getSelectedModule();
if (generalModules.contains(mod)) { if (generalModules.contains(mod)) {
reportModuleStates.put((GeneralReportModule) mod, Boolean.TRUE); return (GeneralReportModule) mod;
} }
return reportModuleStates; return null;
} }
/** /**
@ -191,13 +187,12 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
* *
* @return * @return
*/ */
Map<FileReportModule, Boolean> getFileModuleStates() { FileReportModule getFileModule() {
Map<FileReportModule, Boolean> reportModuleStates = new LinkedHashMap<>();
ReportModule mod = getSelectedModule(); ReportModule mod = getSelectedModule();
if (fileModules.contains(mod)) { if (fileModules.contains(mod)) {
reportModuleStates.put((FileReportModule) mod, Boolean.TRUE); return (FileReportModule) mod;
} }
return reportModuleStates; return null;
} }
/** /**

View File

@ -1,4 +1,4 @@
/* /*
* *
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
@ -65,13 +65,17 @@ public final class ReportWizardAction extends CallableSystemAction implements Pr
wiz.setTitle(NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.reportWiz.title")); wiz.setTitle(NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.reportWiz.title"));
if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) { if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ReportGenerator generator = new ReportGenerator((Map<TableReportModule, Boolean>) wiz.getProperty("tableModuleStates"), //NON-NLS ReportGenerator generator = new ReportGenerator(); //NON-NLS
(Map<GeneralReportModule, Boolean>) wiz.getProperty("generalModuleStates"), //NON-NLS TableReportModule tableReport = (TableReportModule) wiz.getProperty("tableModule");
(Map<FileReportModule, Boolean>) wiz.getProperty("fileModuleStates")); //NON-NLS GeneralReportModule generalReport = (GeneralReportModule) wiz.getProperty("generalModule");
generator.generateTableReports((Map<BlackboardArtifact.Type, Boolean>) wiz.getProperty("artifactStates"), (Map<String, Boolean>) wiz.getProperty("tagStates")); //NON-NLS FileReportModule fileReport = (FileReportModule) wiz.getProperty("fileModule");
generator.generateFileListReports((Map<FileReportDataTypes, Boolean>) wiz.getProperty("fileReportOptions")); //NON-NLS if (tableReport != null) {
generator.generateGeneralReports(); generator.generateTableReport(tableReport, (Map<BlackboardArtifact.Type, Boolean>) wiz.getProperty("artifactStates"), (Map<String, Boolean>) wiz.getProperty("tagStates")); //NON-NLS
generator.displayProgressPanels(); } else if (generalReport != null) {
generator.generateGeneralReport(generalReport);
} else if (fileReport != null) {
generator.generateFileListReport(fileReport, (Map<FileReportDataTypes, Boolean>) wiz.getProperty("fileReportOptions")); //NON-NLS
}
} }
} }

View File

@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.report;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Collection; import java.util.Collection;
import java.util.Map;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
@ -108,17 +107,17 @@ class ReportWizardPanel1 implements WizardDescriptor.FinishablePanel<WizardDescr
@Override @Override
public void storeSettings(WizardDescriptor wiz) { public void storeSettings(WizardDescriptor wiz) {
Map<TableReportModule, Boolean> tables = getComponent().getTableModuleStates(); TableReportModule module = getComponent().getTableModule();
Map<GeneralReportModule, Boolean> generals = getComponent().getGeneralModuleStates(); GeneralReportModule general = getComponent().getGeneralModule();
wiz.putProperty("tableModuleStates", tables); //NON-NLS wiz.putProperty("tableModule", module); //NON-NLS
wiz.putProperty("generalModuleStates", generals); //NON-NLS wiz.putProperty("generalModule", general); //NON-NLS
wiz.putProperty("fileModuleStates", getComponent().getFileModuleStates()); //NON-NLS wiz.putProperty("fileModule", getComponent().getFileModule()); //NON-NLS
// Store preferences that WizardIterator will use to determine what // Store preferences that WizardIterator will use to determine what
// panels need to be shown // panels need to be shown
Preferences prefs = NbPreferences.forModule(ReportWizardPanel1.class); Preferences prefs = NbPreferences.forModule(ReportWizardPanel1.class);
prefs.putBoolean("tableModule", any(tables.values())); //NON-NLS prefs.putBoolean("tableModule", module != null); //NON-NLS
prefs.putBoolean("generalModule", any(generals.values())); //NON-NLS prefs.putBoolean("generalModule", general != null); //NON-NLS
} }
/** /**

File diff suppressed because it is too large Load Diff