Merge branch 'master' into new-features-20120503

Conflicts:
	KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestService.java
This commit is contained in:
adam-m 2012-05-17 10:24:39 -04:00
commit 708dbd63ee
17 changed files with 433 additions and 274 deletions

View File

@ -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

View File

@ -18,9 +18,7 @@
*/
package org.sleuthkit.autopsy.keywordsearch;
import java.io.IOException;
import org.openide.util.Exceptions;
import org.sleuthkit.autopsy.datamodel.FsContentStringStream;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
@ -28,6 +26,7 @@ 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.SwingWorker;
@ -76,12 +75,10 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent
private Map<Keyword, List<ContentHit>> 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;
private final byte[] STRING_CHUNK_BUF = new byte[(int) MAX_STRING_CHUNK_SIZE];
public enum IngestStatus {
@ -167,8 +164,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;
@ -232,7 +228,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
@ -515,15 +510,21 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent
private List<Keyword> keywords;
private ProgressHandle progress;
private final Logger logger = Logger.getLogger(Searcher.class.getName());
private boolean finalRun = false;
Searcher(List<Keyword> keywords) {
this.keywords = keywords;
}
Searcher(List<Keyword> 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;
@ -573,6 +574,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;
@ -709,7 +713,7 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent
}
detailsSb.append("</table>");
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
@ -728,19 +732,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"));
}
}
}
}

View File

@ -98,7 +98,6 @@ public interface KeywordSearchQuery {
* @param snippet snippet preview with hit context, or null if there is no snippet
* @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 snippet, String listName);

View File

@ -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=

View File

@ -50,55 +50,55 @@ 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.getCaseDirectory()+File.separator+"autopsy-copy.db"));
dbconnect tempdbconnect = new dbconnect("org.sqlite.JDBC", "jdbc:sqlite:"+currentCase.getCaseDirectory()+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;");
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;");
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("</tbody></table><br /><br />");
keyword = uniqueresults.getString("keyword");
table.append("<strong>").append(keyword).append("</strong>");
table.append("<table><thead><tr><th>").append("File Name").append("</th><th>Preview</th><th>Keyword List</th></tr><tbody>");
}
else{
table.append("</tbody></table><br /><br />");
keyword = uniqueresults.getString("keyword");
table.append("<strong>").append(keyword).append("</strong>");
table.append("<table><thead><tr><th>").append("File Name").append("</th><th>Preview</th><th>Keyword List</th></tr><tbody>");
}
table.append("<tr><td>").append(uniqueresults.getString("name")).append("</td>");
table.append("<td>").append(uniqueresults.getString("preview")).append("</td>").append("<td>").append(uniqueresults.getString("exp")).append("</td>").append("</tr>");
table.append("<tr><td>").append(uniqueresults.getString("name")).append("</td>");
table.append("<td>").append(uniqueresults.getString("preview")).append("</td>").append("<td>").append(uniqueresults.getString("list")).append("<br />(").append(uniqueresults.getString("exp")).append(")").append("</td>").append("</tr>");
}
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.getCaseDirectory()+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();
}

View File

@ -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
@ -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);
@ -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);

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
@ -41,15 +41,16 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="updateLabel" pref="160" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="progBar" pref="221" max="32767" attributes="0"/>
<Component id="progBar" pref="220" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -57,7 +58,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="updateLabel" alignment="3" pref="23" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="cancelButton" max="32767" attributes="0"/>
@ -111,5 +115,15 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="updateLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportFilter.updateLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportFilter.updateLabel.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -39,7 +39,7 @@ import org.sleuthkit.datamodel.SleuthkitCase;
public class ReportFilter extends javax.swing.JPanel {
public static ArrayList<Integer> filters = new ArrayList<Integer>();
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);
}
}
@ -77,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
@ -112,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(
@ -121,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)
@ -156,9 +161,8 @@ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
String preview = ReportAction.preview;
ArrayList<JCheckBox> reportList = ReportAction.reportList;
ArrayList<String> classList = new ArrayList<String>();
for(JCheckBox box : reportList)
{
if(box.isSelected()){
for (JCheckBox box : reportList) {
if (box.isSelected()) {
classList.add(box.getName());
}
@ -216,8 +220,7 @@ private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:e
}
});
}
public void progBarDone() {
int max = progBar.getMaximum();
progBar.setValue(max);
@ -229,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...");
@ -258,12 +273,11 @@ 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;
private javax.swing.JButton jButton2;
private javax.swing.JProgressBar progBar;
private javax.swing.JLabel updateLabel;
// End of variables declaration//GEN-END:variables
}

View File

@ -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();

View File

@ -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<BlackboardArtifact, ArrayList<BlackboardAttribute>> 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, "<br>", 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("</tbody></table>");
if (countWebBookmark > 0) {
formatted_Report.append(nodeWebBookmark);
formatted_Report.append("</tbody></table>");
@ -422,51 +419,51 @@ 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 String getExtension() {
String ext = ".html";
return ext;
}
@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 +472,4 @@ public class ReportHTML implements ReportModule{
public void getPreview(String path) {
BrowserControl.openUrl(path);
}
}

View File

@ -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,22 @@ 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);
/**
* Calls to the report module to execute a method to get the extension
* that is used for the report
*
* @return String the extension the file will be saved as
*
*/
public String getExtension();
}

View File

@ -29,15 +29,7 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" alignment="0" pref="300" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="128" max="32767" attributes="0"/>
<Component id="saveReport" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jPanel1" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -45,45 +37,79 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="165" max="32767" attributes="0"/>
<Component id="jPanel1" min="-2" pref="76" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" pref="26" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="saveReport" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportPanel.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="saveReport">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportPanel.saveReport.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportPanel.saveReport.actionCommand" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveReportActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="338" max="32767" attributes="0"/>
<Component id="saveReport" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel1" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="saveReport" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="horizontalTextPosition" type="int" value="2"/>
<Property name="verticalTextPosition" type="int" value="1"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="saveReport">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportPanel.saveReport.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportPanel.saveReport.actionCommand" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveReportActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportPanel.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -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 {
}// </editor-fold>//GEN-END:initComponents
private void saveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveReportActionPerformed
HashMap<ReportModule, String> 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 = "<html>These reports were generated on " + dateFormat.format(date) + ". <br><br>";
jLabel1.setText(reportText);
final JPanel tpanel = new JPanel(new GridBagLayout());
SwingUtilities.invokeLater(new Runnable() {
GridBagConstraints c = new GridBagConstraints();
@Override
public void run() {
HashMap<ReportModule, String> reports = rpa.getReports();
int cc = 0;
for (Map.Entry<ReportModule, String> 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<ReportModule, String> 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<ReportModule, String> entry : reports.entrySet()) {
exportReport(path, entry.getKey().getExtension(), 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
}

View File

@ -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;
@ -41,7 +41,8 @@ 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<ReportModule,String> reports = new HashMap<ReportModule,String>();
public ReportPanelAction() {
}
@ -66,28 +67,37 @@ 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() {
@Override
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);
reports.put((ReportModule)reportObject,path);
if(s == null ? preview == null : s.equals(preview))
{
@ -97,7 +107,6 @@ public class ReportPanelAction {
} catch (Exception e) {
}
rr.progBarSet(cc);
}
// StopWatch a = new StopWatch();
@ -152,7 +161,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 +196,8 @@ public class ReportPanelAction {
Log.get(ReportFilterAction.class).log(Level.WARNING, "Error displaying " + ACTION_NAME + " window.", ex);
}
}
public HashMap<ReportModule,String> getReports(){
return reports;
}
}

View File

@ -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();
}
}

View File

@ -424,6 +424,11 @@ public class ReportXLS implements ReportModule {
String type = "XLS";
return type;
}
@Override
public String getExtension() {
String ext = ".xlsx";
return ext;
}
@Override
public ReportConfiguration GetReportConfiguration() {

View File

@ -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
}
@ -233,6 +233,12 @@ public class ReportXML implements ReportModule {
String type = "XML";
return type;
}
@Override
public String getExtension() {
String ext = ".xml";
return ext;
}
@Override
public ReportConfiguration GetReportConfiguration() {
@ -268,8 +274,8 @@ public class ReportXML implements ReportModule {
return img.getName();
}
//@Override
public String visit(File file) {
@Override
public String visit(org.sleuthkit.datamodel.File file) {
return file.getName();
}
}