Skip to content
Snippets Groups Projects
Unverified Commit fc8a10ea authored by Richard Cordovano's avatar Richard Cordovano Committed by GitHub
Browse files

Merge pull request #1943 from gdicristofaro/6355-geolocationNPE

6355 geolocation npe
parents 2879a039 3e9c20f1
Branches
Tags
No related merge requests found
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
public final class GeoArtifactsHelper extends ArtifactHelperBase { public final class GeoArtifactsHelper extends ArtifactHelperBase {
private static final BlackboardAttribute.Type WAYPOINTS_ATTR_TYPE = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_WAYPOINTS); private static final BlackboardAttribute.Type WAYPOINTS_ATTR_TYPE = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_WAYPOINTS);
private static final BlackboardAttribute.Type TRACKPOINTS_ATTR_TYPE = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_TRACKPOINTS); private static final BlackboardAttribute.Type TRACKPOINTS_ATTR_TYPE = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_TRACKPOINTS);
private final String programName; private final String programName;
/** /**
...@@ -67,28 +67,32 @@ public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String progra ...@@ -67,28 +67,32 @@ public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String progra
* (elevation) axes. * (elevation) axes.
* *
* @param trackName The name of the GPS track, may be null. * @param trackName The name of the GPS track, may be null.
* @param trackPoints The track points that make up the track. * @param trackPoints The track points that make up the track. This list
* should be non-null and non-empty.
* @param moreAttributes Additional attributes for the TSK_GPS_TRACK * @param moreAttributes Additional attributes for the TSK_GPS_TRACK
* artifact, may be null. * artifact, may be null.
* *
* @return The TSK_GPS_TRACK artifact that was added to the case database. * @return The TSK_GPS_TRACK artifact that was added to the case database.
* *
* @throws TskCoreException If there is an error creating the artifact. * @throws TskCoreException If there is an error creating the
* @throws BlackboardException If there is a error posting the artifact to * artifact.
* the blackboard. * @throws BlackboardException If there is a error posting the artifact
* to the blackboard.
* @throws IllegalArgumentException If the trackpoints provided are null or
* empty.
*/ */
public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException { public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
if (trackPoints == null) { if (trackPoints == null || trackPoints.isEmpty()) {
throw new IllegalArgumentException(String.format("addTrack was passed a null list of track points")); throw new IllegalArgumentException(String.format("addTrack was passed a null or empty list of track points"));
} }
BlackboardArtifact artifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACK);
List<BlackboardAttribute> attributes = new ArrayList<>(); List<BlackboardAttribute> attributes = new ArrayList<>();
if (trackName != null) { if (trackName != null) {
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), trackName)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), trackName));
} }
// acquire necessary attribute. If 'toAttribute' call throws an exception, an artifact will not be created for this instance.
attributes.add(BlackboardJsonAttrUtil.toAttribute(TRACKPOINTS_ATTR_TYPE, getModuleName(), trackPoints)); attributes.add(BlackboardJsonAttrUtil.toAttribute(TRACKPOINTS_ATTR_TYPE, getModuleName(), trackPoints));
if (programName != null) { if (programName != null) {
...@@ -99,13 +103,14 @@ public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, ...@@ -99,13 +103,14 @@ public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints,
attributes.addAll(moreAttributes); attributes.addAll(moreAttributes);
} }
BlackboardArtifact artifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACK);
artifact.addAttributes(attributes); artifact.addAttributes(attributes);
getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName()); getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
return artifact; return artifact;
} }
/** /**
* Adds a TSK_GPS_ROUTE artifact to the case database. A Global Positioning * Adds a TSK_GPS_ROUTE artifact to the case database. A Global Positioning
* System (GPS) route artifact records one or more waypoints entered into a * System (GPS) route artifact records one or more waypoints entered into a
...@@ -117,19 +122,23 @@ public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, ...@@ -117,19 +122,23 @@ public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints,
* @param creationTime The time at which the route was created as * @param creationTime The time at which the route was created as
* milliseconds from the Java epoch of * milliseconds from the Java epoch of
* 1970-01-01T00:00:00Z, may be null. * 1970-01-01T00:00:00Z, may be null.
* @param wayPoints The waypoints that make up the route. * @param wayPoints The waypoints that make up the route. This list
* should be non-null and non-empty.
* @param moreAttributes Additional attributes for the TSK_GPS_ROUTE * @param moreAttributes Additional attributes for the TSK_GPS_ROUTE
* artifact, may be null. * artifact, may be null.
* *
* @return The TSK_GPS_ROUTE artifact that was added to the case database. * @return The TSK_GPS_ROUTE artifact that was added to the case database.
* *
* @throws TskCoreException If there is an error creating the artifact. * @throws TskCoreException If there is an error creating the
* @throws BlackboardException If there is a error posting the artifact to * artifact.
* the blackboard. * @throws BlackboardException If there is a error posting the artifact
* to the blackboard.
* @throws IllegalArgumentException If the waypoints provided are null or
* empty.
*/ */
public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException { public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
if (wayPoints == null) { if (wayPoints == null || wayPoints.isEmpty()) {
throw new IllegalArgumentException(String.format("addRoute was passed a null list of waypoints")); throw new IllegalArgumentException(String.format("addRoute was passed a null or empty list of waypoints"));
} }
BlackboardArtifact artifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE); BlackboardArtifact artifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE);
...@@ -159,5 +168,5 @@ public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypo ...@@ -159,5 +168,5 @@ public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypo
return artifact; return artifact;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment