From 8d4a22e388c839052d88ec526d73d4510528fe82 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 6 Oct 2020 14:25:10 -0400 Subject: [PATCH] debugging and additional tests --- .../datamodel/RecentFilesSummary.java | 2 +- .../datamodel/RecentFilesSummaryTest.java | 46 +++++++------------ 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummary.java b/Core/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummary.java index 38722ac227..6c4601af88 100755 --- a/Core/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummary.java +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummary.java @@ -244,7 +244,7 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor { } BlackboardArtifact messageArtifact = skCase.getBlackboardArtifact(attribute.getValueLong()); - if (isMessageArtifact(messageArtifact)) { + if (messageArtifact != null && isMessageArtifact(messageArtifact)) { Content content = artifact.getParent(); if (content instanceof AbstractFile) { String sender; diff --git a/Core/test/unit/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummaryTest.java b/Core/test/unit/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummaryTest.java index 500a7e2934..95871dae2e 100644 --- a/Core/test/unit/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummaryTest.java +++ b/Core/test/unit/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummaryTest.java @@ -298,13 +298,9 @@ public class RecentFilesSummaryTest { BlackboardArtifact successItem = getRecentDocumentArtifact(dataSource, 1001, DAY_SECONDS, "/a/path"); BlackboardArtifact nullTime = getRecentDocumentArtifact(dataSource, 1002, null, "/a/path2"); - BlackboardArtifact zeroTime = getRecentDocumentArtifact(dataSource, 10021, 0L, "/a/path2a"); -// BlackboardArtifact nullPath = getRecentDocumentArtifact(dataSource, 1003, DAY_SECONDS * 2, null); -// BlackboardArtifact emptyPath = getRecentDocumentArtifact(dataSource, 1004, DAY_SECONDS * 3, ""); -// BlackboardArtifact blankPath = getRecentDocumentArtifact(dataSource, 1005, DAY_SECONDS * 4, " "); -// List artifacts = Arrays.asList(nullTime, zeroTime, nullPath, emptyPath, blankPath, successItem); - + BlackboardArtifact zeroTime = getRecentDocumentArtifact(dataSource, 10021, 0L, "/a/path2a"); List artifacts = Arrays.asList(nullTime, zeroTime, successItem); + Pair casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts)); RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft()); List results = summary.getRecentlyOpenedDocuments(dataSource, 10); @@ -379,13 +375,8 @@ public class RecentFilesSummaryTest { BlackboardArtifact successItem = getRecentDownloadArtifact(dataSource, 1001, DAY_SECONDS, "domain1.com", "/a/path1"); BlackboardArtifact nullTime = getRecentDownloadArtifact(dataSource, 1002, null, "domain2.com", "/a/path2"); BlackboardArtifact zeroTime = getRecentDownloadArtifact(dataSource, 10021, 0L, "domain2a.com", "/a/path2a"); -// BlackboardArtifact nullPathAndDomain = getRecentDownloadArtifact(dataSource, 1003, DAY_SECONDS * 2, null, null); -// BlackboardArtifact emptyPathAndDomain = getRecentDownloadArtifact(dataSource, 1004, DAY_SECONDS * 3, "", ""); -// BlackboardArtifact blankPathAndDomain = getRecentDownloadArtifact(dataSource, 1005, DAY_SECONDS * 4, " ", " "); -// List artifacts = Arrays.asList(nullTime, zeroTime, nullPathAndDomain, emptyPathAndDomain, -// blankPathAndDomain, successItem); - List artifacts = Arrays.asList(nullTime, zeroTime, successItem); + Pair casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts)); RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft()); @@ -510,6 +501,10 @@ public class RecentFilesSummaryTest { BlackboardAttribute associatedAttr = TskMockUtils.getAttribute(ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT, associatedId); + if (item.getMessageArtifactTypeId() == null) { + return associatedAttr; + } + // find the artifact type or null if not found ARTIFACT_TYPE messageType = Stream.of(ARTIFACT_TYPE.values()) .filter((artType) -> artType.getTypeID() == item.getMessageArtifactTypeId()) @@ -650,26 +645,17 @@ public class RecentFilesSummaryTest { "person2@sleuthkit.com", null, "/parent/path", "msg2.pdf"); AttachmentArtifactItem zeroTimeStamp = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), "person2a@sleuthkit.com", 0L, "/parent/path", "msg2a.png"); + AttachmentArtifactItem noParentFile = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), + "person4@sleuthkit.com", DAY_SECONDS + 4, "/parent/path", "msg4.jpg", true, false); + AttachmentArtifactItem noAssocAttr = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), + "person3@sleuthkit.com", DAY_SECONDS + 5, "/parent/path", "msg5.gif", false, true); + AttachmentArtifactItem missingAssocArt = new AttachmentArtifactItem(null, + "person3@sleuthkit.com", DAY_SECONDS + 6, "/parent/path", "msg6.pdf"); -// AttachmentArtifactItem noParentFile = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), -// "person4@sleuthkit.com", DAY_SECONDS + 4, "/parent/path", "msg4.jpg", true, false); -// AttachmentArtifactItem noAssocAttr = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), -// "person3@sleuthkit.com", DAY_SECONDS + 5, "/parent/path", "msg5.gif", false, true); -// AttachmentArtifactItem missingAssocArt = new AttachmentArtifactItem(null, -// "person3@sleuthkit.com", DAY_SECONDS + 6, "/parent/path", "msg6.pdf"); -// AttachmentArtifactItem noFrom1 = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), -// null, DAY_SECONDS + 3, "/parent/path", "msg7.pdf"); -// AttachmentArtifactItem noFrom2 = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), -// "person3@sleuthkit.com", DAY_SECONDS + 7, "/parent/path", "msg8.png"); -// AttachmentArtifactItem noPath = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), -// "person3@sleuthkit.com", DAY_SECONDS + 8, null, "msg9.bmp"); -// AttachmentArtifactItem noFile = new AttachmentArtifactItem(ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID(), -// "person3@sleuthkit.com", DAY_SECONDS + 9, "/parent/path", null); -// List items = Arrays.asList(successItem, successItem2, -// wrongArtType, missingTimeStamp, zeroTimeStamp, -// noParentFile, noAssocAttr, missingAssocArt, noFrom1, noFrom2, noPath, noFile); List items = Arrays.asList(successItem, successItem2, - wrongArtType, missingTimeStamp, zeroTimeStamp); + wrongArtType, missingTimeStamp, zeroTimeStamp, + noParentFile, noAssocAttr, missingAssocArt); + Pair casePair = getRecentAttachmentArtifactCase(items); RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());