From 2c4b795a46612b82adeac153f676fbb01ab8856f Mon Sep 17 00:00:00 2001 From: "eugene.livis" Date: Wed, 10 Apr 2024 15:36:08 -0400 Subject: [PATCH] Fixes --- .../services/TagNameDefinition.java | 29 ++++++++++++------- .../eventlisteners/CaseEventListener.java | 10 ++++--- .../imagegallery/ImageGalleryService.java | 12 ++++---- .../imagegallery/actions/AddTagAction.java | 2 +- .../imagegallery/actions/DeleteTagAction.java | 2 +- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java index 25345615b4..c8f04560e9 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2018 Basis Technology Corp. + * Copyright 2011-2024 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,7 +54,7 @@ final public class TagNameDefinition implements Comparable { private static final String TAGS_SETTINGS_NAME = "Tags"; //NON-NLS private static final String TAG_NAMES_SETTING_KEY = "TagNames"; //NON-NLS private static final String TAG_SETTING_VERSION_KEY = "CustomTagNameVersion"; - private static final int TAG_SETTINGS_VERSION = 1; + private static final int TAG_SETTINGS_VERSION = 2; // Changed tag type from TskData.FileKnown to TskData.TagType private final String displayName; private final String description; @@ -85,13 +85,15 @@ final public class TagNameDefinition implements Comparable { * @param description The description for the tag name. * @param color The color for the tag name. * @param status The status denoted by the tag name. + * @deprecated TagNameDefinition(String displayName, String description, TagName.HTML_COLOR color, TskData.TagType status) should be used instead. */ - /* ELTODO public TagNameDefinition(String displayName, String description, TagName.HTML_COLOR color, TskData.FileKnown status) { + @Deprecated + public TagNameDefinition(String displayName, String description, TagName.HTML_COLOR color, TskData.FileKnown status) { this.displayName = displayName; this.description = description; this.color = color; - this.tagType = status; - }*/ + this.tagType = TskData.TagType.convertFileKnownToTagType(status); + } public TagNameDefinition(String displayName, String description, TagName.HTML_COLOR color, TskData.TagType status) { this.displayName = displayName; @@ -323,7 +325,7 @@ final public class TagNameDefinition implements Comparable { Integer version = getPropertyFileVersion(); List definitions = new ArrayList<>(); - if (version == null) { + if (version == null || version == 1) { String tagsProperty = ModuleSettings.getConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY); if (tagsProperty == null || tagsProperty.isEmpty()) { ModuleSettings.setConfigSetting(TAGS_SETTINGS_NAME, TAG_SETTING_VERSION_KEY, Integer.toString(TAG_SETTINGS_VERSION)); @@ -339,22 +341,27 @@ final public class TagNameDefinition implements Comparable { List notableTagList = null; for (String tagProps : individualTags) { String[] attributes = tagProps.split(","); - TskData.TagType fileKnown = TskData.TagType.SUSPICIOUS; + TskData.TagType tagType = TskData.TagType.SUSPICIOUS; if (attributes.length == 3) { // If notableTagList is null load it from the CR. if (notableTagList == null) { - notableTagList = getCRNotableList(); // ELTODO handle backwards compatibility + notableTagList = getCRNotableList(); } else { if (notableTagList.contains(attributes[0])) { - fileKnown = TskData.TagType.BAD; + tagType = TskData.TagType.BAD; } } } else { - fileKnown = TskData.TagType.valueOf(attributes[3]); + if (version == 1) { + // handle backwards compatibility + tagType = TskData.TagType.convertFileKnownToTagType(TskData.FileKnown.valueOf(attributes[3])); + } else { + tagType = TskData.TagType.valueOf(attributes[3]); + } } definitions.add(new TagNameDefinition(attributes[0], attributes[1], - TagName.HTML_COLOR.valueOf(attributes[2]), fileKnown)); + TagName.HTML_COLOR.valueOf(attributes[2]), tagType)); } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java index 64a27e03de..c6f8b96275 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java @@ -482,10 +482,11 @@ public final class CaseEventListener implements PropertyChangeListener { for (BlackboardArtifactTag bbTag : artifactTags) { //start with assumption that none of the other tags applied to this Correlation Attribute will prevent it's status from being changed boolean hasTagWithConflictingKnownStatus = false; - // if the status of the tag has been changed to TskData.TagType.UNKNOWN + // if the status of the tag has been changed to TskData.TagType.UNKNOWN or TskData.TagType.SUSPICIOUS // we need to check the status of all other tags on this correlation attribute before changing // the status of the correlation attribute in the central repository - if (tagName.getTagType() == TskData.TagType.UNKNOWN) { + if (tagName.getTagType() == TskData.TagType.UNKNOWN + || tagName.getTagType() == TskData.TagType.SUSPICIOUS) { Content content = bbTag.getContent(); // If the content which this Blackboard Artifact Tag is linked to is an AbstractFile with KNOWN status then // it's status in the central reporsitory should not be changed to UNKNOWN @@ -522,10 +523,11 @@ public final class CaseEventListener implements PropertyChangeListener { for (ContentTag contentTag : fileTags) { //start with assumption that none of the other tags applied to this ContentTag will prevent it's status from being changed boolean hasTagWithConflictingKnownStatus = false; - // if the status of the tag has been changed to TskData.TagType.UNKNOWN + // if the status of the tag has been changed to TskData.TagType.UNKNOWN or TskData.TagType.SUSPICIOUS // we need to check the status of all other tags on this file before changing // the status of the file in the central repository - if (tagName.getTagType() == TskData.TagType.UNKNOWN) { + if (tagName.getTagType() == TskData.TagType.UNKNOWN + || tagName.getTagType() == TskData.TagType.SUSPICIOUS) { Content content = contentTag.getContent(); TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); List tags = tagsManager.getContentTagsByContent(content); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryService.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryService.java index 897b50ae2b..ff17afbdf2 100755 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryService.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryService.java @@ -65,11 +65,11 @@ public class ImageGalleryService implements AutopsyService { static { // NOTE: The colors here are what will be shown in the border - PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT0, "", TagName.HTML_COLOR.GREEN, TskData.FileKnown.UNKNOWN)); - PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT1, "", TagName.HTML_COLOR.RED, TskData.FileKnown.BAD)); - PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT2, "", TagName.HTML_COLOR.YELLOW, TskData.FileKnown.BAD)); - PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT3, "", TagName.HTML_COLOR.FUCHSIA, TskData.FileKnown.BAD)); - PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT4, "", TagName.HTML_COLOR.BLUE, TskData.FileKnown.UNKNOWN)); + PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT0, "", TagName.HTML_COLOR.GREEN, TskData.TagType.SUSPICIOUS)); + PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT1, "", TagName.HTML_COLOR.RED, TskData.TagType.BAD)); + PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT2, "", TagName.HTML_COLOR.YELLOW, TskData.TagType.BAD)); + PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT3, "", TagName.HTML_COLOR.FUCHSIA, TskData.TagType.BAD)); + PROJECT_VIC_US_CATEGORIES.add(new TagNameDefinition(PV_US_CAT4, "", TagName.HTML_COLOR.BLUE, TskData.TagType.SUSPICIOUS)); } @Override @@ -149,7 +149,7 @@ public class ImageGalleryService implements AutopsyService { private void addProjetVicTagSet(Case currentCase) throws TskCoreException { List tagNames = new ArrayList<>(); for (TagNameDefinition def : PROJECT_VIC_US_CATEGORIES) { - tagNames.add(currentCase.getSleuthkitCase().getTaggingManager().addOrUpdateTagName(def.getDisplayName(), def.getDescription(), def.getColor(), def.getKnownStatus())); + tagNames.add(currentCase.getSleuthkitCase().getTaggingManager().addOrUpdateTagName(def.getDisplayName(), def.getDescription(), def.getColor(), def.getTagType())); } currentCase.getServices().getTagsManager().addTagSet(PROJECT_VIC_TAG_SET_NAME, tagNames); } diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/AddTagAction.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/AddTagAction.java index e6af400473..c75d6e5272 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/AddTagAction.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/AddTagAction.java @@ -68,7 +68,7 @@ public class AddTagAction extends Action { this.selectedFileIDs = selectedFileIDs; this.tagName = tagName; setGraphic(controller.getTagsManager().getGraphic(tagName)); - String notableString = tagName.getKnownStatus() == TskData.FileKnown.BAD ? TagsManager.getNotableTagLabel() : ""; + String notableString = tagName.getTagType() == TskData.TagType.BAD ? TagsManager.getNotableTagLabel() : ""; setText(tagName.getDisplayName() + notableString); setEventHandler(actionEvent -> addTagWithComment("")); } diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/DeleteTagAction.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/DeleteTagAction.java index efe279bba3..c0ec387082 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/DeleteTagAction.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/DeleteTagAction.java @@ -66,7 +66,7 @@ public class DeleteTagAction extends Action { this.tagName = tagName; this.contentTag = contentTag; setGraphic(controller.getTagsManager().getGraphic(tagName)); - String notableString = tagName.getKnownStatus() == TskData.FileKnown.BAD ? TagsManager.getNotableTagLabel() : ""; + String notableString = tagName.getTagType() == TskData.TagType.BAD ? TagsManager.getNotableTagLabel() : ""; setText(tagName.getDisplayName() + notableString); setEventHandler(actionEvent -> deleteTag()); }