mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
refactor names to apply to config and set name separately
This commit is contained in:
parent
fe6c58c034
commit
d176beb1e0
@ -66,10 +66,10 @@ import org.sleuthkit.autopsy.datamodel.NodeSelectionInfo;
|
||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.CommAccountsSearchParams;
|
||||
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.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.CreditCardBinSearchParams;
|
||||
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) {
|
||||
logger.log(Level.WARNING, MessageFormat.format(
|
||||
"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()),
|
||||
ex);
|
||||
}
|
||||
@ -1435,15 +1435,15 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
|
||||
*
|
||||
* @param setKey The search parameter query.
|
||||
*/
|
||||
void displayAnalysisResultSet(AnalysisResultSetSearchParam setKey) {
|
||||
void displayAnalysisResultSet(AnalysisResultConfigSearchParam setKey) {
|
||||
try {
|
||||
this.searchResultManager = new SearchManager(new AnalysisResultSetFetcher(setKey), getPageSize());
|
||||
this.searchResultManager = new SearchManager(new AnalysisResultConfigFetcher(setKey), getPageSize());
|
||||
SearchResultsDTO results = searchResultManager.getResults();
|
||||
displaySearchResults(results, true);
|
||||
} catch (ExecutionException | IllegalArgumentException ex) {
|
||||
logger.log(Level.WARNING, MessageFormat.format(
|
||||
"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()),
|
||||
ex);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.AnalysisResultSearchParam;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.FileSystemContentSearchParam;
|
||||
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.CreditCardBinSearchParams;
|
||||
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.
|
||||
* @param params The search parameters.
|
||||
*/
|
||||
public void displayAnalysisResultSet(AnalysisResultSetSearchParam params) {
|
||||
public void displayAnalysisResultSet(AnalysisResultConfigSearchParam params) {
|
||||
dataResultPanel.displayAnalysisResultSet(params);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
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.DAOEvent;
|
||||
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<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 TreeCounts<AnalysisResultEvent> treeCounts = new TreeCounts<>();
|
||||
@ -175,7 +175,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
BlackboardArtifact.Type artType = searchParams.getArtifactType();
|
||||
|
||||
// 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
|
||||
blackboard.loadBlackboardAttributes(allHits);
|
||||
@ -186,8 +186,8 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
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
|
||||
private AnalysisResultTableSearchResultsDTO fetchSetNameHitsForTable(SearchParams<? extends AnalysisResultSetSearchParam> cacheKey) throws NoCurrentCaseException, TskCoreException {
|
||||
// filters results by configuration attr and needs a search param with the configuration
|
||||
private AnalysisResultTableSearchResultsDTO fetchConfigResultsForTable(SearchParams<? extends AnalysisResultConfigSearchParam> cacheKey) throws NoCurrentCaseException, TskCoreException {
|
||||
|
||||
SleuthkitCase skCase = getCase();
|
||||
Blackboard blackboard = skCase.getBlackboard();
|
||||
@ -195,22 +195,22 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
Long dataSourceId = cacheKey.getParamData().getDataSourceId();
|
||||
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() + " ";
|
||||
if (dataSourceId != null) {
|
||||
originalWhereClause += " AND artifacts.data_source_obj_id = " + dataSourceId + " ";
|
||||
}
|
||||
|
||||
String expectedSetName = cacheKey.getParamData().getSetName();
|
||||
String expectedConfiguration = cacheKey.getParamData().getConfiguration();
|
||||
|
||||
List<AnalysisResult> allResults = new ArrayList<>();
|
||||
allResults.addAll(blackboard.getAnalysisResultsWhere(originalWhereClause));
|
||||
blackboard.loadBlackboardAttributes(allResults);
|
||||
|
||||
// Filter for the selected set
|
||||
// Filter for the selected configuration
|
||||
List<BlackboardArtifact> arts = new ArrayList<>();
|
||||
for (AnalysisResult analysisResult : allResults) {
|
||||
if (Objects.equals(expectedSetName, analysisResult.getConfiguration())) {
|
||||
if (Objects.equals(expectedConfiguration, analysisResult.getConfiguration())) {
|
||||
arts.add(analysisResult);
|
||||
}
|
||||
}
|
||||
@ -282,18 +282,18 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
&& (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) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(event instanceof AnalysisResultSetEvent)) {
|
||||
if (!(event instanceof AnalysisResultConfigEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AnalysisResultSetEvent setEvent = (AnalysisResultSetEvent) event;
|
||||
AnalysisResultConfigEvent setEvent = (AnalysisResultConfigEvent) event;
|
||||
return isAnalysisResultsInvalidating(key, setEvent)
|
||||
&& Objects.equals(key.getSetName(), setEvent.getSetName());
|
||||
&& Objects.equals(key.getConfiguration(), setEvent.getConfiguration());
|
||||
}
|
||||
|
||||
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) {
|
||||
throw new IllegalArgumentException(MessageFormat.format("Illegal data. "
|
||||
+ "Data source id must be null or > 0. "
|
||||
+ "Received data source id: {0}", artifactKey.getDataSourceId() == null ? "<null>" : artifactKey.getDataSourceId()));
|
||||
}
|
||||
|
||||
SearchParams<AnalysisResultSetSearchParam> searchParams = new SearchParams<>(artifactKey, startItem, maxCount);
|
||||
return setHitCache.get(searchParams, () -> fetchSetNameHitsForTable(searchParams));
|
||||
SearchParams<AnalysisResultConfigSearchParam> searchParams = new SearchParams<>(artifactKey, startItem, maxCount);
|
||||
return configHitCache.get(searchParams, () -> fetchConfigResultsForTable(searchParams));
|
||||
}
|
||||
|
||||
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
|
||||
* filtering.
|
||||
*
|
||||
* @return A mapping of set names to their counts.
|
||||
* @return A mapping of configurations to their counts.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* @throws ExecutionException
|
||||
@ -444,7 +444,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
try {
|
||||
// get artifact types and counts
|
||||
SleuthkitCase skCase = getCase();
|
||||
String query = "\n ar.configuration AS set_name\n"
|
||||
String query = "\n ar.configuration AS configuration\n"
|
||||
+ " ,COUNT(*) AS count\n"
|
||||
+ "FROM blackboard_artifacts art\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")
|
||||
+ "GROUP BY ar.configuration";
|
||||
|
||||
Map<String, Long> setCounts = new HashMap<>();
|
||||
Map<String, Long> configurationCounts = new HashMap<>();
|
||||
skCase.getCaseDbAccessManager().select(query, (resultSet) -> {
|
||||
try {
|
||||
while (resultSet.next()) {
|
||||
String setName = resultSet.getString("set_name");
|
||||
String configuration = resultSet.getString("configuration");
|
||||
long count = resultSet.getLong("count");
|
||||
setCounts.put(setName, count);
|
||||
configurationCounts.put(configuration, count);
|
||||
}
|
||||
} 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) {
|
||||
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
|
||||
* tree view.
|
||||
* Get counts for individual configurations of the provided type to be used
|
||||
* in the tree view.
|
||||
*
|
||||
* @param type The blackboard artifact type.
|
||||
* @param dataSourceId The data source object id for which the results
|
||||
* should be filtered or null if no data source
|
||||
* filtering.
|
||||
* @param nullSetName For artifacts with no set, this is the name to
|
||||
* provide. If null, artifacts without a set name will
|
||||
* be ignored.
|
||||
* @param converter Means of converting from data source id and set name
|
||||
* to an AnalysisResultSetSearchParam
|
||||
* @param type The blackboard artifact type.
|
||||
* @param dataSourceId The data source object id for which the
|
||||
* results should be filtered or null if no
|
||||
* data source filtering.
|
||||
* @param blankConfigName For artifacts with no configuration, this
|
||||
* is the name to provide. If null or empty,
|
||||
* artifacts without a configuration will be
|
||||
* ignored.
|
||||
*
|
||||
* @return The sets along with counts to display.
|
||||
* @return The configurations along with counts to display.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* @throws ExecutionException
|
||||
*/
|
||||
public TreeResultsDTO<AnalysisResultSetSearchParam> getConfigurationCounts(
|
||||
public TreeResultsDTO<AnalysisResultConfigSearchParam> getConfigurationCounts(
|
||||
BlackboardArtifact.Type type,
|
||||
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()) {
|
||||
if (evt instanceof AnalysisResultSetEvent
|
||||
if (evt instanceof AnalysisResultConfigEvent
|
||||
&& (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId))
|
||||
&& 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()
|
||||
.sorted((a, b) -> compareSetStrings(a.getKey(), b.getKey()))
|
||||
.sorted((a, b) -> compareStrings(a.getKey(), b.getKey()))
|
||||
.map(entry -> {
|
||||
TreeDisplayCount displayCount = indeterminateSetNames.contains(entry.getKey())
|
||||
TreeDisplayCount displayCount = indeterminateConfigCounts.contains(entry.getKey())
|
||||
? TreeDisplayCount.INDETERMINATE
|
||||
: TreeDisplayCount.getDeterminate(entry.getValue());
|
||||
|
||||
return getSetTreeItem(type,
|
||||
return getConfigTreeItem(type,
|
||||
dataSourceId,
|
||||
entry.getKey(),
|
||||
StringUtils.isBlank(entry.getKey()) ? nullSetName : entry.getKey(),
|
||||
StringUtils.isBlank(entry.getKey()) ? blankConfigName : entry.getKey(),
|
||||
displayCount);
|
||||
})
|
||||
.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
|
||||
@ -595,29 +593,29 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
* @throws IllegalArgumentException
|
||||
* @throws ExecutionException
|
||||
*/
|
||||
public TreeResultsDTO<AnalysisResultSetSearchParam> getSetCounts(
|
||||
public TreeResultsDTO<AnalysisResultConfigSearchParam> getSetCounts(
|
||||
BlackboardArtifact.Type type,
|
||||
Long dataSourceId,
|
||||
String nullSetName) throws IllegalArgumentException, ExecutionException {
|
||||
|
||||
Set<String> indeterminateSetNames = new HashSet<>();
|
||||
for (AnalysisResultEvent evt : this.treeCounts.getEnqueued()) {
|
||||
if (evt instanceof AnalysisResultSetEvent
|
||||
if (evt instanceof AnalysisResultConfigEvent
|
||||
&& (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId))
|
||||
&& 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()
|
||||
.sorted((a, b) -> compareSetStrings(a.getKey(), b.getKey()))
|
||||
.sorted((a, b) -> compareStrings(a.getKey(), b.getKey()))
|
||||
.map(entry -> {
|
||||
TreeDisplayCount displayCount = indeterminateSetNames.contains(entry.getKey())
|
||||
? TreeDisplayCount.INDETERMINATE
|
||||
: TreeDisplayCount.getDeterminate(entry.getValue());
|
||||
|
||||
return getSetTreeItem(type,
|
||||
return getConfigTreeItem(type,
|
||||
dataSourceId,
|
||||
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 b The second string.
|
||||
*
|
||||
* @return The comparator result.
|
||||
*/
|
||||
private int compareSetStrings(String a, String b) {
|
||||
private int compareStrings(String a, String b) {
|
||||
if (a == null && b == null) {
|
||||
return 0;
|
||||
} else if (a == null) {
|
||||
@ -676,7 +674,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
if (evt instanceof KeywordHitEvent
|
||||
&& (dataSourceId == null || Objects.equals(evt.getDataSourceId(), dataSourceId))
|
||||
&& evt.getArtifactType().equals(BlackboardArtifact.Type.TSK_KEYWORD_HIT)
|
||||
&& Objects.equals(((KeywordHitEvent) evt).getSetName(), setName)) {
|
||||
&& Objects.equals(((KeywordHitEvent) evt).getConfiguration(), setName)) {
|
||||
|
||||
KeywordHitEvent keywordEvt = (KeywordHitEvent) evt;
|
||||
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)) {
|
||||
|
||||
KeywordHitEvent keywordEvt = (KeywordHitEvent) evt;
|
||||
if (Objects.equals(keywordEvt.getSetName(), setName)
|
||||
if (Objects.equals(keywordEvt.getConfiguration(), setName)
|
||||
&& Objects.equals(keywordEvt.getSearchString(), regexStr)
|
||||
&& keywordEvt.getSearchType() == searchType) {
|
||||
|
||||
@ -937,7 +935,7 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
void clearCaches() {
|
||||
this.analysisResultCache.invalidateAll();
|
||||
this.keywordHitCache.invalidateAll();
|
||||
this.setHitCache.invalidateAll();
|
||||
this.configHitCache.invalidateAll();
|
||||
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.
|
||||
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<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;
|
||||
|
||||
setMap.computeIfAbsent(Pair.of(art.getType(), configuration), (k) -> new HashSet<>())
|
||||
configMap.computeIfAbsent(Pair.of(art.getType(), configuration), (k) -> new HashSet<>())
|
||||
.add(art.getDataSourceObjectID());
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
@ -1023,25 +1021,25 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
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(
|
||||
// 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()
|
||||
), keywordHitsMap);
|
||||
|
||||
return getResultViewEvents(setMap, keywordHitsMap, IngestManager.getInstance().isIngestRunning());
|
||||
return getResultViewEvents(configMap, keywordHitsMap, IngestManager.getInstance().isIngestRunning());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) to data sources where results were
|
||||
* created.
|
||||
@ -1053,28 +1051,28 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
* @return The list of dao events.
|
||||
*/
|
||||
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,
|
||||
boolean ingestIsRunning) {
|
||||
|
||||
List<AnalysisResultEvent> analysisResultSetEvts = resultsWithSetMap.entrySet().stream()
|
||||
.flatMap(entry -> entry.getValue().stream().map(dsId -> new AnalysisResultSetEvent(entry.getKey().getRight(), entry.getKey().getLeft(), dsId)))
|
||||
List<AnalysisResultEvent> analysisResultConfigEvents = resultsWithConfigMap.entrySet().stream()
|
||||
.flatMap(entry -> entry.getValue().stream().map(dsId -> new AnalysisResultConfigEvent(entry.getKey().getRight(), entry.getKey().getLeft(), dsId)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// divide into ad hoc searches (null set name) and the rest
|
||||
Map<Boolean, List<KeywordHitEvent>> keywordHitEvts = keywordHitsMap.entrySet().stream()
|
||||
.flatMap(entry -> {
|
||||
KeywordHitSearchParam params = entry.getKey();
|
||||
String setName = params.getSetName();
|
||||
String setName = params.getConfiguration();
|
||||
String searchString = params.getRegex();
|
||||
TskData.KeywordSearchQueryType queryType = params.getSearchType();
|
||||
String match = params.getKeyword();
|
||||
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.
|
||||
List<AnalysisResultEvent> daoEvents = Stream.of(analysisResultSetEvts, keywordHitEvts.get(false))
|
||||
// include config results in regular events.
|
||||
List<AnalysisResultEvent> daoEvents = Stream.of(analysisResultConfigEvents, keywordHitEvts.get(false))
|
||||
.filter(lst -> lst != null)
|
||||
.flatMap(s -> s.stream())
|
||||
.collect(Collectors.toList());
|
||||
@ -1120,28 +1118,28 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
KeywordHitEvent khEvt = (KeywordHitEvent) arEvt;
|
||||
return createKWHitsTreeItem(
|
||||
khEvt.getDataSourceId(),
|
||||
khEvt.getSetName(),
|
||||
khEvt.getConfiguration(),
|
||||
khEvt.getMatch(),
|
||||
khEvt.getSearchString(),
|
||||
khEvt.getSearchType(),
|
||||
displayCount
|
||||
);
|
||||
} else if (arEvt instanceof AnalysisResultSetEvent) {
|
||||
AnalysisResultSetEvent setEvt = (AnalysisResultSetEvent) arEvt;
|
||||
return getSetTreeItem(setEvt.getArtifactType(), setEvt.getDataSourceId(),
|
||||
setEvt.getSetName(), setEvt.getSetName(), displayCount);
|
||||
} else if (arEvt instanceof AnalysisResultConfigEvent) {
|
||||
AnalysisResultConfigEvent configEvent = (AnalysisResultConfigEvent) arEvt;
|
||||
return getConfigTreeItem(configEvent.getArtifactType(), configEvent.getDataSourceId(),
|
||||
configEvent.getConfiguration(), configEvent.getConfiguration(), displayCount);
|
||||
} else {
|
||||
return getTreeItem(arEvt.getArtifactType(), arEvt.getDataSourceId(), displayCount, null);
|
||||
}
|
||||
}
|
||||
|
||||
private TreeItemDTO<AnalysisResultSetSearchParam> getSetTreeItem(BlackboardArtifact.Type type,
|
||||
Long dataSourceId, String setName, String displayName, TreeDisplayCount displayCount) {
|
||||
private TreeItemDTO<AnalysisResultConfigSearchParam> getConfigTreeItem(BlackboardArtifact.Type type,
|
||||
Long dataSourceId, String configuration, String displayName, TreeDisplayCount displayCount) {
|
||||
|
||||
return new TreeItemDTO<>(
|
||||
AnalysisResultSetSearchParam.getTypeId(),
|
||||
new AnalysisResultSetSearchParam(type, dataSourceId, setName),
|
||||
setName == null ? 0 : setName,
|
||||
AnalysisResultConfigSearchParam.getTypeId(),
|
||||
new AnalysisResultConfigSearchParam(type, dataSourceId, configuration),
|
||||
configuration == null ? 0 : configuration,
|
||||
displayName,
|
||||
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.
|
||||
*
|
||||
* @param params Parameters to handle fetching of data.
|
||||
*/
|
||||
public AnalysisResultSetFetcher(AnalysisResultSetSearchParam params) {
|
||||
public AnalysisResultConfigFetcher(AnalysisResultConfigSearchParam params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@ -1236,12 +1234,12 @@ public class AnalysisResultDAO extends BlackboardArtifactDAO {
|
||||
|
||||
@Override
|
||||
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
|
||||
public boolean isRefreshRequired(DAOEvent evt) {
|
||||
return getDAO().isAnalysisResultsSetInvalidating(this.getParameters(), evt);
|
||||
return getDAO().isAnalysisResultsConfigInvalidating(this.getParameters(), evt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
/**
|
||||
* 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";
|
||||
|
||||
|
@ -25,7 +25,7 @@ import org.sleuthkit.datamodel.TskData;
|
||||
/**
|
||||
* 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";
|
||||
|
||||
|
@ -24,15 +24,15 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
* 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.
|
||||
*/
|
||||
public class AnalysisResultSetEvent extends AnalysisResultEvent {
|
||||
private final String setName;
|
||||
public class AnalysisResultConfigEvent extends AnalysisResultEvent {
|
||||
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);
|
||||
this.setName = setName;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public String getSetName() {
|
||||
return setName;
|
||||
public String getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ import org.sleuthkit.datamodel.TskData;
|
||||
* An event for an artifact added or changed of a particular type possibly for a
|
||||
* particular data source.
|
||||
*/
|
||||
public class KeywordHitEvent extends AnalysisResultSetEvent {
|
||||
public class KeywordHitEvent extends AnalysisResultConfigEvent {
|
||||
|
||||
private final String searchString;
|
||||
private final String match;
|
||||
|
@ -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.AnalysisResultTreeItem;
|
||||
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.MainDAO;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.TreeResultsDTO;
|
||||
@ -104,8 +104,8 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
Boolean hasChildren = null;
|
||||
if (originalTreeItem instanceof AnalysisResultTreeItem) {
|
||||
hasChildren = ((AnalysisResultTreeItem) originalTreeItem).getHasChildren().orElse(null);
|
||||
} else if (originalTreeItem.getSearchParams() instanceof AnalysisResultSetSearchParam) {
|
||||
String setName = ((AnalysisResultSetSearchParam) originalTreeItem.getSearchParams()).getSetName();
|
||||
} else if (originalTreeItem.getSearchParams() instanceof AnalysisResultConfigSearchParam) {
|
||||
String setName = ((AnalysisResultConfigSearchParam) originalTreeItem.getSearchParams()).getConfiguration();
|
||||
hasChildren = StringUtils.isNotBlank(setName);
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
* Factory displaying all analysis result configurations with count in the
|
||||
* tree.
|
||||
*/
|
||||
static class TreeSetFactory extends TreeChildFactory<AnalysisResultSetSearchParam> {
|
||||
static class TreeSetFactory extends TreeChildFactory<AnalysisResultConfigSearchParam> {
|
||||
|
||||
private final BlackboardArtifact.Type artifactType;
|
||||
private final Long dataSourceId;
|
||||
@ -229,38 +229,38 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TreeNode<AnalysisResultSetSearchParam> createNewNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> rowData) {
|
||||
protected TreeNode<AnalysisResultConfigSearchParam> createNewNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> rowData) {
|
||||
return new TreeSetTypeNode(rowData);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> getOrCreateRelevantChild(TreeEvent treeEvt) {
|
||||
TreeResultsDTO.TreeItemDTO<AnalysisResultSetSearchParam> originalTreeItem = super.getTypedTreeItem(treeEvt, AnalysisResultSetSearchParam.class);
|
||||
protected TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> getOrCreateRelevantChild(TreeEvent treeEvt) {
|
||||
TreeResultsDTO.TreeItemDTO<AnalysisResultConfigSearchParam> originalTreeItem = super.getTypedTreeItem(treeEvt, AnalysisResultConfigSearchParam.class);
|
||||
|
||||
if (originalTreeItem != null
|
||||
&& originalTreeItem.getSearchParams().getArtifactType().equals(this.artifactType)
|
||||
&& (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.
|
||||
AnalysisResultSetSearchParam searchParam = originalTreeItem.getSearchParams();
|
||||
AnalysisResultConfigSearchParam searchParam = originalTreeItem.getSearchParams();
|
||||
return new TreeResultsDTO.TreeItemDTO<>(
|
||||
AnalysisResultSetSearchParam.getTypeId(),
|
||||
new AnalysisResultSetSearchParam(this.artifactType, this.dataSourceId, searchParam.getSetName()),
|
||||
searchParam.getSetName() == null ? 0 : searchParam.getSetName(),
|
||||
searchParam.getSetName() == null ? nullSetName : searchParam.getSetName(),
|
||||
AnalysisResultConfigSearchParam.getTypeId(),
|
||||
new AnalysisResultConfigSearchParam(this.artifactType, this.dataSourceId, searchParam.getConfiguration()),
|
||||
searchParam.getConfiguration() == null ? 0 : searchParam.getConfiguration(),
|
||||
searchParam.getConfiguration() == null ? nullSetName : searchParam.getConfiguration(),
|
||||
originalTreeItem.getDisplayCount());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(TreeItemDTO<? extends AnalysisResultSetSearchParam> o1, TreeItemDTO<? extends AnalysisResultSetSearchParam> o2) {
|
||||
return STRING_COMPARATOR.compare(o1.getSearchParams().getSetName(), o2.getSearchParams().getSetName());
|
||||
public int compare(TreeItemDTO<? extends AnalysisResultConfigSearchParam> o1, TreeItemDTO<? extends AnalysisResultConfigSearchParam> o2) {
|
||||
return STRING_COMPARATOR.compare(o1.getSearchParams().getConfiguration(), o2.getSearchParams().getConfiguration());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -280,15 +280,15 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
/**
|
||||
* A node for a set within an artifact type.
|
||||
*/
|
||||
static class TreeSetTypeNode extends TreeNode<AnalysisResultSetSearchParam> {
|
||||
static class TreeSetTypeNode extends TreeNode<AnalysisResultConfigSearchParam> {
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
*
|
||||
* @param itemData The data to display.
|
||||
*/
|
||||
TreeSetTypeNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> itemData) {
|
||||
super(itemData.getSearchParams().getArtifactType().getTypeName() + "_SET_" + itemData.getSearchParams().getSetName(),
|
||||
TreeSetTypeNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> itemData) {
|
||||
super(itemData.getSearchParams().getArtifactType().getTypeName() + "_SET_" + itemData.getSearchParams().getConfiguration(),
|
||||
getIconPath(itemData.getSearchParams().getArtifactType()),
|
||||
itemData,
|
||||
Children.LEAF,
|
||||
@ -312,7 +312,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
|
||||
@Override
|
||||
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
|
||||
protected TreeResultsDTO<? extends AnalysisResultSetSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException {
|
||||
protected TreeResultsDTO<? extends AnalysisResultConfigSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException {
|
||||
return MainDAO.getInstance().getAnalysisResultDAO().getSetCounts(getArtifactType(), getDataSourceId(), getNullSetName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TreeNode<AnalysisResultSetSearchParam> createNewNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> rowData) {
|
||||
protected TreeNode<AnalysisResultConfigSearchParam> createNewNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> rowData) {
|
||||
return new KeywordSetNode(rowData);
|
||||
}
|
||||
}
|
||||
|
||||
static class KeywordSetNode extends TreeNode<AnalysisResultSetSearchParam> {
|
||||
static class KeywordSetNode extends TreeNode<AnalysisResultConfigSearchParam> {
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
*
|
||||
* @param itemData The data to display.
|
||||
*/
|
||||
public KeywordSetNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultSetSearchParam> itemData) {
|
||||
super("TSK_KEYWORD_HIT_SET_" + itemData.getSearchParams().getSetName(),
|
||||
public KeywordSetNode(TreeResultsDTO.TreeItemDTO<? extends AnalysisResultConfigSearchParam> itemData) {
|
||||
super("TSK_KEYWORD_HIT_SET_" + itemData.getSearchParams().getConfiguration(),
|
||||
getIconPath(itemData.getSearchParams().getArtifactType()),
|
||||
itemData,
|
||||
Children.create(new KeywordSearchTermFactory(itemData.getSearchParams()), true),
|
||||
@ -366,7 +366,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
|
||||
@Override
|
||||
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> {
|
||||
|
||||
private final AnalysisResultSetSearchParam setParams;
|
||||
private final AnalysisResultConfigSearchParam setParams;
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
*
|
||||
* @param setParams The parameters for the set.
|
||||
*/
|
||||
KeywordSearchTermFactory(AnalysisResultSetSearchParam setParams) {
|
||||
KeywordSearchTermFactory(AnalysisResultConfigSearchParam setParams) {
|
||||
this.setParams = setParams;
|
||||
}
|
||||
|
||||
@ -394,7 +394,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
|
||||
@Override
|
||||
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
|
||||
@ -402,7 +402,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
TreeResultsDTO.TreeItemDTO<KeywordSearchTermParams> originalTreeItem = super.getTypedTreeItem(treeEvt, KeywordSearchTermParams.class);
|
||||
|
||||
if (originalTreeItem != null
|
||||
&& Objects.equals(originalTreeItem.getSearchParams().getSetName(), this.setParams.getSetName())
|
||||
&& Objects.equals(originalTreeItem.getSearchParams().getConfiguration(), this.setParams.getConfiguration())
|
||||
&& (this.setParams.getDataSourceId() == null
|
||||
|| Objects.equals(this.setParams.getDataSourceId(), originalTreeItem.getSearchParams().getDataSourceId()))) {
|
||||
|
||||
@ -413,7 +413,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
return new TreeResultsDTO.TreeItemDTO<>(
|
||||
KeywordSearchTermParams.getTypeId(),
|
||||
new KeywordSearchTermParams(
|
||||
this.setParams.getSetName(),
|
||||
this.setParams.getConfiguration(),
|
||||
searchParam.getRegex(),
|
||||
searchParam.getSearchType(),
|
||||
searchParam.hasChildren(),
|
||||
@ -473,7 +473,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
|
||||
if (!searchTermParams.hasChildren()) {
|
||||
KeywordHitSearchParam searchParams = new KeywordHitSearchParam(searchTermParams.getDataSourceId(),
|
||||
searchTermParams.getSetName(),
|
||||
searchTermParams.getConfiguration(),
|
||||
// if literal, keyword is regex
|
||||
TskData.KeywordSearchQueryType.LITERAL.equals(searchTermParams.getSearchType()) ? searchTermParams.getRegex() : null,
|
||||
// if literal, no regex
|
||||
@ -497,7 +497,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
|
||||
@Override
|
||||
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
|
||||
protected TreeResultsDTO<? extends KeywordHitSearchParam> getChildResults() throws IllegalArgumentException, ExecutionException {
|
||||
return MainDAO.getInstance().getAnalysisResultDAO().getKeywordMatchCounts(
|
||||
this.searchTermParams.getSetName(),
|
||||
this.searchTermParams.getConfiguration(),
|
||||
this.searchTermParams.getRegex(),
|
||||
this.searchTermParams.getSearchType(),
|
||||
this.searchTermParams.getDataSourceId());
|
||||
@ -539,7 +539,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
if (originalTreeItem != null
|
||||
&& Objects.equals(originalTreeItem.getSearchParams().getRegex(), this.searchTermParams.getRegex())
|
||||
&& 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
|
||||
|| Objects.equals(this.searchTermParams.getDataSourceId(), originalTreeItem.getSearchParams().getDataSourceId()))) {
|
||||
|
||||
@ -549,7 +549,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
KeywordHitSearchParam.getTypeId(),
|
||||
new KeywordHitSearchParam(
|
||||
this.searchTermParams.getDataSourceId(),
|
||||
this.searchTermParams.getSetName(),
|
||||
this.searchTermParams.getConfiguration(),
|
||||
searchParam.getKeyword(),
|
||||
this.searchTermParams.getRegex(),
|
||||
this.searchTermParams.getSearchType()
|
||||
@ -616,7 +616,7 @@ public class AnalysisResultTypeFactory extends TreeChildFactory<AnalysisResultSe
|
||||
|
||||
@Override
|
||||
public Optional<String> getAnalysisResultConfiguration() {
|
||||
return Optional.of(this.getItemData().getSearchParams().getSetName());
|
||||
return Optional.of(this.getItemData().getSearchParams().getConfiguration());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,13 +1030,13 @@ public class TableSearchTest extends NbTestCase {
|
||||
// Test hash set hits
|
||||
AnalysisResultDAO analysisResultDAO = MainDAO.getInstance().getAnalysisResultDAO();
|
||||
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(3, results.getTotalResultsCount());
|
||||
assertEquals(3, results.getItems().size());
|
||||
|
||||
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(1, results.getTotalResultsCount());
|
||||
assertEquals(1, results.getItems().size());
|
||||
|
Loading…
x
Reference in New Issue
Block a user