mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 02:07:42 +00:00
flesh out FileTypeCategory. Inline usage of FileTypeCategories. refactor InterCaseCommonAttributeSearcher.determineMimeTypeFilter() for readability.
This commit is contained in:
parent
69eb3e6d7f
commit
72e3f14ae4
@ -21,16 +21,15 @@ package org.sleuthkit.autopsy.commonfilesearch;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.coreutils.FileTypeUtils;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
@ -131,69 +130,6 @@ public abstract class AbstractCommonAttributeSearcher {
|
||||
return instanceCollatedCommonFiles;
|
||||
}
|
||||
|
||||
/*
|
||||
* The set of the MIME types that will be checked for extension mismatches
|
||||
* when checkType is ONLY_MEDIA. ".jpg", ".jpeg", ".png", ".psd", ".nef",
|
||||
* ".tiff", ".bmp", ".tec" ".aaf", ".3gp", ".asf", ".avi", ".m1v", ".m2v",
|
||||
* //NON-NLS ".m4v", ".mp4", ".mov", ".mpeg", ".mpg", ".mpe", ".mp4", ".rm",
|
||||
* ".wmv", ".mpv", ".flv", ".swf"
|
||||
*/
|
||||
static final Set<String> MEDIA_PICS_VIDEO_MIME_TYPES = Stream.of(
|
||||
"image/bmp", //NON-NLS
|
||||
"image/gif", //NON-NLS
|
||||
"image/jpeg", //NON-NLS
|
||||
"image/png", //NON-NLS
|
||||
"image/tiff", //NON-NLS
|
||||
"image/vnd.adobe.photoshop", //NON-NLS
|
||||
"image/x-raw-nikon", //NON-NLS
|
||||
"image/x-ms-bmp", //NON-NLS
|
||||
"image/x-icon", //NON-NLS
|
||||
"video/webm", //NON-NLS
|
||||
"video/3gpp", //NON-NLS
|
||||
"video/3gpp2", //NON-NLS
|
||||
"video/ogg", //NON-NLS
|
||||
"video/mpeg", //NON-NLS
|
||||
"video/mp4", //NON-NLS
|
||||
"video/quicktime", //NON-NLS
|
||||
"video/x-msvideo", //NON-NLS
|
||||
"video/x-flv", //NON-NLS
|
||||
"video/x-m4v", //NON-NLS
|
||||
"video/x-ms-wmv", //NON-NLS
|
||||
"application/vnd.ms-asf", //NON-NLS
|
||||
"application/vnd.rn-realmedia", //NON-NLS
|
||||
"application/x-shockwave-flash" //NON-NLS
|
||||
).collect(Collectors.toSet());
|
||||
|
||||
/*
|
||||
* The set of the MIME types that will be checked for extension mismatches
|
||||
* when checkType is ONLY_TEXT_FILES. ".doc", ".docx", ".odt", ".xls",
|
||||
* ".xlsx", ".ppt", ".pptx" ".txt", ".rtf", ".log", ".text", ".xml" ".html",
|
||||
* ".htm", ".css", ".js", ".php", ".aspx" ".pdf"
|
||||
*/
|
||||
static final Set<String> TEXT_FILES_MIME_TYPES = Stream.of(
|
||||
"text/plain", //NON-NLS
|
||||
"text/css", //NON-NLS
|
||||
"text/html", //NON-NLS
|
||||
"text/csv", //NON-NLS
|
||||
"application/rtf", //NON-NLS
|
||||
"application/pdf", //NON-NLS
|
||||
"text/calendar", //NON-NLS
|
||||
"application/json", //NON-NLS
|
||||
"application/javascript", //NON-NLS
|
||||
"application/xml", //NON-NLS
|
||||
"application/x-msoffice", //NON-NLS
|
||||
"application/x-ooxml", //NON-NLS
|
||||
"application/msword", //NON-NLS
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", //NON-NLS
|
||||
"application/vnd.ms-powerpoint", //NON-NLS
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation", //NON-NLS
|
||||
"application/vnd.ms-excel", //NON-NLS
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.presentation", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.spreadsheet", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.text" //NON-NLS
|
||||
).collect(Collectors.toSet());
|
||||
|
||||
/**
|
||||
* @return the filterByMedia
|
||||
*/
|
||||
@ -221,4 +157,16 @@ public abstract class AbstractCommonAttributeSearcher {
|
||||
void setFilterByDoc(boolean filterByDoc) {
|
||||
this.filterByDoc = filterByDoc;
|
||||
}
|
||||
|
||||
|
||||
Set<String> getMimeTypesToFilterOn() {
|
||||
Set<String> mimeTypesToFilterOn = new HashSet<>();
|
||||
if (isFilterByMedia()) {
|
||||
mimeTypesToFilterOn.addAll(FileTypeUtils.FileTypeCategory.VISUAL.getMediaTypes());
|
||||
}
|
||||
if (isFilterByDoc()) {
|
||||
mimeTypesToFilterOn.addAll(FileTypeUtils.FileTypeCategory.DOCUMENTS.getMediaTypes());
|
||||
}
|
||||
return mimeTypesToFilterOn;
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ import java.util.Set;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type;
|
||||
import static org.sleuthkit.autopsy.commonfilesearch.AbstractCommonAttributeSearcher.MEDIA_PICS_VIDEO_MIME_TYPES;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* Algorithm which finds files anywhere in the Central Repo which also occur in
|
||||
@ -57,14 +57,7 @@ public class AllInterCaseCommonAttributeSearcher extends InterCaseCommonAttribut
|
||||
public CommonAttributeSearchResults findMatches() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException {
|
||||
InterCaseSearchResultsProcessor eamDbAttrInst = new InterCaseSearchResultsProcessor(corAttrType);
|
||||
Map<Integer, CommonAttributeValueList> interCaseCommonFiles = eamDbAttrInst.findInterCaseCommonAttributeValues(Case.getCurrentCase());
|
||||
|
||||
Set<String> mimeTypesToFilterOn = new HashSet<>();
|
||||
if (isFilterByMedia()) {
|
||||
mimeTypesToFilterOn.addAll(MEDIA_PICS_VIDEO_MIME_TYPES);
|
||||
}
|
||||
if (isFilterByDoc()) {
|
||||
mimeTypesToFilterOn.addAll(TEXT_FILES_MIME_TYPES);
|
||||
}
|
||||
Set<String> mimeTypesToFilterOn = getMimeTypesToFilterOn();
|
||||
return new CommonAttributeSearchResults(interCaseCommonFiles, this.frequencyPercentageThreshold, this.corAttrType, mimeTypesToFilterOn);
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
*
|
||||
* Copyright 2018 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.
|
||||
@ -23,10 +23,10 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.datamodel.HashUtility;
|
||||
@ -45,25 +45,22 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
@SuppressWarnings("PMD.AbstractNaming")
|
||||
public abstract class IntraCaseCommonAttributeSearcher extends AbstractCommonAttributeSearcher {
|
||||
|
||||
private static final String FILTER_BY_MIME_TYPES_WHERE_CLAUSE = " and mime_type in (%s)"; //NON-NLS // where %s is csv list of mime_types to filter on
|
||||
|
||||
private final Map<Long, String> dataSourceIdToNameMap;
|
||||
|
||||
|
||||
/**
|
||||
* Subclass this to implement different algorithms for getting common files.
|
||||
*
|
||||
* @param dataSourceIdMap a map of obj_id to datasource name
|
||||
* @param dataSourceIdMap a map of obj_id to datasource name
|
||||
* @param filterByMediaMimeType match only on files whose mime types can be
|
||||
* broadly categorized as media types
|
||||
* @param filterByDocMimeType match only on files whose mime types can be
|
||||
* broadly categorized as document types
|
||||
* broadly categorized as media types
|
||||
* @param filterByDocMimeType match only on files whose mime types can be
|
||||
* broadly categorized as document types
|
||||
*/
|
||||
IntraCaseCommonAttributeSearcher(Map<Long, String> dataSourceIdMap, boolean filterByMediaMimeType, boolean filterByDocMimeType, int percentageThreshold) {
|
||||
super(filterByMediaMimeType, filterByDocMimeType, percentageThreshold);
|
||||
this.dataSourceIdToNameMap = dataSourceIdMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Map<Long, String> getDataSourceIdToNameMap() {
|
||||
return Collections.unmodifiableMap(this.dataSourceIdToNameMap);
|
||||
}
|
||||
@ -96,7 +93,8 @@ public abstract class IntraCaseCommonAttributeSearcher extends AbstractCommonAtt
|
||||
* tree table tab to the top component.
|
||||
*
|
||||
* @return a data object with all of the matched files in a hierarchical
|
||||
* format
|
||||
* format
|
||||
*
|
||||
* @throws TskCoreException
|
||||
* @throws NoCurrentCaseException
|
||||
* @throws SQLException
|
||||
@ -149,29 +147,18 @@ public abstract class IntraCaseCommonAttributeSearcher extends AbstractCommonAtt
|
||||
* expression will be conjoined to base query with an AND operator.
|
||||
*
|
||||
* @return sql fragment of the form: 'and "mime_type" in ( [comma delimited
|
||||
* list of mime types] )' or empty string in the event that no types to
|
||||
* filter on were given.
|
||||
* list of mime types] )' or empty string in the event that no types
|
||||
* to filter on were given.
|
||||
*/
|
||||
String determineMimeTypeFilter() {
|
||||
|
||||
Set<String> mimeTypesToFilterOn = new HashSet<>();
|
||||
String mimeTypeString = "";
|
||||
if (isFilterByMedia()) {
|
||||
mimeTypesToFilterOn.addAll(MEDIA_PICS_VIDEO_MIME_TYPES);
|
||||
Set<String> mimeTypesToFilterOn = getMimeTypesToFilterOn();
|
||||
if (mimeTypesToFilterOn.isEmpty()) {
|
||||
return "";
|
||||
} else {
|
||||
String mimeTypeString = mimeTypesToFilterOn.stream()
|
||||
.map(s -> "'" + s + "'")
|
||||
.collect(Collectors.joining(","));
|
||||
return String.format(" and mime_type in (%s)", new Object[]{mimeTypeString});
|
||||
}
|
||||
if (isFilterByDoc()) {
|
||||
mimeTypesToFilterOn.addAll(TEXT_FILES_MIME_TYPES);
|
||||
}
|
||||
StringBuilder mimeTypeFilter = new StringBuilder(mimeTypesToFilterOn.size());
|
||||
if (!mimeTypesToFilterOn.isEmpty()) {
|
||||
for (String mimeType : mimeTypesToFilterOn) {
|
||||
mimeTypeFilter.append(SINGLE_QUOTE).append(mimeType).append(SINGLE_QUTOE_COMMA);
|
||||
}
|
||||
mimeTypeString = mimeTypeFilter.toString().substring(0, mimeTypeFilter.length() - 1);
|
||||
mimeTypeString = String.format(FILTER_BY_MIME_TYPES_WHERE_CLAUSE, new Object[]{mimeTypeString});
|
||||
}
|
||||
return mimeTypeString;
|
||||
}
|
||||
static final String SINGLE_QUTOE_COMMA = "',";
|
||||
static final String SINGLE_QUOTE = "'";
|
||||
}
|
||||
|
@ -20,17 +20,15 @@
|
||||
package org.sleuthkit.autopsy.commonfilesearch;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type;
|
||||
import static org.sleuthkit.autopsy.commonfilesearch.AbstractCommonAttributeSearcher.MEDIA_PICS_VIDEO_MIME_TYPES;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -52,7 +50,7 @@ public class SingleInterCaseCommonAttributeSearcher extends InterCaseCommonAttri
|
||||
* @throws EamDbException
|
||||
*/
|
||||
public SingleInterCaseCommonAttributeSearcher(int correlationCaseId, boolean filterByMediaMimeType,
|
||||
boolean filterByDocMimeType, Type corAttrType, int percentageThreshold) throws EamDbException {
|
||||
boolean filterByDocMimeType, Type corAttrType, int percentageThreshold) throws EamDbException {
|
||||
super(filterByMediaMimeType, filterByDocMimeType, corAttrType, percentageThreshold);
|
||||
|
||||
this.corrleationCaseId = correlationCaseId;
|
||||
@ -81,16 +79,11 @@ public class SingleInterCaseCommonAttributeSearcher extends InterCaseCommonAttri
|
||||
CommonAttributeSearchResults findFiles(CorrelationCase correlationCase) throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException {
|
||||
InterCaseSearchResultsProcessor eamDbAttrInst = new InterCaseSearchResultsProcessor(this.corAttrType);
|
||||
Map<Integer, CommonAttributeValueList> interCaseCommonFiles = eamDbAttrInst.findSingleInterCaseCommonAttributeValues(Case.getCurrentCase(), correlationCase);
|
||||
Set<String> mimeTypesToFilterOn = new HashSet<>();
|
||||
if (isFilterByMedia()) {
|
||||
mimeTypesToFilterOn.addAll(MEDIA_PICS_VIDEO_MIME_TYPES);
|
||||
}
|
||||
if (isFilterByDoc()) {
|
||||
mimeTypesToFilterOn.addAll(TEXT_FILES_MIME_TYPES);
|
||||
}
|
||||
Set<String> mimeTypesToFilterOn = getMimeTypesToFilterOn();
|
||||
return new CommonAttributeSearchResults(interCaseCommonFiles, this.frequencyPercentageThreshold, this.corAttrType, mimeTypesToFilterOn);
|
||||
}
|
||||
|
||||
|
||||
@NbBundle.Messages({
|
||||
"# {0} - case name",
|
||||
"# {1} - attr type",
|
||||
|
@ -20,12 +20,10 @@ package org.sleuthkit.autopsy.coreutils;
|
||||
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.Arrays;
|
||||
import static java.util.Arrays.asList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.openide.util.NbBundle;
|
||||
|
||||
/**
|
||||
@ -33,12 +31,13 @@ import org.openide.util.NbBundle;
|
||||
*/
|
||||
public final class FileTypeUtils {
|
||||
|
||||
private static final ImmutableCollection<String> IMAGE_MIME_TYPES;
|
||||
private static final ImmutableCollection<String> AUDIO_MIME_TYPES;
|
||||
private static final ImmutableCollection<String> VIDEO_MIME_TYPES;
|
||||
private static final ImmutableCollection<String> MEDIA_MIME_TYPES;
|
||||
private static final ImmutableCollection<String> DOCUMENT_MIME_TYPES;
|
||||
private static final ImmutableCollection<String> EXECUTABLE_MIME_TYPES;
|
||||
private static final ImmutableSet<String> IMAGE_MIME_TYPES;
|
||||
private static final ImmutableSet<String> AUDIO_MIME_TYPES;
|
||||
private static final ImmutableSet<String> VIDEO_MIME_TYPES;
|
||||
private static final ImmutableSet<String> MULTI_MEDIA_MIME_TYPES;
|
||||
private static final ImmutableSet<String> DOCUMENT_MIME_TYPES;
|
||||
private static final ImmutableSet<String> EXECUTABLE_MIME_TYPES;
|
||||
private static final ImmutableSet<String> VISUAL_MEDIA_MIME_TYPES;
|
||||
|
||||
static {
|
||||
IMAGE_MIME_TYPES = new ImmutableSet.Builder<String>()
|
||||
@ -51,19 +50,17 @@ public final class FileTypeUtils {
|
||||
"image/vnd.adobe.photoshop", //NON-NLS
|
||||
"image/x-raw-nikon", //NON-NLS
|
||||
"image/x-ms-bmp", //NON-NLS
|
||||
"image/x-icon" //NON-NLS
|
||||
"image/x-icon", //NON-NLS
|
||||
"image/webp", //NON-NLS
|
||||
"image/vnd.microsoft.icon" //NON-NLS
|
||||
).build();
|
||||
AUDIO_MIME_TYPES = new ImmutableSet.Builder<String>()
|
||||
.add("image/bmp", //NON-NLS
|
||||
"image/gif", //NON-NLS
|
||||
"image/jpeg", //NON-NLS
|
||||
"image/png", //NON-NLS
|
||||
"image/tiff", //NON-NLS
|
||||
"image/vnd.adobe.photoshop", //NON-NLS
|
||||
"image/x-raw-nikon", //NON-NLS
|
||||
"image/x-ms-bmp", //NON-NLS
|
||||
"image/x-icon") //NON-NLS
|
||||
.build();
|
||||
.add("audio/midi", //NON-NLS
|
||||
"audio/mpeg", //NON-NLS
|
||||
"audio/webm", //NON-NLS
|
||||
"audio/ogg", //NON-NLS
|
||||
"audio/wav" //NON-NLS
|
||||
).build();
|
||||
VIDEO_MIME_TYPES = new ImmutableSet.Builder<String>()
|
||||
.add("video/webm", //NON-NLS
|
||||
"video/3gpp", //NON-NLS
|
||||
@ -75,12 +72,23 @@ public final class FileTypeUtils {
|
||||
"video/x-msvideo", //NON-NLS
|
||||
"video/x-flv", //NON-NLS
|
||||
"video/x-m4v", //NON-NLS
|
||||
"video/x-ms-wmv")
|
||||
.build();
|
||||
MEDIA_MIME_TYPES = new ImmutableSet.Builder<String>()
|
||||
"video/x-ms-wmv"//NON-NLS
|
||||
).build();
|
||||
VISUAL_MEDIA_MIME_TYPES = new ImmutableSet.Builder<String>()
|
||||
.addAll(IMAGE_MIME_TYPES)
|
||||
.addAll(VIDEO_MIME_TYPES)
|
||||
.add("application/vnd.ms-asf", //NON-NLS
|
||||
"application/vnd.rn-realmedia", //NON-NLS
|
||||
"application/x-shockwave-flash" //NON-NLS
|
||||
).build();
|
||||
MULTI_MEDIA_MIME_TYPES = new ImmutableSet.Builder<String>()
|
||||
.addAll(IMAGE_MIME_TYPES)
|
||||
.addAll(AUDIO_MIME_TYPES)
|
||||
.addAll(VIDEO_MIME_TYPES)
|
||||
.add("application/vnd.ms-asf", //NON-NLS
|
||||
"application/vnd.rn-realmedia", //NON-NLS
|
||||
"application/x-shockwave-flash" //NON-NLS
|
||||
)
|
||||
.build();
|
||||
DOCUMENT_MIME_TYPES = new ImmutableSet.Builder<String>()
|
||||
.add("text/plain", //NON-NLS
|
||||
@ -102,7 +110,7 @@ public final class FileTypeUtils {
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.presentation", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.spreadsheet", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.text" //NON-NLS)
|
||||
"application/vnd.oasis.opendocument.text" //NON-NLS
|
||||
).build();
|
||||
EXECUTABLE_MIME_TYPES = new ImmutableSet.Builder<String>()
|
||||
.add("application/x-bat",//NON-NLS
|
||||
@ -131,77 +139,36 @@ public final class FileTypeUtils {
|
||||
"FileTypeUtils.FileTypeCategory.Video.displayName=Video",
|
||||
"FileTypeUtils.FileTypeCategory.Image.displayName=Image",
|
||||
"FileTypeUtils.FileTypeCategory.Media.displayName=Media",
|
||||
"FileTypeUtils.FileTypeCategory.Visual.displayName=Visual",
|
||||
"FileTypeUtils.FileTypeCategory.Documents.displayName=Documents",
|
||||
"FileTypeUtils.FileTypeCategory.Executables.displayName=Executables"})
|
||||
public enum FileTypeCategory {
|
||||
static public enum FileTypeCategory {
|
||||
|
||||
IMAGE(Bundle.FileTypeUtils_FileTypeCategory_Image_displayName(), Collections.emptyList(), Collections.emptyList()),
|
||||
VIDEO(Bundle.FileTypeUtils_FileTypeCategory_Video_displayName(), Collections.emptyList(), Collections.emptyList()),
|
||||
AUDIO(Bundle.FileTypeUtils_FileTypeCategory_Audio_displayName(), Collections.emptyList(), Collections.emptyList()),
|
||||
Media(Bundle.FileTypeUtils_FileTypeCategory_Media_displayName(),
|
||||
CollectionUtils.union(Arrays.asList(ImageIO.getReaderMIMETypes()),
|
||||
Arrays.asList(
|
||||
"image/bmp", //NON-NLS
|
||||
"image/gif", //NON-NLS
|
||||
"image/jpeg", //NON-NLS
|
||||
"image/png", //NON-NLS
|
||||
"image/tiff", //NON-NLS
|
||||
"image/vnd.adobe.photoshop", //NON-NLS
|
||||
"image/x-raw-nikon", //NON-NLS
|
||||
"image/x-ms-bmp", //NON-NLS
|
||||
"image/x-icon", //NON-NLS
|
||||
"video/webm", //NON-NLS
|
||||
"video/3gpp", //NON-NLS
|
||||
"video/3gpp2", //NON-NLS
|
||||
"video/ogg", //NON-NLS
|
||||
"video/mpeg", //NON-NLS
|
||||
"video/mp4", //NON-NLS
|
||||
"video/quicktime", //NON-NLS
|
||||
"video/x-msvideo", //NON-NLS
|
||||
"video/x-flv", //NON-NLS
|
||||
"video/x-m4v", //NON-NLS
|
||||
"video/x-ms-wmv", //NON-NLS
|
||||
"application/vnd.ms-asf", //NON-NLS
|
||||
"application/vnd.rn-realmedia", //NON-NLS
|
||||
"application/x-shockwave-flash" //NON-NLS
|
||||
)), Collections.emptyList()),
|
||||
Executable(Bundle.FileTypeUtils_FileTypeCategory_Executables_displayName(),
|
||||
Arrays.asList(
|
||||
"application/x-bat",//NON-NLS
|
||||
"application/x-dosexec",//NON-NLS
|
||||
"application/vnd.microsoft.portable-executable",//NON-NLS
|
||||
"application/x-msdownload",//NON-NLS
|
||||
"application/exe",//NON-NLS
|
||||
"application/x-exe",//NON-NLS
|
||||
"application/dos-exe",//NON-NLS
|
||||
"vms/exe",//NON-NLS
|
||||
"application/x-winexe",//NON-NLS
|
||||
"application/msdos-windows",//NON-NLS
|
||||
"application/x-msdos-program"//NON-NLS
|
||||
), Collections.emptyList()),
|
||||
Documents(Bundle.FileTypeUtils_FileTypeCategory_Documents_displayName(),
|
||||
Arrays.asList("text/*", //NON-NLS
|
||||
"application/rtf", //NON-NLS
|
||||
"application/pdf", //NON-NLS
|
||||
"application/json", //NON-NLS
|
||||
"application/javascript", //NON-NLS
|
||||
"application/xml", //NON-NLS
|
||||
"application/x-msoffice", //NON-NLS
|
||||
"application/x-ooxml", //NON-NLS
|
||||
"application/msword", //NON-NLS
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", //NON-NLS
|
||||
"application/vnd.ms-powerpoint", //NON-NLS
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation", //NON-NLS
|
||||
"application/vnd.ms-excel", //NON-NLS
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.presentation", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.spreadsheet", //NON-NLS
|
||||
"application/vnd.oasis.opendocument.text" //NON-NLS)
|
||||
), Collections.emptyList());
|
||||
IMAGE(Bundle.FileTypeUtils_FileTypeCategory_Image_displayName(),
|
||||
IMAGE_MIME_TYPES,
|
||||
Collections.emptyList()),
|
||||
VIDEO(Bundle.FileTypeUtils_FileTypeCategory_Video_displayName(),
|
||||
VIDEO_MIME_TYPES,
|
||||
Collections.emptyList()),
|
||||
AUDIO(Bundle.FileTypeUtils_FileTypeCategory_Audio_displayName(),
|
||||
AUDIO_MIME_TYPES,
|
||||
Collections.emptyList()),
|
||||
VISUAL(Bundle.FileTypeUtils_FileTypeCategory_Media_displayName(),
|
||||
VISUAL_MEDIA_MIME_TYPES,
|
||||
Collections.emptyList()),
|
||||
MEDIA(Bundle.FileTypeUtils_FileTypeCategory_Media_displayName(),
|
||||
MULTI_MEDIA_MIME_TYPES,
|
||||
Collections.emptyList()),
|
||||
EXECUTABLE(Bundle.FileTypeUtils_FileTypeCategory_Executables_displayName(),
|
||||
EXECUTABLE_MIME_TYPES,
|
||||
Collections.emptyList()),
|
||||
DOCUMENTS(Bundle.FileTypeUtils_FileTypeCategory_Documents_displayName(),
|
||||
DOCUMENT_MIME_TYPES,
|
||||
Collections.emptyList());
|
||||
|
||||
private final String displayName;
|
||||
private final ImmutableCollection<String> mediaTypes;
|
||||
private final ImmutableCollection<String> extensions;
|
||||
private final ImmutableSet<String> mediaTypes;
|
||||
private final ImmutableSet<String> extensions;
|
||||
|
||||
private FileTypeCategory(String displayName, Collection<String> mediaTypes, Collection<String> extensions) {
|
||||
this.displayName = displayName;
|
||||
@ -213,12 +180,12 @@ public final class FileTypeUtils {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public ImmutableCollection<String> getMediaTypes() {
|
||||
public ImmutableSet<String> getMediaTypes() {
|
||||
return mediaTypes;
|
||||
|
||||
}
|
||||
|
||||
public ImmutableCollection<String> getExtension() {
|
||||
public ImmutableSet<String> getExtension() {
|
||||
return extensions;
|
||||
}
|
||||
}
|
||||
|
@ -18,17 +18,16 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.timeline.utils;
|
||||
|
||||
import com.google.common.net.MediaType;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.openide.util.NbBundle;
|
||||
import static org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory.Documents;
|
||||
import static org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory.Executable;
|
||||
import static org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory.Media;
|
||||
import org.sleuthkit.datamodel.TimelineManager;
|
||||
import org.sleuthkit.datamodel.timeline.TimelineFilter.FileTypeFilter;
|
||||
import org.sleuthkit.datamodel.timeline.TimelineFilter.FileTypesFilter;
|
||||
import static org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory.MEDIA;
|
||||
import static org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory.EXECUTABLE;
|
||||
import static org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory.DOCUMENTS;
|
||||
|
||||
/**
|
||||
* Utilities to deal with TimelineFilters
|
||||
@ -38,9 +37,9 @@ public final class FilterUtils {
|
||||
private static final Set<String> NON_OTHER_MIME_TYPES = new HashSet<>();
|
||||
|
||||
static {
|
||||
NON_OTHER_MIME_TYPES.addAll(Documents.getMediaTypes());
|
||||
NON_OTHER_MIME_TYPES.addAll(Executable.getMediaTypes());
|
||||
NON_OTHER_MIME_TYPES.addAll(Media.getMediaTypes());
|
||||
NON_OTHER_MIME_TYPES.addAll(DOCUMENTS.getMediaTypes());
|
||||
NON_OTHER_MIME_TYPES.addAll(EXECUTABLE.getMediaTypes());
|
||||
NON_OTHER_MIME_TYPES.addAll(MEDIA.getMediaTypes());
|
||||
}
|
||||
|
||||
private FilterUtils() {
|
||||
@ -57,9 +56,9 @@ public final class FilterUtils {
|
||||
public static FileTypesFilter createDefaultFileTypesFilter() {
|
||||
FileTypesFilter fileTypesFilter = new FileTypesFilter();
|
||||
|
||||
fileTypesFilter.addSubFilter(new FileTypeFilter(Media.getDisplayName(), Media.getMediaTypes()));
|
||||
fileTypesFilter.addSubFilter(new FileTypeFilter(Documents.getDisplayName(), Documents.getMediaTypes()));
|
||||
fileTypesFilter.addSubFilter(new FileTypeFilter(Executable.getDisplayName(), Executable.getMediaTypes()));
|
||||
fileTypesFilter.addSubFilter(new FileTypeFilter(MEDIA.getDisplayName(), MEDIA.getMediaTypes()));
|
||||
fileTypesFilter.addSubFilter(new FileTypeFilter(DOCUMENTS.getDisplayName(), DOCUMENTS.getMediaTypes()));
|
||||
fileTypesFilter.addSubFilter(new FileTypeFilter(EXECUTABLE.getDisplayName(), EXECUTABLE.getMediaTypes()));
|
||||
fileTypesFilter.addSubFilter(new InverseFileTypeFilter(Bundle.FilterUtils_otherFilter_displayName(), NON_OTHER_MIME_TYPES));
|
||||
|
||||
return fileTypesFilter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user