19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.EnumSet;
25 import java.util.List;
28 import java.util.logging.Level;
29 import java.util.stream.Collectors;
30 import org.apache.commons.lang3.StringUtils;
31 import org.openide.nodes.Children;
32 import org.openide.nodes.Sheet;
33 import org.openide.util.NbBundle;
34 import org.openide.util.WeakListeners;
68 @NbBundle.Messages(
"AbstractAbstractFileNode.addFileProperty.desc=no description")
69 private static final String
NO_DESCR = AbstractAbstractFileNode_addFileProperty_desc();
79 String ext = abstractFile.getNameExtension();
80 if (StringUtils.isNotBlank(ext)) {
113 private final PropertyChangeListener
pcl = (PropertyChangeEvent evt) -> {
114 String eventType = evt.getPropertyName();
122 if ((moduleContentEvent.getSource() instanceof Content) ==
false) {
125 Content newContent = (Content) moduleContentEvent.getSource();
128 if (
getContent().getId() == newContent.getId()) {
131 Children parentsChildren = getParentNode().getChildren();
136 if (parentsChildren instanceof ContentChildren) {
137 ((ContentChildren) parentsChildren).refreshChildren();
138 parentsChildren.getNodesCount();
140 }
catch (NullPointerException ex) {
145 if (evt.getNewValue() == null) {
151 if (event.getAddedTag().getContent().equals(content)) {
156 if (event.getDeletedTagInfo().getContentID() == content.getId()) {
161 if (event.getContentID() == content.getId()) {
175 private final PropertyChangeListener
weakPcl = WeakListeners.propertyChange(pcl, null);
178 this.setSheet(createSheet());
181 @NbBundle.Messages({
"AbstractAbstractFileNode.nameColLbl=Name",
182 "AbstractAbstractFileNode.locationColLbl=Location",
183 "AbstractAbstractFileNode.modifiedTimeColLbl=Modified Time",
184 "AbstractAbstractFileNode.changeTimeColLbl=Change Time",
185 "AbstractAbstractFileNode.accessTimeColLbl=Access Time",
186 "AbstractAbstractFileNode.createdTimeColLbl=Created Time",
187 "AbstractAbstractFileNode.sizeColLbl=Size",
188 "AbstractAbstractFileNode.flagsDirColLbl=Flags(Dir)",
189 "AbstractAbstractFileNode.flagsMetaColLbl=Flags(Meta)",
190 "AbstractAbstractFileNode.modeColLbl=Mode",
191 "AbstractAbstractFileNode.useridColLbl=UserID",
192 "AbstractAbstractFileNode.groupidColLbl=GroupID",
193 "AbstractAbstractFileNode.metaAddrColLbl=Meta Addr.",
194 "AbstractAbstractFileNode.attrAddrColLbl=Attr. Addr.",
195 "AbstractAbstractFileNode.typeDirColLbl=Type(Dir)",
196 "AbstractAbstractFileNode.typeMetaColLbl=Type(Meta)",
197 "AbstractAbstractFileNode.knownColLbl=Known",
198 "AbstractAbstractFileNode.md5HashColLbl=MD5 Hash",
199 "AbstractAbstractFileNode.objectId=Object ID",
200 "AbstractAbstractFileNode.mimeType=MIME Type",
201 "AbstractAbstractFileNode.extensionColLbl=Extension"})
204 NAME(AbstractAbstractFileNode_nameColLbl()),
205 LOCATION(AbstractAbstractFileNode_locationColLbl()),
206 MOD_TIME(AbstractAbstractFileNode_modifiedTimeColLbl()),
210 SIZE(AbstractAbstractFileNode_sizeColLbl()),
213 MODE(AbstractAbstractFileNode_modeColLbl()),
214 USER_ID(AbstractAbstractFileNode_useridColLbl()),
215 GROUP_ID(AbstractAbstractFileNode_groupidColLbl()),
218 TYPE_DIR(AbstractAbstractFileNode_typeDirColLbl()),
220 KNOWN(AbstractAbstractFileNode_knownColLbl()),
221 MD5HASH(AbstractAbstractFileNode_md5HashColLbl()),
229 this.displayString = displayString;
234 return displayString;
246 map.put(NAME.toString(), getContentDisplayName(content));
252 map.put(SIZE.toString(), content.getSize());
253 map.put(FLAGS_DIR.toString(), content.getDirFlagAsString());
254 map.put(FLAGS_META.toString(), content.getMetaFlagsAsString());
255 map.put(MODE.toString(), content.getModesAsString());
256 map.put(USER_ID.toString(), content.getUid());
257 map.put(GROUP_ID.toString(), content.getGid());
258 map.put(META_ADDR.toString(), content.getMetaAddr());
259 map.put(ATTR_ADDR.toString(), content.getAttrType().getValue() +
"-" + content.getAttributeId());
260 map.put(TYPE_DIR.toString(), content.getDirType().getLabel());
261 map.put(TYPE_META.toString(), content.getMetaType().toString());
262 map.put(KNOWN.toString(), content.getKnown().getName());
263 map.put(MD5HASH.toString(), StringUtils.defaultString(content.getMd5Hash()));
264 map.put(ObjectID.toString(), content.getId());
265 map.put(MIMETYPE.toString(), StringUtils.defaultString(content.getMIMEType()));
266 map.put(EXTENSION.toString(), content.getNameExtension());
275 List<ContentTag> tags =
new ArrayList<>();
279 logger.log(Level.SEVERE,
"Failed to get tags for content " + content.getName(), ex);
289 return correlationAttribute;
302 @NbBundle.Messages({
"AbstractAbstractFileNode.createSheet.comment.name=C",
303 "AbstractAbstractFileNode.createSheet.comment.displayName=C"})
308 for (ContentTag tag : tags) {
309 if (!StringUtils.isBlank(tag.getComment())) {
315 if (attribute != null && !StringUtils.isBlank(attribute.
getComment())) {
322 sheetSet.put(
new NodeProperty<>(AbstractAbstractFileNode_createSheet_comment_name(), AbstractAbstractFileNode_createSheet_comment_displayName(), NO_DESCR,
334 @NbBundle.Messages({
"AbstractAbstractFileNode.createSheet.score.name=S",
335 "AbstractAbstractFileNode.createSheet.score.displayName=S",
336 "AbstractAbstractFileNode.createSheet.notableFile.description=File recognized as notable.",
337 "AbstractAbstractFileNode.createSheet.interestingResult.description=File has interesting result associated with it.",
338 "AbstractAbstractFileNode.createSheet.taggedFile.description=File has been tagged.",
339 "AbstractAbstractFileNode.createSheet.notableTaggedFile.description=File tagged with notable tag.",
340 "AbstractAbstractFileNode.createSheet.noScore.description=No score"})
343 String description = Bundle.AbstractAbstractFileNode_createSheet_noScore_description();
344 if (content.getKnown() == TskData.FileKnown.BAD) {
346 description = Bundle.AbstractAbstractFileNode_createSheet_notableFile_description();
349 if (score ==
Score.
NO_SCORE && !content.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT).isEmpty()) {
351 description = Bundle.AbstractAbstractFileNode_createSheet_interestingResult_description();
353 }
catch (TskCoreException ex) {
354 logger.log(Level.WARNING,
"Error getting artifacts for file: " + content.getName(), ex);
358 description = Bundle.AbstractAbstractFileNode_createSheet_taggedFile_description();
359 for (ContentTag tag : tags) {
360 if (tag.getName().getKnownStatus() == TskData.FileKnown.BAD) {
362 description = Bundle.AbstractAbstractFileNode_createSheet_notableTaggedFile_description();
367 sheetSet.put(
new NodeProperty<>(Bundle.AbstractAbstractFileNode_createSheet_score_name(), Bundle.AbstractAbstractFileNode_createSheet_score_displayName(), description, score));
370 @NbBundle.Messages({
"AbstractAbstractFileNode.createSheet.count.name=O",
371 "AbstractAbstractFileNode.createSheet.count.displayName=O",
372 "AbstractAbstractFileNode.createSheet.count.noCentralRepo.description=Central repository was not enabled when this column was populated",
373 "AbstractAbstractFileNode.createSheet.count.hashLookupNotRun.description=Hash lookup had not been run on this file when the column was populated",
374 "# {0} - occuranceCount",
375 "AbstractAbstractFileNode.createSheet.count.description=There were {0} datasource(s) found with occurances of the correlation value"})
378 String description = Bundle.AbstractAbstractFileNode_createSheet_count_noCentralRepo_description();
383 description = Bundle.AbstractAbstractFileNode_createSheet_count_description(count);
384 }
else if (attribute != null) {
385 description = Bundle.AbstractAbstractFileNode_createSheet_count_hashLookupNotRun_description();
388 logger.log(Level.WARNING,
"Error getting count of datasources with correlation attribute", ex);
390 logger.log(Level.WARNING,
"Unable to normalize data to get count of datasources with correlation attribute", ex);
394 new NodeProperty<>(Bundle.AbstractAbstractFileNode_createSheet_count_name(), Bundle.AbstractAbstractFileNode_createSheet_count_displayName(), description, count));
405 @NbBundle.Messages(
"AbstractAbstractFileNode.tagsProperty.displayName=Tags")
408 List<ContentTag> tags =
new ArrayList<>();
412 logger.log(Level.SEVERE,
"Failed to get tags for content " + content.getName(), ex);
414 sheetSet.put(
new NodeProperty<>(
"Tags", AbstractAbstractFileNode_tagsProperty_displayName(),
415 NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName())
417 .collect(Collectors.joining(
", "))));
431 sheetSet.put(
new NodeProperty<>(
"Tags", AbstractAbstractFileNode_tagsProperty_displayName(),
432 NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName())
434 .collect(Collectors.joining(
", "))));
439 return file.getUniquePath();
440 }
catch (TskCoreException ex) {
441 logger.log(Level.SEVERE,
"Except while calling Content.getUniquePath() on " + file, ex);
446 static String getContentDisplayName(AbstractFile file) {
447 String name = file.getName();
471 return StringUtils.join(file.getHashSetNames(),
", ");
472 }
catch (TskCoreException tskCoreException) {
473 logger.log(Level.WARNING,
"Error getting hashset hits: ", tskCoreException);
static final Logger logger
final void addScoreProperty(Sheet.Set sheetSet, List< ContentTag > tags)
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static final String DOTDIR
static String getStringTime(long epochSeconds, TimeZone tzone)
static List< String > getArchiveExtensions()
final String displayString
static synchronized IngestManager getInstance()
static String getContentPath(AbstractFile file)
final CorrelationAttributeInstance getCorrelationAttributeInstance()
static final String DOTDOTDIR
static boolean useCentralRepo()
String getCorrelationValue()
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
Type getCorrelationType()
Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value)
TagsManager getTagsManager()
static final Set< Case.Events > CASE_EVENTS_OF_INTEREST
static EamDb getInstance()
static CorrelationAttributeInstance getInstanceFromContent(Content content)
final void addTagProperty(Sheet.Set sheetSet, List< ContentTag > tags)
static final String NO_DESCR
final void addCountProperty(Sheet.Set sheetSet, CorrelationAttributeInstance attribute)
AbstractFilePropertyType(String displayString)
final void addCommentProperty(Sheet.Set sheetSet, List< ContentTag > tags, CorrelationAttributeInstance attribute)
void addIngestModuleEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
final PropertyChangeListener pcl
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
final List< ContentTag > getContentTagsFromDatabase()
static String getHashSetHitsCsvList(AbstractFile file)
void addTagProperty(Sheet.Set sheetSet)
final PropertyChangeListener weakPcl