refactor names to apply to config and set name separately

This commit is contained in:
Greg DiCristofaro 2022-01-26 09:02:38 -05:00
parent fe6c58c034
commit d176beb1e0
10 changed files with 216 additions and 143 deletions

View File

@ -66,10 +66,10 @@ import org.sleuthkit.autopsy.datamodel.NodeSelectionInfo;
import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.IngestManager;
import org.sleuthkit.autopsy.mainui.datamodel.CommAccountsSearchParams; import org.sleuthkit.autopsy.mainui.datamodel.CommAccountsSearchParams;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO.AnalysisResultFetcher; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO.AnalysisResultFetcher;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO.AnalysisResultSetFetcher; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO.AnalysisResultConfigFetcher;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO.KeywordHitResultFetcher; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO.KeywordHitResultFetcher;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSetSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultConfigSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.CommAccountsDAO.CommAccountFetcher; import org.sleuthkit.autopsy.mainui.datamodel.CommAccountsDAO.CommAccountFetcher;
import org.sleuthkit.autopsy.mainui.datamodel.CreditCardBinSearchParams; import org.sleuthkit.autopsy.mainui.datamodel.CreditCardBinSearchParams;
import org.sleuthkit.autopsy.mainui.datamodel.CreditCardDAO.CreditCardByBinFetcher; import org.sleuthkit.autopsy.mainui.datamodel.CreditCardDAO.CreditCardByBinFetcher;
@ -1403,7 +1403,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
} catch (ExecutionException | IllegalArgumentException ex) { } catch (ExecutionException | IllegalArgumentException ex) {
logger.log(Level.WARNING, MessageFormat.format( logger.log(Level.WARNING, MessageFormat.format(
"There was an error fetching data for keyword filter: {0} and data source id: {1}.", "There was an error fetching data for keyword filter: {0} and data source id: {1}.",
keywordHitKey.getSetName(), keywordHitKey.getConfiguration(),
keywordHitKey.getDataSourceId() == null ? "<null>" : keywordHitKey.getDataSourceId()), keywordHitKey.getDataSourceId() == null ? "<null>" : keywordHitKey.getDataSourceId()),
ex); ex);
} }
@ -1435,15 +1435,15 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
* *
* @param setKey The search parameter query. * @param setKey The search parameter query.
*/ */
void displayAnalysisResultSet(AnalysisResultSetSearchParam setKey) { void displayAnalysisResultSet(AnalysisResultConfigSearchParam setKey) {
try { try {
this.searchResultManager = new SearchManager(new AnalysisResultSetFetcher(setKey), getPageSize()); this.searchResultManager = new SearchManager(new AnalysisResultConfigFetcher(setKey), getPageSize());
SearchResultsDTO results = searchResultManager.getResults(); SearchResultsDTO results = searchResultManager.getResults();
displaySearchResults(results, true); displaySearchResults(results, true);
} catch (ExecutionException | IllegalArgumentException ex) { } catch (ExecutionException | IllegalArgumentException ex) {
logger.log(Level.WARNING, MessageFormat.format( logger.log(Level.WARNING, MessageFormat.format(
"There was an error fetching data for hash set filter: {0} and data source id: {1}.", "There was an error fetching data for hash set filter: {0} and data source id: {1}.",
setKey.getSetName(), setKey.getConfiguration(),
setKey.getDataSourceId() == null ? "<null>" : setKey.getDataSourceId()), setKey.getDataSourceId() == null ? "<null>" : setKey.getDataSourceId()),
ex); ex);
} }

View File

@ -45,7 +45,7 @@ import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.FileSystemContentSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.FileSystemContentSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.FileSystemHostSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.FileSystemHostSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSetSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultConfigSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.CommAccountsSearchParams; import org.sleuthkit.autopsy.mainui.datamodel.CommAccountsSearchParams;
import org.sleuthkit.autopsy.mainui.datamodel.CreditCardBinSearchParams; import org.sleuthkit.autopsy.mainui.datamodel.CreditCardBinSearchParams;
import org.sleuthkit.autopsy.mainui.datamodel.CreditCardFileSearchParams; import org.sleuthkit.autopsy.mainui.datamodel.CreditCardFileSearchParams;
@ -468,7 +468,7 @@ public final class DataResultTopComponent extends TopComponent implements DataRe
* Displays results of querying the DAO for an artifact type and set name. * Displays results of querying the DAO for an artifact type and set name.
* @param params The search parameters. * @param params The search parameters.
*/ */
public void displayAnalysisResultSet(AnalysisResultSetSearchParam params) { public void displayAnalysisResultSet(AnalysisResultConfigSearchParam params) {
dataResultPanel.displayAnalysisResultSet(params); dataResultPanel.displayAnalysisResultSet(params);
} }

View File

@ -0,0 +1,75 @@
/*
* Autopsy Forensic Browser
*
* Copyright 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.mainui.datamodel;
import java.util.Objects;
import org.sleuthkit.datamodel.BlackboardArtifact;
/**
* Base class for search params for analysis results that filter by configuration.
*/
public class AnalysisResultConfigSearchParam extends AnalysisResultSearchParam {
private static final String TYPE_ID = "ANALYSIS_RESULT_CONFIG";
/**
* @return The type id for this search parameter.
*/
public static String getTypeId() {
return TYPE_ID;
}
private final String configuration;
public AnalysisResultConfigSearchParam(BlackboardArtifact.Type artifactType, Long dataSourceId, String configuration) {
super(artifactType, dataSourceId);
this.configuration = configuration;
}
public String getConfiguration() {
return configuration;
}
@Override
public int hashCode() {
int hash = 3;
hash = 79 * hash + Objects.hashCode(this.configuration);
hash = 79 * hash + super.hashCode();
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AnalysisResultConfigSearchParam other = (AnalysisResultConfigSearchParam) obj;
if (!Objects.equals(this.configuration, other.configuration)) {
return false;
}
return super.equals(obj);
}
}

View File

@ -18,7 +18,7 @@
*/ */
package org.sleuthkit.autopsy.mainui.datamodel; package org.sleuthkit.autopsy.mainui.datamodel;
import org.sleuthkit.autopsy.mainui.datamodel.events.AnalysisResultSetEvent; import org.sleuthkit.autopsy.mainui.datamodel.events.AnalysisResultConfigEvent;
import org.sleuthkit.autopsy.mainui.datamodel.events.AnalysisResultEvent; import org.sleuthkit.autopsy.mainui.datamodel.events.AnalysisResultEvent;
import org.sleuthkit.autopsy.mainui.datamodel.events.DAOEvent; import org.sleuthkit.autopsy.mainui.datamodel.events.DAOEvent;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
@ -143,7 +143,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
} }
private final Cache<SearchParams<BlackboardArtifactSearchParam>, AnalysisResultTableSearchResultsDTO> analysisResultCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build(); private final Cache<SearchParams<BlackboardArtifactSearchParam>, AnalysisResultTableSearchResultsDTO> analysisResultCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build();
private final Cache<SearchParams<AnalysisResultSetSearchParam>, AnalysisResultTableSearchResultsDTO> setHitCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build(); private final Cache<SearchParams<AnalysisResultConfigSearchParam>, AnalysisResultTableSearchResultsDTO> configHitCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build();
private final Cache<SearchParams<KeywordHitSearchParam>, AnalysisResultTableSearchResultsDTO> keywordHitCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build(); private final Cache<SearchParams<KeywordHitSearchParam>, AnalysisResultTableSearchResultsDTO> keywordHitCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build();
private final TreeCounts<AnalysisResultEvent> treeCounts = new TreeCounts<>(); private final TreeCounts<AnalysisResultEvent> treeCounts = new TreeCounts<>();
@ -175,7 +175,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
BlackboardArtifact.Type artType = searchParams.getArtifactType(); BlackboardArtifact.Type artType = searchParams.getArtifactType();
// get all keyword hits for the search params // get all keyword hits for the search params
List<BlackboardArtifact> allHits = blackboard.getKeywordSearchResults(searchParams.getKeyword(), searchParams.getRegex(), searchParams.getSearchType(), searchParams.getSetName(), dataSourceId); List<BlackboardArtifact> allHits = blackboard.getKeywordSearchResults(searchParams.getKeyword(), searchParams.getRegex(), searchParams.getSearchType(), searchParams.getConfiguration(), dataSourceId);
// populate all attributes in one optimized database call // populate all attributes in one optimized database call
blackboard.loadBlackboardAttributes(allHits); blackboard.loadBlackboardAttributes(allHits);
@ -186,8 +186,8 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
return new AnalysisResultTableSearchResultsDTO(artType, tableData.columnKeys, tableData.rows, cacheKey.getStartItem(), allHits.size()); return new AnalysisResultTableSearchResultsDTO(artType, tableData.columnKeys, tableData.rows, cacheKey.getStartItem(), allHits.size());
} }
// filters results by configuration attr and needs a search param with the set name // filters results by configuration attr and needs a search param with the configuration
private AnalysisResultTableSearchResultsDTO fetchSetNameHitsForTable(SearchParams<? extends AnalysisResultSetSearchParam> cacheKey) throws NoCurrentCaseException, TskCoreException { private AnalysisResultTableSearchResultsDTO fetchConfigResultsForTable(SearchParams<? extends AnalysisResultConfigSearchParam> cacheKey) throws NoCurrentCaseException, TskCoreException {
SleuthkitCase skCase = getCase(); SleuthkitCase skCase = getCase();
Blackboard blackboard = skCase.getBlackboard(); Blackboard blackboard = skCase.getBlackboard();
@ -195,22 +195,22 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
Long dataSourceId = cacheKey.getParamData().getDataSourceId(); Long dataSourceId = cacheKey.getParamData().getDataSourceId();
BlackboardArtifact.Type artType = cacheKey.getParamData().getArtifactType(); BlackboardArtifact.Type artType = cacheKey.getParamData().getArtifactType();
// We currently can't make a query on the set name field because need to use a prepared statement // We currently can't make a query on the configuration field because need to use a prepared statement
String originalWhereClause = " artifacts.artifact_type_id = " + artType.getTypeID() + " "; String originalWhereClause = " artifacts.artifact_type_id = " + artType.getTypeID() + " ";
if (dataSourceId != null) { if (dataSourceId != null) {
originalWhereClause += " AND artifacts.data_source_obj_id = " + dataSourceId + " "; originalWhereClause += " AND artifacts.data_source_obj_id = " + dataSourceId + " ";
} }
String expectedSetName = cacheKey.getParamData().getSetName(); String expectedConfiguration = cacheKey.getParamData().getConfiguration();
List<AnalysisResult> allResults = new ArrayList<>(); List<AnalysisResult> allResults = new ArrayList<>();
allResults.addAll(blackboard.getAnalysisResultsWhere(originalWhereClause)); allResults.addAll(blackboard.getAnalysisResultsWhere(originalWhereClause));
blackboard.loadBlackboardAttributes(allResults); blackboard.loadBlackboardAttributes(allResults);
// Filter for the selected set // Filter for the selected configuration
List<BlackboardArtifact> arts = new ArrayList<>(); List<BlackboardArtifact> arts = new ArrayList<>();
for (AnalysisResult analysisResult : allResults) { for (AnalysisResult analysisResult : allResults) {
if (Objects.equals(expectedSetName, analysisResult.getConfiguration())) { if (Objects.equals(expectedConfiguration, analysisResult.getConfiguration())) {
arts.add(analysisResult); arts.add(analysisResult);
} }
} }
@ -282,18 +282,18 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
&& (key.getDataSourceId() == null || key.getDataSourceId() == analysisResultEvt.getDataSourceId()); && (key.getDataSourceId() == null || key.getDataSourceId() == analysisResultEvt.getDataSourceId());
} }
private boolean isAnalysisResultsSetInvalidating(AnalysisResultSetSearchParam key, DAOEvent event) { private boolean isAnalysisResultsConfigInvalidating(AnalysisResultConfigSearchParam key, DAOEvent event) {
if (event instanceof DeleteAnalysisResultEvent) { if (event instanceof DeleteAnalysisResultEvent) {
return true; return true;
} }
if (!(event instanceof AnalysisResultSetEvent)) { if (!(event instanceof AnalysisResultConfigEvent)) {
return false; return false;
} }
AnalysisResultSetEvent setEvent = (AnalysisResultSetEvent) event; AnalysisResultConfigEvent setEvent = (AnalysisResultConfigEvent) event;
return isAnalysisResultsInvalidating(key, setEvent) return isAnalysisResultsInvalidating(key, setEvent)
&& Objects.equals(key.getSetName(), setEvent.getSetName()); && Objects.equals(key.getConfiguration(), setEvent.getConfiguration());
} }
private boolean isKeywordHitInvalidating(KeywordHitSearchParam parameters, DAOEvent event) { private boolean isKeywordHitInvalidating(KeywordHitSearchParam parameters, DAOEvent event) {
@ -313,15 +313,15 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
} }
public AnalysisResultTableSearchResultsDTO getAnalysisResultSetHits(AnalysisResultSetSearchParam artifactKey, long startItem, Long maxCount) throws ExecutionException, IllegalArgumentException { public AnalysisResultTableSearchResultsDTO getAnalysisResultConfigResults(AnalysisResultConfigSearchParam artifactKey, long startItem, Long maxCount) throws ExecutionException, IllegalArgumentException {
if (artifactKey.getDataSourceId() != null && artifactKey.getDataSourceId() < 0) { if (artifactKey.getDataSourceId() != null && artifactKey.getDataSourceId() < 0) {
throw new IllegalArgumentException(MessageFormat.format("Illegal data. " throw new IllegalArgumentException(MessageFormat.format("Illegal data. "
+ "Data source id must be null or > 0. " + "Data source id must be null or > 0. "
+ "Received data source id: {0}", artifactKey.getDataSourceId() == null ? "<null>" : artifactKey.getDataSourceId())); + "Received data source id: {0}", artifactKey.getDataSourceId() == null ? "<null>" : artifactKey.getDataSourceId()));
} }
SearchParams<AnalysisResultSetSearchParam> searchParams = new SearchParams<>(artifactKey, startItem, maxCount); SearchParams<AnalysisResultConfigSearchParam> searchParams = new SearchParams<>(artifactKey, startItem, maxCount);
return setHitCache.get(searchParams, () -> fetchSetNameHitsForTable(searchParams)); return configHitCache.get(searchParams, () -> fetchConfigResultsForTable(searchParams));
} }
public AnalysisResultTableSearchResultsDTO getKeywordHitsForTable(KeywordHitSearchParam artifactKey, long startItem, Long maxCount) throws ExecutionException, IllegalArgumentException { public AnalysisResultTableSearchResultsDTO getKeywordHitsForTable(KeywordHitSearchParam artifactKey, long startItem, Long maxCount) throws ExecutionException, IllegalArgumentException {
@ -431,7 +431,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
* should be filtered or null if no data source * should be filtered or null if no data source
* filtering. * filtering.
* *
* @return A mapping of set names to their counts. * @return A mapping of configurations to their counts.
* *
* @throws IllegalArgumentException * @throws IllegalArgumentException
* @throws ExecutionException * @throws ExecutionException
@ -444,7 +444,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
try { try {
// get artifact types and counts // get artifact types and counts
SleuthkitCase skCase = getCase(); SleuthkitCase skCase = getCase();
String query = "\n ar.configuration AS set_name\n" String query = "\n ar.configuration AS configuration\n"
+ " ,COUNT(*) AS count\n" + " ,COUNT(*) AS count\n"
+ "FROM blackboard_artifacts art\n" + "FROM blackboard_artifacts art\n"
+ "LEFT JOIN tsk_analysis_results ar ON art.artifact_obj_id = ar.artifact_obj_id\n" + "LEFT JOIN tsk_analysis_results ar ON art.artifact_obj_id = ar.artifact_obj_id\n"
@ -452,22 +452,22 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
+ ((dataSourceId == null) ? "" : " AND art.data_source_obj_id = " + dataSourceId + " \n") + ((dataSourceId == null) ? "" : " AND art.data_source_obj_id = " + dataSourceId + " \n")
+ "GROUP BY ar.configuration"; + "GROUP BY ar.configuration";
Map<String, Long> setCounts = new HashMap<>(); Map<String, Long> configurationCounts = new HashMap<>();
skCase.getCaseDbAccessManager().select(query, (resultSet) -> { skCase.getCaseDbAccessManager().select(query, (resultSet) -> {
try { try {
while (resultSet.next()) { while (resultSet.next()) {
String setName = resultSet.getString("set_name"); String configuration = resultSet.getString("configuration");
long count = resultSet.getLong("count"); long count = resultSet.getLong("count");
setCounts.put(setName, count); configurationCounts.put(configuration, count);
} }
} catch (SQLException ex) { } catch (SQLException ex) {
logger.log(Level.WARNING, "An error occurred while fetching set name counts with query:\nSELECT" + query, ex); logger.log(Level.WARNING, "An error occurred while fetching configuration counts with query:\nSELECT" + query, ex);
} }
}); });
return setCounts; return configurationCounts;
} catch (NoCurrentCaseException | TskCoreException ex) { } catch (NoCurrentCaseException | TskCoreException ex) {
throw new ExecutionException("An error occurred while fetching set counts", ex); throw new ExecutionException("An error occurred while fetching configuration counts", ex);
} }
} }
@ -524,57 +524,55 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
} }
/** /**
* Get counts for individual sets of the provided type to be used in the * Get counts for individual configurations of the provided type to be used
* tree view. * in the tree view.
* *
* @param type The blackboard artifact type. * @param type The blackboard artifact type.
* @param dataSourceId The data source object id for which the results * @param dataSourceId The data source object id for which the
* should be filtered or null if no data source * results should be filtered or null if no
* filtering. * data source filtering.
* @param nullSetName For artifacts with no set, this is the name to * @param blankConfigName For artifacts with no configuration, this
* provide. If null, artifacts without a set name will * is the name to provide. If null or empty,
* be ignored. * artifacts without a configuration will be
* @param converter Means of converting from data source id and set name * ignored.
* to an AnalysisResultSetSearchParam
* *
* @return The sets along with counts to display. * @return The configurations along with counts to display.
* *
* @throws IllegalArgumentException * @throws IllegalArgumentException
* @throws ExecutionException * @throws ExecutionException
*/ */
public TreeResultsDTO<AnalysisResultSetSearchParam> getConfigurationCounts( public TreeResultsDTO<AnalysisResultConfigSearchParam> getConfigurationCounts(
BlackboardArtifact.Type type, BlackboardArtifact.Type type,
Long dataSourceId, Long dataSourceId,
String nullSetName) throws IllegalArgumentException, ExecutionException { String blankConfigName) throws IllegalArgumentException, ExecutionException {
Set<String> indeterminateSetNames = new HashSet<>(); Set<String> indeterminateConfigCounts = new HashSet<>();
for (AnalysisResultEvent evt : this.treeCounts.getEnqueued()) { for (AnalysisResultEvent evt : this.treeCounts.getEnqueued()) {
if (evt instanceof AnalysisResultSetEvent if (evt instanceof AnalysisResultConfigEvent
&& (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId)) && (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId))
&& evt.getArtifactType().equals(type)) { && evt.getArtifactType().equals(type)) {
indeterminateSetNames.add(((AnalysisResultSetEvent) evt).getSetName()); indeterminateConfigCounts.add(((AnalysisResultConfigEvent) evt).getConfiguration());
} }
} }
List<TreeItemDTO<AnalysisResultSetSearchParam>> allSets List<TreeItemDTO<AnalysisResultConfigSearchParam>> allConfigurations
= getConfigurationCountsMap(type, dataSourceId).entrySet().stream() = getConfigurationCountsMap(type, dataSourceId).entrySet().stream()
.sorted((a, b) -> compareSetStrings(a.getKey(), b.getKey())) .sorted((a, b) -> compareStrings(a.getKey(), b.getKey()))
.map(entry -> { .map(entry -> {
TreeDisplayCount displayCount = indeterminateSetNames.contains(entry.getKey()) TreeDisplayCount displayCount = indeterminateConfigCounts.contains(entry.getKey())
? TreeDisplayCount.INDETERMINATE ? TreeDisplayCount.INDETERMINATE
: TreeDisplayCount.getDeterminate(entry.getValue()); : TreeDisplayCount.getDeterminate(entry.getValue());
return getSetTreeItem(type, return getConfigTreeItem(type,
dataSourceId, dataSourceId,
entry.getKey(), entry.getKey(),
StringUtils.isBlank(entry.getKey()) ? nullSetName : entry.getKey(), StringUtils.isBlank(entry.getKey()) ? blankConfigName : entry.getKey(),
displayCount); displayCount);
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
return new TreeResultsDTO<>(allSets); return new TreeResultsDTO<>(allConfigurations);
} }
/** /**
* Get counts for individual sets of the provided type to be used in the * Get counts for individual sets of the provided type to be used in the
@ -595,29 +593,29 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
* @throws IllegalArgumentException * @throws IllegalArgumentException
* @throws ExecutionException * @throws ExecutionException
*/ */
public TreeResultsDTO<AnalysisResultSetSearchParam> getSetCounts( public TreeResultsDTO<AnalysisResultConfigSearchParam> getSetCounts(
BlackboardArtifact.Type type, BlackboardArtifact.Type type,
Long dataSourceId, Long dataSourceId,
String nullSetName) throws IllegalArgumentException, ExecutionException { String nullSetName) throws IllegalArgumentException, ExecutionException {
Set<String> indeterminateSetNames = new HashSet<>(); Set<String> indeterminateSetNames = new HashSet<>();
for (AnalysisResultEvent evt : this.treeCounts.getEnqueued()) { for (AnalysisResultEvent evt : this.treeCounts.getEnqueued()) {
if (evt instanceof AnalysisResultSetEvent if (evt instanceof AnalysisResultConfigEvent
&& (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId)) && (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId))
&& evt.getArtifactType().equals(type)) { && evt.getArtifactType().equals(type)) {
indeterminateSetNames.add(((AnalysisResultSetEvent) evt).getSetName()); indeterminateSetNames.add(((AnalysisResultConfigEvent) evt).getConfiguration());
} }
} }
List<TreeItemDTO<AnalysisResultSetSearchParam>> allSets List<TreeItemDTO<AnalysisResultConfigSearchParam>> allSets
= getSetCountsMap(type, BlackboardAttribute.Type.TSK_SET_NAME, dataSourceId).entrySet().stream() = getSetCountsMap(type, BlackboardAttribute.Type.TSK_SET_NAME, dataSourceId).entrySet().stream()
.sorted((a, b) -> compareSetStrings(a.getKey(), b.getKey())) .sorted((a, b) -> compareStrings(a.getKey(), b.getKey()))
.map(entry -> { .map(entry -> {
TreeDisplayCount displayCount = indeterminateSetNames.contains(entry.getKey()) TreeDisplayCount displayCount = indeterminateSetNames.contains(entry.getKey())
? TreeDisplayCount.INDETERMINATE ? TreeDisplayCount.INDETERMINATE
: TreeDisplayCount.getDeterminate(entry.getValue()); : TreeDisplayCount.getDeterminate(entry.getValue());
return getSetTreeItem(type, return getConfigTreeItem(type,
dataSourceId, dataSourceId,
entry.getKey(), entry.getKey(),
StringUtils.isBlank(entry.getKey()) ? nullSetName : entry.getKey(), StringUtils.isBlank(entry.getKey()) ? nullSetName : entry.getKey(),
@ -629,14 +627,14 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
} }
/** /**
* Compares set strings to properly order for the tree. * Compares strings to properly order for the tree.
* *
* @param a The first string. * @param a The first string.
* @param b The second string. * @param b The second string.
* *
* @return The comparator result. * @return The comparator result.
*/ */
private int compareSetStrings(String a, String b) { private int compareStrings(String a, String b) {
if (a == null && b == null) { if (a == null && b == null) {
return 0; return 0;
} else if (a == null) { } else if (a == null) {
@ -676,7 +674,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
if (evt instanceof KeywordHitEvent if (evt instanceof KeywordHitEvent
&& (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId)) && (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId))
&& evt.getArtifactType().equals(BlackboardArtifact.Type.TSK_KEYWORD_HIT) && evt.getArtifactType().equals(BlackboardArtifact.Type.TSK_KEYWORD_HIT)
&& Objects.equals(((KeywordHitEvent) evt).getSetName(), setName)) { && Objects.equals(((KeywordHitEvent) evt).getConfiguration(), setName)) {
KeywordHitEvent keywordEvt = (KeywordHitEvent) evt; KeywordHitEvent keywordEvt = (KeywordHitEvent) evt;
indeterminateSearchTerms.add(Pair.of(keywordEvt.getSearchString(), keywordEvt.getSearchType())); indeterminateSearchTerms.add(Pair.of(keywordEvt.getSearchString(), keywordEvt.getSearchType()));
@ -872,7 +870,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
&& evt.getArtifactType().equals(BlackboardArtifact.Type.TSK_KEYWORD_HIT)) { && evt.getArtifactType().equals(BlackboardArtifact.Type.TSK_KEYWORD_HIT)) {
KeywordHitEvent keywordEvt = (KeywordHitEvent) evt; KeywordHitEvent keywordEvt = (KeywordHitEvent) evt;
if (Objects.equals(keywordEvt.getSetName(), setName) if (Objects.equals(keywordEvt.getConfiguration(), setName)
&& Objects.equals(keywordEvt.getSearchString(), regexStr) && Objects.equals(keywordEvt.getSearchString(), regexStr)
&& keywordEvt.getSearchType() == searchType) { && keywordEvt.getSearchType() == searchType) {
@ -937,7 +935,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
void clearCaches() { void clearCaches() {
this.analysisResultCache.invalidateAll(); this.analysisResultCache.invalidateAll();
this.keywordHitCache.invalidateAll(); this.keywordHitCache.invalidateAll();
this.setHitCache.invalidateAll(); this.configHitCache.invalidateAll();
this.handleIngestComplete(); this.handleIngestComplete();
} }
@ -995,7 +993,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
} }
// get a grouping of artifacts mapping the artifact type id to data source id. // get a grouping of artifacts mapping the artifact type id to data source id.
Map<Pair<BlackboardArtifact.Type, String>, Set<Long>> setMap = new HashMap<>(); Map<Pair<BlackboardArtifact.Type, String>, Set<Long>> configMap = new HashMap<>();
Map<KeywordHitSearchParam, Set<Long>> keywordHitsMap = new HashMap<>(); Map<KeywordHitSearchParam, Set<Long>> keywordHitsMap = new HashMap<>();
Map<BlackboardArtifact.Type, Set<Long>> analysisResultMap = new HashMap<>(); Map<BlackboardArtifact.Type, Set<Long>> analysisResultMap = new HashMap<>();
@ -1013,7 +1011,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
String configuration = (art instanceof AnalysisResult) ? ((AnalysisResult) art).getConfiguration() : null; String configuration = (art instanceof AnalysisResult) ? ((AnalysisResult) art).getConfiguration() : null;
setMap.computeIfAbsent(Pair.of(art.getType(), configuration), (k) -> new HashSet<>()) configMap.computeIfAbsent(Pair.of(art.getType(), configuration), (k) -> new HashSet<>())
.add(art.getDataSourceObjectID()); .add(art.getDataSourceObjectID());
} }
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
@ -1023,25 +1021,25 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
} }
// don't continue if no relevant items found // don't continue if no relevant items found
if (analysisResultMap.isEmpty() && setMap.isEmpty() && keywordHitsMap.isEmpty()) { if (analysisResultMap.isEmpty() && configMap.isEmpty() && keywordHitsMap.isEmpty()) {
return Collections.emptySet(); return Collections.emptySet();
} }
SubDAOUtils.invalidateKeys(this.analysisResultCache, ar -> Pair.of(ar.getArtifactType(), ar.getDataSourceId()), analysisResultMap); SubDAOUtils.invalidateKeys(this.analysisResultCache, ar -> Pair.of(ar.getArtifactType(), ar.getDataSourceId()), analysisResultMap);
SubDAOUtils.invalidateKeys(this.setHitCache, ar -> Pair.of(Pair.of(ar.getArtifactType(), ar.getSetName()), ar.getDataSourceId()), setMap); SubDAOUtils.invalidateKeys(this.configHitCache, ar -> Pair.of(Pair.of(ar.getArtifactType(), ar.getConfiguration()), ar.getDataSourceId()), configMap);
SubDAOUtils.invalidateKeys(this.keywordHitCache, kw -> Pair.of( SubDAOUtils.invalidateKeys(this.keywordHitCache, kw -> Pair.of(
// null data source for lookup // null data source for lookup
new KeywordHitSearchParam(null, kw.getSetName(), kw.getKeyword(), kw.getRegex(), kw.getSearchType()), new KeywordHitSearchParam(null, kw.getConfiguration(), kw.getKeyword(), kw.getRegex(), kw.getSearchType()),
kw.getDataSourceId() kw.getDataSourceId()
), keywordHitsMap); ), keywordHitsMap);
return getResultViewEvents(setMap, keywordHitsMap, IngestManager.getInstance().isIngestRunning()); return getResultViewEvents(configMap, keywordHitsMap, IngestManager.getInstance().isIngestRunning());
} }
/** /**
* Generate result view events from digest of Autopsy events. * Generate result view events from digest of Autopsy events.
* *
* @param resultsWithSetMap Contains the analysis results that do use a set * @param resultsWithConfigMap Contains the analysis results that do use a set
* name. A mapping of (analysis result type id, set * name. A mapping of (analysis result type id, set
* name) to data sources where results were * name) to data sources where results were
* created. * created.
@ -1053,28 +1051,28 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
* @return The list of dao events. * @return The list of dao events.
*/ */
private Set<? extends DAOEvent> getResultViewEvents( private Set<? extends DAOEvent> getResultViewEvents(
Map<Pair<BlackboardArtifact.Type, String>, Set<Long>> resultsWithSetMap, Map<Pair<BlackboardArtifact.Type, String>, Set<Long>> resultsWithConfigMap,
Map<KeywordHitSearchParam, Set<Long>> keywordHitsMap, Map<KeywordHitSearchParam, Set<Long>> keywordHitsMap,
boolean ingestIsRunning) { boolean ingestIsRunning) {
List<AnalysisResultEvent> analysisResultSetEvts = resultsWithSetMap.entrySet().stream() List<AnalysisResultEvent> analysisResultConfigEvents = resultsWithConfigMap.entrySet().stream()
.flatMap(entry -> entry.getValue().stream().map(dsId -> new AnalysisResultSetEvent(entry.getKey().getRight(), entry.getKey().getLeft(), dsId))) .flatMap(entry -> entry.getValue().stream().map(dsId -> new AnalysisResultConfigEvent(entry.getKey().getRight(), entry.getKey().getLeft(), dsId)))
.collect(Collectors.toList()); .collect(Collectors.toList());
// divide into ad hoc searches (null set name) and the rest // divide into ad hoc searches (null set name) and the rest
Map<Boolean, List<KeywordHitEvent>> keywordHitEvts = keywordHitsMap.entrySet().stream() Map<Boolean, List<KeywordHitEvent>> keywordHitEvts = keywordHitsMap.entrySet().stream()
.flatMap(entry -> { .flatMap(entry -> {
KeywordHitSearchParam params = entry.getKey(); KeywordHitSearchParam params = entry.getKey();
String setName = params.getSetName(); String setName = params.getConfiguration();
String searchString = params.getRegex(); String searchString = params.getRegex();
TskData.KeywordSearchQueryType queryType = params.getSearchType(); TskData.KeywordSearchQueryType queryType = params.getSearchType();
String match = params.getKeyword(); String match = params.getKeyword();
return entry.getValue().stream().map(dsId -> new KeywordHitEvent(setName, searchString, queryType, match, dsId)); return entry.getValue().stream().map(dsId -> new KeywordHitEvent(setName, searchString, queryType, match, dsId));
}) })
.collect(Collectors.partitioningBy(kwe -> kwe.getSetName() == null)); .collect(Collectors.partitioningBy(kwe -> kwe.getConfiguration() == null));
// include set name results in regular events. // include config results in regular events.
List<AnalysisResultEvent> daoEvents = Stream.of(analysisResultSetEvts, keywordHitEvts.get(false)) List<AnalysisResultEvent> daoEvents = Stream.of(analysisResultConfigEvents, keywordHitEvts.get(false))
.filter(lst -> lst != null) .filter(lst -> lst != null)
.flatMap(s -> s.stream()) .flatMap(s -> s.stream())
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -1120,28 +1118,28 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
KeywordHitEvent khEvt = (KeywordHitEvent) arEvt; KeywordHitEvent khEvt = (KeywordHitEvent) arEvt;
return createKWHitsTreeItem( return createKWHitsTreeItem(
khEvt.getDataSourceId(), khEvt.getDataSourceId(),
khEvt.getSetName(), khEvt.getConfiguration(),
khEvt.getMatch(), khEvt.getMatch(),
khEvt.getSearchString(), khEvt.getSearchString(),
khEvt.getSearchType(), khEvt.getSearchType(),
displayCount displayCount
); );
} else if (arEvt instanceof AnalysisResultSetEvent) { } else if (arEvt instanceof AnalysisResultConfigEvent) {
AnalysisResultSetEvent setEvt = (AnalysisResultSetEvent) arEvt; AnalysisResultConfigEvent configEvent = (AnalysisResultConfigEvent) arEvt;
return getSetTreeItem(setEvt.getArtifactType(), setEvt.getDataSourceId(), return getConfigTreeItem(configEvent.getArtifactType(), configEvent.getDataSourceId(),
setEvt.getSetName(), setEvt.getSetName(), displayCount); configEvent.getConfiguration(), configEvent.getConfiguration(), displayCount);
} else { } else {
return getTreeItem(arEvt.getArtifactType(), arEvt.getDataSourceId(), displayCount, null); return getTreeItem(arEvt.getArtifactType(), arEvt.getDataSourceId(), displayCount, null);
} }
} }
private TreeItemDTO<AnalysisResultSetSearchParam> getSetTreeItem(BlackboardArtifact.Type type, private TreeItemDTO<AnalysisResultConfigSearchParam> getConfigTreeItem(BlackboardArtifact.Type type,
Long dataSourceId, String setName, String displayName, TreeDisplayCount displayCount) { Long dataSourceId, String configuration, String displayName, TreeDisplayCount displayCount) {
return new TreeItemDTO<>( return new TreeItemDTO<>(
AnalysisResultSetSearchParam.getTypeId(), AnalysisResultConfigSearchParam.getTypeId(),
new AnalysisResultSetSearchParam(type, dataSourceId, setName), new AnalysisResultConfigSearchParam(type, dataSourceId, configuration),
setName == null ? 0 : setName, configuration == null ? 0 : configuration,
displayName, displayName,
displayCount); displayCount);
} }
@ -1217,16 +1215,16 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
} }
/** /**
* Handles fetching and paging of hashset hits. * Handles fetching and paging of configuration filtered results.
*/ */
public static class AnalysisResultSetFetcher extends DAOFetcher<AnalysisResultSetSearchParam> { public static class AnalysisResultConfigFetcher extends DAOFetcher<AnalysisResultConfigSearchParam> {
/** /**
* Main constructor. * Main constructor.
* *
* @param params Parameters to handle fetching of data. * @param params Parameters to handle fetching of data.
*/ */
public AnalysisResultSetFetcher(AnalysisResultSetSearchParam params) { public AnalysisResultConfigFetcher(AnalysisResultConfigSearchParam params) {
super(params); super(params);
} }
@ -1236,12 +1234,12 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
@Override @Override
public SearchResultsDTO getSearchResults(int pageSize, int pageIdx) throws ExecutionException { public SearchResultsDTO getSearchResults(int pageSize, int pageIdx) throws ExecutionException {
return getDAO().getAnalysisResultSetHits(this.getParameters(), pageIdx * pageSize, (long) pageSize); return getDAO().getAnalysisResultConfigResults(this.getParameters(), pageIdx * pageSize, (long) pageSize);
} }
@Override @Override
public boolean isRefreshRequired(DAOEvent evt) { public boolean isRefreshRequired(DAOEvent evt) {
return getDAO().isAnalysisResultsSetInvalidating(this.getParameters(), evt); return getDAO().isAnalysisResultsConfigInvalidating(this.getParameters(), evt);
} }
} }

View File

@ -23,7 +23,7 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
/** /**
* Key for keyword hits in order to retrieve data from DAO. * Key for keyword hits in order to retrieve data from DAO.
*/ */
public class HashHitSearchParam extends AnalysisResultSetSearchParam { public class HashHitSearchParam extends AnalysisResultConfigSearchParam {
private static final String TYPE_ID = "HASH_HIT"; private static final String TYPE_ID = "HASH_HIT";

View File

@ -25,7 +25,7 @@ import org.sleuthkit.datamodel.TskData;
/** /**
* Parameters for a keyword search term. * Parameters for a keyword search term.
*/ */
public class KeywordSearchTermParams extends AnalysisResultSetSearchParam { public class KeywordSearchTermParams extends AnalysisResultConfigSearchParam {
private static final String TYPE_ID = "KEYWORD_SEARCH_TERMS"; private static final String TYPE_ID = "KEYWORD_SEARCH_TERMS";

View File

@ -24,15 +24,15 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
* An event for an Analysis Result that is organized by Set names to * An event for an Analysis Result that is organized by Set names to
* signal that one has been added or removed on a given data source. * signal that one has been added or removed on a given data source.
*/ */
public class AnalysisResultSetEvent extends AnalysisResultEvent { public class AnalysisResultConfigEvent extends AnalysisResultEvent {
private final String setName; private final String configuration;
public AnalysisResultSetEvent(String setName, BlackboardArtifact.Type artifactType, long dataSourceId) { public AnalysisResultConfigEvent(String configuration, BlackboardArtifact.Type artifactType, long dataSourceId) {
super(artifactType, dataSourceId); super(artifactType, dataSourceId);
this.setName = setName; this.configuration = configuration;
} }
public String getSetName() { public String getConfiguration() {
return setName; return configuration;
} }
} }

View File

@ -26,7 +26,7 @@ import org.sleuthkit.datamodel.TskData;
* An event for an artifact added or changed of a particular type possibly for a * An event for an artifact added or changed of a particular type possibly for a
* particular data source. * particular data source.
*/ */
public class KeywordHitEvent extends AnalysisResultSetEvent { public class KeywordHitEvent extends AnalysisResultConfigEvent {
private final String searchString; private final String searchString;
private final String match; private final String match;

View File

@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.datamodel.utils.IconsUtil;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO.AnalysisResultTreeItem; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultDAO.AnalysisResultTreeItem;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSetSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultConfigSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.KeywordHitSearchParam; import org.sleuthkit.autopsy.mainui.datamodel.KeywordHitSearchParam;
import org.sleuthkit.autopsy.mainui.datamodel.MainDAO; import org.sleuthkit.autopsy.mainui.datamodel.MainDAO;
import org.sleuthkit.autopsy.mainui.datamodel.TreeResultsDTO; import org.sleuthkit.autopsy.mainui.datamodel.TreeResultsDTO;
@ -104,8 +104,8 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
Boolean hasChildren = null; Boolean hasChildren = null;
if (originalTreeItem instanceof AnalysisResultTreeItem) { if (originalTreeItem instanceof AnalysisResultTreeItem) {
hasChildren = ((AnalysisResultTreeItem) originalTreeItem).getHasChildren().orElse(null); hasChildren = ((AnalysisResultTreeItem) originalTreeItem).getHasChildren().orElse(null);
} else if (originalTreeItem.getSearchParams() instanceof AnalysisResultSetSearchParam) { } else if (originalTreeItem.getSearchParams() instanceof AnalysisResultConfigSearchParam) {
String setName = ((AnalysisResultSetSearchParam) originalTreeItem.getSearchParams()).getSetName(); String setName = ((AnalysisResultConfigSearchParam) originalTreeItem.getSearchParams()).getConfiguration();
hasChildren = StringUtils.isNotBlank(setName); hasChildren = StringUtils.isNotBlank(setName);
} }
@ -194,7 +194,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
* Factory displaying all analysis result configurations with count in the * Factory displaying all analysis result configurations with count in the
* tree. * tree.
*/ */
static class TreeSetFactory extends TreeChildFactory<AnalysisResultSetSearchParam> { static class TreeSetFactory extends TreeChildFactory<AnalysisResultConfigSearchParam> {
private final BlackboardArtifact.Type artifactType; private final BlackboardArtifact.Type artifactType;
private final Long dataSourceId; private final Long dataSourceId;
@ -229,38 +229,38 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
} }
@Override @Override
protected TreeResultsDTO<? extends AnalysisResultSetSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException { protected TreeResultsDTO<? extends AnalysisResultConfigSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException {
return MainDAO.getInstance().getAnalysisResultDAO().getConfigurationCounts(this.artifactType, this.dataSourceId, this.nullSetName); return MainDAO.getInstance().getAnalysisResultDAO().getConfigurationCounts(this.artifactType, this.dataSourceId, this.nullSetName);
} }
@Override @Override
protected TreeNode<AnalysisResultSetSearchParam> createNewNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> rowData) { protected TreeNode<AnalysisResultConfigSearchParam> createNewNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> rowData) {
return new TreeSetTypeNode(rowData); return new TreeSetTypeNode(rowData);
} }
@Override @Override
protected TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> getOrCreateRelevantChild(TreeEvent treeEvt) { protected TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> getOrCreateRelevantChild(TreeEvent treeEvt) {
TreeResultsDTO.TreeItemDTO<AnalysisResultSetSearchParam> originalTreeItem = super.getTypedTreeItem(treeEvt, AnalysisResultSetSearchParam.class); TreeResultsDTO.TreeItemDTO<AnalysisResultConfigSearchParam> originalTreeItem = super.getTypedTreeItem(treeEvt, AnalysisResultConfigSearchParam.class);
if (originalTreeItem != null if (originalTreeItem != null
&& originalTreeItem.getSearchParams().getArtifactType().equals(this.artifactType) && originalTreeItem.getSearchParams().getArtifactType().equals(this.artifactType)
&& (this.dataSourceId == null || Objects.equals(this.dataSourceId, originalTreeItem.getSearchParams().getDataSourceId()))) { && (this.dataSourceId == null || Objects.equals(this.dataSourceId, originalTreeItem.getSearchParams().getDataSourceId()))) {
// generate new type so that if it is a subtree event (i.e. keyword hits), the right tree item is created. // generate new type so that if it is a subtree event (i.e. keyword hits), the right tree item is created.
AnalysisResultSetSearchParam searchParam = originalTreeItem.getSearchParams(); AnalysisResultConfigSearchParam searchParam = originalTreeItem.getSearchParams();
return new TreeResultsDTO.TreeItemDTO<>( return new TreeResultsDTO.TreeItemDTO<>(
AnalysisResultSetSearchParam.getTypeId(), AnalysisResultConfigSearchParam.getTypeId(),
new AnalysisResultSetSearchParam(this.artifactType, this.dataSourceId, searchParam.getSetName()), new AnalysisResultConfigSearchParam(this.artifactType, this.dataSourceId, searchParam.getConfiguration()),
searchParam.getSetName() == null ? 0 : searchParam.getSetName(), searchParam.getConfiguration() == null ? 0 : searchParam.getConfiguration(),
searchParam.getSetName() == null ? nullSetName : searchParam.getSetName(), searchParam.getConfiguration() == null ? nullSetName : searchParam.getConfiguration(),
originalTreeItem.getDisplayCount()); originalTreeItem.getDisplayCount());
} }
return null; return null;
} }
@Override @Override
public int compare(TreeItemDTO<? extends AnalysisResultSetSearchParam> o1, TreeItemDTO<? extends AnalysisResultSetSearchParam> o2) { public int compare(TreeItemDTO<? extends AnalysisResultConfigSearchParam> o1, TreeItemDTO<? extends AnalysisResultConfigSearchParam> o2) {
return STRING_COMPARATOR.compare(o1.getSearchParams().getSetName(), o2.getSearchParams().getSetName()); return STRING_COMPARATOR.compare(o1.getSearchParams().getConfiguration(), o2.getSearchParams().getConfiguration());
} }
@Override @Override
@ -280,15 +280,15 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
/** /**
* A node for a set within an artifact type. * A node for a set within an artifact type.
*/ */
static class TreeSetTypeNode extends TreeNode<AnalysisResultSetSearchParam> { static class TreeSetTypeNode extends TreeNode<AnalysisResultConfigSearchParam> {
/** /**
* Main constructor. * Main constructor.
* *
* @param itemData The data to display. * @param itemData The data to display.
*/ */
TreeSetTypeNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> itemData) { TreeSetTypeNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> itemData) {
super(itemData.getSearchParams().getArtifactType().getTypeName() + "_SET_" + itemData.getSearchParams().getSetName(), super(itemData.getSearchParams().getArtifactType().getTypeName() + "_SET_" + itemData.getSearchParams().getConfiguration(),
getIconPath(itemData.getSearchParams().getArtifactType()), getIconPath(itemData.getSearchParams().getArtifactType()),
itemData, itemData,
Children.LEAF, Children.LEAF,
@ -312,7 +312,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
@Override @Override
public Optional<String> getAnalysisResultConfiguration() { public Optional<String> getAnalysisResultConfiguration() {
return Optional.of(this.getItemData().getSearchParams().getSetName()); return Optional.of(this.getItemData().getSearchParams().getConfiguration());
} }
} }
@ -329,25 +329,25 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
} }
@Override @Override
protected TreeResultsDTO<? extends AnalysisResultSetSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException { protected TreeResultsDTO<? extends AnalysisResultConfigSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException {
return MainDAO.getInstance().getAnalysisResultDAO().getSetCounts(getArtifactType(), getDataSourceId(), getNullSetName()); return MainDAO.getInstance().getAnalysisResultDAO().getSetCounts(getArtifactType(), getDataSourceId(), getNullSetName());
} }
@Override @Override
protected TreeNode<AnalysisResultSetSearchParam> createNewNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> rowData) { protected TreeNode<AnalysisResultConfigSearchParam> createNewNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> rowData) {
return new KeywordSetNode(rowData); return new KeywordSetNode(rowData);
} }
} }
static class KeywordSetNode extends TreeNode<AnalysisResultSetSearchParam> { static class KeywordSetNode extends TreeNode<AnalysisResultConfigSearchParam> {
/** /**
* Main constructor. * Main constructor.
* *
* @param itemData The data to display. * @param itemData The data to display.
*/ */
public KeywordSetNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> itemData) { public KeywordSetNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> itemData) {
super("TSK_KEYWORD_HIT_SET_" + itemData.getSearchParams().getSetName(), super("TSK_KEYWORD_HIT_SET_" + itemData.getSearchParams().getConfiguration(),
getIconPath(itemData.getSearchParams().getArtifactType()), getIconPath(itemData.getSearchParams().getArtifactType()),
itemData, itemData,
Children.create(new KeywordSearchTermFactory(itemData.getSearchParams()), true), Children.create(new KeywordSearchTermFactory(itemData.getSearchParams()), true),
@ -366,7 +366,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
@Override @Override
public Optional<String> getAnalysisResultConfiguration() { public Optional<String> getAnalysisResultConfiguration() {
return Optional.of(this.getItemData().getSearchParams().getSetName()); return Optional.of(this.getItemData().getSearchParams().getConfiguration());
} }
} }
@ -376,14 +376,14 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
*/ */
static class KeywordSearchTermFactory extends TreeChildFactory<KeywordSearchTermParams> { static class KeywordSearchTermFactory extends TreeChildFactory<KeywordSearchTermParams> {
private final AnalysisResultSetSearchParam setParams; private final AnalysisResultConfigSearchParam setParams;
/** /**
* Main constructor. * Main constructor.
* *
* @param setParams The parameters for the set. * @param setParams The parameters for the set.
*/ */
KeywordSearchTermFactory(AnalysisResultSetSearchParam setParams) { KeywordSearchTermFactory(AnalysisResultConfigSearchParam setParams) {
this.setParams = setParams; this.setParams = setParams;
} }
@ -394,7 +394,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
@Override @Override
protected TreeResultsDTO<? extends KeywordSearchTermParams> getChildResults() throws IllegalArgumentException, ExecutionException { protected TreeResultsDTO<? extends KeywordSearchTermParams> getChildResults() throws IllegalArgumentException, ExecutionException {
return MainDAO.getInstance().getAnalysisResultDAO().getKeywordSearchTermCounts(this.setParams.getSetName(), this.setParams.getDataSourceId()); return MainDAO.getInstance().getAnalysisResultDAO().getKeywordSearchTermCounts(this.setParams.getConfiguration(), this.setParams.getDataSourceId());
} }
@Override @Override
@ -402,7 +402,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
TreeResultsDTO.TreeItemDTO<KeywordSearchTermParams> originalTreeItem = super.getTypedTreeItem(treeEvt, KeywordSearchTermParams.class); TreeResultsDTO.TreeItemDTO<KeywordSearchTermParams> originalTreeItem = super.getTypedTreeItem(treeEvt, KeywordSearchTermParams.class);
if (originalTreeItem != null if (originalTreeItem != null
&& Objects.equals(originalTreeItem.getSearchParams().getSetName(), this.setParams.getSetName()) && Objects.equals(originalTreeItem.getSearchParams().getConfiguration(), this.setParams.getConfiguration())
&& (this.setParams.getDataSourceId() == null && (this.setParams.getDataSourceId() == null
|| Objects.equals(this.setParams.getDataSourceId(), originalTreeItem.getSearchParams().getDataSourceId()))) { || Objects.equals(this.setParams.getDataSourceId(), originalTreeItem.getSearchParams().getDataSourceId()))) {
@ -413,7 +413,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
return new TreeResultsDTO.TreeItemDTO<>( return new TreeResultsDTO.TreeItemDTO<>(
KeywordSearchTermParams.getTypeId(), KeywordSearchTermParams.getTypeId(),
new KeywordSearchTermParams( new KeywordSearchTermParams(
this.setParams.getSetName(), this.setParams.getConfiguration(),
searchParam.getRegex(), searchParam.getRegex(),
searchParam.getSearchType(), searchParam.getSearchType(),
searchParam.hasChildren(), searchParam.hasChildren(),
@ -473,7 +473,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
if (!searchTermParams.hasChildren()) { if (!searchTermParams.hasChildren()) {
KeywordHitSearchParam searchParams = new KeywordHitSearchParam(searchTermParams.getDataSourceId(), KeywordHitSearchParam searchParams = new KeywordHitSearchParam(searchTermParams.getDataSourceId(),
searchTermParams.getSetName(), searchTermParams.getConfiguration(),
// if literal, keyword is regex // if literal, keyword is regex
TskData.KeywordSearchQueryType.LITERAL.equals(searchTermParams.getSearchType()) ? searchTermParams.getRegex() : null, TskData.KeywordSearchQueryType.LITERAL.equals(searchTermParams.getSearchType()) ? searchTermParams.getRegex() : null,
// if literal, no regex // if literal, no regex
@ -497,7 +497,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
@Override @Override
public Optional<String> getAnalysisResultConfiguration() { public Optional<String> getAnalysisResultConfiguration() {
return Optional.of(this.getItemData().getSearchParams().getSetName()); return Optional.of(this.getItemData().getSearchParams().getConfiguration());
} }
} }
@ -526,7 +526,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
@Override @Override
protected TreeResultsDTO<? extends KeywordHitSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException { protected TreeResultsDTO<? extends KeywordHitSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException {
return MainDAO.getInstance().getAnalysisResultDAO().getKeywordMatchCounts( return MainDAO.getInstance().getAnalysisResultDAO().getKeywordMatchCounts(
this.searchTermParams.getSetName(), this.searchTermParams.getConfiguration(),
this.searchTermParams.getRegex(), this.searchTermParams.getRegex(),
this.searchTermParams.getSearchType(), this.searchTermParams.getSearchType(),
this.searchTermParams.getDataSourceId()); this.searchTermParams.getDataSourceId());
@ -539,7 +539,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
if (originalTreeItem != null if (originalTreeItem != null
&& Objects.equals(originalTreeItem.getSearchParams().getRegex(), this.searchTermParams.getRegex()) && Objects.equals(originalTreeItem.getSearchParams().getRegex(), this.searchTermParams.getRegex())
&& Objects.equals(originalTreeItem.getSearchParams().getSearchType(), this.searchTermParams.getSearchType()) && Objects.equals(originalTreeItem.getSearchParams().getSearchType(), this.searchTermParams.getSearchType())
&& Objects.equals(originalTreeItem.getSearchParams().getSetName(), this.searchTermParams.getSetName()) && Objects.equals(originalTreeItem.getSearchParams().getConfiguration(), this.searchTermParams.getConfiguration())
&& (this.searchTermParams.getDataSourceId() == null && (this.searchTermParams.getDataSourceId() == null
|| Objects.equals(this.searchTermParams.getDataSourceId(), originalTreeItem.getSearchParams().getDataSourceId()))) { || Objects.equals(this.searchTermParams.getDataSourceId(), originalTreeItem.getSearchParams().getDataSourceId()))) {
@ -549,7 +549,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
KeywordHitSearchParam.getTypeId(), KeywordHitSearchParam.getTypeId(),
new KeywordHitSearchParam( new KeywordHitSearchParam(
this.searchTermParams.getDataSourceId(), this.searchTermParams.getDataSourceId(),
this.searchTermParams.getSetName(), this.searchTermParams.getConfiguration(),
searchParam.getKeyword(), searchParam.getKeyword(),
this.searchTermParams.getRegex(), this.searchTermParams.getRegex(),
this.searchTermParams.getSearchType() this.searchTermParams.getSearchType()
@ -616,7 +616,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
@Override @Override
public Optional<String> getAnalysisResultConfiguration() { public Optional<String> getAnalysisResultConfiguration() {
return Optional.of(this.getItemData().getSearchParams().getSetName()); return Optional.of(this.getItemData().getSearchParams().getConfiguration());
} }
} }

View File

@ -1030,13 +1030,13 @@ public class TableSearchTest extends NbTestCase {
// Test hash set hits // Test hash set hits
AnalysisResultDAO analysisResultDAO = MainDAO.getInstance().getAnalysisResultDAO(); AnalysisResultDAO analysisResultDAO = MainDAO.getInstance().getAnalysisResultDAO();
HashHitSearchParam hashParam = new HashHitSearchParam(null, HASH_SET_1); HashHitSearchParam hashParam = new HashHitSearchParam(null, HASH_SET_1);
AnalysisResultTableSearchResultsDTO results = analysisResultDAO.getAnalysisResultSetHits(hashParam, 0, null); AnalysisResultTableSearchResultsDTO results = analysisResultDAO.getAnalysisResultConfigResults(hashParam, 0, null);
assertEquals(BlackboardArtifact.Type.TSK_HASHSET_HIT, results.getArtifactType()); assertEquals(BlackboardArtifact.Type.TSK_HASHSET_HIT, results.getArtifactType());
assertEquals(3, results.getTotalResultsCount()); assertEquals(3, results.getTotalResultsCount());
assertEquals(3, results.getItems().size()); assertEquals(3, results.getItems().size());
hashParam = new HashHitSearchParam(dataSource2.getId(), HASH_SET_1); hashParam = new HashHitSearchParam(dataSource2.getId(), HASH_SET_1);
results = analysisResultDAO.getAnalysisResultSetHits(hashParam, 0, null); results = analysisResultDAO.getAnalysisResultConfigResults(hashParam, 0, null);
assertEquals(BlackboardArtifact.Type.TSK_HASHSET_HIT, results.getArtifactType()); assertEquals(BlackboardArtifact.Type.TSK_HASHSET_HIT, results.getArtifactType());
assertEquals(1, results.getTotalResultsCount()); assertEquals(1, results.getTotalResultsCount());
assertEquals(1, results.getItems().size()); assertEquals(1, results.getItems().size());