mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
6639 refactor to allow for artifact type filters
This commit is contained in:
parent
7514dec615
commit
092430b102
@ -90,12 +90,12 @@ abstract class AbstractDiscoveryFilterPanel extends javax.swing.JPanel {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FileFilter which is represented by this Panel.
|
||||
* Get the AbstractFilter which is represented by this Panel.
|
||||
*
|
||||
* @return The FileFilter for the selected settings, null if the settings
|
||||
* @return The AbstractFilter for the selected settings, null if the settings
|
||||
* are not in use.
|
||||
*/
|
||||
abstract FileSearchFiltering.FileFilter getFilter();
|
||||
abstract AbstractFilter getFilter();
|
||||
|
||||
/**
|
||||
* Remove listeners from the checkbox and the list if they exist.
|
||||
|
62
Core/src/org/sleuthkit/autopsy/discovery/AbstractFilter.java
Normal file
62
Core/src/org/sleuthkit/autopsy/discovery/AbstractFilter.java
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.discovery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
|
||||
/**
|
||||
* Base class for the filters.
|
||||
*/
|
||||
abstract class AbstractFilter {
|
||||
|
||||
/**
|
||||
* Returns part of a query on the tsk_files table that can be AND-ed with
|
||||
* other pieces
|
||||
*
|
||||
* @return the SQL query or an empty string if there is no SQL query for
|
||||
* this filter.
|
||||
*/
|
||||
abstract String getWhereClause();
|
||||
|
||||
/**
|
||||
* Indicates whether this filter needs to use the secondary, non-SQL method
|
||||
* applyAlternateFilter().
|
||||
*
|
||||
* @return false by default
|
||||
*/
|
||||
boolean useAlternateFilter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a secondary filter that does not operate on tsk_files.
|
||||
*
|
||||
* @param currentResults The current list of matching files; empty if no
|
||||
* filters have yet been run.
|
||||
* @param caseDb The case database
|
||||
* @param centralRepoDb The central repo database. Can be null if the
|
||||
* filter does not require it.
|
||||
*
|
||||
* @return The list of files that match this filter (and any that came
|
||||
* before it)
|
||||
*
|
||||
* @throws FileSearchException
|
||||
*/
|
||||
List<ResultFile> applyAlternateFilter(List<ResultFile> currentResults, SleuthkitCase caseDb,
|
||||
CentralRepository centralRepoDb) throws FileSearchException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a description of the selected filter.
|
||||
*
|
||||
* @return A description of the filter
|
||||
*/
|
||||
abstract String getDesc();
|
||||
}
|
@ -61,6 +61,8 @@ abstract class AbstractFiltersPanel extends JPanel implements ActionListener, Li
|
||||
secondColumnPanel.setLayout(new GridBagLayout());
|
||||
}
|
||||
|
||||
abstract SearchData.ResultType getResultType();
|
||||
|
||||
/**
|
||||
* Get the type of results this filters panel is for.
|
||||
*
|
||||
@ -242,12 +244,18 @@ abstract class AbstractFiltersPanel extends JPanel implements ActionListener, Li
|
||||
*
|
||||
* @return The list of filters selected by the user.
|
||||
*/
|
||||
synchronized List<FileSearchFiltering.FileFilter> getFilters() {
|
||||
List<FileSearchFiltering.FileFilter> filtersToUse = new ArrayList<>();
|
||||
filtersToUse.add(new FileSearchFiltering.FileTypeFilter(getFileType()));
|
||||
synchronized List<AbstractFilter> getFilters() {
|
||||
|
||||
List<AbstractFilter> filtersToUse = new ArrayList<>();
|
||||
if (getResultType().equals(SearchData.ResultType.FILE)) {
|
||||
filtersToUse.add(new SearchFiltering.FileTypeFilter(getFileType()));
|
||||
} else if (getResultType().equals(SearchData.ResultType.ARTIFACT)){
|
||||
|
||||
}
|
||||
|
||||
for (AbstractDiscoveryFilterPanel filterPanel : filters) {
|
||||
if (filterPanel.getCheckbox().isSelected()) {
|
||||
FileSearchFiltering.FileFilter filter = filterPanel.getFilter();
|
||||
AbstractFilter filter = filterPanel.getFilter();
|
||||
if (filter != null) {
|
||||
filtersToUse.add(filter);
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.discovery;
|
||||
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
|
||||
/**
|
||||
* Utility enums for searches made for artifacts with Discovery.
|
||||
*/
|
||||
public class ArtifactSearchData extends SearchData {
|
||||
|
||||
|
||||
@Override
|
||||
ResultType getResultType(){
|
||||
return ResultType.ARTIFACT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enum representing the file type. We don't simply use
|
||||
* FileTypeUtils.FileTypeCategory because: - Some file types categories
|
||||
* overlap - It is convenient to have the "OTHER" option for files that
|
||||
* don't match the given types
|
||||
*/
|
||||
@NbBundle.Messages({
|
||||
"ArtifactSearchData.ArtifactType.Domain.displayName=Domain",
|
||||
"ArtifactSearchData.ArtifactType.Other.displayName=Other"})
|
||||
enum ArtifactType {
|
||||
|
||||
DOMAIN(0, Bundle.ArtifactSearchData_ArtifactType_Domain_displayName(), BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK),
|
||||
OTHER(1, Bundle.ArtifactSearchData_ArtifactType_Other_displayName(), null);
|
||||
|
||||
private final int ranking; // For ordering in the UI
|
||||
private final String displayName;
|
||||
private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
|
||||
|
||||
ArtifactType(int value, String displayName, BlackboardArtifact.ARTIFACT_TYPE type) {
|
||||
this.ranking = value;
|
||||
this.displayName = displayName;
|
||||
this.artifactType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MIME types matching this category.
|
||||
*
|
||||
* @return Collection of MIME type strings
|
||||
*/
|
||||
BlackboardArtifact.ARTIFACT_TYPE getMediaTypes() {
|
||||
return artifactType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rank for sorting.
|
||||
*
|
||||
* @return the rank (lower should be displayed first)
|
||||
*/
|
||||
int getRanking() {
|
||||
return ranking;
|
||||
}
|
||||
|
||||
|
||||
static ArtifactType fromBlackboardArtifact(final BlackboardArtifact.ARTIFACT_TYPE type) {
|
||||
switch (type) {
|
||||
case TSK_WEB_BOOKMARK:
|
||||
return DOMAIN;
|
||||
default:
|
||||
return OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
ArtifactSearchData.ArtifactType.Domain.displayName=Domain
|
||||
ArtifactSearchData.ArtifactType.Other.displayName=Other
|
||||
CTL_OpenDiscoveryAction=Discovery
|
||||
# {0} - dataSourceName
|
||||
DataSourceModuleWrapper.exifModule.text=Exif Parser module was not run on data source: {0}\n
|
||||
|
@ -194,10 +194,10 @@ final class DataSourceFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
FileSearchFiltering.FileFilter getFilter() {
|
||||
AbstractFilter getFilter() {
|
||||
if (dataSourceCheckbox.isSelected()) {
|
||||
List<DataSource> dataSources = dataSourceList.getSelectedValuesList().stream().map(t -> t.getDataSource()).collect(Collectors.toList());
|
||||
return new FileSearchFiltering.DataSourceFilter(dataSources);
|
||||
return new SearchFiltering.DataSourceFilter(dataSources);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ final class DiscoveryDialog extends javax.swing.JDialog {
|
||||
tc.open();
|
||||
}
|
||||
tc.resetTopComponent();
|
||||
List<FileSearchFiltering.FileFilter> filters;
|
||||
List<AbstractFilter> filters;
|
||||
if (videosButton.isSelected()) {
|
||||
filters = videoFilterPanel.getFilters();
|
||||
} else if (documentsButton.isSelected()) {
|
||||
|
@ -116,7 +116,7 @@ final class DiscoveryEventUtils {
|
||||
static final class SearchCompleteEvent {
|
||||
|
||||
private final Map<GroupKey, Integer> groupMap;
|
||||
private final List<FileSearchFiltering.FileFilter> searchFilters;
|
||||
private final List<AbstractFilter> searchFilters;
|
||||
private final FileSearch.AttributeType groupingAttribute;
|
||||
private final FileGroup.GroupSortingAlgorithm groupSort;
|
||||
private final FileSorter.SortingMethod fileSortMethod;
|
||||
@ -132,7 +132,7 @@ final class DiscoveryEventUtils {
|
||||
* @param groupSort The sorting algorithm used for groups.
|
||||
* @param fileSortMethod The sorting method used for files.
|
||||
*/
|
||||
SearchCompleteEvent(Map<GroupKey, Integer> groupMap, List<FileSearchFiltering.FileFilter> searchfilters,
|
||||
SearchCompleteEvent(Map<GroupKey, Integer> groupMap, List<AbstractFilter> searchfilters,
|
||||
FileSearch.AttributeType groupingAttribute, FileGroup.GroupSortingAlgorithm groupSort,
|
||||
FileSorter.SortingMethod fileSortMethod) {
|
||||
this.groupMap = groupMap;
|
||||
@ -156,7 +156,7 @@ final class DiscoveryEventUtils {
|
||||
*
|
||||
* @return The search filters which were used by the search.
|
||||
*/
|
||||
List<FileSearchFiltering.FileFilter> getFilters() {
|
||||
List<AbstractFilter> getFilters() {
|
||||
return Collections.unmodifiableList(searchFilters);
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ final class DiscoveryEventUtils {
|
||||
private final FileType resultType;
|
||||
private final GroupKey groupKey;
|
||||
private final int groupSize;
|
||||
private final List<FileSearchFiltering.FileFilter> searchfilters;
|
||||
private final List<AbstractFilter> searchfilters;
|
||||
private final FileSearch.AttributeType groupingAttribute;
|
||||
private final FileGroup.GroupSortingAlgorithm groupSort;
|
||||
private final FileSorter.SortingMethod fileSortMethod;
|
||||
@ -294,7 +294,7 @@ final class DiscoveryEventUtils {
|
||||
* selected.
|
||||
* @param resultType The type of files which exist in the group.
|
||||
*/
|
||||
GroupSelectedEvent(List<FileSearchFiltering.FileFilter> searchfilters,
|
||||
GroupSelectedEvent(List<AbstractFilter> searchfilters,
|
||||
FileSearch.AttributeType groupingAttribute, FileGroup.GroupSortingAlgorithm groupSort,
|
||||
FileSorter.SortingMethod fileSortMethod, GroupKey groupKey, int groupSize, FileType resultType) {
|
||||
this.searchfilters = searchfilters;
|
||||
@ -358,7 +358,7 @@ final class DiscoveryEventUtils {
|
||||
*
|
||||
* @return The search filters which were used by the search.
|
||||
*/
|
||||
List<FileSearchFiltering.FileFilter> getFilters() {
|
||||
List<AbstractFilter> getFilters() {
|
||||
return Collections.unmodifiableList(searchfilters);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,6 @@ import org.openide.windows.RetainLocation;
|
||||
import org.openide.windows.TopComponent;
|
||||
import org.openide.windows.WindowManager;
|
||||
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
|
||||
import org.sleuthkit.autopsy.discovery.FileSearchFiltering.FileFilter;
|
||||
|
||||
/**
|
||||
* Create a dialog for displaying the Discovery results.
|
||||
@ -299,7 +298,7 @@ public final class DiscoveryTopComponent extends TopComponent {
|
||||
void handleSearchCompleteEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompleteEvent) {
|
||||
newSearchButton.setText(Bundle.DiscoveryTopComponent_newSearch_text());
|
||||
progressMessageTextArea.setForeground(Color.black);
|
||||
progressMessageTextArea.setText(Bundle.DiscoveryTopComponent_searchComplete_text(searchCompleteEvent.getFilters().stream().map(FileFilter::getDesc).collect(Collectors.joining("; "))));
|
||||
progressMessageTextArea.setText(Bundle.DiscoveryTopComponent_searchComplete_text(searchCompleteEvent.getFilters().stream().map(AbstractFilter::getDesc).collect(Collectors.joining("; "))));
|
||||
progressMessageTextArea.setCaretPosition(0);
|
||||
}
|
||||
|
||||
|
@ -98,4 +98,9 @@ final class DocumentFilterPanel extends AbstractFiltersPanel {
|
||||
private javax.swing.JSplitPane documentsFiltersSplitPane;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
SearchData.ResultType getResultType() {
|
||||
return SearchData.ResultType.FILE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.discovery;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author wschaefer
|
||||
*/
|
||||
public class DomainFilterPanel extends AbstractFiltersPanel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final ArtifactSearchData.ArtifactType ARTIFACT_TYPE = ArtifactSearchData.ArtifactType.DOMAIN;
|
||||
|
||||
/**
|
||||
* Creates new form DomainFilterPanel
|
||||
*/
|
||||
public DomainFilterPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@Override
|
||||
FileSearchData.FileType getFileType() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
SearchData.ResultType getResultType() {
|
||||
return SearchData.ResultType.ARTIFACT;
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -122,7 +122,7 @@ class FileSearch {
|
||||
* @throws FileSearchException
|
||||
*/
|
||||
static SearchResults runFileSearchDebug(String userName,
|
||||
List<FileSearchFiltering.FileFilter> filters,
|
||||
List<AbstractFilter> filters,
|
||||
AttributeType groupAttributeType,
|
||||
FileGroup.GroupSortingAlgorithm groupSortingType,
|
||||
FileSorter.SortingMethod fileSortingMethod,
|
||||
@ -136,7 +136,7 @@ class FileSearch {
|
||||
attributesNeededForGroupingOrSorting.addAll(fileSortingMethod.getRequiredAttributes());
|
||||
|
||||
// Run the queries for each filter
|
||||
List<ResultFile> resultFiles = FileSearchFiltering.runQueries(filters, caseDb, centralRepoDb);
|
||||
List<ResultFile> resultFiles = SearchFiltering.runQueries(filters, caseDb, centralRepoDb);
|
||||
|
||||
// Add the data to resultFiles for any attributes needed for sorting and grouping
|
||||
addAttributes(attributesNeededForGroupingOrSorting, resultFiles, caseDb, centralRepoDb);
|
||||
@ -174,7 +174,7 @@ class FileSearch {
|
||||
* @throws FileSearchException
|
||||
*/
|
||||
static Map<GroupKey, Integer> getGroupSizes(String userName,
|
||||
List<FileSearchFiltering.FileFilter> filters,
|
||||
List<AbstractFilter> filters,
|
||||
AttributeType groupAttributeType,
|
||||
FileGroup.GroupSortingAlgorithm groupSortingType,
|
||||
FileSorter.SortingMethod fileSortingMethod,
|
||||
@ -211,7 +211,7 @@ class FileSearch {
|
||||
* @throws FileSearchException
|
||||
*/
|
||||
static List<ResultFile> getFilesInGroup(String userName,
|
||||
List<FileSearchFiltering.FileFilter> filters,
|
||||
List<AbstractFilter> filters,
|
||||
AttributeType groupAttributeType,
|
||||
FileGroup.GroupSortingAlgorithm groupSortingType,
|
||||
FileSorter.SortingMethod fileSortingMethod,
|
||||
@ -483,7 +483,7 @@ class FileSearch {
|
||||
* @throws FileSearchException
|
||||
*/
|
||||
private static Map<GroupKey, List<ResultFile>> runFileSearch(String userName,
|
||||
List<FileSearchFiltering.FileFilter> filters,
|
||||
List<AbstractFilter> filters,
|
||||
AttributeType groupAttributeType,
|
||||
FileGroup.GroupSortingAlgorithm groupSortingType,
|
||||
FileSorter.SortingMethod fileSortingMethod,
|
||||
@ -498,7 +498,7 @@ class FileSearch {
|
||||
attributesNeededForGroupingOrSorting.addAll(fileSortingMethod.getRequiredAttributes());
|
||||
|
||||
// Run the queries for each filter
|
||||
List<ResultFile> resultFiles = FileSearchFiltering.runQueries(filters, caseDb, centralRepoDb);
|
||||
List<ResultFile> resultFiles = SearchFiltering.runQueries(filters, caseDb, centralRepoDb);
|
||||
|
||||
// Add the data to resultFiles for any attributes needed for sorting and grouping
|
||||
addAttributes(attributesNeededForGroupingOrSorting, resultFiles, caseDb, centralRepoDb);
|
||||
@ -2077,13 +2077,13 @@ class FileSearch {
|
||||
* @param groupSortingType The algorithm to sort the groups by.
|
||||
* @param fileSortingMethod The method to sort the files by.
|
||||
*/
|
||||
SearchKey(String userName, List<FileSearchFiltering.FileFilter> filters,
|
||||
SearchKey(String userName, List<AbstractFilter> filters,
|
||||
AttributeType groupAttributeType,
|
||||
FileGroup.GroupSortingAlgorithm groupSortingType,
|
||||
FileSorter.SortingMethod fileSortingMethod) {
|
||||
StringBuilder searchStringBuilder = new StringBuilder();
|
||||
searchStringBuilder.append(userName);
|
||||
for (FileSearchFiltering.FileFilter filter : filters) {
|
||||
for (AbstractFilter filter : filters) {
|
||||
searchStringBuilder.append(filter.toString());
|
||||
}
|
||||
searchStringBuilder.append(groupAttributeType).append(groupSortingType).append(fileSortingMethod);
|
||||
|
@ -28,12 +28,17 @@ import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.coreutils.FileTypeUtils;
|
||||
|
||||
/**
|
||||
* Utility enums for FileSearch.
|
||||
* Utility enums for searches made for files with Discovery.
|
||||
*/
|
||||
final class FileSearchData {
|
||||
final class FileSearchData extends SearchData {
|
||||
|
||||
private final static long BYTES_PER_MB = 1000000;
|
||||
|
||||
@Override
|
||||
ResultType getResultType() {
|
||||
return ResultType.FILE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum representing how often the file occurs in the Central Repository.
|
||||
*/
|
||||
@ -384,14 +389,6 @@ final class FileSearchData {
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of enums that are valid for filtering.
|
||||
*
|
||||
* @return enums that can be used to filter
|
||||
*/
|
||||
static List<FileType> getOptionsForFiltering() {
|
||||
return Arrays.asList(IMAGE, VIDEO);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ final class GroupListPanel extends javax.swing.JPanel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private FileType resultType = null;
|
||||
private Map<GroupKey, Integer> groupMap = null;
|
||||
private List<FileSearchFiltering.FileFilter> searchfilters;
|
||||
private List<AbstractFilter> searchfilters;
|
||||
private FileSearch.AttributeType groupingAttribute;
|
||||
private FileGroup.GroupSortingAlgorithm groupSort;
|
||||
private FileSorter.SortingMethod fileSortMethod;
|
||||
|
@ -161,9 +161,9 @@ final class HashSetFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
FileSearchFiltering.FileFilter getFilter() {
|
||||
AbstractFilter getFilter() {
|
||||
if (hashSetCheckbox.isSelected()) {
|
||||
return new FileSearchFiltering.HashSetFilter(hashSetList.getSelectedValuesList());
|
||||
return new SearchFiltering.HashSetFilter(hashSetList.getSelectedValuesList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -103,4 +103,9 @@ final class ImageFilterPanel extends AbstractFiltersPanel {
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JSplitPane imageFiltersSplitPane;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
SearchData.ResultType getResultType() {
|
||||
return SearchData.ResultType.FILE;
|
||||
}
|
||||
}
|
||||
|
@ -163,9 +163,9 @@ final class InterestingItemsFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
FileSearchFiltering.FileFilter getFilter() {
|
||||
AbstractFilter getFilter() {
|
||||
if (interestingItemsCheckbox.isSelected()) {
|
||||
return new FileSearchFiltering.InterestingFileSetFilter(interestingItemsList.getSelectedValuesList());
|
||||
return new SearchFiltering.InterestingFileSetFilter(interestingItemsList.getSelectedValuesList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -167,9 +167,9 @@ final class ObjectDetectedFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
FileSearchFiltering.FileFilter getFilter() {
|
||||
AbstractFilter getFilter() {
|
||||
if (objectsCheckbox.isSelected()) {
|
||||
return new FileSearchFiltering.ObjectDetectionFilter(objectsList.getSelectedValuesList());
|
||||
return new SearchFiltering.ObjectDetectionFilter(objectsList.getSelectedValuesList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ final class PageWorker extends SwingWorker<Void, Void> {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(PageWorker.class.getName());
|
||||
private static final String USER_NAME_PROPERTY = "user.name"; //NON-NLS
|
||||
private final List<FileSearchFiltering.FileFilter> searchfilters;
|
||||
private final List<AbstractFilter> searchfilters;
|
||||
private final FileSearch.AttributeType groupingAttribute;
|
||||
private final FileGroup.GroupSortingAlgorithm groupSort;
|
||||
private final FileSorter.SortingMethod fileSortMethod;
|
||||
@ -61,7 +61,7 @@ final class PageWorker extends SwingWorker<Void, Void> {
|
||||
* @param resultType The type of files which exist in the group.
|
||||
* @param centralRepo The central repository to be used.
|
||||
*/
|
||||
PageWorker(List<FileSearchFiltering.FileFilter> searchfilters, FileSearch.AttributeType groupingAttribute,
|
||||
PageWorker(List<AbstractFilter> searchfilters, FileSearch.AttributeType groupingAttribute,
|
||||
FileGroup.GroupSortingAlgorithm groupSort, FileSorter.SortingMethod fileSortMethod, GroupKey groupKey,
|
||||
int startingEntry, int pageSize, FileSearchData.FileType resultType, CentralRepository centralRepo) {
|
||||
this.searchfilters = searchfilters;
|
||||
|
@ -24,7 +24,7 @@ import javax.swing.DefaultListModel;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import org.sleuthkit.autopsy.discovery.FileSearchFiltering.ParentSearchTerm;
|
||||
import org.sleuthkit.autopsy.discovery.SearchFiltering.ParentSearchTerm;
|
||||
|
||||
/**
|
||||
* Panel to allow configuration of the Parent Folder filter.
|
||||
@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.discovery.FileSearchFiltering.ParentSearchTerm;
|
||||
final class ParentFolderFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private DefaultListModel<FileSearchFiltering.ParentSearchTerm> parentListModel;
|
||||
private DefaultListModel<SearchFiltering.ParentSearchTerm> parentListModel;
|
||||
private static final String[] DEFAULT_IGNORED_PATHS = {"/Windows/", "/Program Files/"}; //NON-NLS
|
||||
|
||||
/**
|
||||
@ -49,7 +49,7 @@ final class ParentFolderFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
private void setUpParentPathFilter() {
|
||||
fullRadioButton.setSelected(true);
|
||||
includeRadioButton.setSelected(true);
|
||||
parentListModel = (DefaultListModel<FileSearchFiltering.ParentSearchTerm>) parentList.getModel();
|
||||
parentListModel = (DefaultListModel<SearchFiltering.ParentSearchTerm>) parentList.getModel();
|
||||
for (String ignorePath : DEFAULT_IGNORED_PATHS) {
|
||||
parentListModel.add(parentListModel.size(), new ParentSearchTerm(ignorePath, false, false));
|
||||
}
|
||||
@ -291,8 +291,8 @@ final class ParentFolderFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
*
|
||||
* @return The list of entered ParentSearchTerm objects
|
||||
*/
|
||||
private List<FileSearchFiltering.ParentSearchTerm> getParentPaths() {
|
||||
List<FileSearchFiltering.ParentSearchTerm> results = new ArrayList<>();
|
||||
private List<SearchFiltering.ParentSearchTerm> getParentPaths() {
|
||||
List<SearchFiltering.ParentSearchTerm> results = new ArrayList<>();
|
||||
for (int i = 0; i < parentListModel.getSize(); i++) {
|
||||
results.add(parentListModel.get(i));
|
||||
}
|
||||
@ -305,9 +305,9 @@ final class ParentFolderFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
FileSearchFiltering.FileFilter getFilter() {
|
||||
AbstractFilter getFilter() {
|
||||
if (parentCheckbox.isSelected()) {
|
||||
return new FileSearchFiltering.ParentFilter(getParentPaths());
|
||||
return new SearchFiltering.ParentFilter(getParentPaths());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -154,9 +154,9 @@ final class PastOccurrencesFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
FileSearchFiltering.FileFilter getFilter() {
|
||||
AbstractFilter getFilter() {
|
||||
if (pastOccurrencesCheckbox.isSelected()) {
|
||||
return new FileSearchFiltering.FrequencyFilter(crFrequencyList.getSelectedValuesList());
|
||||
return new SearchFiltering.FrequencyFilter(crFrequencyList.getSelectedValuesList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ final class ResultsPanel extends javax.swing.JPanel {
|
||||
private final VideoThumbnailViewer videoThumbnailViewer;
|
||||
private final ImageThumbnailViewer imageThumbnailViewer;
|
||||
private final DocumentPreviewViewer documentPreviewViewer;
|
||||
private List<FileSearchFiltering.FileFilter> searchFilters;
|
||||
private List<AbstractFilter> searchFilters;
|
||||
private FileSearch.AttributeType groupingAttribute;
|
||||
private FileGroup.GroupSortingAlgorithm groupSort;
|
||||
private FileSorter.SortingMethod fileSortMethod;
|
||||
|
19
Core/src/org/sleuthkit/autopsy/discovery/SearchData.java
Normal file
19
Core/src/org/sleuthkit/autopsy/discovery/SearchData.java
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.discovery;
|
||||
|
||||
|
||||
abstract class SearchData {
|
||||
|
||||
enum ResultType {
|
||||
FILE,
|
||||
ARTIFACT;
|
||||
}
|
||||
|
||||
abstract ResultType getResultType();
|
||||
|
||||
|
||||
}
|
@ -42,7 +42,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
|
||||
/**
|
||||
* Run various filters to return a subset of files from the current case.
|
||||
*/
|
||||
class FileSearchFiltering {
|
||||
class SearchFiltering {
|
||||
|
||||
/**
|
||||
* Run the given filters to get a list of matching files.
|
||||
@ -54,13 +54,13 @@ class FileSearchFiltering {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static List<ResultFile> runQueries(List<FileFilter> filters, SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException {
|
||||
static List<ResultFile> runQueries(List<AbstractFilter> filters, SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException {
|
||||
if (caseDb == null) {
|
||||
throw new FileSearchException("Case DB parameter is null"); // NON-NLS
|
||||
}
|
||||
// Combine all the SQL queries from the filters into one query
|
||||
String combinedQuery = "";
|
||||
for (FileFilter filter : filters) {
|
||||
for (AbstractFilter filter : filters) {
|
||||
if (!filter.getWhereClause().isEmpty()) {
|
||||
if (!combinedQuery.isEmpty()) {
|
||||
combinedQuery += " AND "; // NON-NLS
|
||||
@ -94,7 +94,7 @@ class FileSearchFiltering {
|
||||
* @throws TskCoreException
|
||||
* @throws FileSearchException
|
||||
*/
|
||||
private static List<ResultFile> getResultList(List<FileFilter> filters, String combinedQuery, SleuthkitCase caseDb, CentralRepository centralRepoDb) throws TskCoreException, FileSearchException {
|
||||
private static List<ResultFile> getResultList(List<AbstractFilter> filters, String combinedQuery, SleuthkitCase caseDb, CentralRepository centralRepoDb) throws TskCoreException, FileSearchException {
|
||||
// Get all matching abstract files
|
||||
List<ResultFile> resultList = new ArrayList<>();
|
||||
List<AbstractFile> sqlResults = caseDb.findAllFilesWhere(combinedQuery);
|
||||
@ -110,7 +110,7 @@ class FileSearchFiltering {
|
||||
}
|
||||
|
||||
// Now run any non-SQL filters.
|
||||
for (FileFilter filter : filters) {
|
||||
for (AbstractFilter filter : filters) {
|
||||
if (filter.useAlternateFilter()) {
|
||||
resultList = filter.applyAlternateFilter(resultList, caseDb, centralRepoDb);
|
||||
}
|
||||
@ -122,61 +122,10 @@ class FileSearchFiltering {
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for the filters.
|
||||
*/
|
||||
static abstract class FileFilter {
|
||||
|
||||
/**
|
||||
* Returns part of a query on the tsk_files table that can be AND-ed
|
||||
* with other pieces
|
||||
*
|
||||
* @return the SQL query or an empty string if there is no SQL query for
|
||||
* this filter.
|
||||
*/
|
||||
abstract String getWhereClause();
|
||||
|
||||
/**
|
||||
* Indicates whether this filter needs to use the secondary, non-SQL
|
||||
* method applyAlternateFilter().
|
||||
*
|
||||
* @return false by default
|
||||
*/
|
||||
boolean useAlternateFilter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a secondary filter that does not operate on tsk_files.
|
||||
*
|
||||
* @param currentResults The current list of matching files; empty if no
|
||||
* filters have yet been run.
|
||||
* @param caseDb The case database
|
||||
* @param centralRepoDb The central repo database. Can be null if the
|
||||
* filter does not require it.
|
||||
*
|
||||
* @return The list of files that match this filter (and any that came
|
||||
* before it)
|
||||
*
|
||||
* @throws FileSearchException
|
||||
*/
|
||||
List<ResultFile> applyAlternateFilter(List<ResultFile> currentResults, SleuthkitCase caseDb,
|
||||
CentralRepository centralRepoDb) throws FileSearchException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a description of the selected filter.
|
||||
*
|
||||
* @return A description of the filter
|
||||
*/
|
||||
abstract String getDesc();
|
||||
}
|
||||
|
||||
/**
|
||||
* A filter for specifying the file size
|
||||
*/
|
||||
static class SizeFilter extends FileFilter {
|
||||
static class SizeFilter extends AbstractFilter {
|
||||
|
||||
private final List<FileSize> fileSizes;
|
||||
|
||||
@ -316,7 +265,7 @@ class FileSearchFiltering {
|
||||
/**
|
||||
* A filter for specifying parent path (either full path or substring)
|
||||
*/
|
||||
static class ParentFilter extends FileFilter {
|
||||
static class ParentFilter extends AbstractFilter {
|
||||
|
||||
private final List<ParentSearchTerm> parentSearchTerms;
|
||||
|
||||
@ -393,7 +342,7 @@ class FileSearchFiltering {
|
||||
/**
|
||||
* A filter for specifying data sources
|
||||
*/
|
||||
static class DataSourceFilter extends FileFilter {
|
||||
static class DataSourceFilter extends AbstractFilter {
|
||||
|
||||
private final List<DataSource> dataSources;
|
||||
|
||||
@ -444,7 +393,7 @@ class FileSearchFiltering {
|
||||
* A filter for specifying keyword list names. A file must contain a keyword
|
||||
* from one of the given lists to pass.
|
||||
*/
|
||||
static class KeywordListFilter extends FileFilter {
|
||||
static class KeywordListFilter extends AbstractFilter {
|
||||
|
||||
private final List<String> listNames;
|
||||
|
||||
@ -480,7 +429,7 @@ class FileSearchFiltering {
|
||||
/**
|
||||
* A filter for specifying file types.
|
||||
*/
|
||||
static class FileTypeFilter extends FileFilter {
|
||||
static class FileTypeFilter extends AbstractFilter {
|
||||
|
||||
private final List<FileType> categories;
|
||||
|
||||
@ -539,7 +488,7 @@ class FileSearchFiltering {
|
||||
/**
|
||||
* A filter for specifying frequency in the central repository.
|
||||
*/
|
||||
static class FrequencyFilter extends FileFilter {
|
||||
static class FrequencyFilter extends AbstractFilter {
|
||||
|
||||
private final List<Frequency> frequencies;
|
||||
|
||||
@ -609,7 +558,7 @@ class FileSearchFiltering {
|
||||
* A filter for specifying hash set names. A file must match one of the
|
||||
* given sets to pass.
|
||||
*/
|
||||
static class HashSetFilter extends FileFilter {
|
||||
static class HashSetFilter extends AbstractFilter {
|
||||
|
||||
private final List<String> setNames;
|
||||
|
||||
@ -647,7 +596,7 @@ class FileSearchFiltering {
|
||||
* A filter for specifying interesting file set names. A file must match one
|
||||
* of the given sets to pass.
|
||||
*/
|
||||
static class InterestingFileSetFilter extends FileFilter {
|
||||
static class InterestingFileSetFilter extends AbstractFilter {
|
||||
|
||||
private final List<String> setNames;
|
||||
|
||||
@ -685,7 +634,7 @@ class FileSearchFiltering {
|
||||
* A filter for specifying object types detected. A file must match one of
|
||||
* the given types to pass.
|
||||
*/
|
||||
static class ObjectDetectionFilter extends FileFilter {
|
||||
static class ObjectDetectionFilter extends AbstractFilter {
|
||||
|
||||
private final List<String> typeNames;
|
||||
|
||||
@ -723,7 +672,7 @@ class FileSearchFiltering {
|
||||
* A filter for specifying the score. A file must have one of the given
|
||||
* scores to pass
|
||||
*/
|
||||
static class ScoreFilter extends FileFilter {
|
||||
static class ScoreFilter extends AbstractFilter {
|
||||
|
||||
private final List<Score> scores;
|
||||
|
||||
@ -800,7 +749,7 @@ class FileSearchFiltering {
|
||||
* A filter for specifying tag names. A file must contain one of the given
|
||||
* tags to pass.
|
||||
*/
|
||||
static class TagsFilter extends FileFilter {
|
||||
static class TagsFilter extends AbstractFilter {
|
||||
|
||||
private final List<TagName> tagNames;
|
||||
|
||||
@ -849,7 +798,7 @@ class FileSearchFiltering {
|
||||
* A filter for specifying that the file must have user content suspected
|
||||
* data.
|
||||
*/
|
||||
static class UserCreatedFilter extends FileFilter {
|
||||
static class UserCreatedFilter extends AbstractFilter {
|
||||
|
||||
/**
|
||||
* Create the ExifFilter
|
||||
@ -877,7 +826,7 @@ class FileSearchFiltering {
|
||||
* A filter for specifying that the file must have been marked as notable in
|
||||
* the CR.
|
||||
*/
|
||||
static class NotableFilter extends FileFilter {
|
||||
static class NotableFilter extends AbstractFilter {
|
||||
|
||||
/**
|
||||
* Create the NotableFilter
|
||||
@ -945,7 +894,7 @@ class FileSearchFiltering {
|
||||
/**
|
||||
* A filter for specifying if known files should be included.
|
||||
*/
|
||||
static class KnownFilter extends FileFilter {
|
||||
static class KnownFilter extends AbstractFilter {
|
||||
|
||||
@Override
|
||||
String getWhereClause() {
|
||||
@ -992,7 +941,7 @@ class FileSearchFiltering {
|
||||
return result;
|
||||
}
|
||||
|
||||
private FileSearchFiltering() {
|
||||
private SearchFiltering(){
|
||||
// Class should not be instantiated
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ final class SearchWorker extends SwingWorker<Void, Void> {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(SearchWorker.class.getName());
|
||||
private static final String USER_NAME_PROPERTY = "user.name"; //NON-NLS
|
||||
private final List<FileSearchFiltering.FileFilter> filters;
|
||||
private final List<AbstractFilter> filters;
|
||||
private final FileSearch.AttributeType groupingAttr;
|
||||
private final FileSorter.SortingMethod fileSort;
|
||||
private final FileGroup.GroupSortingAlgorithm groupSortAlgorithm;
|
||||
@ -52,7 +52,7 @@ final class SearchWorker extends SwingWorker<Void, Void> {
|
||||
* @param groupSort The Algorithm to sort groups by.
|
||||
* @param fileSortMethod The SortingMethod to use for files.
|
||||
*/
|
||||
SearchWorker(CentralRepository centralRepo, List<FileSearchFiltering.FileFilter> searchfilters, FileSearch.AttributeType groupingAttribute, FileGroup.GroupSortingAlgorithm groupSort, FileSorter.SortingMethod fileSortMethod) {
|
||||
SearchWorker(CentralRepository centralRepo, List<AbstractFilter> searchfilters, FileSearch.AttributeType groupingAttribute, FileGroup.GroupSortingAlgorithm groupSort, FileSorter.SortingMethod fileSortMethod) {
|
||||
centralRepoDb = centralRepo;
|
||||
filters = searchfilters;
|
||||
groupingAttr = groupingAttribute;
|
||||
|
@ -178,9 +178,9 @@ final class SizeFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
FileSearchFiltering.FileFilter getFilter() {
|
||||
AbstractFilter getFilter() {
|
||||
if (sizeCheckbox.isSelected()) {
|
||||
return new FileSearchFiltering.SizeFilter(sizeList.getSelectedValuesList());
|
||||
return new SearchFiltering.SizeFilter(sizeList.getSelectedValuesList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -98,9 +98,9 @@ final class UserCreatedFilterPanel extends AbstractDiscoveryFilterPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
FileSearchFiltering.FileFilter getFilter() {
|
||||
AbstractFilter getFilter() {
|
||||
if (userCreatedCheckbox.isSelected()) {
|
||||
return new FileSearchFiltering.UserCreatedFilter();
|
||||
return new SearchFiltering.UserCreatedFilter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -105,4 +105,9 @@ final class VideoFilterPanel extends AbstractFiltersPanel {
|
||||
private javax.swing.JSplitPane videoFiltersSplitPane;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
SearchData.ResultType getResultType() {
|
||||
return SearchData.ResultType.FILE;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user