19 package org.sleuthkit.autopsy.datamodel;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.LinkedHashMap;
24 import java.util.List;
26 import java.util.logging.Level;
27 import org.openide.nodes.Children;
28 import org.openide.nodes.Sheet;
29 import org.openide.util.Lookup;
30 import org.openide.util.NbBundle;
31 import org.openide.util.lookup.Lookups;
36 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
38 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
58 BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID(),
59 BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID(),
60 BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID(),};
66 BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID(),};
80 this.associated = this.getLookup().lookup(Content.class);
81 this.setName(Long.toString(artifact.getArtifactID()));
83 this.setIconBaseWithExtension(iconPath);
97 this.associated = this.getLookup().lookup(Content.class);
98 this.setName(Long.toString(artifact.getArtifactID()));
100 this.setIconBaseWithExtension(
ExtractedContent.getIconFilePath(artifact.getArtifactTypeID()));
109 String displayName =
"";
110 if (associated != null) {
111 displayName = associated.getName();
117 if (artifact != null && artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
119 for (BlackboardAttribute attribute : artifact.getAttributes()) {
120 if (attribute.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) {
122 if (associatedArtifact != null) {
123 displayName = associatedArtifact.getDisplayName() +
" Artifact";
127 }
catch (TskCoreException ex) {
135 Sheet s = super.createSheet();
136 Sheet.Set ss = s.get(Sheet.PROPERTIES);
138 ss = Sheet.createPropertiesSet();
141 final String NO_DESCR = NbBundle.getMessage(this.getClass(),
"BlackboardArtifactNode.noDesc.text");
143 Map<String, Object> map =
new LinkedHashMap<>();
146 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.srcFile.name"),
147 NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.srcFile.displayName"),
149 this.getDisplayName()));
151 for (Map.Entry<String, Object> entry : map.entrySet()) {
159 if (customProperties != null) {
164 final int artifactTypeId = artifact.getArtifactTypeID();
167 if (artifactTypeId == BlackboardArtifact.ARTIFACT_TYPE.TSK_EXT_MISMATCH_DETECTED.getTypeID()) {
169 String actualMimeType =
"";
170 if (associated instanceof AbstractFile) {
171 AbstractFile af = (AbstractFile) associated;
172 ext = af.getNameExtension();
173 actualMimeType = af.getMIMEType();
174 if (actualMimeType == null) {
178 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.ext.name"),
179 NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.ext.displayName"),
183 NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.mimeType.name"),
184 NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.mimeType.displayName"),
189 if (Arrays.asList(SHOW_UNIQUE_PATH).contains(artifactTypeId)) {
190 String sourcePath =
"";
192 sourcePath = associated.getUniquePath();
193 }
catch (TskCoreException ex) {
194 logger.log(Level.WARNING,
"Failed to get unique path from: {0}", associated.getName());
197 if (sourcePath.isEmpty() ==
false) {
199 NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.filePath.name"),
200 NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.filePath.displayName"),
205 if (Arrays.asList(SHOW_FILE_METADATA).contains(artifactTypeId)) {
206 AbstractFile file = associated instanceof AbstractFile ? (AbstractFile) associated : null;
207 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.name"),
208 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
211 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.name"),
212 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.displayName"),
215 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.name"),
216 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.displayName"),
219 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.name"),
220 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.displayName"),
223 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.name"),
224 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.displayName"),
226 associated.getSize()));
229 String dataSourceStr =
"";
231 Content dataSource = associated.getDataSource();
232 if (dataSource != null) {
233 dataSourceStr = dataSource.getName();
237 }
catch (TskCoreException ex) {
238 logger.log(Level.WARNING,
"Failed to get image name from {0}", associated.getName());
241 if (dataSourceStr.isEmpty() ==
false) {
243 NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.dataSrc.name"),
244 NbBundle.getMessage(
this.getClass(),
"BlackboardArtifactNode.createSheet.dataSrc.displayName"),
254 String parentName = associated.getName();
257 while ((parent = parent.getParent()) != null) {
258 parentName = parent.getName();
260 }
catch (TskCoreException ex) {
261 logger.log(Level.WARNING,
"Failed to get parent name from {0}", associated.getName());
274 if (null == customProperties) {
276 customProperties =
new ArrayList<>();
278 customProperties.add(np);
289 @SuppressWarnings(
"deprecation")
292 for (BlackboardAttribute attribute : artifact.getAttributes()) {
293 final int attributeTypeID = attribute.getAttributeType().getTypeID();
295 if (attributeTypeID == ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()
296 || attributeTypeID == ATTRIBUTE_TYPE.TSK_TAGGED_ARTIFACT.getTypeID()
297 || attributeTypeID == ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()
298 || attributeTypeID == ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID()) {
300 }
else if (attribute.getAttributeType().getValueType() == BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME) {
302 }
else if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getTypeID()
303 && attributeTypeID == ATTRIBUTE_TYPE.TSK_TEXT.getTypeID()) {
311 String value = attribute.getDisplayString();
312 if (value.length() > 512) {
313 value = value.substring(0, 512);
315 map.put(attribute.getAttributeType().getDisplayName(), value);
317 map.put(attribute.getAttributeType().getDisplayName(), attribute.getDisplayString());
320 }
catch (TskException ex) {
321 logger.log(Level.SEVERE,
"Getting attributes failed", ex);
327 return v.
visit(
this);
338 List<Object> forLookup =
new ArrayList<>();
339 forLookup.add(artifact);
343 if (content != null) {
344 forLookup.add(content);
350 if (highlight != null) {
351 forLookup.add(highlight);
354 return Lookups.fixed(forLookup.toArray(
new Object[forLookup.size()]));
359 return artifact.getSleuthkitCase().getContentById(artifact.getObjectID());
360 }
catch (TskException ex) {
361 logger.log(Level.WARNING,
"Getting file failed", ex);
363 throw new IllegalArgumentException(
368 if (artifact.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
372 long objectId = content.getId();
374 Lookup lookup = Lookup.getDefault();
377 List<BlackboardAttribute> attributes = artifact.getAttributes();
378 String keyword = null;
379 String regexp = null;
380 for (BlackboardAttribute att : attributes) {
381 final int attributeTypeID = att.getAttributeType().getTypeID();
382 if (attributeTypeID == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID()) {
383 keyword = att.getValueString();
384 }
else if (attributeTypeID == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP.getTypeID()) {
385 regexp = att.getValueString();
386 }
else if (attributeTypeID == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) {
387 objectId = att.getValueLong();
390 if (keyword != null) {
391 boolean isRegexp = (regexp != null && !regexp.equals(
""));
398 return highlightFactory.
createInstance(objectId, keyword, isRegexp, origQuery);
400 }
catch (TskException ex) {
401 logger.log(Level.WARNING,
"Failed to retrieve Blackboard Attributes", ex);
void fillPropertyMap(Map< String, Object > map, BlackboardArtifact artifact)
static String getStringTime(long epochSeconds, TimeZone tzone)
BlackboardArtifactNode(BlackboardArtifact artifact, String iconPath)
static Lookup createLookup(BlackboardArtifact artifact)
static final Integer[] SHOW_FILE_METADATA
TextMarkupLookup createInstance(long objectId, String keyword, boolean isRegex, String originalQuery)
T visit(DataSourcesNode in)
static Content getAssociatedContent(BlackboardArtifact artifact)
List< NodeProperty<?extends Object > > customProperties
String getRootParentName()
final BlackboardArtifact artifact
SleuthkitCase getSleuthkitCase()
static TextMarkupLookup getHighlightLookup(BlackboardArtifact artifact, Content content)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
BlackboardArtifactNode(BlackboardArtifact artifact)
static final Integer[] SHOW_UNIQUE_PATH