mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
more cleanup and null safety
This commit is contained in:
parent
23a1a8e329
commit
77df50c923
@ -34,6 +34,7 @@ import org.sleuthkit.datamodel.TskCoreException;
|
|||||||
public interface ArtifactEventType extends EventType {
|
public interface ArtifactEventType extends EventType {
|
||||||
|
|
||||||
public static final Logger LOGGER = Logger.getLogger(ArtifactEventType.class.getName());
|
public static final Logger LOGGER = Logger.getLogger(ArtifactEventType.class.getName());
|
||||||
|
static final EmptyExtractor EMPTY_EXTRACTOR = new EmptyExtractor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the Artifact type this event type is derived from
|
* @return the Artifact type this event type is derived from
|
||||||
@ -155,7 +156,7 @@ public interface ArtifactEventType extends EventType {
|
|||||||
return type.parseAttributesHelper(artf);
|
return type.parseAttributesHelper(artf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AttributeExtractor implements Function<BlackboardArtifact, String> {
|
static class AttributeExtractor implements Function<BlackboardArtifact, String> {
|
||||||
|
|
||||||
public String apply(BlackboardArtifact artf) {
|
public String apply(BlackboardArtifact artf) {
|
||||||
return Optional.ofNullable(getAttributeSafe(artf, attributeType))
|
return Optional.ofNullable(getAttributeSafe(artf, attributeType))
|
||||||
@ -172,7 +173,7 @@ public interface ArtifactEventType extends EventType {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class EmptyExtractor implements Function<BlackboardArtifact, String> {
|
static class EmptyExtractor implements Function<BlackboardArtifact, String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apply(BlackboardArtifact t) {
|
public String apply(BlackboardArtifact t) {
|
||||||
|
@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.timeline.datamodel.eventtype;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
@ -44,7 +45,7 @@ public enum MiscTypes implements EventType, ArtifactEventType {
|
|||||||
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_MESSAGE),
|
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_MESSAGE),
|
||||||
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME),
|
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME),
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_MESSAGE_TYPE)),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_MESSAGE_TYPE)),
|
||||||
(artf) -> {
|
artf -> {
|
||||||
final BlackboardAttribute dir = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DIRECTION));
|
final BlackboardAttribute dir = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DIRECTION));
|
||||||
final BlackboardAttribute readStatus = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_READ_STATUS));
|
final BlackboardAttribute readStatus = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_READ_STATUS));
|
||||||
final BlackboardAttribute name = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_NAME));
|
final BlackboardAttribute name = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_NAME));
|
||||||
@ -59,23 +60,23 @@ public enum MiscTypes implements EventType, ArtifactEventType {
|
|||||||
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME),
|
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME),
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_PROG_NAME)),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_PROG_NAME)),
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_LOCATION)),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_LOCATION)),
|
||||||
(artf) -> {
|
artf -> {
|
||||||
final BlackboardAttribute latStart = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START));
|
final BlackboardAttribute latStart = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START));
|
||||||
final BlackboardAttribute longStart = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START));
|
final BlackboardAttribute longStart = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START));
|
||||||
final BlackboardAttribute latEnd = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END));
|
final BlackboardAttribute latEnd = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END));
|
||||||
final BlackboardAttribute longEnd = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END));
|
final BlackboardAttribute longEnd = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END));
|
||||||
return String.format("from %1$g %2$g to %3$g %4$g", latStart.getValueDouble(), longStart.getValueDouble(), latEnd.getValueDouble(), longEnd.getValueDouble()); // NON-NLS
|
return String.format("from %1$s %2$s to %3$s %4$s", stringValueOf(latStart), stringValueOf(longStart), stringValueOf(latEnd), stringValueOf(longEnd)); // NON-NLS
|
||||||
}),
|
}),
|
||||||
GPS_TRACKPOINT(NbBundle.getMessage(MiscTypes.class, "MiscTypes.GPSTrackpoint.name"), "gps-trackpoint.png", // NON-NLS
|
GPS_TRACKPOINT(NbBundle.getMessage(MiscTypes.class, "MiscTypes.GPSTrackpoint.name"), "gps-trackpoint.png", // NON-NLS
|
||||||
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_GPS_TRACKPOINT),
|
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_GPS_TRACKPOINT),
|
||||||
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME),
|
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME),
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_PROG_NAME)),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_PROG_NAME)),
|
||||||
(artf) -> {
|
artf -> {
|
||||||
final BlackboardAttribute longitude = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE));
|
final BlackboardAttribute longitude = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE));
|
||||||
final BlackboardAttribute latitude = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LATITUDE));
|
final BlackboardAttribute latitude = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_GEO_LATITUDE));
|
||||||
return (latitude != null ? latitude.getValueDouble() : "") + " " + (longitude != null ? longitude.getValueDouble() : ""); // NON-NLS
|
return stringValueOf(latitude) + " " + stringValueOf(longitude); // NON-NLS
|
||||||
},
|
},
|
||||||
(artf) -> ""),
|
EMPTY_EXTRACTOR),
|
||||||
CALL_LOG(NbBundle.getMessage(MiscTypes.class, "MiscTypes.Calls.name"), "calllog.png", // NON-NLS
|
CALL_LOG(NbBundle.getMessage(MiscTypes.class, "MiscTypes.Calls.name"), "calllog.png", // NON-NLS
|
||||||
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_CALLLOG),
|
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_CALLLOG),
|
||||||
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME_START),
|
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME_START),
|
||||||
@ -85,10 +86,10 @@ public enum MiscTypes implements EventType, ArtifactEventType {
|
|||||||
EMAIL(NbBundle.getMessage(MiscTypes.class, "MiscTypes.Email.name"), "mail-icon-16.png", // NON-NLS
|
EMAIL(NbBundle.getMessage(MiscTypes.class, "MiscTypes.Email.name"), "mail-icon-16.png", // NON-NLS
|
||||||
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_EMAIL_MSG),
|
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_EMAIL_MSG),
|
||||||
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME_SENT),
|
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME_SENT),
|
||||||
(artf) -> {
|
artf -> {
|
||||||
final BlackboardAttribute emailFrom = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_EMAIL_FROM));
|
final BlackboardAttribute emailFrom = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_EMAIL_FROM));
|
||||||
final BlackboardAttribute emailTo = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_EMAIL_TO));
|
final BlackboardAttribute emailTo = getAttributeSafe(artf, new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_EMAIL_TO));
|
||||||
return (emailFrom != null ? emailFrom.getValueString() : "") + " to " + (emailTo != null ? emailTo.getValueString() : ""); // NON-NLS
|
return stringValueOf(emailFrom) + " to " + stringValueOf(emailTo); // NON-NLS
|
||||||
},
|
},
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_SUBJECT)),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_SUBJECT)),
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_PLAIN))),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_PLAIN))),
|
||||||
@ -103,7 +104,7 @@ public enum MiscTypes implements EventType, ArtifactEventType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttributeEventDescription parseAttributesHelper(BlackboardArtifact artf) throws TskCoreException {
|
public AttributeEventDescription parseAttributesHelper(BlackboardArtifact artf) throws TskCoreException {
|
||||||
final BlackboardAttribute dateTimeAttr = getAttributeSafe(artf, getDateTimeAttrubuteType());
|
final BlackboardAttribute dateTimeAttr = artf.getAttribute(getDateTimeAttrubuteType());
|
||||||
|
|
||||||
long time = dateTimeAttr.getValueLong();
|
long time = dateTimeAttr.getValueLong();
|
||||||
|
|
||||||
@ -119,23 +120,23 @@ public enum MiscTypes implements EventType, ArtifactEventType {
|
|||||||
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_INSTALLED_PROG),
|
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_INSTALLED_PROG),
|
||||||
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME),
|
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME),
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_PROG_NAME)),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_PROG_NAME)),
|
||||||
new EmptyExtractor(),
|
EMPTY_EXTRACTOR,
|
||||||
new EmptyExtractor()),
|
EMPTY_EXTRACTOR),
|
||||||
EXIF(NbBundle.getMessage(MiscTypes.class, "MiscTypes.exif.name"), "camera-icon-16.png", // NON-NLS
|
EXIF(NbBundle.getMessage(MiscTypes.class, "MiscTypes.exif.name"), "camera-icon-16.png", // NON-NLS
|
||||||
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_METADATA_EXIF),
|
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_METADATA_EXIF),
|
||||||
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME_CREATED),
|
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DATETIME_CREATED),
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DEVICE_MAKE)),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DEVICE_MAKE)),
|
||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DEVICE_MODEL)),
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DEVICE_MODEL)),
|
||||||
(artifact) -> {
|
artf -> {
|
||||||
try {
|
try {
|
||||||
AbstractFile file = artifact.getSleuthkitCase().getAbstractFileById(artifact.getObjectID());
|
AbstractFile file = artf.getSleuthkitCase().getAbstractFileById(artf.getObjectID());
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
return file.getName();
|
return file.getName();
|
||||||
}
|
}
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Exif event type failed to look up backing file name", ex); //NON-NLS
|
LOGGER.log(Level.SEVERE, "Exif event type failed to look up backing file name", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
return " error loading file name"; // NON-NLS
|
return "error loading file name";
|
||||||
}),
|
}),
|
||||||
DEVICES_ATTACHED(NbBundle.getMessage(MiscTypes.class, "MiscTypes.devicesAttached.name"), "usb_devices.png", // NON-NLS
|
DEVICES_ATTACHED(NbBundle.getMessage(MiscTypes.class, "MiscTypes.devicesAttached.name"), "usb_devices.png", // NON-NLS
|
||||||
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED),
|
TypeUtils.fromEnum(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED),
|
||||||
@ -145,7 +146,9 @@ public enum MiscTypes implements EventType, ArtifactEventType {
|
|||||||
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DEVICE_ID)));
|
new AttributeExtractor(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DEVICE_ID)));
|
||||||
|
|
||||||
static public String stringValueOf(BlackboardAttribute attr) {
|
static public String stringValueOf(BlackboardAttribute attr) {
|
||||||
return attr != null ? attr.getDisplayString() : "";
|
return Optional.ofNullable(attr)
|
||||||
|
.map(BlackboardAttribute::getDisplayString)
|
||||||
|
.orElse("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toFrom(BlackboardAttribute dir) {
|
public static String toFrom(BlackboardAttribute dir) {
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Autopsy Forensic Browser
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* Copyright 2016 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.timeline.datamodel.eventtype;
|
package org.sleuthkit.autopsy.timeline.datamodel.eventtype;
|
||||||
|
|
||||||
@ -10,11 +23,10 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TypeUtils {
|
class TypeUtils {
|
||||||
|
|
||||||
|
//TODO: this will be unncessary once their is BlackboardArtifact.Type constructr that takes a BlackboardArtifact.ARTIFACT_TYPE
|
||||||
|
static BlackboardArtifact.Type fromEnum(BlackboardArtifact.ARTIFACT_TYPE type) {
|
||||||
static BlackboardArtifact.Type fromEnum(BlackboardArtifact.ARTIFACT_TYPE type) {
|
|
||||||
return new BlackboardArtifact.Type(type.getTypeID(), type.getLabel(), type.getDisplayName());
|
return new BlackboardArtifact.Type(type.getTypeID(), type.getLabel(), type.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import org.openide.util.NbBundle;
|
|||||||
import org.sleuthkit.autopsy.timeline.zooming.EventTypeZoomLevel;
|
import org.sleuthkit.autopsy.timeline.zooming.EventTypeZoomLevel;
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -43,8 +44,8 @@ public enum WebTypes implements EventType, ArtifactEventType {
|
|||||||
new AttributeExtractor(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL))) {
|
new AttributeExtractor(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL))) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttributeEventDescription parseAttributesHelper(BlackboardArtifact artf) {
|
public AttributeEventDescription parseAttributesHelper(BlackboardArtifact artf) throws TskCoreException {
|
||||||
long time = ArtifactEventType.getAttributeSafe(artf, getDateTimeAttrubuteType()).getValueLong();
|
long time = artf.getAttribute(getDateTimeAttrubuteType()).getValueLong();
|
||||||
String domain = getShortExtractor().apply(artf);
|
String domain = getShortExtractor().apply(artf);
|
||||||
String path = getMedExtractor().apply(artf);
|
String path = getMedExtractor().apply(artf);
|
||||||
String fileName = StringUtils.substringAfterLast(path, "/");
|
String fileName = StringUtils.substringAfterLast(path, "/");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user