mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
more error checking in timeline
This commit is contained in:
parent
db89cc5d43
commit
62b8c384ea
@ -78,7 +78,6 @@ import org.openide.modules.InstalledFileLocator;
|
||||
import org.openide.nodes.ChildFactory;
|
||||
import org.openide.nodes.Children;
|
||||
import org.openide.nodes.Node;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.HelpCtx;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.actions.CallableSystemAction;
|
||||
@ -109,8 +108,8 @@ import org.sleuthkit.datamodel.TskData;
|
||||
@ActionReferences(value = {
|
||||
@ActionReference(path = "Menu/Tools", position = 100)})
|
||||
@NbBundle.Messages(value = "CTL_TimelineView=Generate Timeline")
|
||||
|
||||
public class Simile2 extends CallableSystemAction implements Presenter.Toolbar, PropertyChangeListener {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Simile2.class.getName());
|
||||
private final java.io.File macRoot = InstalledFileLocator.getDefault().locate("mactime", Simile2.class.getPackage().getName(), false);
|
||||
private JFrame jf; //frame for holding all the elements
|
||||
@ -330,27 +329,27 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
data.getNode().setScaleX(.5);
|
||||
data.getNode().addEventHandler(MouseEvent.MOUSE_CLICKED,
|
||||
new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent e) {
|
||||
if (e.getButton().equals(MouseButton.PRIMARY)) {
|
||||
if (e.getClickCount() == 2) { //Checking for a doubleclick
|
||||
PlatformImpl.startup(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BarChart b = createMonthsWithDrill((YearEpoch) findYear(allYears, Integer.valueOf((String) data.getXValue())));
|
||||
chart_Events = b;
|
||||
scroll_Events.setContent(chart_Events);
|
||||
}
|
||||
});
|
||||
//If a single click, hover a label over the cursor with information about the selection
|
||||
} else if (e.getClickCount() == 1) {
|
||||
l.setText(findYear(allYears, Integer.valueOf((String) data.getXValue())).getNumFiles() + " events");
|
||||
l.setTranslateX(e.getX());
|
||||
l.setTranslateY(e.getY());
|
||||
@Override
|
||||
public void handle(MouseEvent e) {
|
||||
if (e.getButton().equals(MouseButton.PRIMARY)) {
|
||||
if (e.getClickCount() == 2) { //Checking for a doubleclick
|
||||
PlatformImpl.startup(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BarChart b = createMonthsWithDrill((YearEpoch) findYear(allYears, Integer.valueOf((String) data.getXValue())));
|
||||
chart_Events = b;
|
||||
scroll_Events.setContent(chart_Events);
|
||||
}
|
||||
}
|
||||
});
|
||||
//If a single click, hover a label over the cursor with information about the selection
|
||||
} else if (e.getClickCount() == 1) {
|
||||
l.setText(findYear(allYears, Integer.valueOf((String) data.getXValue())).getNumFiles() + " events");
|
||||
l.setTranslateX(e.getX());
|
||||
l.setTranslateY(e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bc.autosize(); //Get an auto height
|
||||
@ -392,21 +391,21 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
data.getNode().setScaleX(.5);
|
||||
data.getNode().addEventHandler(MouseEvent.MOUSE_PRESSED,
|
||||
new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent e) {
|
||||
if (e.getButton().equals(MouseButton.PRIMARY)) {
|
||||
if (e.getClickCount() == 2) {
|
||||
PlatformImpl.startup(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chart_Events = createEventsByMonth(findMonth(ye.months, monthStringToInt((String) data.getXValue())), ye);
|
||||
scroll_Events.setContent(chart_Events);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void handle(MouseEvent e) {
|
||||
if (e.getButton().equals(MouseButton.PRIMARY)) {
|
||||
if (e.getClickCount() == 2) {
|
||||
PlatformImpl.startup(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chart_Events = createEventsByMonth(findMonth(ye.months, monthStringToInt((String) data.getXValue())), ye);
|
||||
scroll_Events.setContent(chart_Events);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,31 +438,31 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
//data.getNode().setScaleX(2);
|
||||
data.getNode().addEventHandler(MouseEvent.MOUSE_PRESSED,
|
||||
new EventHandler<MouseEvent>() {
|
||||
MonthEpoch myme = me;
|
||||
MonthEpoch myme = me;
|
||||
|
||||
@Override
|
||||
public void handle(MouseEvent e) {
|
||||
int day = (Integer.valueOf(((String) data.getXValue()).split("-")[1]));
|
||||
DayEpoch de = myme.getDay(day);
|
||||
List<AbstractFile> afs = Collections.EMPTY_LIST;
|
||||
if (de != null) {
|
||||
afs = de.getEvents();
|
||||
} else {
|
||||
logger.log(Level.SEVERE, "There were no events for the clicked-on day.");
|
||||
}
|
||||
final FsContentRootNode d = new FsContentRootNode("Test Root", afs);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void handle(MouseEvent e) {
|
||||
int day = (Integer.valueOf(((String) data.getXValue()).split("-")[1]));
|
||||
DayEpoch de = myme.getDay(day);
|
||||
List<AbstractFile> afs = Collections.EMPTY_LIST;
|
||||
if (de != null) {
|
||||
afs = de.getEvents();
|
||||
} else {
|
||||
logger.log(Level.SEVERE, "There were no events for the clicked-on day.");
|
||||
}
|
||||
final FsContentRootNode d = new FsContentRootNode("Test Root", afs);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dataResult.setNode(d);
|
||||
}
|
||||
});
|
||||
|
||||
//set result viewer title path with the current date
|
||||
String dateString = ye.getYear() + "-" + (1+me.getMonthInt()) + "-" + + de.dayNum;
|
||||
dataResult.setPath(dateString);
|
||||
public void run() {
|
||||
dataResult.setNode(d);
|
||||
}
|
||||
});
|
||||
|
||||
//set result viewer title path with the current date
|
||||
String dateString = ye.getYear() + "-" + (1 + me.getMonthInt()) + "-" + +de.dayNum;
|
||||
dataResult.setPath(dateString);
|
||||
}
|
||||
});
|
||||
}
|
||||
bc.autosize();
|
||||
bc.setPrefWidth(Width_Frame);
|
||||
@ -488,7 +487,8 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @param mon The month to convert. Must be minimum 4 characters long "February" and "Febr" are acceptable.
|
||||
* @param mon The month to convert. Must be minimum 4 characters long
|
||||
* "February" and "Febr" are acceptable.
|
||||
* @return The integer value of the month. February = 1, July = 6
|
||||
*/
|
||||
private static int monthStringToInt(String mon) {
|
||||
@ -505,7 +505,9 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
|
||||
/**
|
||||
* Used for finding the proper month in a list of available months
|
||||
* @param lst The list of months to search through. It is assumed that the desired match is in this list.
|
||||
*
|
||||
* @param lst The list of months to search through. It is assumed that the
|
||||
* desired match is in this list.
|
||||
* @param match The month, in integer format, to retrieve.
|
||||
* @return The month epoch as specified by match.
|
||||
*/
|
||||
@ -518,9 +520,11 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Used for finding the proper year in a list of available years
|
||||
* @param lst The list of years to search through. It is assumed that the desired match is in this list.
|
||||
*
|
||||
* @param lst The list of years to search through. It is assumed that the
|
||||
* desired match is in this list.
|
||||
* @param match The year to retrieve.
|
||||
* @return The year epoch as specified by match.
|
||||
*/
|
||||
@ -575,11 +579,9 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
jf.dispose();
|
||||
|
||||
// remove ourself as change listener on Case
|
||||
Case currcase = Case.getCurrentCase();
|
||||
if (currcase != null) {
|
||||
currcase.removePropertyChangeListener(this);
|
||||
listeningToAddImage = false;
|
||||
}
|
||||
Case.removePropertyChangeListener(this);
|
||||
listeningToAddImage = false;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -587,6 +589,7 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
* All of those are Epochs.
|
||||
*/
|
||||
abstract class Epoch {
|
||||
|
||||
abstract public int getNumFiles();
|
||||
}
|
||||
|
||||
@ -614,7 +617,7 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
|
||||
public MonthEpoch getMonth(int monthNum) {
|
||||
MonthEpoch month = null;
|
||||
for (MonthEpoch me :months) {
|
||||
for (MonthEpoch me : months) {
|
||||
if (me.getMonthInt() == monthNum) {
|
||||
month = me;
|
||||
break;
|
||||
@ -743,15 +746,19 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
|
||||
// The node factories used to make lists of files to send to the result viewer
|
||||
private class FsContentNodeChildFactory extends ChildFactory<AbstractFile> {
|
||||
|
||||
List<AbstractFile> l;
|
||||
|
||||
FsContentNodeChildFactory(List<AbstractFile> l) {
|
||||
this.l = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean createKeys(List<AbstractFile> list) {
|
||||
list.addAll(l);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Node createNodeForKey(AbstractFile file) {
|
||||
Node wrapped;
|
||||
@ -765,15 +772,18 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
}
|
||||
|
||||
private class FsContentRootNode extends DisplayableItemNode {
|
||||
|
||||
FsContentRootNode(String NAME, List<AbstractFile> l) {
|
||||
super(Children.create(new FsContentNodeChildFactory(l), true));
|
||||
super.setName(NAME);
|
||||
super.setDisplayName(NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayableItemNode.TYPE getDisplayableItemNodeType() {
|
||||
return DisplayableItemNode.TYPE.CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(DisplayableItemNodeVisitor<T> v) {
|
||||
return null;
|
||||
@ -829,14 +839,20 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
return years;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crate a body file and return its path or null if error
|
||||
*
|
||||
* @return absolute path string or null if error
|
||||
*/
|
||||
private String makeBodyFile() {
|
||||
// Setup timestamp
|
||||
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss");
|
||||
Date date = new Date();
|
||||
String datenotime = dateFormat.format(date);
|
||||
|
||||
Case currentCase = Case.getCurrentCase();
|
||||
SleuthkitCase skCase = currentCase.getSleuthkitCase();
|
||||
final Case currentCase = Case.getCurrentCase();
|
||||
final SleuthkitCase skCase = currentCase.getSleuthkitCase();
|
||||
|
||||
// Get report path
|
||||
String bodyFilePath = moduleDir.getAbsolutePath()
|
||||
+ java.io.File.separator + currentCase.getName() + "-" + datenotime + ".txt";
|
||||
@ -845,34 +861,39 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
String filesAndDirs = "type = '" + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType() + "' "
|
||||
+ "AND name != '.' "
|
||||
+ "AND name != '..'";
|
||||
List<FsContent> fs = Collections.EMPTY_LIST;
|
||||
List<FsContent> fs = null;
|
||||
try {
|
||||
fs = skCase.findFilesWhere(filesAndDirs);
|
||||
} catch (TskCoreException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
logger.log(Level.SEVERE, "Error querying image files to make a body file: " + bodyFilePath, ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Loop files and write info to report
|
||||
FileWriter fileWriter = null;
|
||||
try {
|
||||
fileWriter = new FileWriter(bodyFilePath, true);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, "Error creating output stream to write body file to: " + bodyFilePath, ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
BufferedWriter out = null;
|
||||
try {
|
||||
out = new BufferedWriter(new FileWriter(bodyFilePath, true));
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.WARNING, "Could not create new BufferedWriter for body file.", ex);
|
||||
}
|
||||
for (FsContent file : fs) {
|
||||
try {
|
||||
out = new BufferedWriter(fileWriter);
|
||||
for (FsContent file : fs) {
|
||||
// try {
|
||||
// MD5|name|inode|mode_as_string|ObjId|GID|size|atime|mtime|ctime|crtime
|
||||
//out = new BufferedWriter(new FileWriter(bodyFilePath, true));
|
||||
|
||||
if (file.getMd5Hash() != null) {
|
||||
out.write(file.getMd5Hash());
|
||||
}
|
||||
out.write("|");
|
||||
String path = "";
|
||||
String path = null;
|
||||
try {
|
||||
path = file.getUniquePath();
|
||||
} catch (TskCoreException e) {
|
||||
logger.log(Level.WARNING, "Failed to get the unique path.", e);
|
||||
logger.log(Level.SEVERE, "Failed to get the unique path of: " + file + " and writing body file.", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
out.write(path);
|
||||
@ -899,18 +920,21 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
out.write("|");
|
||||
out.write(Long.toString(file.getCrtime()));
|
||||
out.write("\n");
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.WARNING, "Probelm while trying to write data to the body file.", ex);
|
||||
break;
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.WARNING, "Error while trying to write data to the body file.", ex);
|
||||
return null;
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch (IOException ex1) {
|
||||
logger.log(Level.WARNING, "Could not flush and/or close body file.", ex1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch (IOException ex1) {
|
||||
logger.log(Level.WARNING, "Could not flush and/or close body file.", ex1);
|
||||
}
|
||||
|
||||
return bodyFilePath;
|
||||
}
|
||||
@ -952,8 +976,10 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
return;
|
||||
}
|
||||
|
||||
final Case currentCase = Case.getCurrentCase();
|
||||
|
||||
try {
|
||||
if (Case.getCurrentCase().getImages().isEmpty()) {
|
||||
if (currentCase.getImages().isEmpty()) {
|
||||
logger.log(Level.INFO, "Error creating timeline, there are no images to parse");
|
||||
} else {
|
||||
|
||||
@ -978,14 +1004,13 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
Platform.setImplicitExit(false);
|
||||
|
||||
// listen for case changes (specifically images being added).
|
||||
Case currcase = Case.getCurrentCase();
|
||||
if (currcase != null && !listeningToAddImage) {
|
||||
currcase.addPropertyChangeListener(this);
|
||||
if (Case.isCaseOpen() && !listeningToAddImage) {
|
||||
Case.addPropertyChangeListener(this);
|
||||
listeningToAddImage = true;
|
||||
}
|
||||
|
||||
// create the modal dialog
|
||||
SwingUtilities.invokeLater(new Runnable () {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dialog = new TimelineProgressDialog(jf, true);
|
||||
@ -994,11 +1019,11 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
});
|
||||
|
||||
// initialize mactimeFileName
|
||||
mactimeFileName = Case.getCurrentCase().getName() + "-MACTIME.txt";
|
||||
mactimeFileName = currentCase.getName() + "-MACTIME.txt";
|
||||
|
||||
// see if data has been added to the database since the last
|
||||
// time timeline ran
|
||||
long objId = Case.getCurrentCase().getSleuthkitCase().getLastObjectId();
|
||||
long objId = currentCase.getSleuthkitCase().getLastObjectId();
|
||||
if (objId != lastObjectId && lastObjectId != -1) {
|
||||
clearMactimeData();
|
||||
}
|
||||
@ -1008,7 +1033,9 @@ public class Simile2 extends CallableSystemAction implements Presenter.Toolbar,
|
||||
customize();
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
logger.log(Level.SEVERE, "Error when generating timeline, ", ex);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Unexpected error when generating timeline, ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user