minor changes and refactoring

This commit is contained in:
Greg DiCristofaro 2020-09-14 14:20:36 -04:00
parent 983cf3352a
commit e73863fce7
12 changed files with 48 additions and 23 deletions

View File

@ -40,7 +40,7 @@ import org.sleuthkit.datamodel.TskCoreException;
/** /**
* Providing data for the data source analysis tab. * Providing data for the data source analysis tab.
*/ */
public class AnalysisSummary implements DataSourceSummaryDataModel { public class AnalysisSummary implements EventUpdateGovernor {
private static final BlackboardAttribute.Type TYPE_SET_NAME = new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_SET_NAME); private static final BlackboardAttribute.Type TYPE_SET_NAME = new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_SET_NAME);

View File

@ -32,7 +32,7 @@ import org.sleuthkit.datamodel.TskData;
/** /**
* Provides methods to query for data source overview details. * Provides methods to query for data source overview details.
*/ */
public class ContainerSummary implements DataSourceSummaryDataModel { public class ContainerSummary implements EventUpdateGovernor {
private static final Set<Integer> ARTIFACT_UPDATE_TYPE_IDS = new HashSet<>(Arrays.asList( private static final Set<Integer> ARTIFACT_UPDATE_TYPE_IDS = new HashSet<>(Arrays.asList(
BlackboardArtifact.ARTIFACT_TYPE.TSK_OS_INFO.getTypeID(), BlackboardArtifact.ARTIFACT_TYPE.TSK_OS_INFO.getTypeID(),
BlackboardArtifact.ARTIFACT_TYPE.TSK_DATA_SOURCE_USAGE.getTypeID() BlackboardArtifact.ARTIFACT_TYPE.TSK_DATA_SOURCE_USAGE.getTypeID()

View File

@ -23,9 +23,11 @@ import java.util.Set;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
/** /**
* Interface for data model classes in data source summary. * Interface for determiining when data should update based on autopsy (i.e.
* case/ingest) events.
*/ */
public interface DataSourceSummaryDataModel { public interface EventUpdateGovernor {
/** /**
* @return The set of Case Events for which data should be updated. * @return The set of Case Events for which data should be updated.
*/ */
@ -34,14 +36,16 @@ public interface DataSourceSummaryDataModel {
} }
/** /**
* @return The set of BlackboardArtifact id's for which data shoulde be updated. * @return The set of BlackboardArtifact id's for which data shoulde be
*/ * updated.
*/
default Set<Integer> getArtifactIdUpdates() { default Set<Integer> getArtifactIdUpdates() {
return Collections.emptySet(); return Collections.emptySet();
} }
/** /**
* Whether or not the content should be updated on receiving new content. * Whether or not the content should be updated on receiving new content.
*
* @return True if it should refresh on new content. * @return True if it should refresh on new content.
*/ */
default boolean shouldRefreshOnNewContent() { default boolean shouldRefreshOnNewContent() {

View File

@ -28,7 +28,7 @@ import org.sleuthkit.datamodel.TskCoreException;
/** /**
* Provides methods to query for datasource files by mime type. * Provides methods to query for datasource files by mime type.
*/ */
public class MimeTypeSummary implements DataSourceSummaryDataModel { public class MimeTypeSummary implements EventUpdateGovernor {
private final SleuthkitCaseProvider provider; private final SleuthkitCaseProvider provider;

View File

@ -43,7 +43,7 @@ import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
/** /**
* Helper class for getting data for the Recent Files Data Summary tab. * Helper class for getting data for the Recent Files Data Summary tab.
*/ */
public class RecentFilesSummary implements DataSourceSummaryDataModel { public class RecentFilesSummary implements EventUpdateGovernor {
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);

View File

@ -42,7 +42,7 @@ import org.sleuthkit.datamodel.TskCoreException;
/** /**
* Provides information to populate Top Programs Summary queries. * Provides information to populate Top Programs Summary queries.
*/ */
public class TopProgramsSummary implements DataSourceSummaryDataModel { public class TopProgramsSummary implements EventUpdateGovernor {
private static final Set<Integer> ARTIFACT_UPDATE_TYPE_IDS = new HashSet<>(Arrays.asList( private static final Set<Integer> ARTIFACT_UPDATE_TYPE_IDS = new HashSet<>(Arrays.asList(
ARTIFACT_TYPE.TSK_PROG_RUN.getTypeID() ARTIFACT_TYPE.TSK_PROG_RUN.getTypeID()

View File

@ -27,7 +27,7 @@ import org.sleuthkit.datamodel.TskData;
/** /**
* Provides information for the DataSourceSummaryCountsPanel. * Provides information for the DataSourceSummaryCountsPanel.
*/ */
public class TypesSummary implements DataSourceSummaryDataModel { public class TypesSummary implements EventUpdateGovernor {
private final SleuthkitCaseProvider provider; private final SleuthkitCaseProvider provider;

View File

@ -47,7 +47,7 @@ import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
* time, the data being provided for domains is fictitious and is done as a * time, the data being provided for domains is fictitious and is done as a
* placeholder. * placeholder.
*/ */
public class UserActivitySummary implements DataSourceSummaryDataModel { public class UserActivitySummary implements EventUpdateGovernor {
private static final BlackboardArtifact.Type TYPE_DEVICE_ATTACHED = new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED); private static final BlackboardArtifact.Type TYPE_DEVICE_ATTACHED = new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED);

View File

@ -30,7 +30,6 @@ import java.util.stream.Stream;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.datasourcesummary.datamodel.DataSourceSummaryDataModel;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchResult; import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchResult;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker; import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker.DataFetchComponents; import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker.DataFetchComponents;
@ -41,6 +40,7 @@ import org.sleuthkit.autopsy.ingest.IngestManager.IngestModuleEvent;
import org.sleuthkit.autopsy.ingest.ModuleContentEvent; import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
import org.sleuthkit.autopsy.ingest.ModuleDataEvent; import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.DataSource;
import org.sleuthkit.autopsy.datasourcesummary.datamodel.EventUpdateGovernor;
/** /**
* Base class from which other tabs in data source summary derive. * Base class from which other tabs in data source summary derive.
@ -95,11 +95,10 @@ abstract class BaseDataSourceSummaryPanel extends JPanel {
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }
protected BaseDataSourceSummaryPanel(DataSourceSummaryDataModel...dataModels) { protected BaseDataSourceSummaryPanel(EventUpdateGovernor...dataModels) {
this( this(getUnionSet(EventUpdateGovernor::getCaseEventUpdates, dataModels),
getUnionSet(DataSourceSummaryDataModel::getCaseEventUpdates, dataModels), getUnionSet(EventUpdateGovernor::getArtifactIdUpdates, dataModels),
getUnionSet(DataSourceSummaryDataModel::getArtifactIdUpdates, dataModels), Stream.of(dataModels).anyMatch(EventUpdateGovernor::shouldRefreshOnNewContent)
Stream.of(dataModels).anyMatch(DataSourceSummaryDataModel::shouldRefreshOnNewContent)
); );
} }

View File

@ -0,0 +1,14 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.sleuthkit.autopsy.datasourcesummary.ui;
/**
*
* @author gregd
*/
public class EventUpdateHandler {
}

View File

@ -113,6 +113,7 @@ public final class RecentFilesPanel extends BaseDataSourceSummaryPanel {
JTablePanel<RecentFileDetails> pane = (JTablePanel<RecentFileDetails>) openedDocPane; JTablePanel<RecentFileDetails> pane = (JTablePanel<RecentFileDetails>) openedDocPane;
pane.setModel(tableModel); pane.setModel(tableModel);
pane.setColumnModel(JTablePanel.getTableColumnModel(list)); pane.setColumnModel(JTablePanel.getTableColumnModel(list));
pane.setKeyFunction((recentFile) -> recentFile.getPath());
tablePanelList.add(pane); tablePanelList.add(pane);
DataFetchWorker.DataFetchComponents<DataSource, List<RecentFileDetails>> worker DataFetchWorker.DataFetchComponents<DataSource, List<RecentFileDetails>> worker
@ -147,6 +148,7 @@ public final class RecentFilesPanel extends BaseDataSourceSummaryPanel {
JTablePanel<RecentDownloadDetails> pane = (JTablePanel<RecentDownloadDetails>) downloadsPane; JTablePanel<RecentDownloadDetails> pane = (JTablePanel<RecentDownloadDetails>) downloadsPane;
pane.setModel(tableModel); pane.setModel(tableModel);
pane.setKeyFunction((download) -> download.getPath());
pane.setColumnModel(JTablePanel.getTableColumnModel(list)); pane.setColumnModel(JTablePanel.getTableColumnModel(list));
tablePanelList.add(pane); tablePanelList.add(pane);
@ -182,6 +184,7 @@ public final class RecentFilesPanel extends BaseDataSourceSummaryPanel {
JTablePanel<RecentAttachmentDetails> pane = (JTablePanel<RecentAttachmentDetails>) attachmentsPane; JTablePanel<RecentAttachmentDetails> pane = (JTablePanel<RecentAttachmentDetails>) attachmentsPane;
pane.setModel(tableModel); pane.setModel(tableModel);
pane.setKeyFunction((attachment) -> attachment.getPath());
pane.setColumnModel(JTablePanel.getTableColumnModel(list)); pane.setColumnModel(JTablePanel.getTableColumnModel(list));
tablePanelList.add(pane); tablePanelList.add(pane);

View File

@ -116,7 +116,8 @@ public class UserActivityPanel extends BaseDataSourceSummaryPanel {
Bundle.UserActivityPanel_TopProgramsTableModel_lastrun_header(), Bundle.UserActivityPanel_TopProgramsTableModel_lastrun_header(),
(prog) -> new DefaultCellModel(getFormatted(prog.getLastRun())), (prog) -> new DefaultCellModel(getFormatted(prog.getLastRun())),
150) 150)
)); ))
.setKeyFunction((prog) -> prog.getProgramPath() + prog.getProgramName());
// set up recent domains table // set up recent domains table
private final JTablePanel<TopDomainsResult> recentDomainsTable = JTablePanel.getJTablePanel(Arrays.asList( private final JTablePanel<TopDomainsResult> recentDomainsTable = JTablePanel.getJTablePanel(Arrays.asList(
@ -135,7 +136,8 @@ public class UserActivityPanel extends BaseDataSourceSummaryPanel {
Bundle.UserActivityPanel_TopDomainsTableModel_lastAccess_header(), Bundle.UserActivityPanel_TopDomainsTableModel_lastAccess_header(),
(recentDomain) -> new DefaultCellModel(getFormatted(recentDomain.getLastVisit())), (recentDomain) -> new DefaultCellModel(getFormatted(recentDomain.getLastVisit())),
150) 150)
)); ))
.setKeyFunction((domain) -> domain.getDomain());
// top web searches table // top web searches table
private final JTablePanel<TopWebSearchResult> topWebSearchesTable = JTablePanel.getJTablePanel(Arrays.asList( private final JTablePanel<TopWebSearchResult> topWebSearchesTable = JTablePanel.getJTablePanel(Arrays.asList(
@ -157,7 +159,8 @@ public class UserActivityPanel extends BaseDataSourceSummaryPanel {
(webSearch) -> new DefaultCellModel(webSearch.getTranslatedResult()), (webSearch) -> new DefaultCellModel(webSearch.getTranslatedResult()),
250 250
) )
)); ))
.setKeyFunction((query) -> query.getSearchString());
// top devices attached table // top devices attached table
private final JTablePanel<TopDeviceAttachedResult> topDevicesAttachedTable = JTablePanel.getJTablePanel(Arrays.asList( private final JTablePanel<TopDeviceAttachedResult> topDevicesAttachedTable = JTablePanel.getJTablePanel(Arrays.asList(
@ -186,7 +189,8 @@ public class UserActivityPanel extends BaseDataSourceSummaryPanel {
}, },
250 250
) )
)); ))
.setKeyFunction((topDevice) -> topDevice.getDeviceId());
// top accounts table // top accounts table
private final JTablePanel<TopAccountResult> topAccountsTable = JTablePanel.getJTablePanel(Arrays.asList( private final JTablePanel<TopAccountResult> topAccountsTable = JTablePanel.getJTablePanel(Arrays.asList(
@ -202,7 +206,8 @@ public class UserActivityPanel extends BaseDataSourceSummaryPanel {
(account) -> new DefaultCellModel(getFormatted(account.getLastAccess())), (account) -> new DefaultCellModel(getFormatted(account.getLastAccess())),
150 150
) )
)); ))
.setKeyFunction((topAccount) -> topAccount.getAccountType());
private final List<JTablePanel<?>> tables = Arrays.asList( private final List<JTablePanel<?>> tables = Arrays.asList(
topProgramsTable, topProgramsTable,