3412: update the reports directory name from 'case timestamp' to 'case timestamp reportType'

This commit is contained in:
U-BASIS\zhaohui 2018-01-03 14:56:47 -05:00
parent cb9a967c4b
commit f1e6d8ff72
7 changed files with 62 additions and 28 deletions

View File

@ -49,6 +49,7 @@ 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;
@ -66,6 +67,7 @@ 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;
@ -101,6 +103,13 @@ 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
@ -119,7 +128,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(baseReportDir).delete(); new File(stixReportDir).delete();
return; return;
} }
if (stixFileName.isEmpty()) { if (stixFileName.isEmpty()) {
@ -129,7 +138,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(baseReportDir).delete(); new File(stixReportDir).delete();
return; return;
} }
File stixFile = new File(stixFileName); File stixFile = new File(stixFileName);
@ -142,7 +151,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(baseReportDir).delete(); new File(stixReportDir).delete();
return; return;
} }
@ -649,7 +658,7 @@ public class STIXReportModule implements GeneralReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return "stix.txt"; //NON-NLS return " " + STIX_REPORT + File.separator + "stix.txt"; //NON-NLS
} }
@Override @Override

View File

@ -19,6 +19,7 @@
package org.sleuthkit.autopsy.report; package org.sleuthkit.autopsy.report;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
@ -27,6 +28,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.openide.filesystems.FileUtil;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
@ -45,6 +47,7 @@ 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;
@ -58,7 +61,14 @@ class FileReportText implements FileReportModule {
@Override @Override
public void startReport(String baseReportDir) { public void startReport(String baseReportDir) {
this.reportPath = baseReportDir + FILE_NAME; String fileReportDir = baseReportDir + " " + FILE_REPORT;
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) {
@ -138,6 +148,6 @@ class FileReportText implements FileReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return FILE_NAME; return " " + FILE_REPORT + File.separator + FILE_NAME;
} }
} }

View File

@ -28,6 +28,7 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.JPanel; import javax.swing.JPanel;
import org.openide.filesystems.FileUtil;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
@ -44,6 +45,7 @@ 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;
@ -76,7 +78,12 @@ 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"));
reportPath = baseReportDir + "BodyFile.txt"; //NON-NLS 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
currentCase = Case.getCurrentCase(); currentCase = Case.getCurrentCase();
skCase = currentCase.getSleuthkitCase(); skCase = currentCase.getSleuthkitCase();
@ -180,7 +187,7 @@ class ReportBodyFile implements GeneralReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return NbBundle.getMessage(this.getClass(), "ReportBodyFile.getFilePath.text"); return " " + TSK_BODY_REPORT + java.io.File.separator + NbBundle.getMessage(this.getClass(), "ReportBodyFile.getFilePath.text");
} }
@Override @Override

View File

@ -18,6 +18,7 @@
*/ */
package org.sleuthkit.autopsy.report; package org.sleuthkit.autopsy.report;
import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -25,6 +26,7 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openide.filesystems.FileUtil;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
@ -33,6 +35,7 @@ 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;
@ -65,6 +68,11 @@ 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.
@ -269,7 +277,7 @@ class ReportExcel implements TableReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return "Excel.xlsx"; //NON-NLS return " " + EXCEL_REPORT + File.separator + "Excel.xlsx"; //NON-NLS
} }
/** /**

View File

@ -93,17 +93,9 @@ 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 + File.separator; this.reportPath = currentCase.getReportDirectory() + File.separator + currentCase.getDisplayName() + " " + dateNoTime + " ";
this.errorList = new ArrayList<>(); this.errorList = new ArrayList<>();
// Create the root reports directory.
try {
FileUtil.createFolder(new File(this.reportPath));
} 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
}
} }
/** /**

View File

@ -73,7 +73,7 @@ class ReportHTML implements TableReportModule {
private static ReportHTML instance; private static ReportHTML instance;
private static final int MAX_THUMBS_PER_PAGE = 1000; private static final int MAX_THUMBS_PER_PAGE = 1000;
private static final String HTML_REPORT = "HTML Report"; private static final String HTML_REPORT = "HTML Report";
private static final String HTML_SUBDIR = "reports"; private static final String HTML_SUBDIR = "content";
private Case currentCase; private Case currentCase;
private SleuthkitCase skCase; private SleuthkitCase skCase;
static Integer THUMBNAIL_COLUMNS = 5; static Integer THUMBNAIL_COLUMNS = 5;
@ -161,7 +161,7 @@ class ReportHTML implements TableReportModule {
if (null != artifactType) { if (null != artifactType) {
// set the icon file name // set the icon file name
iconFileName = dataTypeToFileName(artifactType.getDisplayName()) + ".png"; //NON-NLS iconFileName = dataTypeToFileName(artifactType.getDisplayName()) + ".png"; //NON-NLS
iconFilePath = subPath + iconFileName; iconFilePath = subPath + File.separator + iconFileName;
// determine the source image to use // determine the source image to use
switch (artifactType) { switch (artifactType) {
@ -272,7 +272,7 @@ class ReportHTML implements TableReportModule {
logger.log(Level.WARNING, "useDataTypeIcon: unhandled artifact type = " + dataType); //NON-NLS logger.log(Level.WARNING, "useDataTypeIcon: unhandled artifact type = " + dataType); //NON-NLS
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/star.png"); //NON-NLS in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/star.png"); //NON-NLS
iconFileName = "star.png"; //NON-NLS iconFileName = "star.png"; //NON-NLS
iconFilePath = subPath + iconFileName; iconFilePath = subPath + File.separator + iconFileName;
break; break;
} }
} else if (dataType.startsWith(ARTIFACT_TYPE.TSK_ACCOUNT.getDisplayName())) { } else if (dataType.startsWith(ARTIFACT_TYPE.TSK_ACCOUNT.getDisplayName())) {
@ -285,11 +285,11 @@ class ReportHTML implements TableReportModule {
*/ */
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/accounts.png"); //NON-NLS in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/accounts.png"); //NON-NLS
iconFileName = "accounts.png"; //NON-NLS iconFileName = "accounts.png"; //NON-NLS
iconFilePath = subPath + iconFileName; iconFilePath = subPath + File.separator + iconFileName;
} else { // no defined artifact found for this dataType } else { // no defined artifact found for this dataType
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/star.png"); //NON-NLS in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/star.png"); //NON-NLS
iconFileName = "star.png"; //NON-NLS iconFileName = "star.png"; //NON-NLS
iconFilePath = subPath + iconFileName; iconFilePath = subPath + File.separator + iconFileName;
} }
try { try {
@ -329,7 +329,7 @@ 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 + " " + HTML_REPORT + File.separator; //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 {
@ -801,7 +801,7 @@ class ReportHTML implements TableReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return HTML_REPORT + File.separator + "report.html"; //NON-NLS return " " + HTML_REPORT + File.separator + "report.html"; //NON-NLS
} }
@Override @Override

View File

@ -53,6 +53,7 @@ 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;
@ -103,7 +104,14 @@ 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();
@ -832,7 +840,7 @@ class ReportKML implements GeneralReportModule {
@Override @Override
public String getRelativeFilePath() { public String getRelativeFilePath() {
return "ReportKML.kml"; //NON-NLS return " " + KML_REPORT + File.separator + "ReportKML.kml"; //NON-NLS
} }
@Override @Override