Merge pull request #3345 from zhhl/3412-updatehtmlreportPath

3412: rename index.html to report.html and move html report files to …
This commit is contained in:
Richard Cordovano 2018-01-09 15:04:14 -05:00 committed by GitHub
commit ba9e2f7fcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 79 additions and 57 deletions

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 Basis Technology Corp.
* Copyright 2013 - 2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -29,7 +29,7 @@ import java.util.Map;
import java.util.logging.Level;
import javax.swing.JPanel;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
import org.mitre.cybox.cybox_2.ObjectType;
@ -100,7 +100,7 @@ public class STIXReportModule implements GeneralReportModule {
// Start the progress bar and setup the report
progressPanel.setIndeterminate(false);
progressPanel.start();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.readSTIX"));
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.readSTIX"));
reportPath = baseReportDir + getRelativeFilePath();
File reportFile = new File(reportPath);
// Check if the user wants to display all output or just hits

View File

@ -47,13 +47,13 @@ ReportBodyFile.getDesc.text=Body file format report with MAC times for every fil
ReportBodyFile.getFilePath.text=BodyFile.txt
ReportKML.progress.querying=Querying 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.getFilePath.text=ReportKML.kml
ReportBranding.defaultReportTitle.text=Autopsy Forensic Report
ReportBranding.defaultReportFooter.text=Powered by Autopsy Open Source Digital Forensics Platform - www.sleuthkit.org
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.sheetName.text=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.msg=Tagged Results and Contents that contain images.
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.writeIndex.title=for case {0}
ReportHTML.writeIndex.noFrames.msg=Your browser is not compatible with our frame setup.
ReportHTML.writeIndex.noFrames.seeNav=Please see <a href\="nav.html">the navigation page</a> for artifact links,
ReportHTML.writeIndex.seeSum=and <a href\="summary.html">the summary page</a> for a case summary.
ReportHTML.writeIndex.noFrames.seeNav=Please see <a href\="content\nav.html">the navigation page</a> for artifact links,
ReportHTML.writeIndex.seeSum=and <a href\="content\summary.html">the summary page</a> for a case summary.
ReportHTML.writeNav.title=Report Navigation
ReportHTML.writeNav.h1=Report Navigation
ReportHTML.writeNav.summary=Case Summary
@ -190,7 +190,7 @@ ReportHTML.writeSum.title=Case Summary
ReportHTML.writeSum.warningMsg=<span>Warning, this report was run before ingest services completed\!</span>
#
# autopsy/test/scripts/regression.py._html_report_diff() uses reportGenOn.text, caseName, caseNum,
# examiner as a regex signature to skip index.html and summary.html
# examiner as a regex signature to skip report.html and summary.html
#
ReportHTML.writeSum.reportGenOn.text=HTML Report Generated on {0}
ReportHTML.writeSum.caseName=Case\:

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 Basis Technology Corp.
* Copyright 2013 - 2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -2,7 +2,7 @@
*
* Autopsy Forensic Browser
*
* Copyright 2012-2014 Basis Technology Corp.
* Copyright 2012-2018 Basis Technology Corp.
*
* Copyright 2012 42six Solutions.
* Contact: aebadirad <at> 42six <dot> com
@ -76,7 +76,7 @@ class ReportBodyFile implements GeneralReportModule {
progressPanel.setIndeterminate(false);
progressPanel.start();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportBodyFile.progress.querying"));
reportPath = baseReportDir + "BodyFile.txt"; //NON-NLS
reportPath = baseReportDir + getRelativeFilePath(); //NON-NLS
currentCase = Case.getCurrentCase();
skCase = currentCase.getSleuthkitCase();

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013-2017 Basis Technology Corp.
* Copyright 2013-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -66,7 +66,7 @@ class ReportExcel implements TableReportModule {
public void startReport(String baseReportDir) {
// Set the path and save it for when the report is written to disk.
this.reportPath = baseReportDir + getRelativeFilePath();
// Make a workbook.
wb = new XSSFWorkbook();

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 Basis Technology Corp.
* Copyright 2013 - 2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -63,7 +63,7 @@ class ReportGenerator {
*/
private ReportProgressPanel progressPanel;
private final String reportPath;
private String reportPathFormatString;
private final ReportGenerationPanel reportGenerationPanel = new ReportGenerationPanel();
static final String REPORTS_DIR = "Reports"; //NON-NLS
@ -93,19 +93,12 @@ class ReportGenerator {
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss");
Date date = new Date();
String dateNoTime = dateFormat.format(date);
this.reportPath = currentCase.getReportDirectory() + File.separator + currentCase.getDisplayName() + " " + dateNoTime + File.separator;
this.reportPathFormatString = currentCase.getReportDirectory() + File.separator + currentCase.getDisplayName() + " %s " + dateNoTime + File.separator;
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
}
}
/**
* Display the progress panels to the user, and add actions to close the
* parent dialog.
@ -145,9 +138,17 @@ class ReportGenerator {
*/
void generateGeneralReport(GeneralReportModule generalReportModule) {
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);
ReportWorker worker = new ReportWorker(() -> {
generalReportModule.generateReport(reportPath, progressPanel);
generalReportModule.generateReport(reportPathFormatString, progressPanel);
});
worker.execute();
displayProgressPanel();
@ -164,9 +165,17 @@ class ReportGenerator {
*/
void generateTableReport(TableReportModule tableReport, Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) {
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);
ReportWorker worker = new ReportWorker(() -> {
tableReport.startReport(reportPath);
tableReport.startReport(reportPathFormatString);
TableReportGenerator generator = new TableReportGenerator(artifactTypeSelections, tagNameSelections, progressPanel, tableReport);
generator.execute();
tableReport.endReport();
@ -187,6 +196,14 @@ class ReportGenerator {
*/
void generateFileListReport(FileReportModule fileReportModule, Map<FileReportDataTypes, Boolean> 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<>();
for (Entry<FileReportDataTypes, Boolean> e : enabledInfo.entrySet()) {
if (e.getValue()) {
@ -204,7 +221,7 @@ class ReportGenerator {
List<AbstractFile> files = getFiles();
int numFiles = files.size();
if (progressPanel.getStatus() != ReportStatus.CANCELED) {
fileReportModule.startReport(reportPath);
fileReportModule.startReport(reportPathFormatString);
fileReportModule.startTable(enabled);
}
progressPanel.setIndeterminate(false);
@ -262,7 +279,7 @@ class ReportGenerator {
private void setupProgressPanel(ReportModule module) {
String reportFilePath = module.getRelativeFilePath();
if (!reportFilePath.isEmpty()) {
this.progressPanel = reportGenerationPanel.addReport(module.getName(), reportPath + reportFilePath);
this.progressPanel = reportGenerationPanel.addReport(module.getName(), String.format(reportPathFormatString, module.getName()) + reportFilePath);
} else {
this.progressPanel = reportGenerationPanel.addReport(module.getName(), null);
}

View File

@ -2,7 +2,7 @@
*
* Autopsy Forensic Browser
*
* Copyright 2012-2014 Basis Technology Corp.
* Copyright 2012-2018 Basis Technology Corp.
*
* Copyright 2012 42six Solutions.
* Contact: aebadirad <at> 42six <dot> com
@ -72,6 +72,7 @@ class ReportHTML implements TableReportModule {
private static final String THUMBS_REL_PATH = "thumbs" + File.separator; //NON-NLS
private static ReportHTML instance;
private static final int MAX_THUMBS_PER_PAGE = 1000;
private static final String HTML_SUBDIR = "content";
private Case currentCase;
private SleuthkitCase skCase;
static Integer THUMBNAIL_COLUMNS = 5;
@ -79,6 +80,7 @@ class ReportHTML implements TableReportModule {
private Map<String, Integer> dataTypes;
private String path;
private String thumbsPath;
private String subPath;
private String currentDataType; // name of current data type
private Integer rowCount; // number of rows (aka artifacts or tags) for the current data type
private Writer out;
@ -107,6 +109,7 @@ class ReportHTML implements TableReportModule {
path = "";
thumbsPath = "";
subPath = "";
currentDataType = "";
rowCount = 0;
@ -157,7 +160,7 @@ class ReportHTML implements TableReportModule {
if (null != artifactType) {
// set the icon file name
iconFileName = dataTypeToFileName(artifactType.getDisplayName()) + ".png"; //NON-NLS
iconFilePath = path + File.separator + iconFileName;
iconFilePath = subPath + File.separator + iconFileName;
// determine the source image to use
switch (artifactType) {
@ -268,7 +271,7 @@ class ReportHTML implements TableReportModule {
logger.log(Level.WARNING, "useDataTypeIcon: unhandled artifact type = " + dataType); //NON-NLS
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/star.png"); //NON-NLS
iconFileName = "star.png"; //NON-NLS
iconFilePath = path + File.separator + iconFileName;
iconFilePath = subPath + File.separator + iconFileName;
break;
}
} else if (dataType.startsWith(ARTIFACT_TYPE.TSK_ACCOUNT.getDisplayName())) {
@ -281,11 +284,11 @@ class ReportHTML implements TableReportModule {
*/
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/accounts.png"); //NON-NLS
iconFileName = "accounts.png"; //NON-NLS
iconFilePath = path + File.separator + iconFileName;
iconFilePath = subPath + File.separator + iconFileName;
} else { // no defined artifact found for this dataType
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/star.png"); //NON-NLS
iconFileName = "star.png"; //NON-NLS
iconFilePath = path + File.separator + iconFileName;
iconFilePath = subPath + File.separator + iconFileName;
}
try {
@ -325,10 +328,11 @@ class ReportHTML implements TableReportModule {
// Refresh the HTML report
refresh();
// Setup the path for the HTML report
this.path = baseReportDir + "HTML Report" + File.separator; //NON-NLS
this.thumbsPath = this.path + "thumbs" + File.separator; //NON-NLS
this.path = baseReportDir; //NON-NLS
this.subPath = this.path + HTML_SUBDIR + File.separator;
this.thumbsPath = this.subPath + THUMBS_REL_PATH; //NON-NLS
try {
FileUtil.createFolder(new File(this.path));
FileUtil.createFolder(new File(this.subPath));
FileUtil.createFolder(new File(this.thumbsPath));
} catch (IOException ex) {
logger.log(Level.SEVERE, "Unable to make HTML report folder."); //NON-NLS
@ -367,7 +371,7 @@ class ReportHTML implements TableReportModule {
public void startDataType(String name, String description) {
String title = dataTypeToFileName(name);
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path + title + ".html"), "UTF-8")); //NON-NLS
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(subPath + title + ".html"), "UTF-8")); //NON-NLS
} catch (FileNotFoundException ex) {
logger.log(Level.SEVERE, "File not found: {0}", ex); //NON-NLS
} catch (UnsupportedEncodingException ex) {
@ -747,7 +751,7 @@ class ReportHTML implements TableReportModule {
// Make a folder for the local file with the same tagName as the tag.
StringBuilder localFilePath = new StringBuilder(); // full path
localFilePath.append(path);
localFilePath.append(subPath);
localFilePath.append(dirName2);
File localFileFolder = new File(localFilePath.toString());
if (!localFileFolder.exists()) {
@ -777,7 +781,7 @@ class ReportHTML implements TableReportModule {
}
// get the relative path
return localFilePath.toString().substring(path.length());
return localFilePath.toString().substring(subPath.length());
}
/**
@ -795,7 +799,7 @@ class ReportHTML implements TableReportModule {
@Override
public String getRelativeFilePath() {
return "HTML Report" + File.separator + "index.html"; //NON-NLS
return "report.html"; //NON-NLS
}
@Override
@ -814,7 +818,7 @@ class ReportHTML implements TableReportModule {
private void writeCss() {
Writer cssOut = null;
try {
cssOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path + "index.css"), "UTF-8")); //NON-NLS NON-NLS
cssOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(subPath + "index.css"), "UTF-8")); //NON-NLS NON-NLS
String css = "body {margin: 0px; padding: 0px; background: #FFFFFF; font: 13px/20px Arial, Helvetica, sans-serif; color: #535353;}\n"
+ //NON-NLS
"#content {padding: 30px;}\n"
@ -875,7 +879,7 @@ class ReportHTML implements TableReportModule {
*/
private void writeIndex() {
Writer indexOut = null;
String indexFilePath = path + "index.html"; //NON-NLS
String indexFilePath = path + "report.html"; //NON-NLS
try {
indexOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(indexFilePath), "UTF-8")); //NON-NLS
StringBuilder index = new StringBuilder();
@ -883,7 +887,7 @@ class ReportHTML implements TableReportModule {
String iconPath = reportBranding.getAgencyLogoPath();
if (iconPath == null) {
// use default Autopsy icon if custom icon is not set
iconPath = "favicon.ico";
iconPath = HTML_SUBDIR + "favicon.ico";
} else {
iconPath = Paths.get(reportBranding.getAgencyLogoPath()).getFileName().toString(); //ref to writeNav() for agency_logo
}
@ -895,8 +899,8 @@ class ReportHTML implements TableReportModule {
index.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"); //NON-NLS
index.append("</head>\n"); //NON-NLS
index.append("<frameset cols=\"350px,*\">\n"); //NON-NLS
index.append("<frame src=\"nav.html\" name=\"nav\">\n"); //NON-NLS
index.append("<frame src=\"summary.html\" name=\"content\">\n"); //NON-NLS
index.append("<frame src=\"" + HTML_SUBDIR).append(File.separator).append("nav.html\" name=\"nav\">\n"); //NON-NLS
index.append("<frame src=\"" + HTML_SUBDIR).append(File.separator).append("summary.html\" name=\"content\">\n"); //NON-NLS
index.append("<noframes>").append(NbBundle.getMessage(this.getClass(), "ReportHTML.writeIndex.noFrames.msg")).append("<br />\n"); //NON-NLS
index.append(NbBundle.getMessage(this.getClass(), "ReportHTML.writeIndex.noFrames.seeNav")).append("<br />\n"); //NON-NLS
index.append(NbBundle.getMessage(this.getClass(), "ReportHTML.writeIndex.seeSum")).append("</noframes>\n"); //NON-NLS
@ -906,7 +910,7 @@ class ReportHTML implements TableReportModule {
Case.getCurrentCase().addReport(indexFilePath, NbBundle.getMessage(this.getClass(),
"ReportHTML.writeIndex.srcModuleName.text"), "");
} catch (IOException ex) {
logger.log(Level.SEVERE, "Error creating Writer for index.html: {0}", ex); //NON-NLS
logger.log(Level.SEVERE, "Error creating Writer for report.html: {0}", ex); //NON-NLS
} catch (TskCoreException ex) {
String errorMessage = String.format("Error adding %s to case as a report", indexFilePath); //NON-NLS
logger.log(Level.SEVERE, errorMessage, ex);
@ -927,7 +931,7 @@ class ReportHTML implements TableReportModule {
private void writeNav() {
Writer navOut = null;
try {
navOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path + "nav.html"), "UTF-8")); //NON-NLS
navOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(subPath + "nav.html"), "UTF-8")); //NON-NLS
StringBuilder nav = new StringBuilder();
nav.append("<html>\n<head>\n\t<title>").append( //NON-NLS
NbBundle.getMessage(this.getClass(), "ReportHTML.writeNav.title"))
@ -972,24 +976,24 @@ class ReportHTML implements TableReportModule {
String generatorLogoPath = reportBranding.getGeneratorLogoPath();
if (generatorLogoPath != null && !generatorLogoPath.isEmpty()) {
File from = new File(generatorLogoPath);
File to = new File(path);
File to = new File(subPath);
FileUtil.copyFile(FileUtil.toFileObject(from), FileUtil.toFileObject(to), "generator_logo"); //NON-NLS
}
String agencyLogoPath = reportBranding.getAgencyLogoPath();
if (agencyLogoPath != null && !agencyLogoPath.isEmpty()) {
Path destinationPath = Paths.get(path);
Path destinationPath = Paths.get(subPath);
Files.copy(Files.newInputStream(Paths.get(agencyLogoPath)), destinationPath.resolve(Paths.get(agencyLogoPath).getFileName())); //NON-NLS
}
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/favicon.ico"); //NON-NLS
output = new FileOutputStream(new File(path + File.separator + "favicon.ico"));
output = new FileOutputStream(new File(subPath + "favicon.ico"));
FileUtil.copy(in, output);
in.close();
output.close();
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/summary.png"); //NON-NLS
output = new FileOutputStream(new File(path + File.separator + "summary.png"));
output = new FileOutputStream(new File(subPath + "summary.png"));
FileUtil.copy(in, output);
in.close();
output.close();
@ -1019,7 +1023,7 @@ class ReportHTML implements TableReportModule {
private void writeSummary() {
Writer out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path + "summary.html"), "UTF-8")); //NON-NLS
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(subPath + "summary.html"), "UTF-8")); //NON-NLS
StringBuilder head = new StringBuilder();
head.append("<html>\n<head>\n<title>").append( //NON-NLS
NbBundle.getMessage(this.getClass(), "ReportHTML.writeSum.title")).append("</title>\n"); //NON-NLS

View File

@ -2,7 +2,7 @@
*
* Autopsy Forensic Browser
*
* Copyright 2014-2016 Basis Technology Corp.
* Copyright 2014-2018 Basis Technology Corp.
* contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -104,6 +104,7 @@ class ReportKML implements GeneralReportModule {
progressPanel.start();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.querying"));
String kmlFileFullPath = baseReportDir + REPORT_KML; //NON-NLS
currentCase = Case.getCurrentCase();
skCase = currentCase.getSleuthkitCase();

View File

@ -652,10 +652,10 @@ class TestData(object):
# we are looking for is the only one in the self.reports_dir folder
html_path = ""
for fs in os.listdir(self.reports_dir):
html_path = make_path(self.reports_dir, fs)
if os.path.isdir(html_path):
if "HTML Report" in fs:
html_path = make_path(self.reports_dir, fs)
break
return make_path(html_path, os.listdir(html_path)[0])
return html_path
def get_sorted_data_path(self, file_type):
"""Get the path to the BlackboardDump file that corresponds to the given DBType.