From 525b87d096712c6f4e0f670f2878746d9730394c Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Tue, 26 May 2015 09:35:47 -0400 Subject: [PATCH] Updated report interface variable name to make it more clear. Updated sample python report module --- .../modules/stix/STIXReportModule.java | 6 ++--- .../autopsy/report/FileReportModule.java | 4 ++-- .../autopsy/report/FileReportText.java | 4 ++-- .../autopsy/report/GeneralReportModule.java | 4 ++-- .../report/GeneralReportModuleAdapter.java | 2 +- .../autopsy/report/ReportBodyFile.java | 6 ++--- .../sleuthkit/autopsy/report/ReportExcel.java | 6 ++--- .../sleuthkit/autopsy/report/ReportHTML.java | 6 ++--- .../sleuthkit/autopsy/report/ReportKML.java | 8 +++---- .../autopsy/report/ReportModule.java | 8 +++---- .../autopsy/report/TableReportModule.java | 4 ++-- pythonExamples/reportmodule.py | 22 ++++++++++++++----- 12 files changed, 46 insertions(+), 34 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/STIXReportModule.java b/Core/src/org/sleuthkit/autopsy/modules/stix/STIXReportModule.java index e9f7bd4c43..963cc717e6 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/STIXReportModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/STIXReportModule.java @@ -96,16 +96,16 @@ public class STIXReportModule implements GeneralReportModule { /** * . * - * @param path path to save the report + * @param baseReportDir path to save the report * @param progressPanel panel to update the report's progress */ @Override - public void generateReport(String path, ReportProgressPanel progressPanel) { + public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) { // Start the progress bar and setup the report progressPanel.setIndeterminate(false); progressPanel.start(); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "STIXReportModule.progress.readSTIX")); - reportPath = path + getRelativeFilePath(); + reportPath = baseReportDir + getRelativeFilePath(); // Check if the user wants to display all output or just hits reportAllResults = configPanel.getShowAllResults(); diff --git a/Core/src/org/sleuthkit/autopsy/report/FileReportModule.java b/Core/src/org/sleuthkit/autopsy/report/FileReportModule.java index e69f4c0ac8..393467685b 100755 --- a/Core/src/org/sleuthkit/autopsy/report/FileReportModule.java +++ b/Core/src/org/sleuthkit/autopsy/report/FileReportModule.java @@ -29,9 +29,9 @@ import org.sleuthkit.datamodel.AbstractFile; interface FileReportModule extends ReportModule { /** * Initialize the report which will be stored at the given path. - * @param path + * @param baseReportDir Base directory to store the report file in. Report should go into baseReportDir + getRelativeFilePath(). */ - public void startReport(String path); + public void startReport(String baseReportDir); /** * End the report. diff --git a/Core/src/org/sleuthkit/autopsy/report/FileReportText.java b/Core/src/org/sleuthkit/autopsy/report/FileReportText.java index bdfd7c284c..2dd7e8b676 100755 --- a/Core/src/org/sleuthkit/autopsy/report/FileReportText.java +++ b/Core/src/org/sleuthkit/autopsy/report/FileReportText.java @@ -54,8 +54,8 @@ import org.sleuthkit.datamodel.AbstractFile; } @Override - public void startReport(String path) { - this.reportPath = path + FILE_NAME; + public void startReport(String baseReportDir) { + this.reportPath = baseReportDir + FILE_NAME; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.reportPath))); } catch (IOException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/report/GeneralReportModule.java b/Core/src/org/sleuthkit/autopsy/report/GeneralReportModule.java index 08aa476b9f..8d5bf001b0 100644 --- a/Core/src/org/sleuthkit/autopsy/report/GeneralReportModule.java +++ b/Core/src/org/sleuthkit/autopsy/report/GeneralReportModule.java @@ -26,10 +26,10 @@ public interface GeneralReportModule extends ReportModule { * Called to generate the report. Method is responsible for saving the file at the * path specified and updating progress via the progressPanel object. * - * @param reportPath path to save the report + * @param baseReportDir Base directory that reports are being stored in. Report should go into baseReportDir + getRelativeFilePath(). * @param progressPanel panel to update the report's progress with */ - public void generateReport(String reportPath, ReportProgressPanel progressPanel); + public void generateReport(String baseReportDir, ReportProgressPanel progressPanel); /** * Returns the configuration panel for the report, which is displayed in diff --git a/Core/src/org/sleuthkit/autopsy/report/GeneralReportModuleAdapter.java b/Core/src/org/sleuthkit/autopsy/report/GeneralReportModuleAdapter.java index 6e8bc52500..f66b1c69a2 100755 --- a/Core/src/org/sleuthkit/autopsy/report/GeneralReportModuleAdapter.java +++ b/Core/src/org/sleuthkit/autopsy/report/GeneralReportModuleAdapter.java @@ -38,7 +38,7 @@ public abstract class GeneralReportModuleAdapter implements GeneralReportModule } @Override - public abstract void generateReport(String reportPath, ReportProgressPanel progressPanel); + public abstract void generateReport(String baseReportDir, ReportProgressPanel progressPanel); @Override public JPanel getConfigurationPanel() { diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportBodyFile.java b/Core/src/org/sleuthkit/autopsy/report/ReportBodyFile.java index d772871c79..1d79efc8c3 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportBodyFile.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportBodyFile.java @@ -63,17 +63,17 @@ import org.sleuthkit.datamodel.*; /** * Generates a body file format report for use with the MAC time tool. - * @param path path to save the report + * @param baseReportDir path to save the report * @param progressPanel panel to update the report's progress */ @Override @SuppressWarnings("deprecation") - public void generateReport(String path, ReportProgressPanel progressPanel) { + public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) { // Start the progress bar and setup the report progressPanel.setIndeterminate(false); progressPanel.start(); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportBodyFile.progress.querying")); - reportPath = path + "BodyFile.txt"; //NON-NLS + reportPath = baseReportDir + "BodyFile.txt"; //NON-NLS currentCase = Case.getCurrentCase(); skCase = currentCase.getSleuthkitCase(); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportExcel.java b/Core/src/org/sleuthkit/autopsy/report/ReportExcel.java index c348e79f5c..8b9d6dd7cb 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportExcel.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportExcel.java @@ -58,12 +58,12 @@ import org.sleuthkit.datamodel.TskCoreException; /** * Start the Excel report by creating the Workbook, initializing styles, * and writing the summary. - * @param path path to save the report + * @param baseReportDir path to save the report */ @Override - public void startReport(String path) { + public void startReport(String baseReportDir) { // Set the path and save it for when the report is written to disk. - this.reportPath = path + getRelativeFilePath(); + this.reportPath = baseReportDir + getRelativeFilePath(); // Make a workbook. wb = new XSSFWorkbook(); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java b/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java index 67a2cbbbf5..18d41df409 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java @@ -299,14 +299,14 @@ import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM; /** * Start this report by setting the path, refreshing member variables, * and writing the skeleton for the HTML report. - * @param path path to save the report + * @param baseReportDir path to save the report */ @Override - public void startReport(String path) { + public void startReport(String baseReportDir) { // Refresh the HTML report refresh(); // Setup the path for the HTML report - this.path = path + "HTML Report" + File.separator; //NON-NLS + this.path = baseReportDir + "HTML Report" + File.separator; //NON-NLS this.thumbsPath = this.path + "thumbs" + File.separator; //NON-NLS try { FileUtil.createFolder(new File(this.path)); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportKML.java b/Core/src/org/sleuthkit/autopsy/report/ReportKML.java index 1f6c5a665b..fac72da35b 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportKML.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportKML.java @@ -70,18 +70,18 @@ class ReportKML implements GeneralReportModule { /** * Generates a body file format report for use with the MAC time tool. * - * @param path path to save the report + * @param baseReportDir path to save the report * @param progressPanel panel to update the report's progress */ @Override - public void generateReport(String path, ReportProgressPanel progressPanel) { + public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) { // Start the progress bar and setup the report progressPanel.setIndeterminate(false); progressPanel.start(); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.querying")); - reportPath = path + "ReportKML.kml"; //NON-NLS - String reportPath2 = path + "ReportKML.txt"; //NON-NLS + reportPath = baseReportDir + "ReportKML.kml"; //NON-NLS + String reportPath2 = baseReportDir + "ReportKML.txt"; //NON-NLS currentCase = Case.getCurrentCase(); skCase = currentCase.getSleuthkitCase(); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportModule.java b/Core/src/org/sleuthkit/autopsy/report/ReportModule.java index 2d0ab6b0d2..7441835263 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportModule.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportModule.java @@ -40,11 +40,11 @@ interface ReportModule { /** * Gets the relative path of the report file, if any, generated by this - * module. The path should be relative to the time stamp subdirectory of - * reports directory. + * module. The path should be relative to the location that gets passed in + * to generateReport() (or similar). * - * @return Report file path relative to the time stamp subdirectory reports - * directory, may be null if the module does not produce a report file. + * @return Relative path to where report will be stored. + * May be null if the module does not produce a report file. */ public String getRelativeFilePath(); } diff --git a/Core/src/org/sleuthkit/autopsy/report/TableReportModule.java b/Core/src/org/sleuthkit/autopsy/report/TableReportModule.java index 448afe753f..cb5e9c3b28 100644 --- a/Core/src/org/sleuthkit/autopsy/report/TableReportModule.java +++ b/Core/src/org/sleuthkit/autopsy/report/TableReportModule.java @@ -35,9 +35,9 @@ import java.util.List; * Start the report. Open any output streams, initialize member variables, * write summary and navigation pages. Considered the "constructor" of the report. * - * @param path String path to save the report + * @param baseReportDir Directory to save the report file into. Report should go into baseReportDir + getRelativeFilePath(). */ - public void startReport(String path); + public void startReport(String baseReportDir); /** * End the report. Close all output streams and write any end-of-report diff --git a/pythonExamples/reportmodule.py b/pythonExamples/reportmodule.py index 566ad0f1c3..fc1c017905 100755 --- a/pythonExamples/reportmodule.py +++ b/pythonExamples/reportmodule.py @@ -27,25 +27,36 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. + +# Report module for Autopsy. +# +# Search for TODO for the things that you need to change +# See http://sleuthkit.org/autopsy/docs/api-docs/3.1/index.html for documentation + from java.lang import System from org.sleuthkit.autopsy.casemodule import Case from org.sleuthkit.autopsy.report import GeneralReportModuleAdapter -# Sample module that writes a file with the number of files -# created in the last 2 weeks. +# TODO: Rename this to something more specific class SampleGeneralReportModule(GeneralReportModuleAdapter): + # TODO: Rename this. Will be shown to users when making a report def getName(self): return "Sample Jython Report Module" + # TODO: rewrite this def getDescription(self): return "A sample Jython report module" + # TODO: Update this to reflect where the report file will be written to def getRelativeFilePath(self): return "sampleReport.txt" - def generateReport(self, reportPath, progressBar): - # Configure progress bar for 2 tasks + # TODO: Update this method to make a report + def generateReport(self, baseReportDir, progressBar): + + # For an example, we write a file with the number of files created in the past 2 weeks + # Configure progress bar for 2 tasks progressBar.setIndeterminate(False) progressBar.start() progressBar.setMaximumProgress(2) @@ -62,9 +73,10 @@ class SampleGeneralReportModule(GeneralReportModuleAdapter): progressBar.increment() # Write the result to the report file. - report = open(reportPath + '\\' + self.getRelativeFilePath(), 'w') + report = open(baseReportDir + '\\' + self.getRelativeFilePath(), 'w') report.write("file count = %d" % fileCount) Case.getCurrentCase().addReport(report.name, "SampleGeneralReportModule", "Sample Python Report"); report.close() + progressBar.increment() progressBar.complete() \ No newline at end of file