19 package org.sleuthkit.datamodel;
21 import java.io.Serializable;
22 import java.io.UnsupportedEncodingException;
23 import java.text.MessageFormat;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.List;
30 import java.util.Objects;
31 import java.util.ResourceBundle;
48 private static final ResourceBundle bundle = ResourceBundle.getBundle(
"org.sleuthkit.datamodel.Bundle");
49 private final long artifactId;
50 private final long sourceObjId;
51 private final long artifactObjId;
52 private final long dataSourceObjId;
53 private final int artifactTypeId;
54 private final String artifactTypeName;
55 private final String displayName;
58 private final List<BlackboardAttribute> attrsCache =
new ArrayList<BlackboardAttribute>();
59 private boolean loadedCacheFromDb =
false;
61 private String uniquePath;
63 private byte[] contentBytes = null;
65 private volatile boolean checkedHasChildren;
67 private volatile int childrenCount;
89 BlackboardArtifact(
SleuthkitCase sleuthkitCase,
long artifactID,
long sourceObjId,
long artifactObjId,
long dataSourceObjId,
int artifactTypeID, String artifactTypeName, String displayName,
ReviewStatus reviewStatus) {
91 this.sleuthkitCase = sleuthkitCase;
92 this.artifactId = artifactID;
93 this.sourceObjId = sourceObjId;
94 this.artifactObjId = artifactObjId;
95 this.artifactTypeId = artifactTypeID;
96 this.dataSourceObjId = dataSourceObjId;
97 this.artifactTypeName = artifactTypeName;
98 this.displayName = displayName;
99 this.reviewStatus = reviewStatus;
101 this.checkedHasChildren =
false;
102 this.hasChildren =
false;
103 this.childrenCount = -1;
126 BlackboardArtifact(
SleuthkitCase sleuthkitCase,
long artifactID,
long sourceObjId,
long artifactObjID,
long dataSourceObjID,
int artifactTypeID, String artifactTypeName, String displayName,
ReviewStatus reviewStatus,
boolean isNew) {
127 this(sleuthkitCase, artifactID, sourceObjId, artifactObjID, dataSourceObjID, artifactTypeID, artifactTypeName, displayName, reviewStatus);
134 this.loadedCacheFromDb =
true;
145 return sleuthkitCase;
154 return this.artifactId;
164 return this.sourceObjId;
172 long getDataSourceObjectID() {
173 return this.dataSourceObjId;
182 return this.artifactTypeId;
191 return this.artifactTypeName;
200 return this.displayName;
212 StringBuilder shortDescription =
new StringBuilder(
"");
214 case TSK_WEB_BOOKMARK:
216 case TSK_WEB_DOWNLOAD:
217 case TSK_WEB_HISTORY:
220 case TSK_KEYWORD_HIT:
223 case TSK_DEVICE_ATTACHED:
270 shortDescription.append(
" ");
271 shortDescription.append(MessageFormat.format(bundle.getString(
"BlackboardArtifact.shortDescriptionDate.text"), date.
getDisplayString()));
298 reviewStatus = newStatus;
313 attribute.setArtifactId(artifactId);
316 attrsCache.add(attribute);
328 ArrayList<BlackboardAttribute> attributes;
329 if (
false == loadedCacheFromDb) {
332 attrsCache.addAll(attributes);
333 loadedCacheFromDb =
true;
335 attributes =
new ArrayList<BlackboardAttribute>(attrsCache);
357 if (attribute.getAttributeType().equals(attributeType)) {
374 if (attributes.isEmpty()) {
378 attribute.setArtifactId(artifactId);
382 attrsCache.addAll(attributes);
395 if (uniquePath == null) {
398 if (myParent != null) {
407 if (parent == null) {
408 ObjectInfo parentInfo;
410 if (parentInfo == null) {
429 return new ArrayList<BlackboardArtifact>();
445 return new ArrayList<BlackboardArtifact>();
461 return new ArrayList<BlackboardArtifact>();
476 return new ArrayList<BlackboardArtifact>();
590 return new ArrayList<>();
603 return new HashSet<String>();
619 throw new TskCoreException(
"Cannot create artifact of an artifact. Not supported.");
634 throw new TskCoreException(
"Cannot create artifact of an artifact. Not supported.");
647 return visitor.
visit(
this);
659 if (
object == null) {
662 if (getClass() !=
object.getClass()) {
677 hash = 41 * hash + (int) (this.artifactId ^ (this.artifactId >>> 32));
688 return "BlackboardArtifact{" +
"artifactID=" + artifactId +
", objID=" +
getObjectID() +
", artifactObjID=" + artifactObjId +
", artifactTypeID=" + artifactTypeId +
", artifactTypeName=" + artifactTypeName +
", displayName=" + displayName +
", Case=" +
getSleuthkitCase() +
'}';
703 return visitor.
visit(
this);
715 if (contentBytes == null) {
717 loadArtifactContent();
723 return contentBytes.length;
750 if (contentBytes == null) {
751 loadArtifactContent();
754 if (0 == contentBytes.length) {
759 long readLen = Math.min(contentBytes.length - offset, len);
760 System.arraycopy(contentBytes, 0, buf, 0, (
int) readLen);
762 return (
int) readLen;
773 if (myParent == null) {
787 StringBuilder artifactContents =
new StringBuilder();
792 }
catch (TskCoreException ex) {
793 throw new TskCoreException(
"Unable to get datasource for artifact: " + this.
toString(), ex);
795 if (dataSource == null) {
796 throw new TskCoreException(
"Datasource was null for artifact: " + this.
toString());
801 artifactContents.append(attribute.getAttributeType().getDisplayName());
802 artifactContents.append(
" : ");
803 artifactContents.append(attribute.getDisplayString());
804 artifactContents.append(System.lineSeparator());
806 }
catch (TskCoreException ex) {
807 throw new TskCoreException(
"Unable to get attributes for artifact: " + this.
toString(), ex);
811 contentBytes = artifactContents.toString().getBytes(
"UTF-8");
812 }
catch (UnsupportedEncodingException ex) {
813 throw new TskCoreException(
"Failed to convert artifact string to bytes for artifact: " + this.
toString(), ex);
821 public static final class Type implements Serializable {
823 private static final long serialVersionUID = 1L;
824 private final String typeName;
825 private final int typeID;
826 private final String displayName;
835 public Type(
int typeID, String typeName, String displayName) {
836 this.typeID = typeID;
837 this.typeName = typeName;
838 this.displayName = displayName;
856 return this.typeName;
874 return this.displayName;
888 }
else if (!(that instanceof
Type)) {
891 return ((Type) that).sameType(
this);
902 private boolean sameType(
Type that) {
916 hash = 83 * hash + Objects.hashCode(this.typeID);
917 hash = 83 * hash + Objects.hashCode(this.displayName);
918 hash = 83 * hash + Objects.hashCode(this.typeName);
933 TSK_GEN_INFO(1,
"TSK_GEN_INFO",
934 bundle.getString(
"BlackboardArtifact.tskGenInfo.text")),
938 TSK_WEB_BOOKMARK(2,
"TSK_WEB_BOOKMARK",
939 bundle.getString(
"BlackboardArtifact.tskWebBookmark.text")),
943 TSK_WEB_COOKIE(3,
"TSK_WEB_COOKIE",
944 bundle.getString(
"BlackboardArtifact.tskWebCookie.text")),
948 TSK_WEB_HISTORY(4,
"TSK_WEB_HISTORY",
949 bundle.getString(
"BlackboardArtifact.tskWebHistory.text")),
953 TSK_WEB_DOWNLOAD(5,
"TSK_WEB_DOWNLOAD",
954 bundle.getString(
"BlackboardArtifact.tskWebDownload.text")),
958 TSK_RECENT_OBJECT(6,
"TSK_RECENT_OBJ",
959 bundle.getString(
"BlackboardArtifact.tsk.recentObject.text")),
963 TSK_GPS_TRACKPOINT(7,
"TSK_GPS_TRACKPOINT",
964 bundle.getString(
"BlackboardArtifact.tskGpsTrackpoint.text")),
968 TSK_INSTALLED_PROG(8,
"TSK_INSTALLED_PROG",
969 bundle.getString(
"BlackboardArtifact.tskInstalledProg.text")),
973 TSK_KEYWORD_HIT(9,
"TSK_KEYWORD_HIT",
974 bundle.getString(
"BlackboardArtifact.tskKeywordHits.text")),
978 TSK_HASHSET_HIT(10,
"TSK_HASHSET_HIT",
979 bundle.getString(
"BlackboardArtifact.tskHashsetHit.text")),
983 TSK_DEVICE_ATTACHED(11,
"TSK_DEVICE_ATTACHED",
984 bundle.getString(
"BlackboardArtifact.tskDeviceAttached.text")),
989 TSK_INTERESTING_FILE_HIT(12,
"TSK_INTERESTING_FILE_HIT",
990 bundle.getString(
"BlackboardArtifact.tskInterestingFileHit.text")),
994 TSK_EMAIL_MSG(13,
"TSK_EMAIL_MSG",
995 bundle.getString(
"BlackboardArtifact.tskEmailMsg.text")),
999 TSK_EXTRACTED_TEXT(14,
"TSK_EXTRACTED_TEXT",
1000 bundle.getString(
"BlackboardArtifact.tskExtractedText.text")),
1004 TSK_WEB_SEARCH_QUERY(15,
"TSK_WEB_SEARCH_QUERY",
1005 bundle.getString(
"BlackboardArtifact.tskWebSearchQuery.text")),
1009 TSK_METADATA_EXIF(16,
"TSK_METADATA_EXIF",
1010 bundle.getString(
"BlackboardArtifact.tskMetadataExif.text")),
1017 TSK_TAG_FILE(17,
"TSK_TAG_FILE",
1018 bundle.getString(
"BlackboardArtifact.tagFile.text")),
1025 TSK_TAG_ARTIFACT(18,
"TSK_TAG_ARTIFACT",
1026 bundle.getString(
"BlackboardArtifact.tskTagArtifact.text")),
1030 TSK_OS_INFO(19,
"TSK_OS_INFO",
1031 bundle.getString(
"BlackboardArtifact.tskOsInfo.text")),
1035 TSK_OS_ACCOUNT(20,
"TSK_OS_ACCOUNT",
1036 bundle.getString(
"BlackboardArtifact.tskOsAccount.text")),
1040 TSK_SERVICE_ACCOUNT(21,
"TSK_SERVICE_ACCOUNT",
1041 bundle.getString(
"BlackboardArtifact.tskServiceAccount.text")),
1048 TSK_TOOL_OUTPUT(22,
"TSK_TOOL_OUTPUT",
1049 bundle.getString(
"BlackboardArtifact.tskToolOutput.text")),
1054 TSK_CONTACT(23,
"TSK_CONTACT",
1055 bundle.getString(
"BlackboardArtifact.tskContact.text")),
1060 TSK_MESSAGE(24,
"TSK_MESSAGE",
1061 bundle.getString(
"BlackboardArtifact.tskMessage.text")),
1065 TSK_CALLLOG(25,
"TSK_CALLLOG",
1066 bundle.getString(
"BlackboardArtifact.tskCalllog.text")),
1070 TSK_CALENDAR_ENTRY(26,
"TSK_CALENDAR_ENTRY",
1071 bundle.getString(
"BlackboardArtifact.tskCalendarEntry.text")),
1075 TSK_SPEED_DIAL_ENTRY(27,
"TSK_SPEED_DIAL_ENTRY",
1076 bundle.getString(
"BlackboardArtifact.tskSpeedDialEntry.text")),
1080 TSK_BLUETOOTH_PAIRING(28,
"TSK_BLUETOOTH_PAIRING",
1081 bundle.getString(
"BlackboardArtifact.tskBluetoothPairing.text")),
1085 TSK_GPS_BOOKMARK(29,
"TSK_GPS_BOOKMARK",
1086 bundle.getString(
"BlackboardArtifact.tskGpsBookmark.text")),
1090 TSK_GPS_LAST_KNOWN_LOCATION(30,
"TSK_GPS_LAST_KNOWN_LOCATION",
1091 bundle.getString(
"BlackboardArtifact.tskGpsLastKnownLocation.text")),
1095 TSK_GPS_SEARCH(31,
"TSK_GPS_SEARCH",
1096 bundle.getString(
"BlackboardArtifact.tskGpsSearch.text")),
1100 TSK_PROG_RUN(32,
"TSK_PROG_RUN",
1101 bundle.getString(
"BlackboardArtifact.tskProgRun.text")),
1105 TSK_ENCRYPTION_DETECTED(33,
"TSK_ENCRYPTION_DETECTED",
1106 bundle.getString(
"BlackboardArtifact.tskEncryptionDetected.text")),
1110 TSK_EXT_MISMATCH_DETECTED(34,
"TSK_EXT_MISMATCH_DETECTED",
1111 bundle.getString(
"BlackboardArtifact.tskExtMismatchDetected.text")),
1116 TSK_INTERESTING_ARTIFACT_HIT(35,
"TSK_INTERESTING_ARTIFACT_HIT",
1117 bundle.getString(
"BlackboardArtifact.tskInterestingArtifactHit.text")),
1121 TSK_GPS_ROUTE(36,
"TSK_GPS_ROUTE",
1122 bundle.getString(
"BlackboardArtifact.tskGpsRoute.text")),
1126 TSK_REMOTE_DRIVE(37,
"TSK_REMOTE_DRIVE",
1127 bundle.getString(
"BlackboardArtifact.tskRemoteDrive.text")),
1131 TSK_FACE_DETECTED(38,
"TSK_FACE_DETECTED",
1132 bundle.getString(
"BlackboardArtifact.tskFaceDetected.text")),
1136 TSK_ACCOUNT(39,
"TSK_ACCOUNT",
1137 bundle.getString(
"BlackboardArtifact.tskAccount.text")),
1141 TSK_ENCRYPTION_SUSPECTED(40,
"TSK_ENCRYPTION_SUSPECTED",
1142 bundle.getString(
"BlackboardArtifact.tskEncryptionSuspected.text")),
1146 TSK_OBJECT_DETECTED(41,
"TSK_OBJECT_DETECTED",
1147 bundle.getString(
"BlackboardArtifact.tskObjectDetected.text")),
1151 TSK_WIFI_NETWORK(42,
"TSK_WIFI_NETWORK",
1152 bundle.getString(
"BlackboardArtifact.tskWIFINetwork.text")),
1156 TSK_DEVICE_INFO(43,
"TSK_DEVICE_INFO",
1157 bundle.getString(
"BlackboardArtifact.tskDeviceInfo.text")),
1161 TSK_SIM_ATTACHED(44,
"TSK_SIM_ATTACHED",
1162 bundle.getString(
"BlackboardArtifact.tskSimAttached.text")),
1166 TSK_BLUETOOTH_ADAPTER(45,
"TSK_BLUETOOTH_ADAPTER",
1167 bundle.getString(
"BlackboardArtifact.tskBluetoothAdapter.text")),
1171 TSK_WIFI_NETWORK_ADAPTER(46,
"TSK_WIFI_NETWORK_ADAPTER",
1172 bundle.getString(
"BlackboardArtifact.tskWIFINetworkAdapter.text")),
1176 TSK_VERIFICATION_FAILED(47,
"TSK_VERIFICATION_FAILED",
1177 bundle.getString(
"BlackboardArtifact.tskVerificationFailed.text")),
1181 TSK_DATA_SOURCE_USAGE(48,
"TSK_DATA_SOURCE_USAGE",
1182 bundle.getString(
"BlackboardArtifact.tskDataSourceUsage.text")),
1186 TSK_WEB_FORM_AUTOFILL(49,
"TSK_WEB_FORM_AUTOFILL",
1187 bundle.getString(
"BlackboardArtifact.tskWebFormAutofill.text")),
1191 TSK_WEB_FORM_ADDRESS(50,
"TSK_WEB_FORM_ADDRESSES ",
1192 bundle.getString(
"BlackboardArtifact.tskWebFormAddresses.text")),
1200 TSK_DOWNLOAD_SOURCE(51,
"TSK_DOWNLOAD_SOURCE",
1201 bundle.getString(
"BlackboardArtifact.tskDownloadSource.text")),
1205 TSK_WEB_CACHE(52,
"TSK_WEB_CACHE",
1206 bundle.getString(
"BlackboardArtifact.tskWebCache.text")),
1210 TSK_TL_EVENT(53,
"TSK_TL_EVENT",
1211 bundle.getString(
"BlackboardArtifact.tskTLEvent.text")),
1215 TSK_CLIPBOARD_CONTENT(54,
"TSK_CLIPBOARD_CONTENT",
1216 bundle.getString(
"BlackboardArtifact.tskClipboardContent.text")),
1220 TSK_ASSOCIATED_OBJECT(55,
"TSK_ASSOCIATED_OBJECT",
1221 bundle.getString(
"BlackboardArtifact.tskAssociatedObject.text")),
1225 TSK_USER_CONTENT_SUSPECTED(56,
"TSK_USER_CONTENT_SUSPECTED",
1226 bundle.getString(
"BlackboardArtifact.tskUserContentSuspected.text")),
1230 TSK_METADATA(57,
"TSK_METADATA",
1231 bundle.getString(
"BlackboardArtifact.tskMetadata.text"));
1233 private final String label;
1234 private final int typeId;
1235 private final String displayName;
1244 private ARTIFACT_TYPE(
int typeId, String label, String displayName) {
1245 this.typeId = typeId;
1247 this.displayName = displayName;
1278 if (value.getLabel().equals(label)) {
1282 throw new IllegalArgumentException(
"No ARTIFACT_TYPE matching type: " + label);
1297 if (value.getTypeID() == id) {
1301 throw new IllegalArgumentException(
"No ARTIFACT_TYPE matching type: " +
id);
1326 return visitor.
visit(
this);
1340 private final Integer id;
1341 private final String name;
1342 private final String displayName;
1343 private final static Map<Integer, ReviewStatus> idToStatus =
new HashMap<Integer, ReviewStatus>();
1347 idToStatus.put(status.getID(), status);
1359 private ReviewStatus(Integer
id, String name, String displayNameKey) {
1362 this.displayName = ResourceBundle.getBundle(
"org.sleuthkit.datamodel.Bundle").getString(displayNameKey);
1373 return idToStatus.get(
id);
1426 protected BlackboardArtifact(
SleuthkitCase sleuthkitCase,
long artifactID,
long objID,
long artifactObjID,
long dataSourceObjId,
int artifactTypeID, String artifactTypeName, String displayName) {
1427 this(sleuthkitCase, artifactID, objID, artifactObjID, dataSourceObjId, artifactTypeID, artifactTypeName, displayName,
ReviewStatus.
UNDECIDED);
1446 if (loadedCacheFromDb ==
false) {
1449 attrsCache.addAll(attrs);
1450 loadedCacheFromDb =
true;
1452 ArrayList<BlackboardAttribute> filteredAttributes =
new ArrayList<BlackboardAttribute>();
1454 if (attr.getAttributeType().getTypeID() == attributeType.getTypeID()) {
1455 filteredAttributes.add(attr);
1458 return filteredAttributes;
1463 return this.artifactObjId;
1476 List<Long> childrenIDs =
new ArrayList<Long>();
1478 childrenIDs.addAll(
getSleuthkitCase().getBlackboardArtifactChildrenIds(
this));
1485 if (childrenCount != -1) {
1486 return childrenCount;
1491 hasChildren = childrenCount > 0;
1492 checkedHasChildren =
true;
1494 return childrenCount;
1499 if (checkedHasChildren ==
true) {
1505 hasChildren = childrenCount > 0;
1506 checkedHasChildren =
true;
1521 List<Content> children =
new ArrayList<>();
static ARTIFACT_TYPE fromID(int id)
synchronized String getUniquePath()
long getAllArtifactsCount()
ArrayList< BlackboardArtifact > getArtifacts(int artifactTypeID)
ArrayList< BlackboardAttribute > getBlackboardAttributes(final BlackboardArtifact artifact)
static ARTIFACT_TYPE fromLabel(String label)
void addBlackboardAttributes(Collection< BlackboardAttribute > attributes, int artifactTypeId)
Type(int typeID, String typeName, String displayName)
String getArtifactTypeName()
void addAttributes(Collection< BlackboardAttribute > attributes)
void addBlackboardAttribute(BlackboardAttribute attr, int artifactTypeId)
List< BlackboardAttribute > getAttributes(final BlackboardAttribute.ATTRIBUTE_TYPE attributeType)
long getArtifactsCount(int artifactTypeID)
Content getContentById(long id)
BlackboardArtifact getGenInfoArtifact()
final int read(byte[] buf, long offset, long len)
String getShortDescription()
SleuthkitCase getSleuthkitCase()
void addAttribute(BlackboardAttribute attribute)
boolean equals(Object object)
ReviewStatus getReviewStatus()
ArrayList< BlackboardArtifact > getArtifacts(BlackboardArtifact.ARTIFACT_TYPE type)
Set< String > getHashSetNames()
public< T > T accept(SleuthkitItemVisitor< T > visitor)
String getDisplayString()
BlackboardArtifact newArtifact(int artifactTypeID)
BlackboardAttribute getAttribute(BlackboardAttribute.Type attributeType)
List< Long > getChildrenIds()
long getArtifactsCount(String artifactTypeName)
BlackboardArtifact getGenInfoArtifact(boolean create)
ArrayList< BlackboardArtifact > getArtifacts(String artifactTypeName)
BlackboardAttribute.Type getAttributeType()
List< BlackboardAttribute > getAttributes()
BlackboardArtifact(SleuthkitCase sleuthkitCase, long artifactID, long objID, long artifactObjID, long dataSourceObjId, int artifactTypeID, String artifactTypeName, String displayName)
List< Content > getChildren()
synchronized Content getParent()
boolean equals(Object that)
ArrayList< BlackboardArtifact > getAllArtifacts()
void setReviewStatus(ReviewStatus newStatus)
long getArtifactsCount(BlackboardArtifact.ARTIFACT_TYPE type)
ArrayList< BlackboardAttribute > getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE attr_type)
static ReviewStatus withID(int id)
BlackboardArtifact newArtifact(BlackboardArtifact.ARTIFACT_TYPE type)
void setReviewStatus(BlackboardArtifact artifact, BlackboardArtifact.ReviewStatus newStatus)