From ed9d2ad596e0dfd76094e75df294960724050232 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Fri, 12 May 2017 12:21:13 -0400 Subject: [PATCH 1/4] 2596 Added Artifact Type and and Details Columns --- .../datamodel/BlackboardArtifactNode.java | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java index 6c245954d9..eec4a30217 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java @@ -42,6 +42,7 @@ import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagAddedEvent; import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagDeletedEvent; import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent; import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent; +import static org.sleuthkit.autopsy.datamodel.DisplayableItemNode.findLinked; import org.sleuthkit.autopsy.timeline.actions.ViewArtifactInTimelineAction; import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction; import org.sleuthkit.datamodel.AbstractFile; @@ -100,7 +101,7 @@ public class BlackboardArtifactNode extends DisplayableItemNode { } } else if (eventType.equals(Case.Events.CONTENT_TAG_DELETED.toString())) { ContentTagDeletedEvent event = (ContentTagDeletedEvent) evt; - if (event.getDeletedTagInfo().getContentID()== associated.getId()) { + if (event.getDeletedTagInfo().getContentID() == associated.getId()) { updateSheet(); } } else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) { @@ -194,6 +195,7 @@ public class BlackboardArtifactNode extends DisplayableItemNode { return actionsList.toArray(new Action[actionsList.size()]); } + @NbBundle.Messages({"# {0} - artifactDisplayName","BlackboardArtifactNode.displayName.artifact={0} Artifact"}) /** * Set the filter node display name. The value will either be the file name * or something along the lines of e.g. "Messages Artifact" for keyword hits @@ -208,15 +210,19 @@ public class BlackboardArtifactNode extends DisplayableItemNode { // If this is a node for a keyword hit on an artifact, we set the // display name to be the artifact type name followed by " Artifact" // e.g. "Messages Artifact". - if (artifact != null && - (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID() || - artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID())) { + if (artifact != null + && (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID() + || artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID())) { try { for (BlackboardAttribute attribute : artifact.getAttributes()) { if (attribute.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) { BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); if (associatedArtifact != null) { - displayName = associatedArtifact.getDisplayName() + " Artifact"; + if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID() && associated != null) { + artifact.getDisplayName(); + } else { + displayName = NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.displayName.artifact", associatedArtifact.getDisplayName()); + } } } } @@ -227,6 +233,13 @@ public class BlackboardArtifactNode extends DisplayableItemNode { this.setDisplayName(displayName); } + @NbBundle.Messages({ + "BlackboardArtifactNode.createSheet.artifactType.displayName=Artifact Type", + "BlackboardArtifactNode.createSheet.artifactType.name=Artifact Type", + "BlackboardArtifactNode.createSheet.artifactDetails.displayName=Artifact Details", + "BlackboardArtifactNode.createSheet.artifactDetails.name=Artifact Details", + "BlackboardArtifactNode.artifact.displayName=Artifact"}) + @Override protected Sheet createSheet() { Sheet s = super.createSheet(); @@ -244,6 +257,26 @@ public class BlackboardArtifactNode extends DisplayableItemNode { NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.srcFile.displayName"), NO_DESCR, this.getDisplayName())); + if (associated != null && artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) { + try { + for (BlackboardAttribute attribute : artifact.getAttributes()) { + if (attribute.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) { + BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); + ss.put(new NodeProperty<>(NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.name"), + NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.displayName"), + NO_DESCR, + associatedArtifact.getDisplayName() + " " + NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.artifact.displayName"))); + ss.put(new NodeProperty<>(NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactDetails.name"), + NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactDetails.displayName"), + NO_DESCR, + associatedArtifact.getShortDescription())); + } + + } + } catch (TskCoreException ex) { + // Do nothing since the display name will be set to the file name. + } + } for (Map.Entry entry : map.entrySet()) { ss.put(new NodeProperty<>(entry.getKey(), @@ -354,7 +387,7 @@ public class BlackboardArtifactNode extends DisplayableItemNode { LOGGER.log(Level.SEVERE, "Failed to get tags for artifact " + artifact.getDisplayName(), ex); } ss.put(new NodeProperty<>("Tags", NbBundle.getMessage(AbstractAbstractFileNode.class, "BlackboardArtifactNode.createSheet.tags.displayName"), - NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName()).collect(Collectors.joining(", ")))); + NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName()).collect(Collectors.joining(", ")))); return s; } @@ -469,7 +502,6 @@ public class BlackboardArtifactNode extends DisplayableItemNode { NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.getAssocCont.exception.msg")); } - @Override public boolean isLeafTypeNode() { return true; From 2ba924bb81481f78c8da2bb2ba2d89e8de7f3558 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Fri, 12 May 2017 14:23:57 -0400 Subject: [PATCH 2/4] 2596 find associated attribute with already defined method, remove un-needed null check --- .../datamodel/BlackboardArtifactNode.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java index eec4a30217..b4daf83988 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java @@ -195,7 +195,7 @@ public class BlackboardArtifactNode extends DisplayableItemNode { return actionsList.toArray(new Action[actionsList.size()]); } - @NbBundle.Messages({"# {0} - artifactDisplayName","BlackboardArtifactNode.displayName.artifact={0} Artifact"}) + @NbBundle.Messages({"# {0} - artifactDisplayName", "BlackboardArtifactNode.displayName.artifact={0} Artifact"}) /** * Set the filter node display name. The value will either be the file name * or something along the lines of e.g. "Messages Artifact" for keyword hits @@ -218,7 +218,7 @@ public class BlackboardArtifactNode extends DisplayableItemNode { if (attribute.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) { BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); if (associatedArtifact != null) { - if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID() && associated != null) { + if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) { artifact.getDisplayName(); } else { displayName = NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.displayName.artifact", associatedArtifact.getDisplayName()); @@ -257,21 +257,19 @@ public class BlackboardArtifactNode extends DisplayableItemNode { NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.srcFile.displayName"), NO_DESCR, this.getDisplayName())); - if (associated != null && artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) { + if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) { try { - for (BlackboardAttribute attribute : artifact.getAttributes()) { - if (attribute.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) { - BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); - ss.put(new NodeProperty<>(NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.name"), - NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.displayName"), - NO_DESCR, - associatedArtifact.getDisplayName() + " " + NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.artifact.displayName"))); - ss.put(new NodeProperty<>(NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactDetails.name"), - NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactDetails.displayName"), - NO_DESCR, - associatedArtifact.getShortDescription())); - } - + BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT)); + if (attribute != null) { + BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); + ss.put(new NodeProperty<>(NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.name"), + NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.displayName"), + NO_DESCR, + associatedArtifact.getDisplayName() + " " + NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.artifact.displayName"))); + ss.put(new NodeProperty<>(NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactDetails.name"), + NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactDetails.displayName"), + NO_DESCR, + associatedArtifact.getShortDescription())); } } catch (TskCoreException ex) { // Do nothing since the display name will be set to the file name. From c61c1798072a0c1112ad3abf5e95c01c23490fb9 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\zhaohui" Date: Mon, 15 May 2017 13:23:11 -0400 Subject: [PATCH 3/4] 2640: override the default WindowWaiter.WaitwidnowTimeout to git WizardOperator more time to wait it's fully loaded and also at StartAddxxxxDataSource time give timeouts for casedatabase and solr to create --- .../autopsy/testing/AutopsyTestCases.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java b/Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java index b95112232e..2ba740ecb6 100755 --- a/Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java +++ b/Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java @@ -39,7 +39,9 @@ import javax.swing.text.JTextComponent; import org.netbeans.jellytools.MainWindowOperator; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jellytools.WizardOperator; +import org.netbeans.jemmy.JemmyProperties; import org.netbeans.jemmy.Timeout; +import org.netbeans.jemmy.Timeouts; import org.netbeans.jemmy.operators.JButtonOperator; import org.netbeans.jemmy.operators.JCheckBoxOperator; import org.netbeans.jemmy.operators.JComboBoxOperator; @@ -57,7 +59,8 @@ public class AutopsyTestCases { private static final Logger logger = Logger.getLogger(AutopsyTestCases.class.getName()); private long start; - + private Timeouts timeouts; //Set a new timeout value for WizardOpertor + /** * Escapes the slashes in a file or directory path. * @@ -78,6 +81,12 @@ public class AutopsyTestCases { public AutopsyTestCases() { start = 0; + /* + * Nightly test failed at this point because of TimeoutExpiredException. So we set 4 minutes (This number is based on test experience) for WizardOperator + * to override the default WaitWindowTimeouts=60000 + */ + timeouts = JemmyProperties.getCurrentTimeouts(); + timeouts.setTimeout("WindowWaiter.WaitWindowTimeOut", 240000); } public void testNewCaseWizardOpen(String title) { @@ -104,8 +113,13 @@ public class AutopsyTestCases { } public void testStartAddImageFileDataSource() { + /* + * This time out is to give time for creating case database and opening solr index + */ + new Timeout("pausing", 120000).sleep(); logger.info("Starting Add Image process"); WizardOperator wo = new WizardOperator("Add Data Source"); + wo.setTimeouts(timeouts); while(!wo.btNext().isEnabled()){ new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled } @@ -123,8 +137,13 @@ public class AutopsyTestCases { } public void testStartAddLogicalFilesDataSource() { + /* + * This time out is to give time for creating case database and opening solr index + */ + new Timeout("pausing", 120000).sleep(); logger.info("Starting Add Logical Files process"); WizardOperator wo = new WizardOperator("Add Data Source"); + wo.setTimeouts(timeouts); while(!wo.btNext().isEnabled()){ new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled } From 8db38095b3da4ee1cab95672f6006b51cb7620ab Mon Sep 17 00:00:00 2001 From: "U-BASIS\\zhaohui" Date: Mon, 15 May 2017 13:53:05 -0400 Subject: [PATCH 4/4] 2640: Add a convenient function so regression test can change different timeouts --- .../autopsy/testing/AutopsyTestCases.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java b/Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java index 2ba740ecb6..236c9afecd 100755 --- a/Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java +++ b/Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java @@ -59,7 +59,6 @@ public class AutopsyTestCases { private static final Logger logger = Logger.getLogger(AutopsyTestCases.class.getName()); private long start; - private Timeouts timeouts; //Set a new timeout value for WizardOpertor /** * Escapes the slashes in a file or directory path. @@ -81,12 +80,6 @@ public class AutopsyTestCases { public AutopsyTestCases() { start = 0; - /* - * Nightly test failed at this point because of TimeoutExpiredException. So we set 4 minutes (This number is based on test experience) for WizardOperator - * to override the default WaitWindowTimeouts=60000 - */ - timeouts = JemmyProperties.getCurrentTimeouts(); - timeouts.setTimeout("WindowWaiter.WaitWindowTimeOut", 240000); } public void testNewCaseWizardOpen(String title) { @@ -119,7 +112,7 @@ public class AutopsyTestCases { new Timeout("pausing", 120000).sleep(); logger.info("Starting Add Image process"); WizardOperator wo = new WizardOperator("Add Data Source"); - wo.setTimeouts(timeouts); + wo.setTimeouts(resetTimeouts("WindowWaiter.WaitWindowTimeOut", 240000)); while(!wo.btNext().isEnabled()){ new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled } @@ -143,7 +136,7 @@ public class AutopsyTestCases { new Timeout("pausing", 120000).sleep(); logger.info("Starting Add Logical Files process"); WizardOperator wo = new WizardOperator("Add Data Source"); - wo.setTimeouts(timeouts); + wo.setTimeouts(resetTimeouts("WindowWaiter.WaitWindowTimeOut", 240000)); while(!wo.btNext().isEnabled()){ new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled } @@ -336,4 +329,15 @@ public class AutopsyTestCases { } } + + /* + * Nightly test failed at WindowWaiter.WaitWindowTimeOut because of TimeoutExpiredException. So we + * use this conveninent method to override the default Jemmy Timeouts value. + */ + + private Timeouts resetTimeouts(String name, int value) { + Timeouts timeouts = JemmyProperties.getCurrentTimeouts(); + timeouts.setTimeout(name, value); + return timeouts; + } }