Add checks for null after calls to getAbstractFileById

This commit is contained in:
APriestman 2015-05-27 14:16:35 -04:00
parent ad779792e0
commit b67eda618f
8 changed files with 98 additions and 49 deletions

View File

@ -85,6 +85,11 @@ class CallLogAnalyzer {
SleuthkitCase skCase = currentCase.getSleuthkitCase(); SleuthkitCase skCase = currentCase.getSleuthkitCase();
try { try {
AbstractFile f = skCase.getAbstractFileById(fId); AbstractFile f = skCase.getAbstractFileById(fId);
if(f == null){
logger.log(Level.SEVERE, "Error getting abstract file " + fId); //NON-NLS
return;
}
try { try {
resultSet = statement.executeQuery( resultSet = statement.executeQuery(
"SELECT number,date,duration,type, name FROM calls ORDER BY date DESC;"); //NON-NLS "SELECT number,date,duration,type, name FROM calls ORDER BY date DESC;"); //NON-NLS

View File

@ -101,6 +101,11 @@ class ContactAnalyzer {
SleuthkitCase skCase = currentCase.getSleuthkitCase(); SleuthkitCase skCase = currentCase.getSleuthkitCase();
try { try {
AbstractFile f = skCase.getAbstractFileById(fId); AbstractFile f = skCase.getAbstractFileById(fId);
if(f == null){
logger.log(Level.SEVERE, "Error getting abstract file " + fId); //NON-NLS
return;
}
try { try {
// get display_name, mimetype(email or phone number) and data1 (phonenumber or email address depending on mimetype) // get display_name, mimetype(email or phone number) and data1 (phonenumber or email address depending on mimetype)
//sorted by name, so phonenumber/email would be consecutive for a person if they exist. //sorted by name, so phonenumber/email would be consecutive for a person if they exist.

View File

@ -85,6 +85,11 @@ class TextMessageAnalyzer {
SleuthkitCase skCase = currentCase.getSleuthkitCase(); SleuthkitCase skCase = currentCase.getSleuthkitCase();
try { try {
AbstractFile f = skCase.getAbstractFileById(fId); AbstractFile f = skCase.getAbstractFileById(fId);
if(f == null){
logger.log(Level.SEVERE, "Error getting abstract file " + fId); //NON-NLS
return;
}
try { try {
resultSet = statement.executeQuery( resultSet = statement.executeQuery(
"Select address,date,type,subject,body FROM sms;"); //NON-NLS "Select address,date,type,subject,body FROM sms;"); //NON-NLS

View File

@ -806,7 +806,10 @@ import org.sleuthkit.datamodel.TskData;
logger.log(Level.WARNING, "Error while getting content from a blackboard artifact to report on.", ex); //NON-NLS logger.log(Level.WARNING, "Error while getting content from a blackboard artifact to report on.", ex); //NON-NLS
return; return;
} }
checkIfFileIsImage(file);
if(file != null){
checkIfFileIsImage(file);
}
} }
/** /**
@ -978,8 +981,11 @@ import org.sleuthkit.datamodel.TskData;
String list = resultSet.getString("list"); //NON-NLS String list = resultSet.getString("list"); //NON-NLS
String uniquePath = ""; String uniquePath = "";
try { try {
uniquePath = skCase.getAbstractFileById(objId).getUniquePath(); AbstractFile f = skCase.getAbstractFileById(objId);
if(f != null){
uniquePath = skCase.getAbstractFileById(objId).getUniquePath();
}
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
errorList.add( errorList.add(
NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetAbstractFileByID")); NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetAbstractFileByID"));
@ -1109,7 +1115,10 @@ import org.sleuthkit.datamodel.TskData;
String uniquePath = ""; String uniquePath = "";
try { try {
uniquePath = skCase.getAbstractFileById(objId).getUniquePath(); AbstractFile f = skCase.getAbstractFileById(objId);
if(f != null){
uniquePath = skCase.getAbstractFileById(objId).getUniquePath();
}
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
errorList.add( errorList.add(
NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetAbstractFileFromID")); NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetAbstractFileFromID"));
@ -1772,15 +1781,23 @@ import org.sleuthkit.datamodel.TskData;
break; break;
case TSK_EXT_MISMATCH_DETECTED: case TSK_EXT_MISMATCH_DETECTED:
AbstractFile file = skCase.getAbstractFileById(getObjectID()); AbstractFile file = skCase.getAbstractFileById(getObjectID());
orderedRowData.add(file.getName()); if(file != null){
orderedRowData.add(file.getNameExtension()); orderedRowData.add(file.getName());
List<BlackboardAttribute> attrs = file.getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG); orderedRowData.add(file.getNameExtension());
if (!attrs.isEmpty()) { List<BlackboardAttribute> attrs = file.getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG);
orderedRowData.add(attrs.get(0).getValueString()); if (!attrs.isEmpty()) {
orderedRowData.add(attrs.get(0).getValueString());
} else {
orderedRowData.add("");
}
orderedRowData.add(file.getUniquePath());
} else { } else {
orderedRowData.add(""); // Make empty rows to make sure the formatting is correct
} orderedRowData.add(null);
orderedRowData.add(file.getUniquePath()); orderedRowData.add(null);
orderedRowData.add(null);
orderedRowData.add(null);
}
break; break;
case TSK_OS_INFO: case TSK_OS_INFO:
orderedRowData.add(mappedAttributes.get(ATTRIBUTE_TYPE.TSK_PROCESSOR_ARCHITECTURE.getTypeID())); orderedRowData.add(mappedAttributes.get(ATTRIBUTE_TYPE.TSK_PROCESSOR_ARCHITECTURE.getTypeID()));

View File

@ -131,12 +131,14 @@ class ReportKML implements GeneralReportModule {
if (lon != 0 && lat != 0) { if (lon != 0 && lat != 0) {
aFile = artifact.getSleuthkitCase().getAbstractFileById(artifact.getObjectID()); aFile = artifact.getSleuthkitCase().getAbstractFileById(artifact.getObjectID());
extractedToPath = reportPath + aFile.getName(); if(aFile != null){
geoPath = extractedToPath; extractedToPath = reportPath + aFile.getName();
f = new File(extractedToPath); geoPath = extractedToPath;
f.createNewFile(); f = new File(extractedToPath);
copyFileUsingStream(aFile, f); f.createNewFile();
imageName = aFile.getName(); copyFileUsingStream(aFile, f);
imageName = aFile.getName();
}
out.write(String.valueOf(lat)); out.write(String.valueOf(lat));
out.write(";"); out.write(";");
out.write(String.valueOf(lon)); out.write(String.valueOf(lon));

View File

@ -243,32 +243,37 @@ public class EventsRepository {
} else { } else {
try { try {
AbstractFile f = skCase.getAbstractFileById(fID); AbstractFile f = skCase.getAbstractFileById(fID);
//TODO: This is broken for logical files? fix -jm
//TODO: logical files don't necessarily have valid timestamps, so ... -jm if(f != null){
final String uniquePath = f.getUniquePath(); //TODO: This is broken for logical files? fix -jm
final String parentPath = f.getParentPath(); //TODO: logical files don't necessarily have valid timestamps, so ... -jm
String datasourceName = StringUtils.substringBefore(StringUtils.stripStart(uniquePath, "/"), parentPath); final String uniquePath = f.getUniquePath();
String rootFolder = StringUtils.substringBetween(parentPath, "/", "/"); final String parentPath = f.getParentPath();
String shortDesc = datasourceName + "/" + StringUtils.defaultIfBlank(rootFolder, ""); String datasourceName = StringUtils.substringBefore(StringUtils.stripStart(uniquePath, "/"), parentPath);
String medD = datasourceName + parentPath; String rootFolder = StringUtils.substringBetween(parentPath, "/", "/");
String shortDesc = datasourceName + "/" + StringUtils.defaultIfBlank(rootFolder, "");
String medD = datasourceName + parentPath;
//insert it into the db if time is > 0 => time is legitimate (drops logical files) //insert it into the db if time is > 0 => time is legitimate (drops logical files)
if (f.getAtime() > 0) { if (f.getAtime() > 0) {
eventDB.insertEvent(f.getAtime(), FileSystemTypes.FILE_ACCESSED, fID, null, uniquePath, medD, shortDesc, f.getKnown(), trans); eventDB.insertEvent(f.getAtime(), FileSystemTypes.FILE_ACCESSED, fID, null, uniquePath, medD, shortDesc, f.getKnown(), trans);
} }
if (f.getMtime() > 0) { if (f.getMtime() > 0) {
eventDB.insertEvent(f.getMtime(), FileSystemTypes.FILE_MODIFIED, fID, null, uniquePath, medD, shortDesc, f.getKnown(), trans); eventDB.insertEvent(f.getMtime(), FileSystemTypes.FILE_MODIFIED, fID, null, uniquePath, medD, shortDesc, f.getKnown(), trans);
} }
if (f.getCtime() > 0) { if (f.getCtime() > 0) {
eventDB.insertEvent(f.getCtime(), FileSystemTypes.FILE_CHANGED, fID, null, uniquePath, medD, shortDesc, f.getKnown(), trans); eventDB.insertEvent(f.getCtime(), FileSystemTypes.FILE_CHANGED, fID, null, uniquePath, medD, shortDesc, f.getKnown(), trans);
} }
if (f.getCrtime() > 0) { if (f.getCrtime() > 0) {
eventDB.insertEvent(f.getCrtime(), FileSystemTypes.FILE_CREATED, fID, null, uniquePath, medD, shortDesc, f.getKnown(), trans); eventDB.insertEvent(f.getCrtime(), FileSystemTypes.FILE_CREATED, fID, null, uniquePath, medD, shortDesc, f.getKnown(), trans);
} }
process(Arrays.asList(new ProgressWindow.ProgressUpdate(i, numFiles, process(Arrays.asList(new ProgressWindow.ProgressUpdate(i, numFiles,
NbBundle.getMessage(this.getClass(), NbBundle.getMessage(this.getClass(),
"EventsRepository.progressWindow.msg.populateMacEventsFiles2"), f.getName()))); "EventsRepository.progressWindow.msg.populateMacEventsFiles2"), f.getName())));
} else {
LOGGER.log(Level.WARNING, "failed to look up data for file : " + fID); // NON-NLS
}
} catch (TskCoreException tskCoreException) { } catch (TskCoreException tskCoreException) {
LOGGER.log(Level.WARNING, "failed to insert mac event for file : " + fID, tskCoreException); // NON-NLS LOGGER.log(Level.WARNING, "failed to insert mac event for file : " + fID, tskCoreException); // NON-NLS
} }

View File

@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.timeline.zooming.EventTypeZoomLevel; import org.sleuthkit.autopsy.timeline.zooming.EventTypeZoomLevel;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
@ -129,7 +130,11 @@ public enum MiscTypes implements EventType, ArtifactEventType {
(BlackboardArtifact t, (BlackboardArtifact t,
Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> u) -> { Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> u) -> {
try { try {
return t.getSleuthkitCase().getAbstractFileById(t.getObjectID()).getName(); AbstractFile f = t.getSleuthkitCase().getAbstractFileById(t.getObjectID());
if(f != null){
return f.getName();
}
return " error loading file name"; // NON-NLS
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
return " error loading file name"; // NON-NLS return " error loading file name"; // NON-NLS

View File

@ -101,13 +101,18 @@ public class EventRootNode extends DisplayableItemNode {
if (eventID >= 0) { if (eventID >= 0) {
final TimeLineEvent eventById = filteredEvents.getEventById(eventID); final TimeLineEvent eventById = filteredEvents.getEventById(eventID);
try { try {
if (eventById.getType().getSuperType() == BaseTypes.FILE_SYSTEM) { AbstractFile file = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(eventById.getFileID());
return new EventNode(eventById, Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(eventById.getFileID())); if(file != null){
} else { if (eventById.getType().getSuperType() == BaseTypes.FILE_SYSTEM) {
AbstractFile file = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(eventById.getFileID()); return new EventNode(eventById, file);
BlackboardArtifact blackboardArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(eventById.getArtifactID()); } else {
BlackboardArtifact blackboardArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(eventById.getArtifactID());
return new EventNode(eventById, file, blackboardArtifact); return new EventNode(eventById, file, blackboardArtifact);
}
} else {
LOGGER.log(Level.WARNING, "Failed to lookup sleuthkit object backing TimeLineEvent."); // NON-NLS
return null;
} }
} catch (TskCoreException tskCoreException) { } catch (TskCoreException tskCoreException) {