mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Moved RecentFilesSummary into contentutils package
This commit is contained in:
parent
8784853f4b
commit
22041a8ca6
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2019 - 2020 Basis Technology Corp.
|
* Copyright 2019 - 2021 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.datasourcesummary.datamodel;
|
package org.sleuthkit.autopsy.contentutils;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -41,7 +41,7 @@ import org.sleuthkit.datamodel.TskData.TSK_FS_META_TYPE_ENUM;
|
|||||||
* Utilities for getting information about a data source or all data sources
|
* Utilities for getting information about a data source or all data sources
|
||||||
* from the case database.
|
* from the case database.
|
||||||
*/
|
*/
|
||||||
final class DataSourceInfoUtilities {
|
public final class DataSourceInfoUtilities {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a count of tsk_files for a particular datasource.
|
* Gets a count of tsk_files for a particular datasource.
|
||||||
@ -55,7 +55,7 @@ final class DataSourceInfoUtilities {
|
|||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
static Long getCountOfTskFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
|
public static Long getCountOfTskFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
|
||||||
throws TskCoreException, SQLException {
|
throws TskCoreException, SQLException {
|
||||||
if (currentDataSource != null) {
|
if (currentDataSource != null) {
|
||||||
return skCase.countFilesWhere(
|
return skCase.countFilesWhere(
|
||||||
@ -77,7 +77,7 @@ final class DataSourceInfoUtilities {
|
|||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
static Long getCountOfRegularFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
|
public static Long getCountOfRegularFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
|
||||||
throws TskCoreException, SQLException {
|
throws TskCoreException, SQLException {
|
||||||
String whereClause = "meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue();
|
String whereClause = "meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue();
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ final class DataSourceInfoUtilities {
|
|||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
static Long getCountOfRegNonSlackFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
|
public static Long getCountOfRegNonSlackFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
|
||||||
throws TskCoreException, SQLException {
|
throws TskCoreException, SQLException {
|
||||||
String whereClause = "meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue()
|
String whereClause = "meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue()
|
||||||
+ " AND type<>" + TSK_DB_FILES_TYPE_ENUM.SLACK.getFileType();
|
+ " AND type<>" + TSK_DB_FILES_TYPE_ENUM.SLACK.getFileType();
|
||||||
@ -115,7 +115,7 @@ final class DataSourceInfoUtilities {
|
|||||||
/**
|
/**
|
||||||
* An interface for handling a result set and returning a value.
|
* An interface for handling a result set and returning a value.
|
||||||
*/
|
*/
|
||||||
interface ResultSetHandler<T> {
|
public interface ResultSetHandler<T> {
|
||||||
|
|
||||||
T process(ResultSet resultset) throws SQLException;
|
T process(ResultSet resultset) throws SQLException;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ final class DataSourceInfoUtilities {
|
|||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
static <T> T getBaseQueryResult(SleuthkitCase skCase, String query, ResultSetHandler<T> processor)
|
public static <T> T getBaseQueryResult(SleuthkitCase skCase, String query, ResultSetHandler<T> processor)
|
||||||
throws TskCoreException, SQLException {
|
throws TskCoreException, SQLException {
|
||||||
try (SleuthkitCase.CaseDbQuery dbQuery = skCase.executeQuery(query)) {
|
try (SleuthkitCase.CaseDbQuery dbQuery = skCase.executeQuery(query)) {
|
||||||
ResultSet resultSet = dbQuery.getResultSet();
|
ResultSet resultSet = dbQuery.getResultSet();
|
||||||
@ -149,14 +149,14 @@ final class DataSourceInfoUtilities {
|
|||||||
*
|
*
|
||||||
* @return The clause.
|
* @return The clause.
|
||||||
*/
|
*/
|
||||||
static String getMetaFlagsContainsStatement(TSK_FS_META_FLAG_ENUM flag) {
|
public static String getMetaFlagsContainsStatement(TSK_FS_META_FLAG_ENUM flag) {
|
||||||
return "meta_flags & " + flag.getValue() + " > 0";
|
return "meta_flags & " + flag.getValue() + " > 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum for specifying the sort order for getAttributes.
|
* Enum for specifying the sort order for getAttributes.
|
||||||
*/
|
*/
|
||||||
enum SortOrder {
|
public enum SortOrder {
|
||||||
DESCENDING,
|
DESCENDING,
|
||||||
ASCENDING
|
ASCENDING
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ final class DataSourceInfoUtilities {
|
|||||||
*
|
*
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
*/
|
*/
|
||||||
static List<BlackboardArtifact> getArtifacts(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder) throws TskCoreException {
|
public static List<BlackboardArtifact> getArtifacts(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder) throws TskCoreException {
|
||||||
return getArtifacts(skCase, artifactType, dataSource, attributeType, sortOrder, 0);
|
return getArtifacts(skCase, artifactType, dataSource, attributeType, sortOrder, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ final class DataSourceInfoUtilities {
|
|||||||
*
|
*
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
*/
|
*/
|
||||||
static List<BlackboardArtifact> getArtifacts(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder, int maxCount) throws TskCoreException {
|
public static List<BlackboardArtifact> getArtifacts(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder, int maxCount) throws TskCoreException {
|
||||||
if (maxCount < 0) {
|
if (maxCount < 0) {
|
||||||
throw new IllegalArgumentException("Invalid maxCount passed to getArtifacts, value must be equal to or greater than 0");
|
throw new IllegalArgumentException("Invalid maxCount passed to getArtifacts, value must be equal to or greater than 0");
|
||||||
}
|
}
|
||||||
@ -380,7 +380,7 @@ final class DataSourceInfoUtilities {
|
|||||||
* @return The 'getValueString()' value or null if the attribute or String
|
* @return The 'getValueString()' value or null if the attribute or String
|
||||||
* could not be retrieved.
|
* could not be retrieved.
|
||||||
*/
|
*/
|
||||||
static String getStringOrNull(BlackboardArtifact artifact, Type attributeType) {
|
public static String getStringOrNull(BlackboardArtifact artifact, Type attributeType) {
|
||||||
BlackboardAttribute attr = getAttributeOrNull(artifact, attributeType);
|
BlackboardAttribute attr = getAttributeOrNull(artifact, attributeType);
|
||||||
return (attr == null) ? null : attr.getValueString();
|
return (attr == null) ? null : attr.getValueString();
|
||||||
}
|
}
|
||||||
@ -394,7 +394,7 @@ final class DataSourceInfoUtilities {
|
|||||||
* @return The 'getValueLong()' value or null if the attribute could not be
|
* @return The 'getValueLong()' value or null if the attribute could not be
|
||||||
* retrieved.
|
* retrieved.
|
||||||
*/
|
*/
|
||||||
static Long getLongOrNull(BlackboardArtifact artifact, Type attributeType) {
|
public static Long getLongOrNull(BlackboardArtifact artifact, Type attributeType) {
|
||||||
BlackboardAttribute attr = getAttributeOrNull(artifact, attributeType);
|
BlackboardAttribute attr = getAttributeOrNull(artifact, attributeType);
|
||||||
return (attr == null) ? null : attr.getValueLong();
|
return (attr == null) ? null : attr.getValueLong();
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ final class DataSourceInfoUtilities {
|
|||||||
* @return The 'getValueInt()' value or null if the attribute could not be
|
* @return The 'getValueInt()' value or null if the attribute could not be
|
||||||
* retrieved.
|
* retrieved.
|
||||||
*/
|
*/
|
||||||
static Integer getIntOrNull(BlackboardArtifact artifact, Type attributeType) {
|
public static Integer getIntOrNull(BlackboardArtifact artifact, Type attributeType) {
|
||||||
BlackboardAttribute attr = getAttributeOrNull(artifact, attributeType);
|
BlackboardAttribute attr = getAttributeOrNull(artifact, attributeType);
|
||||||
return (attr == null) ? null : attr.getValueInt();
|
return (attr == null) ? null : attr.getValueInt();
|
||||||
}
|
}
|
||||||
@ -423,7 +423,7 @@ final class DataSourceInfoUtilities {
|
|||||||
* @return The date determined from the 'getValueLong()' as seconds from
|
* @return The date determined from the 'getValueLong()' as seconds from
|
||||||
* epoch or null if the attribute could not be retrieved or is 0.
|
* epoch or null if the attribute could not be retrieved or is 0.
|
||||||
*/
|
*/
|
||||||
static Date getDateOrNull(BlackboardArtifact artifact, Type attributeType) {
|
public static Date getDateOrNull(BlackboardArtifact artifact, Type attributeType) {
|
||||||
Long longVal = getLongOrNull(artifact, attributeType);
|
Long longVal = getLongOrNull(artifact, attributeType);
|
||||||
return (longVal == null || longVal == 0) ? null : new Date(longVal * 1000);
|
return (longVal == null || longVal == 0) ? null : new Date(longVal * 1000);
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2020 Basis Technology Corp.
|
* Copyright 2021 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -16,9 +16,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.datasourcesummary.datamodel;
|
package org.sleuthkit.autopsy.contentutils;
|
||||||
|
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DefaultArtifactUpdateGovernor;
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -33,6 +32,8 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
@ -40,13 +41,12 @@ import org.sleuthkit.datamodel.Content;
|
|||||||
import org.sleuthkit.datamodel.DataSource;
|
import org.sleuthkit.datamodel.DataSource;
|
||||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for getting data for the Recent Files Data Summary tab.
|
* Helper class for getting Recent Activity data.
|
||||||
*/
|
*/
|
||||||
public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
public class RecentFilesSummary {
|
||||||
|
|
||||||
private final static BlackboardAttribute.Type DATETIME_ACCESSED_ATT = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED);
|
private final static BlackboardAttribute.Type DATETIME_ACCESSED_ATT = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED);
|
||||||
private final static BlackboardAttribute.Type DOMAIN_ATT = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN);
|
private final static BlackboardAttribute.Type DOMAIN_ATT = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN);
|
||||||
@ -66,30 +66,13 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()
|
ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()
|
||||||
));
|
));
|
||||||
|
|
||||||
private final SleuthkitCaseProvider provider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
public RecentFilesSummary() {
|
private RecentFilesSummary() {
|
||||||
this(SleuthkitCaseProvider.DEFAULT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static Set<Integer> getArtifactTypeIdsForRefresh() {
|
||||||
* Construct object with given SleuthkitCaseProvider
|
|
||||||
*
|
|
||||||
* @param provider SleuthkitCaseProvider provider, cannot be null.
|
|
||||||
*/
|
|
||||||
public RecentFilesSummary(SleuthkitCaseProvider provider) {
|
|
||||||
if (provider == null) {
|
|
||||||
throw new IllegalArgumentException("Unable to construct RecentFileSummary object. SleuthkitCaseProvider cannot be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.provider = provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Integer> getArtifactTypeIdsForRefresh() {
|
|
||||||
return ARTIFACT_UPDATE_TYPE_IDS;
|
return ARTIFACT_UPDATE_TYPE_IDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +84,7 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
* @param limit The maximum number of entries to return.
|
* @param limit The maximum number of entries to return.
|
||||||
* @return The sorted limited list with unique paths.
|
* @return The sorted limited list with unique paths.
|
||||||
*/
|
*/
|
||||||
private <T extends RecentFileDetails> List<T> getSortedLimited(List<T> fileDetails, int limit) {
|
private static <T extends RecentFileDetails> List<T> getSortedLimited(List<T> fileDetails, int limit) {
|
||||||
Map<String, T> fileDetailsMap = fileDetails.stream()
|
Map<String, T> fileDetailsMap = fileDetails.stream()
|
||||||
.filter(details -> details != null)
|
.filter(details -> details != null)
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
@ -122,7 +105,7 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
* @param artifact The artifact.
|
* @param artifact The artifact.
|
||||||
* @return The derived object or null if artifact is invalid.
|
* @return The derived object or null if artifact is invalid.
|
||||||
*/
|
*/
|
||||||
private RecentFileDetails getRecentlyOpenedDocument(BlackboardArtifact artifact) {
|
private static RecentFileDetails getRecentlyOpenedDocument(BlackboardArtifact artifact) {
|
||||||
String path = DataSourceInfoUtilities.getStringOrNull(artifact, PATH_ATT);
|
String path = DataSourceInfoUtilities.getStringOrNull(artifact, PATH_ATT);
|
||||||
Long lastOpened = DataSourceInfoUtilities.getLongOrNull(artifact, DATETIME_ACCESSED_ATT);
|
Long lastOpened = DataSourceInfoUtilities.getLongOrNull(artifact, DATETIME_ACCESSED_ATT);
|
||||||
|
|
||||||
@ -144,17 +127,17 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
* @return A list RecentFileDetails representing the most recently opened
|
* @return A list RecentFileDetails representing the most recently opened
|
||||||
* documents or an empty list if none were found.
|
* documents or an empty list if none were found.
|
||||||
*
|
*
|
||||||
* @throws SleuthkitCaseProviderException
|
* @throws NoCurrentCaseException
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
*/
|
*/
|
||||||
public List<RecentFileDetails> getRecentlyOpenedDocuments(DataSource dataSource, int maxCount) throws SleuthkitCaseProviderException, TskCoreException {
|
public static List<RecentFileDetails> getRecentlyOpenedDocuments(DataSource dataSource, int maxCount) throws TskCoreException, NoCurrentCaseException {
|
||||||
if (dataSource == null) {
|
if (dataSource == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
throwOnNonPositiveCount(maxCount);
|
throwOnNonPositiveCount(maxCount);
|
||||||
|
|
||||||
List<RecentFileDetails> details = provider.get().getBlackboard()
|
List<RecentFileDetails> details = Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboard()
|
||||||
.getArtifacts(ARTIFACT_TYPE.TSK_RECENT_OBJECT.getTypeID(), dataSource.getId()).stream()
|
.getArtifacts(ARTIFACT_TYPE.TSK_RECENT_OBJECT.getTypeID(), dataSource.getId()).stream()
|
||||||
.map(art -> getRecentlyOpenedDocument(art))
|
.map(art -> getRecentlyOpenedDocument(art))
|
||||||
.filter(d -> d != null)
|
.filter(d -> d != null)
|
||||||
@ -170,7 +153,7 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
* @param artifact The artifact.
|
* @param artifact The artifact.
|
||||||
* @return The derived object or null if artifact is invalid.
|
* @return The derived object or null if artifact is invalid.
|
||||||
*/
|
*/
|
||||||
private RecentDownloadDetails getRecentDownload(BlackboardArtifact artifact) {
|
private static RecentDownloadDetails getRecentDownload(BlackboardArtifact artifact) {
|
||||||
Long accessedTime = DataSourceInfoUtilities.getLongOrNull(artifact, DATETIME_ACCESSED_ATT);
|
Long accessedTime = DataSourceInfoUtilities.getLongOrNull(artifact, DATETIME_ACCESSED_ATT);
|
||||||
String domain = DataSourceInfoUtilities.getStringOrNull(artifact, DOMAIN_ATT);
|
String domain = DataSourceInfoUtilities.getStringOrNull(artifact, DOMAIN_ATT);
|
||||||
String path = DataSourceInfoUtilities.getStringOrNull(artifact, PATH_ATT);
|
String path = DataSourceInfoUtilities.getStringOrNull(artifact, PATH_ATT);
|
||||||
@ -187,7 +170,7 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
*
|
*
|
||||||
* @param count The count.
|
* @param count The count.
|
||||||
*/
|
*/
|
||||||
private void throwOnNonPositiveCount(int count) {
|
private static void throwOnNonPositiveCount(int count) {
|
||||||
if (count < 1) {
|
if (count < 1) {
|
||||||
throw new IllegalArgumentException("Invalid count: value must be greater than 0.");
|
throw new IllegalArgumentException("Invalid count: value must be greater than 0.");
|
||||||
}
|
}
|
||||||
@ -205,16 +188,16 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
* found.
|
* found.
|
||||||
*
|
*
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
* @throws SleuthkitCaseProviderException
|
* @throws NoCurrentCaseException
|
||||||
*/
|
*/
|
||||||
public List<RecentDownloadDetails> getRecentDownloads(DataSource dataSource, int maxCount) throws TskCoreException, SleuthkitCaseProviderException {
|
public static List<RecentDownloadDetails> getRecentDownloads(DataSource dataSource, int maxCount) throws TskCoreException, NoCurrentCaseException {
|
||||||
if (dataSource == null) {
|
if (dataSource == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
throwOnNonPositiveCount(maxCount);
|
throwOnNonPositiveCount(maxCount);
|
||||||
|
|
||||||
List<RecentDownloadDetails> details = provider.get().getBlackboard()
|
List<RecentDownloadDetails> details = Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboard()
|
||||||
.getArtifacts(ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getTypeID(), dataSource.getId()).stream()
|
.getArtifacts(ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getTypeID(), dataSource.getId()).stream()
|
||||||
.map(art -> getRecentDownload(art))
|
.map(art -> getRecentDownload(art))
|
||||||
.filter(d -> d != null)
|
.filter(d -> d != null)
|
||||||
@ -232,17 +215,17 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
*
|
*
|
||||||
* @return A list of RecentFileDetails of the most recent attachments.
|
* @return A list of RecentFileDetails of the most recent attachments.
|
||||||
*
|
*
|
||||||
* @throws SleuthkitCaseProviderException
|
* @throws NoCurrentCaseException
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
*/
|
*/
|
||||||
public List<RecentAttachmentDetails> getRecentAttachments(DataSource dataSource, int maxCount) throws SleuthkitCaseProviderException, TskCoreException {
|
public static List<RecentAttachmentDetails> getRecentAttachments(DataSource dataSource, int maxCount) throws NoCurrentCaseException, TskCoreException {
|
||||||
if (dataSource == null) {
|
if (dataSource == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
throwOnNonPositiveCount(maxCount);
|
throwOnNonPositiveCount(maxCount);
|
||||||
|
|
||||||
SleuthkitCase skCase = provider.get();
|
SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase();
|
||||||
|
|
||||||
List<BlackboardArtifact> associatedArtifacts = skCase.getBlackboard()
|
List<BlackboardArtifact> associatedArtifacts = skCase.getBlackboard()
|
||||||
.getArtifacts(ASSOCATED_OBJ_ART.getTypeID(), dataSource.getId());
|
.getArtifacts(ASSOCATED_OBJ_ART.getTypeID(), dataSource.getId());
|
||||||
@ -268,7 +251,7 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
* @return The derived object or null.
|
* @return The derived object or null.
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
*/
|
*/
|
||||||
private RecentAttachmentDetails getRecentAttachment(BlackboardArtifact artifact, SleuthkitCase skCase) throws TskCoreException {
|
private static RecentAttachmentDetails getRecentAttachment(BlackboardArtifact artifact, SleuthkitCase skCase) throws TskCoreException {
|
||||||
// get associated artifact or return no result
|
// get associated artifact or return no result
|
||||||
BlackboardAttribute attribute = artifact.getAttribute(ASSOCATED_ATT);
|
BlackboardAttribute attribute = artifact.getAttribute(ASSOCATED_ATT);
|
||||||
if (attribute == null) {
|
if (attribute == null) {
|
||||||
@ -309,7 +292,7 @@ public class RecentFilesSummary implements DefaultArtifactUpdateGovernor {
|
|||||||
*
|
*
|
||||||
* @return True if the given artifact is a message artifact
|
* @return True if the given artifact is a message artifact
|
||||||
*/
|
*/
|
||||||
private boolean isMessageArtifact(BlackboardArtifact nodeArtifact) {
|
private static boolean isMessageArtifact(BlackboardArtifact nodeArtifact) {
|
||||||
final int artifactTypeID = nodeArtifact.getArtifactTypeID();
|
final int artifactTypeID = nodeArtifact.getArtifactTypeID();
|
||||||
return artifactTypeID == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
|
return artifactTypeID == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
|
||||||
|| artifactTypeID == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID();
|
|| artifactTypeID == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID();
|
@ -30,6 +30,7 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.DataSourceInfoUtilities;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||||
|
@ -24,6 +24,7 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.DataSourceInfoUtilities;
|
||||||
import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
|
import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.DataSourceInfoUtilities;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||||
import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
|
import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
|
@ -32,6 +32,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
import org.sleuthkit.autopsy.centralrepository.ingestmodule.CentralRepoIngestModuleFactory;
|
import org.sleuthkit.autopsy.centralrepository.ingestmodule.CentralRepoIngestModuleFactory;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DefaultArtifactUpdateGovernor;
|
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DefaultArtifactUpdateGovernor;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.DataSourceInfoUtilities;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
|
@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020-2021 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.sleuthkit.autopsy.datasourcesummary.datamodel;
|
||||||
|
|
||||||
|
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DefaultArtifactUpdateGovernor;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentAttachmentDetails;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentDownloadDetails;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentFileDetails;
|
||||||
|
import org.sleuthkit.datamodel.DataSource;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper class for converting org.sleuthkit.autopsy.contentutils.RecentFilesSummary functionality into
|
||||||
|
* a DefaultArtifactUpdateGovernor used by Recent Files Data Summary tab.
|
||||||
|
*/
|
||||||
|
public class RecentFilesGetter implements DefaultArtifactUpdateGovernor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
public RecentFilesGetter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> getArtifactTypeIdsForRefresh() {
|
||||||
|
return RecentFilesSummary.getArtifactTypeIdsForRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of the most recently opened documents based on the
|
||||||
|
* TSK_RECENT_OBJECT artifact.
|
||||||
|
*
|
||||||
|
* @param dataSource The data source to query.
|
||||||
|
* @param maxCount The maximum number of results to return, pass 0 to get a
|
||||||
|
* list of all results.
|
||||||
|
*
|
||||||
|
* @return A list RecentFileDetails representing the most recently opened
|
||||||
|
* documents or an empty list if none were found.
|
||||||
|
*
|
||||||
|
* @throws SleuthkitCaseProviderException
|
||||||
|
* @throws TskCoreException
|
||||||
|
*/
|
||||||
|
public List<RecentFileDetails> getRecentlyOpenedDocuments(DataSource dataSource, int maxCount) throws SleuthkitCaseProviderException, TskCoreException {
|
||||||
|
try {
|
||||||
|
return RecentFilesSummary.getRecentlyOpenedDocuments(dataSource, maxCount);
|
||||||
|
} catch (NoCurrentCaseException ex) {
|
||||||
|
throw new SleuthkitCaseProviderException("No currently open case.", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of the most recent downloads based on the value of the the
|
||||||
|
* artifact TSK_DATETIME_ACCESSED attribute.
|
||||||
|
*
|
||||||
|
* @param dataSource Data source to query.
|
||||||
|
* @param maxCount Maximum number of results to return, passing 0 will
|
||||||
|
* return all results.
|
||||||
|
*
|
||||||
|
* @return A list of RecentFileDetails objects or empty list if none were
|
||||||
|
* found.
|
||||||
|
*
|
||||||
|
* @throws TskCoreException
|
||||||
|
* @throws SleuthkitCaseProviderException
|
||||||
|
*/
|
||||||
|
public List<RecentDownloadDetails> getRecentDownloads(DataSource dataSource, int maxCount) throws TskCoreException, SleuthkitCaseProviderException {
|
||||||
|
try {
|
||||||
|
return RecentFilesSummary.getRecentDownloads(dataSource, maxCount);
|
||||||
|
} catch (NoCurrentCaseException ex) {
|
||||||
|
throw new SleuthkitCaseProviderException("No currently open case.", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of the most recent message attachments.
|
||||||
|
*
|
||||||
|
* @param dataSource Data source to query.
|
||||||
|
* @param maxCount Maximum number of results to return, passing 0 will
|
||||||
|
* return all results.
|
||||||
|
*
|
||||||
|
* @return A list of RecentFileDetails of the most recent attachments.
|
||||||
|
*
|
||||||
|
* @throws SleuthkitCaseProviderException
|
||||||
|
* @throws TskCoreException
|
||||||
|
*/
|
||||||
|
public List<RecentAttachmentDetails> getRecentAttachments(DataSource dataSource, int maxCount) throws SleuthkitCaseProviderException, TskCoreException {
|
||||||
|
try {
|
||||||
|
return RecentFilesSummary.getRecentAttachments(dataSource, maxCount);
|
||||||
|
} catch (NoCurrentCaseException ex) {
|
||||||
|
throw new SleuthkitCaseProviderException("No currently open case.", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.DataSourceInfoUtilities;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||||
import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
|
import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2020 Basis Technology Corp.
|
* Copyright 2020-2021 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -39,6 +39,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.DataSourceInfoUtilities;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
import org.sleuthkit.datamodel.DataSource;
|
import org.sleuthkit.datamodel.DataSource;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2020 Basis Technology Corp.
|
* Copyright 2020-2021 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -30,10 +30,10 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary;
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesGetter;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentAttachmentDetails;
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentAttachmentDetails;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentDownloadDetails;
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentDownloadDetails;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentFileDetails;
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentFileDetails;
|
||||||
import static org.sleuthkit.autopsy.datasourcesummary.ui.BaseDataSourceSummaryPanel.getTableExport;
|
import static org.sleuthkit.autopsy.datasourcesummary.ui.BaseDataSourceSummaryPanel.getTableExport;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.CellModelTableCellRenderer;
|
import org.sleuthkit.autopsy.datasourcesummary.uiutils.CellModelTableCellRenderer;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ColumnModel;
|
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ColumnModel;
|
||||||
@ -120,13 +120,13 @@ public final class RecentFilesPanel extends BaseDataSourceSummaryPanel {
|
|||||||
"RecentFilePanel_emailParserModuleName=Email Parser"
|
"RecentFilePanel_emailParserModuleName=Email Parser"
|
||||||
})
|
})
|
||||||
public RecentFilesPanel() {
|
public RecentFilesPanel() {
|
||||||
this(new RecentFilesSummary());
|
this(new RecentFilesGetter());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form RecentFilesPanel
|
* Creates new form RecentFilesPanel
|
||||||
*/
|
*/
|
||||||
public RecentFilesPanel(RecentFilesSummary dataHandler) {
|
public RecentFilesPanel(RecentFilesGetter dataHandler) {
|
||||||
super(dataHandler);
|
super(dataHandler);
|
||||||
docsFetcher = (dataSource) -> dataHandler.getRecentlyOpenedDocuments(dataSource, 10);
|
docsFetcher = (dataSource) -> dataHandler.getRecentlyOpenedDocuments(dataSource, 10);
|
||||||
downloadsFetcher = (dataSource) -> dataHandler.getRecentDownloads(dataSource, 10);
|
downloadsFetcher = (dataSource) -> dataHandler.getRecentDownloads(dataSource, 10);
|
||||||
|
@ -27,7 +27,7 @@ import org.junit.Assert;
|
|||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.DataSourceInfoUtilities.SortOrder;
|
import org.sleuthkit.autopsy.contentutils.DataSourceInfoUtilities.SortOrder;
|
||||||
import org.sleuthkit.datamodel.Blackboard;
|
import org.sleuthkit.datamodel.Blackboard;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
@ -36,6 +36,7 @@ import org.sleuthkit.datamodel.SleuthkitCase;
|
|||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
import org.sleuthkit.autopsy.testutils.TskMockUtils;
|
import org.sleuthkit.autopsy.testutils.TskMockUtils;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
import org.sleuthkit.autopsy.contentutils.DataSourceInfoUtilities;
|
||||||
import org.sleuthkit.autopsy.testutils.RandomizationUtils;
|
import org.sleuthkit.autopsy.testutils.RandomizationUtils;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||||
import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
|
import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
|
||||||
|
@ -40,9 +40,9 @@ import static org.mockito.Mockito.never;
|
|||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentAttachmentDetails;
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentAttachmentDetails;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentDownloadDetails;
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentDownloadDetails;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentFileDetails;
|
import org.sleuthkit.autopsy.contentutils.RecentFilesSummary.RecentFileDetails;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
import org.sleuthkit.autopsy.testutils.RandomizationUtils;
|
import org.sleuthkit.autopsy.testutils.RandomizationUtils;
|
||||||
import org.sleuthkit.autopsy.testutils.TskMockUtils;
|
import org.sleuthkit.autopsy.testutils.TskMockUtils;
|
||||||
@ -62,15 +62,15 @@ import org.sleuthkit.datamodel.TskCoreException;
|
|||||||
public class RecentFilesSummaryTest {
|
public class RecentFilesSummaryTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for calling methods in RecentFilesSummary in a uniform
|
* An interface for calling methods in RecentFilesGetter in a uniform
|
||||||
* manner.
|
manner.
|
||||||
*/
|
*/
|
||||||
private interface RecentFilesMethod<T> {
|
private interface RecentFilesMethod<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Means of acquiring data from a method in RecentFilesSummary.
|
* Means of acquiring data from a method in RecentFilesGetter.
|
||||||
*
|
*
|
||||||
* @param recentFilesSummary The RecentFilesSummary object.
|
* @param recentFilesSummary The RecentFilesGetter object.
|
||||||
* @param dataSource The datasource.
|
* @param dataSource The datasource.
|
||||||
* @param count The number of items to retrieve.
|
* @param count The number of items to retrieve.
|
||||||
*
|
*
|
||||||
@ -79,7 +79,7 @@ public class RecentFilesSummaryTest {
|
|||||||
* @throws SleuthkitCaseProviderException
|
* @throws SleuthkitCaseProviderException
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
*/
|
*/
|
||||||
List<T> fetch(RecentFilesSummary recentFilesSummary, DataSource dataSource, int count)
|
List<T> fetch(RecentFilesGetter recentFilesSummary, DataSource dataSource, int count)
|
||||||
throws SleuthkitCaseProviderException, TskCoreException;
|
throws SleuthkitCaseProviderException, TskCoreException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public class RecentFilesSummaryTest {
|
|||||||
throws TskCoreException, SleuthkitCaseProviderException {
|
throws TskCoreException, SleuthkitCaseProviderException {
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(null);
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(null);
|
||||||
DataSource dataSource = TskMockUtils.getDataSource(1);
|
DataSource dataSource = TskMockUtils.getDataSource(1);
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
method.fetch(summary, dataSource, -1);
|
method.fetch(summary, dataSource, -1);
|
||||||
@ -146,7 +146,7 @@ public class RecentFilesSummaryTest {
|
|||||||
throws SleuthkitCaseProviderException, TskCoreException {
|
throws SleuthkitCaseProviderException, TskCoreException {
|
||||||
|
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(null);
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(null);
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
|
|
||||||
List<? extends T> items = recentFilesMethod.fetch(summary, null, 10);
|
List<? extends T> items = recentFilesMethod.fetch(summary, null, 10);
|
||||||
Assert.assertNotNull("Expected method " + methodName + " to return an empty list.", items);
|
Assert.assertNotNull("Expected method " + methodName + " to return an empty list.", items);
|
||||||
@ -184,7 +184,7 @@ public class RecentFilesSummaryTest {
|
|||||||
throws SleuthkitCaseProviderException, TskCoreException {
|
throws SleuthkitCaseProviderException, TskCoreException {
|
||||||
|
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(Collections.emptyList());
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(Collections.emptyList());
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
DataSource dataSource = TskMockUtils.getDataSource(1);
|
DataSource dataSource = TskMockUtils.getDataSource(1);
|
||||||
List<? extends T> items = recentFilesMethod.fetch(summary, dataSource, 10);
|
List<? extends T> items = recentFilesMethod.fetch(summary, dataSource, 10);
|
||||||
Assert.assertNotNull("Expected method " + methodName + " to return an empty list.", items);
|
Assert.assertNotNull("Expected method " + methodName + " to return an empty list.", items);
|
||||||
@ -278,7 +278,7 @@ public class RecentFilesSummaryTest {
|
|||||||
|
|
||||||
// run through method
|
// run through method
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
List<RecentFileDetails> results = summary.getRecentlyOpenedDocuments(dataSource, countRequest);
|
List<RecentFileDetails> results = summary.getRecentlyOpenedDocuments(dataSource, countRequest);
|
||||||
|
|
||||||
// verify results
|
// verify results
|
||||||
@ -302,7 +302,7 @@ public class RecentFilesSummaryTest {
|
|||||||
List<BlackboardArtifact> artifacts = Arrays.asList(item2, item3, item1);
|
List<BlackboardArtifact> artifacts = Arrays.asList(item2, item3, item1);
|
||||||
|
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
List<RecentFileDetails> results = summary.getRecentlyOpenedDocuments(dataSource, 10);
|
List<RecentFileDetails> results = summary.getRecentlyOpenedDocuments(dataSource, 10);
|
||||||
|
|
||||||
// verify results (only successItem)
|
// verify results (only successItem)
|
||||||
@ -322,7 +322,7 @@ public class RecentFilesSummaryTest {
|
|||||||
List<BlackboardArtifact> artifacts = Arrays.asList(nullTime, zeroTime, successItem);
|
List<BlackboardArtifact> artifacts = Arrays.asList(nullTime, zeroTime, successItem);
|
||||||
|
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
List<RecentFileDetails> results = summary.getRecentlyOpenedDocuments(dataSource, 10);
|
List<RecentFileDetails> results = summary.getRecentlyOpenedDocuments(dataSource, 10);
|
||||||
|
|
||||||
// verify results (only successItem)
|
// verify results (only successItem)
|
||||||
@ -373,7 +373,7 @@ public class RecentFilesSummaryTest {
|
|||||||
|
|
||||||
// call method
|
// call method
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
List<RecentDownloadDetails> results = summary.getRecentDownloads(dataSource, countRequest);
|
List<RecentDownloadDetails> results = summary.getRecentDownloads(dataSource, countRequest);
|
||||||
|
|
||||||
// verify results
|
// verify results
|
||||||
@ -399,7 +399,7 @@ public class RecentFilesSummaryTest {
|
|||||||
List<BlackboardArtifact> artifacts = Arrays.asList(item2, item3, item1);
|
List<BlackboardArtifact> artifacts = Arrays.asList(item2, item3, item1);
|
||||||
|
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
|
|
||||||
// call method
|
// call method
|
||||||
List<RecentDownloadDetails> results = summary.getRecentDownloads(dataSource, 10);
|
List<RecentDownloadDetails> results = summary.getRecentDownloads(dataSource, 10);
|
||||||
@ -422,7 +422,7 @@ public class RecentFilesSummaryTest {
|
|||||||
List<BlackboardArtifact> artifacts = Arrays.asList(nullTime, zeroTime, successItem);
|
List<BlackboardArtifact> artifacts = Arrays.asList(nullTime, zeroTime, successItem);
|
||||||
|
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
Pair<SleuthkitCase, Blackboard> casePair = DataSourceSummaryMockUtils.getArtifactsTSKMock(RandomizationUtils.getMixedUp(artifacts));
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
|
|
||||||
// call method
|
// call method
|
||||||
List<RecentDownloadDetails> results = summary.getRecentDownloads(dataSource, 10);
|
List<RecentDownloadDetails> results = summary.getRecentDownloads(dataSource, 10);
|
||||||
@ -651,7 +651,7 @@ public class RecentFilesSummaryTest {
|
|||||||
|
|
||||||
List<AttachmentArtifactItem> mixedUpItems = RandomizationUtils.getMixedUp(items);
|
List<AttachmentArtifactItem> mixedUpItems = RandomizationUtils.getMixedUp(items);
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = getRecentAttachmentArtifactCase(mixedUpItems);
|
Pair<SleuthkitCase, Blackboard> casePair = getRecentAttachmentArtifactCase(mixedUpItems);
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
|
|
||||||
// retrieve results
|
// retrieve results
|
||||||
List<RecentAttachmentDetails> results = summary.getRecentAttachments(dataSource, countRequest);
|
List<RecentAttachmentDetails> results = summary.getRecentAttachments(dataSource, countRequest);
|
||||||
@ -698,7 +698,7 @@ public class RecentFilesSummaryTest {
|
|||||||
noParentFile, noAssocAttr, missingAssocArt);
|
noParentFile, noAssocAttr, missingAssocArt);
|
||||||
|
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = getRecentAttachmentArtifactCase(items);
|
Pair<SleuthkitCase, Blackboard> casePair = getRecentAttachmentArtifactCase(items);
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
|
|
||||||
// get data
|
// get data
|
||||||
List<RecentAttachmentDetails> results = summary.getRecentAttachments(dataSource, 10);
|
List<RecentAttachmentDetails> results = summary.getRecentAttachments(dataSource, 10);
|
||||||
@ -735,7 +735,7 @@ public class RecentFilesSummaryTest {
|
|||||||
List<AttachmentArtifactItem> items = Arrays.asList(item1, item2, item3);
|
List<AttachmentArtifactItem> items = Arrays.asList(item1, item2, item3);
|
||||||
|
|
||||||
Pair<SleuthkitCase, Blackboard> casePair = getRecentAttachmentArtifactCase(items);
|
Pair<SleuthkitCase, Blackboard> casePair = getRecentAttachmentArtifactCase(items);
|
||||||
RecentFilesSummary summary = new RecentFilesSummary(() -> casePair.getLeft());
|
RecentFilesGetter summary = new RecentFilesGetter();
|
||||||
|
|
||||||
// get data
|
// get data
|
||||||
List<RecentAttachmentDetails> results = summary.getRecentAttachments(dataSource, 10);
|
List<RecentAttachmentDetails> results = summary.getRecentAttachments(dataSource, 10);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user