From 18414d783c630f71bb5bdbdbb41da7a1344c11e4 Mon Sep 17 00:00:00 2001 From: Alex Ebadirad Date: Tue, 15 May 2012 09:05:58 -0700 Subject: [PATCH 1/9] temp dir for copy of db fix, reportxml visitor content issue fixed --- Report/src/org/sleuthkit/autopsy/report/Report.java | 6 +++--- Report/src/org/sleuthkit/autopsy/report/ReportXML.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Report/src/org/sleuthkit/autopsy/report/Report.java b/Report/src/org/sleuthkit/autopsy/report/Report.java index 73542a0467..6ad10aec29 100644 --- a/Report/src/org/sleuthkit/autopsy/report/Report.java +++ b/Report/src/org/sleuthkit/autopsy/report/Report.java @@ -51,8 +51,8 @@ public class Report { SleuthkitCase tempDb = currentCase.getSleuthkitCase(); try { ReportUtils util = new ReportUtils(); - util.copy(new FileInputStream(currentCase.getCaseDirectory()+File.separator+"autopsy.db"), new FileOutputStream(currentCase.getCaseDirectory()+File.separator+"autopsy-copy.db")); - dbconnect tempdbconnect = new dbconnect("org.sqlite.JDBC", "jdbc:sqlite:"+currentCase.getCaseDirectory()+File.separator+"autopsy-copy.db"); + util.copy(new FileInputStream(currentCase.getCaseDirectory()+File.separator+"autopsy.db"), new FileOutputStream(currentCase.getTempDirectory()+File.separator+"autopsy-copy.db")); + dbconnect tempdbconnect = new dbconnect("org.sqlite.JDBC", "jdbc:sqlite:"+currentCase.getTempDirectory()+File.separator+"autopsy-copy.db"); tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_keyword;"); tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_preview;"); tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_exp;"); @@ -92,7 +92,7 @@ public class Report { tempdbconnect.executeStmt("DROP TABLE IF EXISTS report;"); tempdbconnect.closeConnection(); - File f1 = new File(currentCase.getCaseDirectory()+File.separator+"autopsy-copy.db"); + File f1 = new File(currentCase.getTempDirectory()+File.separator+"autopsy-copy.db"); boolean success = f1.delete(); } catch (Exception e) { diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportXML.java b/Report/src/org/sleuthkit/autopsy/report/ReportXML.java index 8f50db617b..91983df5ee 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportXML.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportXML.java @@ -268,7 +268,7 @@ public class ReportXML implements ReportModule { return img.getName(); } - //@Override + @Override public String visit(File file) { return file.getName(); } From 884a3d1b27466130d71fdbf4df7b6ae9e2e5d335 Mon Sep 17 00:00:00 2001 From: Alex Ebadirad Date: Tue, 15 May 2012 10:47:02 -0700 Subject: [PATCH 2/9] AUT-53 bug fixes for: checkbox/lookup code use case temp dir for db copy fixed html report keyword list column reportxml visitor content exceptions css style should be present Better formatting on files Do not merge without changing line 51 in BlackboardArtifact.java in the sleuthkit from: TSK_RECENT_OBJECT(6, "TSK_RECENT_OBJ", "Recent Documents"), to: TSK_RECENT_OBJECT(6, "TSK_RECENT_OBJECT", "Recent Documents"), Signed-off-by: Alex Ebadirad --- HashDatabase/nbproject/genfiles.properties | 8 +- .../org/sleuthkit/autopsy/report/Report.java | 87 ++++++++++--------- .../autopsy/report/ReportAction.java | 17 ++-- .../autopsy/report/ReportFilter.form | 2 +- .../autopsy/report/ReportFilter.java | 26 +++--- .../autopsy/report/ReportFilterAction.java | 2 +- .../sleuthkit/autopsy/report/ReportHTML.java | 85 ++++++++---------- .../autopsy/report/ReportModule.java | 13 +-- .../sleuthkit/autopsy/report/ReportUtils.java | 21 ++--- .../sleuthkit/autopsy/report/ReportXML.java | 4 +- 10 files changed, 126 insertions(+), 139 deletions(-) diff --git a/HashDatabase/nbproject/genfiles.properties b/HashDatabase/nbproject/genfiles.properties index dbef507b7e..f53f934917 100644 --- a/HashDatabase/nbproject/genfiles.properties +++ b/HashDatabase/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=ec4b156b +build.xml.data.CRC32=656aafec build.xml.script.CRC32=1308cb72 -build.xml.stylesheet.CRC32=a56c6a5b@1.46.2 +build.xml.stylesheet.CRC32=a56c6a5b@2.47.2 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=ec4b156b +nbproject/build-impl.xml.data.CRC32=656aafec nbproject/build-impl.xml.script.CRC32=a7a0d07a -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47.2 diff --git a/Report/src/org/sleuthkit/autopsy/report/Report.java b/Report/src/org/sleuthkit/autopsy/report/Report.java index 6ad10aec29..4422e733a8 100644 --- a/Report/src/org/sleuthkit/autopsy/report/Report.java +++ b/Report/src/org/sleuthkit/autopsy/report/Report.java @@ -50,55 +50,56 @@ public class Report { Case currentCase = Case.getCurrentCase(); // get the most updated case SleuthkitCase tempDb = currentCase.getSleuthkitCase(); try { - ReportUtils util = new ReportUtils(); - util.copy(new FileInputStream(currentCase.getCaseDirectory()+File.separator+"autopsy.db"), new FileOutputStream(currentCase.getTempDirectory()+File.separator+"autopsy-copy.db")); - dbconnect tempdbconnect = new dbconnect("org.sqlite.JDBC", "jdbc:sqlite:"+currentCase.getTempDirectory()+File.separator+"autopsy-copy.db"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_keyword;"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_preview;"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_exp;"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_name;"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report;"); + ReportUtils util = new ReportUtils(); + util.copy(new FileInputStream(currentCase.getCaseDirectory() + File.separator + "autopsy.db"), new FileOutputStream(currentCase.getTempDirectory() + File.separator + "autopsy-copy.db")); + dbconnect tempdbconnect = new dbconnect("org.sqlite.JDBC", "jdbc:sqlite:" + currentCase.getTempDirectory() + File.separator + "autopsy-copy.db"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_keyword;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_preview;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_exp;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_list;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_name;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report;"); String temp1 = "CREATE TABLE report_keyword AS SELECT value_text as keyword,blackboard_attributes.attribute_type_id, blackboard_attributes.artifact_id FROM blackboard_attributes WHERE attribute_type_id = 10;"; - String temp2 = "CREATE TABLE report_preview AS SELECT value_text as preview, blackboard_attributes.attribute_type_id, blackboard_attributes.artifact_id FROM blackboard_attributes WHERE attribute_type_id = 11;"; - String temp3 = "CREATE TABLE report_exp AS SELECT value_text as exp, blackboard_attributes.attribute_type_id, blackboard_attributes.artifact_id FROM blackboard_attributes WHERE attribute_type_id = 12;"; - String temp4 = "CREATE TABLE report_name AS SELECT name, report_keyword.artifact_id from tsk_files,blackboard_artifacts, report_keyword WHERE blackboard_artifacts.artifact_id = report_keyword.artifact_id AND blackboard_artifacts.obj_id = tsk_files.obj_id;"; - String temp5 = "CREATE TABLE report AS SELECT keyword,preview,exp, name from report_keyword INNER JOIN report_preview ON report_keyword.artifact_id=report_preview.artifact_id INNER JOIN report_exp ON report_preview.artifact_id=report_exp.artifact_id INNER JOIN report_name ON report_exp.artifact_id=report_name.artifact_id;"; - tempdbconnect.executeStmt(temp1); - tempdbconnect.executeStmt(temp2); - tempdbconnect.executeStmt(temp3); - tempdbconnect.executeStmt(temp4); - tempdbconnect.executeStmt(temp5); - ResultSet uniqueresults = tempdbconnect.executeQry("SELECT keyword, preview, exp, name FROM report ORDER BY keyword ASC"); - String keyword = ""; - while (uniqueresults.next()) { - if(uniqueresults.getString("keyword") == null ? keyword == null : uniqueresults.getString("keyword").equals(keyword)) - { - + String temp2 = "CREATE TABLE report_preview AS SELECT value_text as preview, blackboard_attributes.attribute_type_id, blackboard_attributes.artifact_id FROM blackboard_attributes WHERE attribute_type_id = 12;"; + String temp3 = "CREATE TABLE report_exp AS SELECT value_text as exp, blackboard_attributes.attribute_type_id, blackboard_attributes.artifact_id FROM blackboard_attributes WHERE attribute_type_id = 11;"; + String temp4 = "CREATE TABLE report_list AS SELECT value_text as list, blackboard_attributes.attribute_type_id, blackboard_attributes.artifact_id FROM blackboard_attributes WHERE attribute_type_id = 13;"; + String temp5 = "CREATE TABLE report_name AS SELECT name, report_keyword.artifact_id from tsk_files,blackboard_artifacts, report_keyword WHERE blackboard_artifacts.artifact_id = report_keyword.artifact_id AND blackboard_artifacts.obj_id = tsk_files.obj_id;"; + String temp6 = "CREATE TABLE report AS SELECT keyword,preview,exp,list,name from report_keyword INNER JOIN report_preview ON report_keyword.artifact_id=report_preview.artifact_id INNER JOIN report_exp ON report_preview.artifact_id=report_exp.artifact_id INNER JOIN report_list ON report_exp.artifact_id=report_list.artifact_id INNER JOIN report_name ON report_list.artifact_id=report_name.artifact_id;"; + tempdbconnect.executeStmt(temp1); + tempdbconnect.executeStmt(temp2); + tempdbconnect.executeStmt(temp3); + tempdbconnect.executeStmt(temp4); + tempdbconnect.executeStmt(temp5); + tempdbconnect.executeStmt(temp6); + ResultSet uniqueresults = tempdbconnect.executeQry("SELECT keyword, exp, preview, list, name FROM report ORDER BY keyword ASC"); + String keyword = ""; + while (uniqueresults.next()) { + if (uniqueresults.getString("keyword") == null ? keyword == null : uniqueresults.getString("keyword").equals(keyword)) { + } else { + table.append("

"); + keyword = uniqueresults.getString("keyword"); + table.append("").append(keyword).append(""); + table.append(""); } - else{ - table.append("
").append("File Name").append("PreviewKeyword List


"); - keyword = uniqueresults.getString("keyword"); - table.append("").append(keyword).append(""); - table.append(""); - } - table.append(""); - table.append("").append("").append(""); - + table.append(""); + table.append("").append("").append(""); + } - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_keyword;"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_preview;"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_exp;"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_name;"); - tempdbconnect.executeStmt("DROP TABLE IF EXISTS report;"); - tempdbconnect.closeConnection(); - - File f1 = new File(currentCase.getTempDirectory()+File.separator+"autopsy-copy.db"); - boolean success = f1.delete(); - + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_keyword;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_preview;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_exp;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_name;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_list;"); + tempdbconnect.executeStmt("DROP TABLE IF EXISTS report;"); + tempdbconnect.closeConnection(); + + File f1 = new File(currentCase.getTempDirectory() + File.separator + "autopsy-copy.db"); + boolean success = f1.delete(); + } catch (Exception e) { Logger.getLogger(Report.class.getName()).log(Level.WARNING, "Exception occurred", e); } - + return table.toString(); } diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportAction.java b/Report/src/org/sleuthkit/autopsy/report/ReportAction.java index 6e148c83eb..807a9902f3 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportAction.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportAction.java @@ -62,7 +62,7 @@ public final class ReportAction extends CallableSystemAction implements Presente public static ReportConfiguration config; public ReportAction() { - setEnabled(false); + setEnabled(false); Case.addPropertyChangeListener(new PropertyChangeListener() { @Override @@ -155,8 +155,8 @@ public final class ReportAction extends CallableSystemAction implements Presente } } }; - - private class previewListener implements ItemListener { + + private class previewListener implements ItemListener { @Override public void itemStateChanged(ItemEvent e) { @@ -172,7 +172,7 @@ public final class ReportAction extends CallableSystemAction implements Presente } if (e.getStateChange() == ItemEvent.SELECTED) { String temp = buttan.getName(); - temp = temp.substring(0, temp.length()-1); + temp = temp.substring(0, temp.length() - 1); preview = temp; } } @@ -202,7 +202,7 @@ public final class ReportAction extends CallableSystemAction implements Presente reportList.clear(); config = new ReportConfiguration(); final JPanel filterpanel = new JPanel(new GridLayout(0, 2, 5, 5)); - final JPanel artpanel = new JPanel(new GridLayout(0, 3, 5, 5)); + final JPanel artpanel = new JPanel(new GridLayout(0, 3, 0, 0)); SwingUtilities.invokeLater(new Runnable() { @Override @@ -214,7 +214,7 @@ public final class ReportAction extends CallableSystemAction implements Presente filterpanel.setAlignmentY(Component.TOP_ALIGNMENT); filterpanel.setAlignmentX(Component.LEFT_ALIGNMENT); filterpanel.setSize(300, 100); - ButtonGroup previewGroup = new ButtonGroup(); + ButtonGroup previewGroup = new ButtonGroup(); for (ReportModule m : Lookup.getDefault().lookupAll(ReportModule.class)) { String name = m.getName(); String desc = m.getReportTypeDescription(); @@ -239,12 +239,13 @@ public final class ReportAction extends CallableSystemAction implements Presente artpanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); artpanel.setAlignmentY(Component.TOP_ALIGNMENT); artpanel.setAlignmentX(Component.LEFT_ALIGNMENT); - artpanel.setSize(300, 100); - for (BlackboardArtifact.ARTIFACT_TYPE a : panel.config.config.keySet()) { + artpanel.setPreferredSize(new Dimension(300, 150)); + for (BlackboardArtifact.ARTIFACT_TYPE a : ReportFilter.config.config.keySet()) { JCheckBox ce = new JCheckBox(); ce.setText(a.getDisplayName()); ce.setToolTipText(a.getDisplayName()); ce.setName(a.getLabel()); + ce.setPreferredSize(new Dimension(60, 30)); ce.setSelected(true); ce.addItemListener(clistener); artpanel.add(ce); diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportFilter.form b/Report/src/org/sleuthkit/autopsy/report/ReportFilter.form index 83cfc136ca..dd2ffc7dc0 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportFilter.form +++ b/Report/src/org/sleuthkit/autopsy/report/ReportFilter.form @@ -44,7 +44,7 @@ - + diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportFilter.java b/Report/src/org/sleuthkit/autopsy/report/ReportFilter.java index 86ef0f121d..229a03eae1 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportFilter.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportFilter.java @@ -39,7 +39,7 @@ import org.sleuthkit.datamodel.SleuthkitCase; public class ReportFilter extends javax.swing.JPanel { public static ArrayList filters = new ArrayList(); - public static ReportConfiguration config = new ReportConfiguration(); + public static ReportConfiguration config = new ReportConfiguration(); private final Logger logger = Logger.getLogger(this.getClass().getName()); public final ReportFilter panel = this; ReportPanelAction rpa = new ReportPanelAction(); @@ -51,16 +51,14 @@ public class ReportFilter extends javax.swing.JPanel { * Creates new form ReportFilter */ public ReportFilter() { - this.setLayout(new GridLayout(0,1)); + this.setLayout(new GridLayout(0, 1)); initComponents(); cancel = false; - try{ - config.getAllTypes(); - - } - catch(ReportModuleException ex) - { - Logger.getLogger(Report.class.getName()).log(Level.SEVERE, "Exception occurred", ex); + try { + config.getAllTypes(); + + } catch (ReportModuleException ex) { + Logger.getLogger(Report.class.getName()).log(Level.SEVERE, "Exception occurred", ex); } } @@ -156,9 +154,8 @@ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS String preview = ReportAction.preview; ArrayList reportList = ReportAction.reportList; ArrayList classList = new ArrayList(); - for(JCheckBox box : reportList) - { - if(box.isSelected()){ + for (JCheckBox box : reportList) { + if (box.isSelected()) { classList.add(box.getName()); } @@ -216,8 +213,7 @@ private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:e } }); } - - + public void progBarDone() { int max = progBar.getMaximum(); progBar.setValue(max); @@ -258,8 +254,6 @@ private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:e jButton2.addActionListener(e); cancelButton.addActionListener(e); } - - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelButton; private javax.swing.JButton jButton1; diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportFilterAction.java b/Report/src/org/sleuthkit/autopsy/report/ReportFilterAction.java index 3dbee14e68..6d27d3ec84 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportFilterAction.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportFilterAction.java @@ -50,7 +50,7 @@ class ReportFilterAction { cpane = frame.getContentPane(); // initialize panel with loaded settings final ReportFilter panel = new ReportFilter(); - + // add the panel to the popup window popUpWindow.add(panel); popUpWindow.pack(); diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java b/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java index 8d7b606ca1..f2d1e1ca06 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java @@ -46,8 +46,9 @@ import org.sleuthkit.datamodel.TskData; * * @author Alex */ -public class ReportHTML implements ReportModule{ +public class ReportHTML implements ReportModule { //Declare our publically accessible formatted Report, this will change everytime they run a Report + public static StringBuilder formatted_Report = new StringBuilder(); private static StringBuilder unformatted_header = new StringBuilder(); private static StringBuilder formatted_header = new StringBuilder(); @@ -55,22 +56,21 @@ public class ReportHTML implements ReportModule{ private ReportConfiguration config; private static ReportHTML instance = null; - ReportHTML(){ - + ReportHTML() { } - - public static synchronized ReportHTML getDefault() { + + public static synchronized ReportHTML getDefault() { if (instance == null) { instance = new ReportHTML(); } return instance; } - + @Override public String generateReport(ReportConfiguration reportconfig) throws ReportModuleException { config = reportconfig; - ReportGen reportobj = new ReportGen(); - reportobj.populateReport(reportconfig); + ReportGen reportobj = new ReportGen(); + reportobj.populateReport(reportconfig); HashMap> report = reportobj.Results; //This is literally a terrible way to count up all the types of artifacts, and doesn't include any added ones. //Unlike the XML Report, which is dynamic, this is formatted and needs to be redone later instead of being hardcoded. @@ -269,23 +269,20 @@ public class ReportHTML implements ReportModule{ String value = ""; Integer type = tempatt.getAttributeTypeID(); if (type.equals(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID()) || type.equals(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LAST_ACCESSED.getTypeID())) { - try{ - SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - value = sdf.format(new java.util.Date((tempatt.getValueLong()))); - } - catch(Exception ex){ - - } + try { + SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + value = sdf.format(new java.util.Date((tempatt.getValueLong()))); + } catch (Exception ex) { + } } else { value = tempatt.getValueString(); } - if(value == null || value.isEmpty()) - { + if (value == null || value.isEmpty()) { value = ""; } value = ReportUtils.insertPeriodically(value, "
", 30); attributes.put(type, value); - + } @@ -373,7 +370,7 @@ public class ReportHTML implements ReportModule{ //Add them back in order //formatted_Report.append(nodeGen); // formatted_Report.append("
").append("File Name").append("PreviewKeyword List
").append(uniqueresults.getString("name")).append("").append(uniqueresults.getString("preview")).append("").append(uniqueresults.getString("exp")).append("
").append(uniqueresults.getString("name")).append("").append(uniqueresults.getString("preview")).append("").append(uniqueresults.getString("list")).append("
(").append(uniqueresults.getString("exp")).append(")").append("
"); - + if (countWebBookmark > 0) { formatted_Report.append(nodeWebBookmark); formatted_Report.append(""); @@ -422,51 +419,46 @@ public class ReportHTML implements ReportModule{ // unformatted_header.append(formatted_Report); htmlPath = currentCase.getCaseDirectory() + "/Reports/" + caseName + "-" + datenotime + ".html"; this.save(htmlPath); - + } catch (Exception e) { Logger.getLogger(ReportHTML.class.getName()).log(Level.WARNING, "Exception occurred", e); } return htmlPath; } - + @Override - public String getName(){ - String name = "HTML"; - return name; + public String getName() { + String name = "HTML"; + return name; } - - + @Override - public void save(String path) - { - try{ - Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), "UTF-8")); + public void save(String path) { + try { + Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), "UTF-8")); out.write(formatted_header.toString()); out.flush(); out.close(); + } catch (IOException e) { + Logger.getLogger(ReportHTML.class.getName()).log(Level.SEVERE, "Could not write out HTML report!", e); } - catch(IOException e){ - Logger.getLogger(ReportHTML.class.getName()).log(Level.SEVERE, "Could not write out HTML report!", e); - } - - } - - @Override - public String getReportType(){ - String type = "HTML"; - return type; - } - + } + @Override - public ReportConfiguration GetReportConfiguration(){ + public String getReportType() { + String type = "HTML"; + return type; + } + + @Override + public ReportConfiguration GetReportConfiguration() { return config; } - @Override - public String getReportTypeDescription(){ + public String getReportTypeDescription() { String desc = "This is an html formatted report that is meant to be viewed in a modern browser."; return desc; } @@ -475,7 +467,4 @@ public class ReportHTML implements ReportModule{ public void getPreview(String path) { BrowserControl.openUrl(path); } - - - } \ No newline at end of file diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportModule.java b/Report/src/org/sleuthkit/autopsy/report/ReportModule.java index 7178888ee0..df285c54ac 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportModule.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportModule.java @@ -48,7 +48,7 @@ public interface ReportModule { * @return */ public String getReportType(); - + /** * Returns a basic string name for the report. What is 'officially' titled. * @@ -68,12 +68,13 @@ public interface ReportModule { * module generates */ public String getReportTypeDescription(); - - + /** - * Calls to the report module to execute a method to display the report that was generated. - *@param String the path to the file - * + * Calls to the report module to execute a method to display the report that + * was generated. + * + * @param String the path to the file + * */ public void getPreview(String path); } \ No newline at end of file diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportUtils.java b/Report/src/org/sleuthkit/autopsy/report/ReportUtils.java index 8c5b86f554..d5639717c2 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportUtils.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportUtils.java @@ -58,18 +58,19 @@ public class ReportUtils { } return builder.toString(); } - + public static void copy(InputStream in, OutputStream out) throws IOException { - BufferedInputStream bin = new BufferedInputStream(in); - BufferedOutputStream bout = new BufferedOutputStream(out); + BufferedInputStream bin = new BufferedInputStream(in); + BufferedOutputStream bout = new BufferedOutputStream(out); - while (true) { - int datum = bin.read(); - if (datum == -1) - break; - bout.write(datum); + while (true) { + int datum = bin.read(); + if (datum == -1) { + break; + } + bout.write(datum); + } + bout.flush(); } - bout.flush(); - } } \ No newline at end of file diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportXML.java b/Report/src/org/sleuthkit/autopsy/report/ReportXML.java index 91983df5ee..e5bb4ea865 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportXML.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportXML.java @@ -177,7 +177,7 @@ public class ReportXML implements ReportModule { if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_DEVICE_ATTACHED.getTypeID()) { nodeDevice.addContent(artifact); } - + //end of master loop } @@ -269,7 +269,7 @@ public class ReportXML implements ReportModule { } @Override - public String visit(File file) { + public String visit(org.sleuthkit.datamodel.File file) { return file.getName(); } } From 5e6749dbd5cba22891df33e8f8afa3c0a2efc31a Mon Sep 17 00:00:00 2001 From: Alex Ebadirad Date: Tue, 15 May 2012 12:58:01 -0700 Subject: [PATCH 3/9] Modified method use to from label instead of having to rely on blackboardartifact.java enum to match the label. Can merge without need to modify tsk now. --- Report/src/org/sleuthkit/autopsy/report/ReportAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportAction.java b/Report/src/org/sleuthkit/autopsy/report/ReportAction.java index 807a9902f3..e7b8e2b9e6 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportAction.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportAction.java @@ -140,7 +140,7 @@ public final class ReportAction extends CallableSystemAction implements Presente Object source = e.getItem(); JCheckBox comp = (JCheckBox) source; String name = comp.getName(); - BlackboardArtifact.ARTIFACT_TYPE type = BlackboardArtifact.ARTIFACT_TYPE.valueOf(name); + BlackboardArtifact.ARTIFACT_TYPE type = BlackboardArtifact.ARTIFACT_TYPE.fromLabel(name); if (e.getStateChange() == ItemEvent.DESELECTED) { try { config.setGenArtifactType(type, Boolean.FALSE); From 86c58ede4bfe54a0c23c05f963ae18e50bfd9b13 Mon Sep 17 00:00:00 2001 From: Alex Ebadirad Date: Tue, 15 May 2012 15:09:33 -0700 Subject: [PATCH 4/9] Cleans up some spacing issues Save/export report now functions differently, only saving the reports that ran New view each report after its been run in default program Added some getters and privitized some data members Added new method to get extention for each report type so we can use it to write files using a universal save method Signed-off-by: Alex Ebadirad --- .../sleuthkit/autopsy/report/ReportHTML.java | 5 + .../autopsy/report/ReportModule.java | 9 + .../sleuthkit/autopsy/report/ReportPanel.form | 112 +++++++----- .../sleuthkit/autopsy/report/ReportPanel.java | 164 ++++++++++++------ .../autopsy/report/ReportPanelAction.java | 13 +- .../sleuthkit/autopsy/report/ReportXLS.java | 5 + .../sleuthkit/autopsy/report/ReportXML.java | 6 + 7 files changed, 217 insertions(+), 97 deletions(-) diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java b/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java index f2d1e1ca06..56982b107d 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java @@ -451,6 +451,11 @@ public class ReportHTML implements ReportModule { String type = "HTML"; return type; } + @Override + public String getExtention() { + String ext = ".html"; + return ext; + } @Override public ReportConfiguration GetReportConfiguration() { diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportModule.java b/Report/src/org/sleuthkit/autopsy/report/ReportModule.java index df285c54ac..da2b8680d3 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportModule.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportModule.java @@ -77,4 +77,13 @@ public interface ReportModule { * */ public void getPreview(String path); + + /** + * Calls to the report module to execute a method to get the extention + * that is used for the report + * + * @return String the extention the file will be saved as + * + */ + public String getExtention(); } \ No newline at end of file diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportPanel.form b/Report/src/org/sleuthkit/autopsy/report/ReportPanel.form index 2985491963..ce69998999 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportPanel.form +++ b/Report/src/org/sleuthkit/autopsy/report/ReportPanel.form @@ -29,15 +29,7 @@ - - - - - - - - - + @@ -45,45 +37,79 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportPanel.java b/Report/src/org/sleuthkit/autopsy/report/ReportPanel.java index 1f0be0aeaa..9e0d183ec6 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportPanel.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportPanel.java @@ -20,14 +20,18 @@ */ package org.sleuthkit.autopsy.report; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.*; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import org.jdom.output.XMLOutputter; +import java.util.HashMap; +import java.util.Map; +import javax.swing.*; +import javax.swing.border.Border; /** * @@ -35,11 +39,17 @@ import org.jdom.output.XMLOutputter; */ public class ReportPanel extends javax.swing.JPanel { + private ReportPanelAction rpa; + /** * Creates new form ReportPanel */ - public ReportPanel() { + public ReportPanel(ReportPanelAction reportpanelaction) { initComponents(); + this.setLayout(new GridLayout(0, 1)); + Border border = BorderFactory.createTitledBorder("Report Summary"); + this.setBorder(border); + rpa = reportpanelaction; } /** @@ -53,11 +63,14 @@ public class ReportPanel extends javax.swing.JPanel { jFileChooser1 = new javax.swing.JFileChooser(); jOptionPane1 = new javax.swing.JOptionPane(); - jButton1 = new javax.swing.JButton(); - saveReport = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); + saveReport = new javax.swing.JButton(); + jButton1 = new javax.swing.JButton(); - jButton1.setText(org.openide.util.NbBundle.getMessage(ReportPanel.class, "ReportPanel.jButton1.text")); // NOI18N + jLabel1.setText(org.openide.util.NbBundle.getMessage(ReportPanel.class, "ReportPanel.jLabel1.text")); // NOI18N + jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.TOP); saveReport.setText(org.openide.util.NbBundle.getMessage(ReportPanel.class, "ReportPanel.saveReport.text")); // NOI18N saveReport.setActionCommand(org.openide.util.NbBundle.getMessage(ReportPanel.class, "ReportPanel.saveReport.actionCommand")); // NOI18N @@ -67,31 +80,47 @@ public class ReportPanel extends javax.swing.JPanel { } }); - jLabel1.setText(org.openide.util.NbBundle.getMessage(ReportPanel.class, "ReportPanel.jLabel1.text")); // NOI18N + jButton1.setText(org.openide.util.NbBundle.getMessage(ReportPanel.class, "ReportPanel.jButton1.text")); // NOI18N + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jButton1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 338, Short.MAX_VALUE) + .addComponent(saveReport)) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap(150, Short.MAX_VALUE) + .addComponent(jLabel1) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(saveReport) + .addComponent(jButton1)) + .addContainerGap()) + ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addComponent(jButton1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 128, Short.MAX_VALUE) - .addComponent(saveReport))) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jButton1) - .addComponent(saveReport)) + .addContainerGap(165, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); @@ -100,8 +129,9 @@ public class ReportPanel extends javax.swing.JPanel { }// //GEN-END:initComponents private void saveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveReportActionPerformed + HashMap reports = rpa.getReports(); + saveReportAction(reports); - saveReportAction(); }//GEN-LAST:event_saveReportActionPerformed /** * Sets the listener for the OK button @@ -113,49 +143,82 @@ private void saveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI } public void setFinishedReportText() { + DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); - String reportText = "Report was sucessfully generated at " + dateFormat.format(date) + "."; + String reportText = "These reports were generated on " + dateFormat.format(date) + ".

"; jLabel1.setText(reportText); + final JPanel tpanel = new JPanel(new GridBagLayout()); + + SwingUtilities.invokeLater(new Runnable() { + + GridBagConstraints c = new GridBagConstraints(); + + @Override + public void run() { + HashMap reports = rpa.getReports(); + int cc = 0; + for (Map.Entry entry : reports.entrySet()) { + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.gridwidth = 2; + c.gridx = 0; + c.gridy = cc; + String tempText = entry.getKey().getName() + " report - " + entry.getValue() + ""; + JLabel lb = new JLabel(); + lb.setText(tempText); + tpanel.add(lb, c); + tpanel.revalidate(); + tpanel.repaint(); + + JButton jb = new JButton(); + jb.setText("View Report"); + c.fill = GridBagConstraints.NONE; + c.weightx = 0.0; + c.gridwidth = 1; + c.gridx = 2; + c.gridy = cc; + final ReportModule rep = entry.getKey(); + final String path = entry.getValue(); + jb.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + rep.getPreview(path); + } + }); + tpanel.add(jb, c); + tpanel.revalidate(); + tpanel.repaint(); + cc++; + } + } + }); + this.add(tpanel, 0); + } - private void saveReportAction() { + private void saveReportAction(HashMap reports) { int option = jFileChooser1.showSaveDialog(this); if (option == JFileChooser.APPROVE_OPTION) { if (jFileChooser1.getSelectedFile() != null) { String path = jFileChooser1.getSelectedFile().toString(); - exportReport(path); + for (Map.Entry entry : reports.entrySet()) { + exportReport(path, entry.getKey().getExtention(), entry.getKey()); + } } } } - private void exportReport(String path) { + private void exportReport(String path, String ext, ReportModule report) { - String htmlpath = ReportUtils.changeExtension(path, ".html"); - String xmlpath = ReportUtils.changeExtension(path, ".xml"); - String xlspath = ReportUtils.changeExtension(path, ".xlsx"); + String newpath = ReportUtils.changeExtension(path + "-" + report.getName(), ext); try { - Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlpath), "UTF-8")); - - // FileOutputStream out = new FileOutputStream(htmlpath); - out.write(ReportHTML.formatted_Report.toString()); - out.flush(); - out.close(); - - //xls report - FileOutputStream fos = new FileOutputStream(xlspath); - ReportXLS.wb.write(fos); - fos.close(); - - FileOutputStream xmlout = new FileOutputStream(xmlpath); - XMLOutputter serializer = new XMLOutputter(); - serializer.output(ReportXML.xmldoc, xmlout); - xmlout.flush(); - xmlout.close(); - JOptionPane.showMessageDialog(this, "Report has been successfully saved!"); - } catch (IOException e) { - System.err.println(e); + report.save(newpath); + JOptionPane.showMessageDialog(this, "\n" + report.getName() + " report has been successfully saved to: \n" + newpath); + } catch (Exception e) { + JOptionPane.showMessageDialog(this, "\n" + report.getName() + " report has failed to save! \n Reason:" + e); } } // Variables declaration - do not modify//GEN-BEGIN:variables @@ -163,6 +226,7 @@ private void saveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI private javax.swing.JFileChooser jFileChooser1; private javax.swing.JLabel jLabel1; private javax.swing.JOptionPane jOptionPane1; + private javax.swing.JPanel jPanel1; private javax.swing.JButton saveReport; // End of variables declaration//GEN-END:variables } diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportPanelAction.java b/Report/src/org/sleuthkit/autopsy/report/ReportPanelAction.java index 2ac1aa5844..28864a1079 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportPanelAction.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportPanelAction.java @@ -26,8 +26,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.HashMap; import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.SwingUtilities; @@ -42,6 +42,7 @@ public class ReportPanelAction { private static final String ACTION_NAME = "Report Preview"; private StringBuilder viewReport = new StringBuilder(); private int cc = 0; + private HashMap reports = new HashMap(); public ReportPanelAction() { } @@ -75,7 +76,7 @@ public class ReportPanelAction { @Override public void run() { - + reports.clear(); for (String s : classList) { cc++; try { @@ -87,7 +88,7 @@ public class ReportPanelAction { String path = invoke.toString(); Class[] argTypes2 = new Class[] { String.class}; Method getpreview = reportclass.getMethod("getPreview",argTypes2); - + reports.put((ReportModule)reportObject,path); if(s == null ? preview == null : s.equals(preview)) { @@ -152,7 +153,7 @@ public class ReportPanelAction { //Set the temporary label to let the user know its done and is waiting on the report - final ReportPanel panel = new ReportPanel(); + final ReportPanel panel = new ReportPanel(this); panel.setjButton1ActionListener(new ActionListener() { @@ -187,4 +188,8 @@ public class ReportPanelAction { Log.get(ReportFilterAction.class).log(Level.WARNING, "Error displaying " + ACTION_NAME + " window.", ex); } } + + public HashMap getReports(){ + return reports; + } } diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportXLS.java b/Report/src/org/sleuthkit/autopsy/report/ReportXLS.java index 94a72b0454..aee8c1247b 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportXLS.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportXLS.java @@ -424,6 +424,11 @@ public class ReportXLS implements ReportModule { String type = "XLS"; return type; } + @Override + public String getExtention() { + String ext = ".xlsx"; + return ext; + } @Override public ReportConfiguration GetReportConfiguration() { diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportXML.java b/Report/src/org/sleuthkit/autopsy/report/ReportXML.java index e5bb4ea865..936aed8e48 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportXML.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportXML.java @@ -233,6 +233,12 @@ public class ReportXML implements ReportModule { String type = "XML"; return type; } + + @Override + public String getExtention() { + String ext = ".xml"; + return ext; + } @Override public ReportConfiguration GetReportConfiguration() { From 449c4ef3a60bea4f324c516f3d5ceb7da89374d4 Mon Sep 17 00:00:00 2001 From: Alex Ebadirad Date: Wed, 16 May 2012 08:31:16 -0700 Subject: [PATCH 5/9] fixed typo for method from extention to extension Signed-off-by: Alex Ebadirad --- Report/src/org/sleuthkit/autopsy/report/ReportHTML.java | 2 +- Report/src/org/sleuthkit/autopsy/report/ReportModule.java | 6 +++--- Report/src/org/sleuthkit/autopsy/report/ReportPanel.form | 2 +- Report/src/org/sleuthkit/autopsy/report/ReportPanel.java | 2 +- Report/src/org/sleuthkit/autopsy/report/ReportXLS.java | 2 +- Report/src/org/sleuthkit/autopsy/report/ReportXML.java | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java b/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java index 56982b107d..c455c8662f 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportHTML.java @@ -452,7 +452,7 @@ public class ReportHTML implements ReportModule { return type; } @Override - public String getExtention() { + public String getExtension() { String ext = ".html"; return ext; } diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportModule.java b/Report/src/org/sleuthkit/autopsy/report/ReportModule.java index da2b8680d3..9c8e86b2ef 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportModule.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportModule.java @@ -79,11 +79,11 @@ public interface ReportModule { public void getPreview(String path); /** - * Calls to the report module to execute a method to get the extention + * Calls to the report module to execute a method to get the extension * that is used for the report * - * @return String the extention the file will be saved as + * @return String the extension the file will be saved as * */ - public String getExtention(); + public String getExtension(); } \ No newline at end of file diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportPanel.form b/Report/src/org/sleuthkit/autopsy/report/ReportPanel.form index ce69998999..4638b993c5 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportPanel.form +++ b/Report/src/org/sleuthkit/autopsy/report/ReportPanel.form @@ -67,7 +67,7 @@ - + diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportPanel.java b/Report/src/org/sleuthkit/autopsy/report/ReportPanel.java index 9e0d183ec6..60568a3f47 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportPanel.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportPanel.java @@ -205,7 +205,7 @@ private void saveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI if (jFileChooser1.getSelectedFile() != null) { String path = jFileChooser1.getSelectedFile().toString(); for (Map.Entry entry : reports.entrySet()) { - exportReport(path, entry.getKey().getExtention(), entry.getKey()); + exportReport(path, entry.getKey().getExtension(), entry.getKey()); } } } diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportXLS.java b/Report/src/org/sleuthkit/autopsy/report/ReportXLS.java index aee8c1247b..4fb656d952 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportXLS.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportXLS.java @@ -425,7 +425,7 @@ public class ReportXLS implements ReportModule { return type; } @Override - public String getExtention() { + public String getExtension() { String ext = ".xlsx"; return ext; } diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportXML.java b/Report/src/org/sleuthkit/autopsy/report/ReportXML.java index 936aed8e48..ffee13420c 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportXML.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportXML.java @@ -235,7 +235,7 @@ public class ReportXML implements ReportModule { } @Override - public String getExtention() { + public String getExtension() { String ext = ".xml"; return ext; } From a6d43b67a646a3918934b3694c2ff6d7a2fb2c7d Mon Sep 17 00:00:00 2001 From: Alex Ebadirad Date: Wed, 16 May 2012 10:40:44 -0700 Subject: [PATCH 6/9] Using copycasedb method now, additional information to the filterpanel to show more progress so it doesn't appear anything is 'hanging'. Signed-off-by: Alex Ebadirad --- .../autopsy/report/Bundle.properties | 2 ++ .../org/sleuthkit/autopsy/report/Report.java | 3 +- .../autopsy/report/ReportFilter.form | 22 +++++++++++--- .../autopsy/report/ReportFilter.java | 30 +++++++++++++++---- .../autopsy/report/ReportPanelAction.java | 18 +++++++---- 5 files changed, 59 insertions(+), 16 deletions(-) diff --git a/Report/src/org/sleuthkit/autopsy/report/Bundle.properties b/Report/src/org/sleuthkit/autopsy/report/Bundle.properties index af5d6ace1a..4f6bf32b0e 100644 --- a/Report/src/org/sleuthkit/autopsy/report/Bundle.properties +++ b/Report/src/org/sleuthkit/autopsy/report/Bundle.properties @@ -11,3 +11,5 @@ ReportPanel.jLabel1.text=jLabel1 ReportPanel.saveReport.actionCommand= ReportPanel.saveReport.text=Export Report... ReportPanel.jButton1.text=Close +ReportFilter.updateLabel.toolTipText= +ReportFilter.updateLabel.text= diff --git a/Report/src/org/sleuthkit/autopsy/report/Report.java b/Report/src/org/sleuthkit/autopsy/report/Report.java index 4422e733a8..1df3949616 100644 --- a/Report/src/org/sleuthkit/autopsy/report/Report.java +++ b/Report/src/org/sleuthkit/autopsy/report/Report.java @@ -50,8 +50,7 @@ public class Report { Case currentCase = Case.getCurrentCase(); // get the most updated case SleuthkitCase tempDb = currentCase.getSleuthkitCase(); try { - ReportUtils util = new ReportUtils(); - util.copy(new FileInputStream(currentCase.getCaseDirectory() + File.separator + "autopsy.db"), new FileOutputStream(currentCase.getTempDirectory() + File.separator + "autopsy-copy.db")); + tempDb.copyCaseDB(currentCase.getTempDirectory() + File.separator + "autopsy-copy.db"); dbconnect tempdbconnect = new dbconnect("org.sqlite.JDBC", "jdbc:sqlite:" + currentCase.getTempDirectory() + File.separator + "autopsy-copy.db"); tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_keyword;"); tempdbconnect.executeStmt("DROP TABLE IF EXISTS report_preview;"); diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportFilter.form b/Report/src/org/sleuthkit/autopsy/report/ReportFilter.form index dd2ffc7dc0..584bcb04e5 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportFilter.form +++ b/Report/src/org/sleuthkit/autopsy/report/ReportFilter.form @@ -1,4 +1,4 @@ - +
@@ -41,15 +41,16 @@ - + + - + @@ -57,7 +58,10 @@ - + + + + @@ -111,5 +115,15 @@ + + + + + + + + + + diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportFilter.java b/Report/src/org/sleuthkit/autopsy/report/ReportFilter.java index 229a03eae1..cdc6f2d0a2 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportFilter.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportFilter.java @@ -75,6 +75,7 @@ public class ReportFilter extends javax.swing.JPanel { progBar = new javax.swing.JProgressBar(); jButton1 = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); + updateLabel = new javax.swing.JLabel(); jButton2.setText(org.openide.util.NbBundle.getMessage(ReportFilter.class, "ReportFilter.jButton2.text")); // NOI18N jButton2.setActionCommand(org.openide.util.NbBundle.getMessage(ReportFilter.class, "ReportFilter.jButton2.actionCommand")); // NOI18N @@ -110,6 +111,9 @@ public class ReportFilter extends javax.swing.JPanel { } }); + updateLabel.setText(org.openide.util.NbBundle.getMessage(ReportFilter.class, "ReportFilter.updateLabel.text")); // NOI18N + updateLabel.setToolTipText(org.openide.util.NbBundle.getMessage(ReportFilter.class, "ReportFilter.updateLabel.toolTipText")); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -119,18 +123,21 @@ public class ReportFilter extends javax.swing.JPanel { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jButton1) - .addContainerGap()) + .addGap(18, 18, 18) + .addComponent(updateLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() - .addComponent(progBar, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE) + .addComponent(progBar, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cancelButton) - .addGap(24, 24, 24)))) + .addComponent(cancelButton))) + .addGap(24, 24, 24)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(19, 19, 19) - .addComponent(jButton1) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton1) + .addComponent(updateLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(cancelButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -225,6 +232,18 @@ private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:e progBar.setString("Querying Database for Report Results..."); } + public void setUpdateLabel(final String text) { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + updateLabel.setText(text); + updateLabel.repaint(); + } + }); + + } + public void progBarText() { progBar.setString("Populating Report - Please wait..."); @@ -259,5 +278,6 @@ private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:e private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JProgressBar progBar; + private javax.swing.JLabel updateLabel; // End of variables declaration//GEN-END:variables } diff --git a/Report/src/org/sleuthkit/autopsy/report/ReportPanelAction.java b/Report/src/org/sleuthkit/autopsy/report/ReportPanelAction.java index 28864a1079..dfa8e713a4 100644 --- a/Report/src/org/sleuthkit/autopsy/report/ReportPanelAction.java +++ b/Report/src/org/sleuthkit/autopsy/report/ReportPanelAction.java @@ -41,7 +41,7 @@ public class ReportPanelAction { private static final String ACTION_NAME = "Report Preview"; private StringBuilder viewReport = new StringBuilder(); - private int cc = 0; + private int cc = 1; private HashMap reports = new HashMap(); public ReportPanelAction() { } @@ -67,9 +67,17 @@ public class ReportPanelAction { @Override public void run() { - rr.progBarCount(classList.size()); + rr.progBarCount(classList.size()+1); } }); + // Advance the bar a bit so the user knows something is happening + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + rr.progBarSet(1); + } + }); //Turn our results into the appropriate xml/html reports //TODO: add a way for users to select what they will run when Thread reportThread = new Thread(new Runnable() { @@ -78,13 +86,14 @@ public class ReportPanelAction { public void run() { reports.clear(); for (String s : classList) { - cc++; try { - Class reportclass = Class.forName(s); + final Class reportclass = Class.forName(s); + rr.setUpdateLabel("Running " + reportclass.getSimpleName() + " report..."); Object reportObject = reportclass.newInstance(); Class[] argTypes = new Class[] { ReportConfiguration.class}; Method generatereport = reportclass.getDeclaredMethod("generateReport",argTypes); Object invoke = generatereport.invoke(reportObject,reportconfig); + rr.progBarSet(cc); String path = invoke.toString(); Class[] argTypes2 = new Class[] { String.class}; Method getpreview = reportclass.getMethod("getPreview",argTypes2); @@ -98,7 +107,6 @@ public class ReportPanelAction { } catch (Exception e) { } - rr.progBarSet(cc); } // StopWatch a = new StopWatch(); From d4affa5ef679b111b70af228f2d2c20dcc902c45 Mon Sep 17 00:00:00 2001 From: adam-m Date: Thu, 17 May 2012 10:09:37 -0400 Subject: [PATCH 7/9] Keyword search ingest: handle final searcher case if thread cancel() is non-blocking operation In done(), collect and log all exceptions thrown while in background --- .../KeywordSearchIngestService.java | 44 +++++++++++-------- .../keywordsearch/KeywordSearchQuery.java | 3 +- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java index fee64feb90..c5c8355c9a 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java @@ -74,12 +74,10 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent private Map> currentResults; private volatile int messageID = 0; private boolean processedFiles; - private volatile boolean finalRun = false; private volatile boolean finalRunComplete = false; private final String hashDBServiceName = "Hash Lookup"; private SleuthkitCase caseHandle = null; boolean initialized = false; - public enum IngestStatus { @@ -165,8 +163,7 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent updateKeywords(); //run one last search as there are probably some new files committed if (keywords != null && !keywords.isEmpty() && processedFiles == true) { - finalRun = true; - searcher = new Searcher(keywords); + searcher = new Searcher(keywords, true); //final searcher run searcher.execute(); } else { finalRunComplete = true; @@ -230,7 +227,6 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent } processedFiles = false; - finalRun = false; finalRunComplete = false; searcherDone = true; //make sure to start the initial searcher //keeps track of all results per run not to repeat reporting the same hits @@ -517,15 +513,21 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent private List keywords; private ProgressHandle progress; private final Logger logger = Logger.getLogger(Searcher.class.getName()); + private boolean finalRun = false; Searcher(List keywords) { this.keywords = keywords; } + Searcher(List keywords, boolean finalRun) { + this(keywords); + this.finalRun = finalRun; + } + @Override protected Object doInBackground() throws Exception { logger.log(Level.INFO, "Starting new searcher"); - + //make sure other searchers are not spawned searcherDone = false; @@ -691,7 +693,7 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent } detailsSb.append(""); - managerProxy.postMessage(IngestMessage.createDataMessage(++messageID, instance, subjectSb.toString(), detailsSb.toString(), uniqueKey, written.getArtifact())); + managerProxy.postMessage(IngestMessage.createDataMessage(++messageID, instance, subjectSb.toString(), detailsSb.toString(), uniqueKey, written.getArtifact())); } //for each term hit @@ -710,19 +712,25 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent @Override protected void done() { - super.done(); - searcherDone = true; //next searcher can start + try { + super.get(); //block and get all exceptions thrown while doInBackground() - progress.finish(); + } catch (Exception ex) { + logger.log(Level.WARNING, "Searcher exceptions occurred, while in background. ", ex); + } finally { + searcherDone = true; //next searcher can start - logger.log(Level.INFO, "Searcher done"); - if (finalRun) { - logger.log(Level.INFO, "The final searcher in this ingest done."); - finalRunComplete = true; - keywords.clear(); - keywordLists.clear(); - keywordToList.clear(); - managerProxy.postMessage(IngestMessage.createMessage(++messageID, MessageType.INFO, KeywordSearchIngestService.instance, "Completed")); + progress.finish(); + + logger.log(Level.INFO, "Searcher done"); + if (finalRun) { + logger.log(Level.INFO, "The final searcher in this ingest done."); + finalRunComplete = true; + keywords.clear(); + keywordLists.clear(); + keywordToList.clear(); + managerProxy.postMessage(IngestMessage.createMessage(++messageID, MessageType.INFO, KeywordSearchIngestService.instance, "Completed")); + } } } } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java index c991cd7dec..a99dab53a3 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java @@ -84,9 +84,8 @@ public interface KeywordSearchQuery { * @param newFsHit fscontent for which to write results for this hit * @param listName listname * @return collection of results (with cached bb artifacts/attributes) created and written - * @throws NoOpenCoreException if could not write to bb because required query failed due to server error, this could be a notification to stop processing */ - public KeywordWriteResult writeToBlackBoard(String termHit, FsContent newFsHit, String listName) throws NoOpenCoreException; + public KeywordWriteResult writeToBlackBoard(String termHit, FsContent newFsHit, String listName); } From 9e2de4cb639e149d4fcdaf3d2667f414cefc0fd4 Mon Sep 17 00:00:00 2001 From: adam-m Date: Thu, 17 May 2012 10:17:33 -0400 Subject: [PATCH 8/9] Catch cancellation exception in addition to checking for iscancelled --- .../autopsy/keywordsearch/KeywordSearchIngestService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java index c5c8355c9a..bb5a831b0b 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java @@ -26,9 +26,9 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.CancellationException; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.Timer; import org.apache.commons.lang.StringEscapeUtils; @@ -577,6 +577,9 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent //or wait for recovery to kick in and run again later //likely case has closed and threads are being interrupted return null; + } catch (CancellationException e) { + logger.log(Level.INFO, "Cancel detected, bailing during keyword query: " + keywordQuery.getQuery()); + return null; } catch (Exception e) { logger.log(Level.WARNING, "Error performing query: " + keywordQuery.getQuery(), e); continue; From 042b47b7668490326cd6806e64a50fb418abded1 Mon Sep 17 00:00:00 2001 From: adam-m Date: Thu, 17 May 2012 10:21:33 -0400 Subject: [PATCH 9/9] fix signature before merge --- .../org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java index a99dab53a3..eb6caa1632 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java @@ -85,7 +85,7 @@ public interface KeywordSearchQuery { * @param listName listname * @return collection of results (with cached bb artifacts/attributes) created and written */ - public KeywordWriteResult writeToBlackBoard(String termHit, FsContent newFsHit, String listName); + public KeywordWriteResult writeToBlackBoard(String termHit, FsContent newFsHit, String listName) throws NoOpenCoreException; }