3412: Updates to let base directory not be touched by the modules and stay with ReportGenerator

This commit is contained in:
U-BASIS\zhaohui 2018-01-08 14:15:51 -05:00
parent a67b61aaec
commit 316edff6f9
8 changed files with 50 additions and 62 deletions

View File

@ -49,7 +49,6 @@ 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.openide.filesystems.FileUtil;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
@ -67,7 +66,6 @@ import org.sleuthkit.datamodel.TskCoreException;
public class STIXReportModule implements GeneralReportModule { public class STIXReportModule implements GeneralReportModule {
private static final Logger logger = Logger.getLogger(STIXReportModule.class.getName()); private static final Logger logger = Logger.getLogger(STIXReportModule.class.getName());
private static final String STIX_REPORT = "STIX Report";
private STIXReportModuleConfigPanel configPanel; private STIXReportModuleConfigPanel configPanel;
private static STIXReportModule instance = null; private static STIXReportModule instance = null;
private String reportPath; private String reportPath;
@ -103,13 +101,6 @@ public class STIXReportModule implements GeneralReportModule {
progressPanel.setIndeterminate(false); progressPanel.setIndeterminate(false);
progressPanel.start(); progressPanel.start();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.readSTIX")); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.readSTIX"));
String stixReportDir = baseReportDir + " " + STIX_REPORT;
try {
FileUtil.createFolder(new File(stixReportDir));
} catch (IOException ex) {
logger.log(Level.SEVERE, "Unable to make STIX report folder."); //NON-NLS
}
reportPath = baseReportDir + getRelativeFilePath(); reportPath = baseReportDir + getRelativeFilePath();
File reportFile = new File(reportPath); File reportFile = new File(reportPath);
// Check if the user wants to display all output or just hits // Check if the user wants to display all output or just hits
@ -128,7 +119,7 @@ public class STIXReportModule implements GeneralReportModule {
progressPanel.complete(ReportStatus.ERROR); progressPanel.complete(ReportStatus.ERROR);
progressPanel.updateStatusLabel( progressPanel.updateStatusLabel(
NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.noFildDirProvided")); NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.noFildDirProvided"));
new File(stixReportDir).delete(); new File(baseReportDir).delete();
return; return;
} }
if (stixFileName.isEmpty()) { if (stixFileName.isEmpty()) {
@ -138,7 +129,7 @@ public class STIXReportModule implements GeneralReportModule {
progressPanel.complete(ReportStatus.ERROR); progressPanel.complete(ReportStatus.ERROR);
progressPanel.updateStatusLabel( progressPanel.updateStatusLabel(
NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.noFildDirProvided")); NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.noFildDirProvided"));
new File(stixReportDir).delete(); new File(baseReportDir).delete();
return; return;
} }
File stixFile = new File(stixFileName); File stixFile = new File(stixFileName);
@ -151,7 +142,7 @@ public class STIXReportModule implements GeneralReportModule {
progressPanel.complete(ReportStatus.ERROR); progressPanel.complete(ReportStatus.ERROR);
progressPanel.updateStatusLabel( progressPanel.updateStatusLabel(
NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.couldNotOpenFileDir", stixFileName)); NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.couldNotOpenFileDir", stixFileName));
new File(stixReportDir).delete(); new File(baseReportDir).delete();
return; return;
} }
@ -658,7 +649,7 @@ public class STIXReportModule implements GeneralReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return " " + STIX_REPORT + File.separator + "stix.txt"; //NON-NLS return "stix.txt"; //NON-NLS
} }
@Override @Override

View File

@ -47,13 +47,13 @@ ReportBodyFile.getDesc.text=Body file format report with MAC times for every fil
ReportBodyFile.getFilePath.text=BodyFile.txt ReportBodyFile.getFilePath.text=BodyFile.txt
ReportKML.progress.querying=Querying files... ReportKML.progress.querying=Querying files...
ReportKML.progress.loading=Loading files... ReportKML.progress.loading=Loading files...
ReportKML.getName.text=Google Earth/KML ReportKML.getName.text=Google Earth KML
ReportKML.getDesc.text=KML format report with coordinates for relevant files. This format can be used for google earth views. ReportKML.getDesc.text=KML format report with coordinates for relevant files. This format can be used for google earth views.
ReportKML.getFilePath.text=ReportKML.kml ReportKML.getFilePath.text=ReportKML.kml
ReportBranding.defaultReportTitle.text=Autopsy Forensic Report ReportBranding.defaultReportTitle.text=Autopsy Forensic Report
ReportBranding.defaultReportFooter.text=Powered by Autopsy Open Source Digital Forensics Platform - www.sleuthkit.org ReportBranding.defaultReportFooter.text=Powered by Autopsy Open Source Digital Forensics Platform - www.sleuthkit.org
ReportExcel.numAartifacts.text=Number of artifacts\: ReportExcel.numAartifacts.text=Number of artifacts\:
ReportExcel.getName.text=Results - Excel ReportExcel.getName.text=Excel Report
ReportExcel.getDesc.text=A report about results and tagged items in Excel (XLS) format. ReportExcel.getDesc.text=A report about results and tagged items in Excel (XLS) format.
ReportExcel.sheetName.text=Summary ReportExcel.sheetName.text=Summary
ReportExcel.cellVal.summary=Summary ReportExcel.cellVal.summary=Summary
@ -177,12 +177,12 @@ ReportGenerator.errors.reportErrorText=Error generating report:
ReportHTML.addThumbRows.dataType.title=Tagged Images - {0} ReportHTML.addThumbRows.dataType.title=Tagged Images - {0}
ReportHTML.addThumbRows.dataType.msg=Tagged Results and Contents that contain images. ReportHTML.addThumbRows.dataType.msg=Tagged Results and Contents that contain images.
ReportHTML.thumbLink.tags=Tags\: ReportHTML.thumbLink.tags=Tags\:
ReportHTML.getName.text=Results - HTML ReportHTML.getName.text=HTML Report
ReportHTML.getDesc.text=A report about results and tagged items in HTML format. ReportHTML.getDesc.text=A report about results and tagged items in HTML format.
ReportHTML.writeIndex.title=for case {0} ReportHTML.writeIndex.title=for case {0}
ReportHTML.writeIndex.noFrames.msg=Your browser is not compatible with our frame setup. ReportHTML.writeIndex.noFrames.msg=Your browser is not compatible with our frame setup.
ReportHTML.writeIndex.noFrames.seeNav=Please see <a href\="reports\nav.html">the navigation page</a> for artifact links, ReportHTML.writeIndex.noFrames.seeNav=Please see <a href\="content\nav.html">the navigation page</a> for artifact links,
ReportHTML.writeIndex.seeSum=and <a href\="reports\summary.html">the summary page</a> for a case summary. ReportHTML.writeIndex.seeSum=and <a href\="content\summary.html">the summary page</a> for a case summary.
ReportHTML.writeNav.title=Report Navigation ReportHTML.writeNav.title=Report Navigation
ReportHTML.writeNav.h1=Report Navigation ReportHTML.writeNav.h1=Report Navigation
ReportHTML.writeNav.summary=Case Summary ReportHTML.writeNav.summary=Case Summary

View File

@ -47,7 +47,6 @@ class FileReportText implements FileReportModule {
private String reportPath; private String reportPath;
private Writer out; private Writer out;
private static final String FILE_NAME = "file-report.txt"; //NON-NLS private static final String FILE_NAME = "file-report.txt"; //NON-NLS
private static final String FILE_REPORT = "Text Report";
private static FileReportText instance; private static FileReportText instance;
@ -61,14 +60,7 @@ class FileReportText implements FileReportModule {
@Override @Override
public void startReport(String baseReportDir) { public void startReport(String baseReportDir) {
String fileReportDir = baseReportDir + " " + FILE_REPORT; this.reportPath = baseReportDir + FILE_NAME;
try {
FileUtil.createFolder(new File(fileReportDir));
} catch (IOException ex) {
logger.log(Level.SEVERE, "Unable to make File report folder."); //NON-NLS
}
this.reportPath = baseReportDir + getRelativeFilePath();
try { try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.reportPath))); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.reportPath)));
} catch (IOException ex) { } catch (IOException ex) {
@ -148,6 +140,6 @@ class FileReportText implements FileReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return " " + FILE_REPORT + File.separator + FILE_NAME; return FILE_NAME;
} }
} }

View File

@ -45,7 +45,6 @@ import org.sleuthkit.datamodel.*;
class ReportBodyFile implements GeneralReportModule { class ReportBodyFile implements GeneralReportModule {
private static final Logger logger = Logger.getLogger(ReportBodyFile.class.getName()); private static final Logger logger = Logger.getLogger(ReportBodyFile.class.getName());
private static final String TSK_BODY_REPORT = "TSK Body File Report";
private static ReportBodyFile instance = null; private static ReportBodyFile instance = null;
private Case currentCase; private Case currentCase;
@ -78,11 +77,6 @@ class ReportBodyFile implements GeneralReportModule {
progressPanel.setIndeterminate(false); progressPanel.setIndeterminate(false);
progressPanel.start(); progressPanel.start();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportBodyFile.progress.querying")); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportBodyFile.progress.querying"));
try {
FileUtil.createFolder(new java.io.File(baseReportDir + " " + TSK_BODY_REPORT));
} catch (IOException ex) {
logger.log(Level.SEVERE, "Unable to make TSK Body File report folder."); //NON-NLS
}
reportPath = baseReportDir + getRelativeFilePath(); //NON-NLS reportPath = baseReportDir + getRelativeFilePath(); //NON-NLS
currentCase = Case.getCurrentCase(); currentCase = Case.getCurrentCase();
skCase = currentCase.getSleuthkitCase(); skCase = currentCase.getSleuthkitCase();
@ -187,7 +181,7 @@ class ReportBodyFile implements GeneralReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return " " + TSK_BODY_REPORT + java.io.File.separator + NbBundle.getMessage(this.getClass(), "ReportBodyFile.getFilePath.text"); return NbBundle.getMessage(this.getClass(), "ReportBodyFile.getFilePath.text");
} }
@Override @Override

View File

@ -35,7 +35,6 @@ import org.sleuthkit.datamodel.TskCoreException;
class ReportExcel implements TableReportModule { class ReportExcel implements TableReportModule {
private static final Logger logger = Logger.getLogger(ReportExcel.class.getName()); private static final Logger logger = Logger.getLogger(ReportExcel.class.getName());
private static final String EXCEL_REPORT = "Excel Report";
private static ReportExcel instance; private static ReportExcel instance;
private Workbook wb; private Workbook wb;
@ -68,11 +67,6 @@ class ReportExcel implements TableReportModule {
@Override @Override
public void startReport(String baseReportDir) { public void startReport(String baseReportDir) {
// Set the path and save it for when the report is written to disk. // Set the path and save it for when the report is written to disk.
try {
FileUtil.createFolder(new File(baseReportDir + " " + EXCEL_REPORT));
} catch (IOException ex) {
logger.log(Level.SEVERE, "Unable to make Excel report folder."); //NON-NLS
}
this.reportPath = baseReportDir + getRelativeFilePath(); this.reportPath = baseReportDir + getRelativeFilePath();
// Make a workbook. // Make a workbook.
@ -277,7 +271,7 @@ class ReportExcel implements TableReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return " " + EXCEL_REPORT + File.separator + "Excel.xlsx"; //NON-NLS return "Excel.xlsx"; //NON-NLS
} }
/** /**

View File

@ -63,7 +63,7 @@ class ReportGenerator {
*/ */
private ReportProgressPanel progressPanel; private ReportProgressPanel progressPanel;
private final String reportPath; private String reportPathFormatString;
private final ReportGenerationPanel reportGenerationPanel = new ReportGenerationPanel(); private final ReportGenerationPanel reportGenerationPanel = new ReportGenerationPanel();
static final String REPORTS_DIR = "Reports"; //NON-NLS static final String REPORTS_DIR = "Reports"; //NON-NLS
@ -93,11 +93,12 @@ class ReportGenerator {
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss"); DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss");
Date date = new Date(); Date date = new Date();
String dateNoTime = dateFormat.format(date); String dateNoTime = dateFormat.format(date);
this.reportPath = currentCase.getReportDirectory() + File.separator + currentCase.getDisplayName() + " " + dateNoTime + " "; this.reportPathFormatString = currentCase.getReportDirectory() + File.separator + currentCase.getDisplayName() + " %s " + dateNoTime + File.separator;
this.errorList = new ArrayList<>(); this.errorList = new ArrayList<>();
} }
/** /**
* Display the progress panels to the user, and add actions to close the * Display the progress panels to the user, and add actions to close the
* parent dialog. * parent dialog.
@ -137,9 +138,17 @@ class ReportGenerator {
*/ */
void generateGeneralReport(GeneralReportModule generalReportModule) { void generateGeneralReport(GeneralReportModule generalReportModule) {
if (generalReportModule != null) { if (generalReportModule != null) {
reportPathFormatString = String.format(reportPathFormatString, generalReportModule.getName());
// Create the root reports directory.
try {
FileUtil.createFolder(new File(reportPathFormatString));
} catch (IOException ex) {
errorList.add(NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedMakeRptFolder"));
logger.log(Level.SEVERE, "Failed to make report folder, may be unable to generate reports.", ex); //NON-NLS
}
setupProgressPanel(generalReportModule); setupProgressPanel(generalReportModule);
ReportWorker worker = new ReportWorker(() -> { ReportWorker worker = new ReportWorker(() -> {
generalReportModule.generateReport(reportPath, progressPanel); generalReportModule.generateReport(reportPathFormatString, progressPanel);
}); });
worker.execute(); worker.execute();
displayProgressPanel(); displayProgressPanel();
@ -156,9 +165,17 @@ class ReportGenerator {
*/ */
void generateTableReport(TableReportModule tableReport, Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) { void generateTableReport(TableReportModule tableReport, Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) {
if (tableReport != null && null != artifactTypeSelections) { if (tableReport != null && null != artifactTypeSelections) {
reportPathFormatString = String.format(reportPathFormatString, tableReport.getName());
// Create the root reports directory.
try {
FileUtil.createFolder(new File(reportPathFormatString));
} catch (IOException ex) {
errorList.add(NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedMakeRptFolder"));
logger.log(Level.SEVERE, "Failed to make report folder, may be unable to generate reports.", ex); //NON-NLS
}
setupProgressPanel(tableReport); setupProgressPanel(tableReport);
ReportWorker worker = new ReportWorker(() -> { ReportWorker worker = new ReportWorker(() -> {
tableReport.startReport(reportPath); tableReport.startReport(reportPathFormatString);
TableReportGenerator generator = new TableReportGenerator(artifactTypeSelections, tagNameSelections, progressPanel, tableReport); TableReportGenerator generator = new TableReportGenerator(artifactTypeSelections, tagNameSelections, progressPanel, tableReport);
generator.execute(); generator.execute();
tableReport.endReport(); tableReport.endReport();
@ -179,6 +196,14 @@ class ReportGenerator {
*/ */
void generateFileListReport(FileReportModule fileReportModule, Map<FileReportDataTypes, Boolean> enabledInfo) { void generateFileListReport(FileReportModule fileReportModule, Map<FileReportDataTypes, Boolean> enabledInfo) {
if (fileReportModule != null && null != enabledInfo) { if (fileReportModule != null && null != enabledInfo) {
reportPathFormatString = String.format(reportPathFormatString, fileReportModule.getName());
// Create the root reports directory.
try {
FileUtil.createFolder(new File(reportPathFormatString));
} catch (IOException ex) {
errorList.add(NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedMakeRptFolder"));
logger.log(Level.SEVERE, "Failed to make report folder, may be unable to generate reports.", ex); //NON-NLS
}
List<FileReportDataTypes> enabled = new ArrayList<>(); List<FileReportDataTypes> enabled = new ArrayList<>();
for (Entry<FileReportDataTypes, Boolean> e : enabledInfo.entrySet()) { for (Entry<FileReportDataTypes, Boolean> e : enabledInfo.entrySet()) {
if (e.getValue()) { if (e.getValue()) {
@ -196,7 +221,7 @@ class ReportGenerator {
List<AbstractFile> files = getFiles(); List<AbstractFile> files = getFiles();
int numFiles = files.size(); int numFiles = files.size();
if (progressPanel.getStatus() != ReportStatus.CANCELED) { if (progressPanel.getStatus() != ReportStatus.CANCELED) {
fileReportModule.startReport(reportPath); fileReportModule.startReport(reportPathFormatString);
fileReportModule.startTable(enabled); fileReportModule.startTable(enabled);
} }
progressPanel.setIndeterminate(false); progressPanel.setIndeterminate(false);
@ -254,7 +279,7 @@ class ReportGenerator {
private void setupProgressPanel(ReportModule module) { private void setupProgressPanel(ReportModule module) {
String reportFilePath = module.getRelativeFilePath(); String reportFilePath = module.getRelativeFilePath();
if (!reportFilePath.isEmpty()) { if (!reportFilePath.isEmpty()) {
this.progressPanel = reportGenerationPanel.addReport(module.getName(), reportPath + reportFilePath); this.progressPanel = reportGenerationPanel.addReport(module.getName(), String.format(reportPathFormatString, module.getName()) + reportFilePath);
} else { } else {
this.progressPanel = reportGenerationPanel.addReport(module.getName(), null); this.progressPanel = reportGenerationPanel.addReport(module.getName(), null);
} }

View File

@ -329,11 +329,10 @@ class ReportHTML implements TableReportModule {
// Refresh the HTML report // Refresh the HTML report
refresh(); refresh();
// Setup the path for the HTML report // Setup the path for the HTML report
this.path = baseReportDir + " " + HTML_REPORT + File.separator; //NON-NLS this.path = baseReportDir; //NON-NLS
this.subPath = this.path + HTML_SUBDIR + File.separator; this.subPath = this.path + HTML_SUBDIR + File.separator;
this.thumbsPath = this.subPath + THUMBS_REL_PATH; //NON-NLS this.thumbsPath = this.subPath + THUMBS_REL_PATH; //NON-NLS
try { try {
FileUtil.createFolder(new File(this.path));
FileUtil.createFolder(new File(this.subPath)); FileUtil.createFolder(new File(this.subPath));
FileUtil.createFolder(new File(this.thumbsPath)); FileUtil.createFolder(new File(this.thumbsPath));
} catch (IOException ex) { } catch (IOException ex) {
@ -801,7 +800,7 @@ class ReportHTML implements TableReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return " " + HTML_REPORT + File.separator + "report.html"; //NON-NLS return "report.html"; //NON-NLS
} }
@Override @Override

View File

@ -53,7 +53,6 @@ class ReportKML implements GeneralReportModule {
private static final String KML_STYLE_FILE = "style.kml"; private static final String KML_STYLE_FILE = "style.kml";
private static final String REPORT_KML = "ReportKML.kml"; private static final String REPORT_KML = "ReportKML.kml";
private static final String STYLESHEETS_PATH = "/org/sleuthkit/autopsy/report/stylesheets/"; private static final String STYLESHEETS_PATH = "/org/sleuthkit/autopsy/report/stylesheets/";
private static final String KML_REPORT = "Google Earth KML Report";
private static ReportKML instance = null; private static ReportKML instance = null;
private Case currentCase; private Case currentCase;
private SleuthkitCase skCase; private SleuthkitCase skCase;
@ -104,13 +103,7 @@ class ReportKML implements GeneralReportModule {
progressPanel.setIndeterminate(true); progressPanel.setIndeterminate(true);
progressPanel.start(); progressPanel.start();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.querying")); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.querying"));
baseReportDir += " " + KML_REPORT + File.separator;
String kmlFileFullPath = baseReportDir + REPORT_KML; //NON-NLS String kmlFileFullPath = baseReportDir + REPORT_KML; //NON-NLS
try {
FileUtil.createFolder(new File(baseReportDir));
} catch (IOException ex) {
logger.log(Level.SEVERE, "Unable to make KML report folder."); //NON-NLS
}
currentCase = Case.getCurrentCase(); currentCase = Case.getCurrentCase();
skCase = currentCase.getSleuthkitCase(); skCase = currentCase.getSleuthkitCase();
@ -840,7 +833,7 @@ class ReportKML implements GeneralReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return " " + KML_REPORT + File.separator + "ReportKML.kml"; //NON-NLS return "ReportKML.kml"; //NON-NLS
} }
@Override @Override