mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
Code review
This commit is contained in:
parent
d2cd43be75
commit
53b5eac2a7
@ -26,21 +26,26 @@ import java.util.Map;
|
|||||||
* Class for persisting the file properties used by FileReportGenerator to drive
|
* Class for persisting the file properties used by FileReportGenerator to drive
|
||||||
* report generation by FileReportModules.
|
* report generation by FileReportModules.
|
||||||
*/
|
*/
|
||||||
class FileReportSettings implements Serializable {
|
final class FileReportSettings implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Map<FileReportDataTypes, Boolean> filePropertiesInfo = new HashMap<>();
|
private Map<FileReportDataTypes, Boolean> filePropertiesInfo = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates FileReportSettings object.
|
* Creates FileReportSettings object.
|
||||||
*
|
*
|
||||||
* @param fileReportInfo the Information that should be included about each
|
* @param fileReportInfo The information that should be included about each
|
||||||
* file in the report.
|
* file in the report.
|
||||||
*/
|
*/
|
||||||
FileReportSettings(Map<FileReportDataTypes, Boolean> fileReportInfo) {
|
FileReportSettings(Map<FileReportDataTypes, Boolean> fileReportInfo) {
|
||||||
this.filePropertiesInfo = fileReportInfo;
|
this.filePropertiesInfo = fileReportInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets file report settings.
|
||||||
|
*
|
||||||
|
* @return File report settings
|
||||||
|
*/
|
||||||
Map<FileReportDataTypes, Boolean> getFileProperties() {
|
Map<FileReportDataTypes, Boolean> getFileProperties() {
|
||||||
return filePropertiesInfo;
|
return filePropertiesInfo;
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ package org.sleuthkit.autopsy.report;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for persisting information about ReportModule (e.g. whether the report
|
* Class for persisting information about a report module (e.g. whether the report
|
||||||
* module is enabled).
|
* module is enabled).
|
||||||
*/
|
*/
|
||||||
class ModuleStatus implements Serializable {
|
final class ModuleStatus implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final String moduleName;
|
private final String moduleName;
|
||||||
@ -33,8 +33,8 @@ class ModuleStatus implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Creates ModuleStatus object.
|
* Creates ModuleStatus object.
|
||||||
*
|
*
|
||||||
* @param module implementation of a ReportModule interface
|
* @param module Implementation of a ReportModule interface
|
||||||
* @param enabled boolean flag whether the module is enabled
|
* @param enabled Boolean flag whether the module is enabled
|
||||||
*/
|
*/
|
||||||
ModuleStatus(ReportModule module, boolean enabled) {
|
ModuleStatus(ReportModule module, boolean enabled) {
|
||||||
this.moduleName = module.getClass().getCanonicalName();
|
this.moduleName = module.getClass().getCanonicalName();
|
||||||
|
@ -20,7 +20,7 @@ package org.sleuthkit.autopsy.report;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the ReportModuleSettings interface for use by report
|
* Implementation of the ReportModuleSettings interface for use by report
|
||||||
* modules that do not have per report job options.
|
* modules that do not have settings.
|
||||||
*/
|
*/
|
||||||
public final class NoReportModuleSettings implements ReportModuleSettings {
|
public final class NoReportModuleSettings implements ReportModuleSettings {
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ package org.sleuthkit.autopsy.report;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Instances of this exception class are thrown when there is an error during
|
* Instances of this exception class are thrown when there is an error during
|
||||||
* serialization and deserialization of reporting configuration.
|
* serialization and deserialization of a reporting configuration.
|
||||||
*/
|
*/
|
||||||
class ReportConfigException extends Exception {
|
final class ReportConfigException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -22,9 +22,7 @@ import java.awt.BorderLayout;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import static java.util.Collections.swap;
|
import static java.util.Collections.swap;
|
||||||
import java.util.HashMap;
|
|
||||||
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;
|
||||||
@ -35,7 +33,6 @@ import javax.swing.event.ListSelectionEvent;
|
|||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import org.openide.DialogDisplayer;
|
import org.openide.DialogDisplayer;
|
||||||
import org.openide.NotifyDescriptor;
|
import org.openide.NotifyDescriptor;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
|
||||||
@ -70,14 +67,14 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
|
|||||||
tableModules = ReportModuleLoader.getTableReportModules();
|
tableModules = ReportModuleLoader.getTableReportModules();
|
||||||
generalModules = ReportModuleLoader.getGeneralReportModules();
|
generalModules = ReportModuleLoader.getGeneralReportModules();
|
||||||
fileModules = ReportModuleLoader.getFileReportModules();
|
fileModules = ReportModuleLoader.getFileReportModules();
|
||||||
|
|
||||||
for (TableReportModule module : tableModules) {
|
for (TableReportModule module : tableModules) {
|
||||||
if (!moduleIsValid(module)) {
|
if (!moduleIsValid(module)) {
|
||||||
popupWarning(module);
|
popupWarning(module);
|
||||||
tableModules.remove(module);
|
tableModules.remove(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (GeneralReportModule module : generalModules) {
|
for (GeneralReportModule module : generalModules) {
|
||||||
if (!moduleIsValid(module)) {
|
if (!moduleIsValid(module)) {
|
||||||
popupWarning(module);
|
popupWarning(module);
|
||||||
@ -88,15 +85,15 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
|
|||||||
for (FileReportModule module : fileModules) {
|
for (FileReportModule module : fileModules) {
|
||||||
if (!moduleIsValid(module)) {
|
if (!moduleIsValid(module)) {
|
||||||
popupWarning(module);
|
popupWarning(module);
|
||||||
fileModules.remove(module);
|
fileModules.remove(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// our theory is that the report table modules are more common, so they go on top
|
// our theory is that the report table modules are more common, so they go on top
|
||||||
modules.addAll(tableModules);
|
modules.addAll(tableModules);
|
||||||
modules.addAll(fileModules);
|
modules.addAll(fileModules);
|
||||||
modules.addAll(generalModules);
|
modules.addAll(generalModules);
|
||||||
|
|
||||||
portableCaseModule = new PortableCaseReportModule();
|
portableCaseModule = new PortableCaseReportModule();
|
||||||
if (moduleIsValid(portableCaseModule)) {
|
if (moduleIsValid(portableCaseModule)) {
|
||||||
modules.add(portableCaseModule);
|
modules.add(portableCaseModule);
|
||||||
@ -113,7 +110,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
|
|||||||
indexOfHTMLReportModule++;
|
indexOfHTMLReportModule++;
|
||||||
}
|
}
|
||||||
swap(modules, indexOfHTMLReportModule, 0);
|
swap(modules, indexOfHTMLReportModule, 0);
|
||||||
|
|
||||||
modulesJList.getSelectionModel().addListSelectionListener(this);
|
modulesJList.getSelectionModel().addListSelectionListener(this);
|
||||||
modulesJList.setCellRenderer(new ModuleCellRenderer());
|
modulesJList.setCellRenderer(new ModuleCellRenderer());
|
||||||
modulesJList.setListData(modules.toArray(new ReportModule[modules.size()]));
|
modulesJList.setListData(modules.toArray(new ReportModule[modules.size()]));
|
||||||
@ -181,7 +178,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the selection status of the Portable Case report module.
|
* Get the selection status of the Portable Case report module.
|
||||||
*
|
*
|
||||||
@ -303,7 +300,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
|
|||||||
configurationPanel.add(panel, BorderLayout.CENTER);
|
configurationPanel.add(panel, BorderLayout.CENTER);
|
||||||
configurationPanel.revalidate();
|
configurationPanel.revalidate();
|
||||||
configurationPanel.repaint();
|
configurationPanel.repaint();
|
||||||
|
|
||||||
boolean generalModuleSelected = (module instanceof GeneralReportModule);
|
boolean generalModuleSelected = (module instanceof GeneralReportModule);
|
||||||
|
|
||||||
wizPanel.setNext(!generalModuleSelected);
|
wizPanel.setNext(!generalModuleSelected);
|
||||||
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* A bundling of all the settings objects that define a report configuration.
|
* A bundling of all the settings objects that define a report configuration.
|
||||||
*/
|
*/
|
||||||
class ReportingConfig implements Serializable {
|
final class ReportingConfig implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private String configName;
|
private String configName;
|
||||||
@ -79,7 +79,7 @@ class ReportingConfig implements Serializable {
|
|||||||
this.fileReportSettings = settings;
|
this.fileReportSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileReportSettings getFileReportModuleSettings() {
|
FileReportSettings getFileReportSettings() {
|
||||||
return this.fileReportSettings;
|
return this.fileReportSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
|||||||
* all of the settings that make up a reporting configuration in an atomic,
|
* all of the settings that make up a reporting configuration in an atomic,
|
||||||
* thread safe way.
|
* thread safe way.
|
||||||
*/
|
*/
|
||||||
class ReportingConfigLoader {
|
final class ReportingConfigLoader {
|
||||||
|
|
||||||
private static final String REPORT_CONFIG_FOLDER = "ReportingConfigs"; //NON-NLS
|
private static final String REPORT_CONFIG_FOLDER = "ReportingConfigs"; //NON-NLS
|
||||||
private static final String REPORT_CONFIG_FOLDER_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), ReportingConfigLoader.REPORT_CONFIG_FOLDER).toAbsolutePath().toString();
|
private static final String REPORT_CONFIG_FOLDER_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), ReportingConfigLoader.REPORT_CONFIG_FOLDER).toAbsolutePath().toString();
|
||||||
private static final String REPORT_CONFIG_FILE_NAME = "ReportingConfiguration.properties";
|
private static final String REPORT_CONFIG_FILE_EXTENSION = ".settings";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deserialize all of the settings that make up a reporting configuration in
|
* Deserialize all of the settings that make up a reporting configuration in
|
||||||
@ -53,7 +53,7 @@ class ReportingConfigLoader {
|
|||||||
static synchronized ReportingConfig loadConfig(String configName) throws ReportConfigException {
|
static synchronized ReportingConfig loadConfig(String configName) throws ReportConfigException {
|
||||||
|
|
||||||
// construct the file path
|
// construct the file path
|
||||||
Path reportFilePath = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, configName, REPORT_CONFIG_FILE_NAME);
|
Path reportFilePath = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, configName + REPORT_CONFIG_FILE_EXTENSION);
|
||||||
File reportFile = reportFilePath.toFile();
|
File reportFile = reportFilePath.toFile();
|
||||||
|
|
||||||
// Return null if a reporting configuration for the given name does not exist.
|
// Return null if a reporting configuration for the given name does not exist.
|
||||||
@ -65,7 +65,7 @@ class ReportingConfigLoader {
|
|||||||
throw new ReportConfigException("Unable to read reporting configuration file " + reportFilePath.toString());
|
throw new ReportConfigException("Unable to read reporting configuration file " + reportFilePath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// read in the confuguration
|
// read in the configuration
|
||||||
ReportingConfig config = null;
|
ReportingConfig config = null;
|
||||||
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(reportFilePath.toString()))) {
|
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(reportFilePath.toString()))) {
|
||||||
config = (ReportingConfig) in.readObject();
|
config = (ReportingConfig) in.readObject();
|
||||||
@ -87,7 +87,7 @@ class ReportingConfigLoader {
|
|||||||
static synchronized void saveConfig(ReportingConfig config) throws ReportConfigException {
|
static synchronized void saveConfig(ReportingConfig config) throws ReportConfigException {
|
||||||
|
|
||||||
// construct the configuration directory path
|
// 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);
|
||||||
|
|
||||||
// create configuration directory
|
// create configuration directory
|
||||||
try {
|
try {
|
||||||
@ -97,11 +97,11 @@ class ReportingConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save the configuration
|
// save the configuration
|
||||||
String filePath = pathToConfigDir.toString() + File.separator + REPORT_CONFIG_FILE_NAME;
|
String filePath = pathToConfigDir.toString() + File.separator + config.getName() + REPORT_CONFIG_FILE_EXTENSION;
|
||||||
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
|
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
|
||||||
out.writeObject(config);
|
out.writeObject(config);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new ReportConfigException("Unable to save reporting configuration " + pathToConfigDir.toString(), ex);
|
throw new ReportConfigException("Unable to save reporting configuration " + filePath, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
|
|||||||
* by the TableReportGenerator class to drive report generation by
|
* by the TableReportGenerator class to drive report generation by
|
||||||
* TableReportModules.
|
* TableReportModules.
|
||||||
*/
|
*/
|
||||||
class TableReportSettings implements Serializable {
|
final class TableReportSettings implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections = new HashMap<>();
|
private Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections = new HashMap<>();
|
||||||
@ -37,9 +37,9 @@ class TableReportSettings implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Creates TableReportSettings object.
|
* Creates TableReportSettings object.
|
||||||
*
|
*
|
||||||
* @param artifactTypeSelections the enabled/disabled state of the artifact
|
* @param artifactTypeSelections The enabled/disabled state of the artifact
|
||||||
* types to be included in the report
|
* types to be included in the report
|
||||||
* @param tagNameSelections the enabled/disabled state of the tag names to
|
* @param tagNameSelections The enabled/disabled state of the tag names to
|
||||||
* be included in the report
|
* be included in the report
|
||||||
*/
|
*/
|
||||||
TableReportSettings(Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) {
|
TableReportSettings(Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user