Merge branch 'custom-release-2.11.0' of https://github.com/sleuthkit/autopsy into custom-release-2.11.0

This commit is contained in:
Raman 2018-01-08 10:08:28 -05:00
commit 1b9165ce31
19 changed files with 134 additions and 225 deletions

View File

@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.corecomponents;
import java.awt.Dimension; import java.awt.Dimension;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static java.util.Objects.nonNull;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
@ -30,7 +29,6 @@ import javax.swing.JPanel;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.TskCoreException;
/** /**
* Video viewer part of the Media View layered pane. Uses different engines * Video viewer part of the Media View layered pane. Uses different engines
@ -153,11 +151,9 @@ public abstract class MediaViewVideoPanel extends JPanel implements FrameCapture
if (AUDIO_EXTENSIONS.contains("." + extension) || getExtensionsList().contains("." + extension)) { if (AUDIO_EXTENSIONS.contains("." + extension) || getExtensionsList().contains("." + extension)) {
SortedSet<String> mimeTypes = new TreeSet<>(getMimeTypes()); SortedSet<String> mimeTypes = new TreeSet<>(getMimeTypes());
try { try {
String mimeType = new FileTypeDetector().detect(file); String mimeType = new FileTypeDetector().detectMIMEType(file);
if (nonNull(mimeType)) { return mimeTypes.contains(mimeType);
return mimeTypes.contains(mimeType); } catch (FileTypeDetector.FileTypeDetectorInitException ex) {
}
} catch (FileTypeDetector.FileTypeDetectorInitException | TskCoreException ex) {
logger.log(Level.WARNING, "Failed to look up mimetype for " + file.getName() + " using FileTypeDetector. Fallingback on AbstractFile.isMimeType", ex); logger.log(Level.WARNING, "Failed to look up mimetype for " + file.getName() + " using FileTypeDetector. Fallingback on AbstractFile.isMimeType", ex);
if (!mimeTypes.isEmpty() && file.isMimeType(mimeTypes) == AbstractFile.MimeMatchEnum.TRUE) { if (!mimeTypes.isEmpty() && file.isMimeType(mimeTypes) == AbstractFile.MimeMatchEnum.TRUE) {
return true; return true;

View File

@ -263,12 +263,12 @@ public class ImageUtils {
return true; return true;
} else { } else {
try { try {
String mimeType = getFileTypeDetector().detect(file); String mimeType = getFileTypeDetector().detectMIMEType(file);
if (StringUtils.isNotBlank(mimeTypePrefix) && mimeType.startsWith(mimeTypePrefix)) { if (StringUtils.isNotBlank(mimeTypePrefix) && mimeType.startsWith(mimeTypePrefix)) {
return true; return true;
} }
return supportedMimeTypes.contains(mimeType); return supportedMimeTypes.contains(mimeType);
} catch (FileTypeDetectorInitException | TskCoreException ex) { } catch (FileTypeDetectorInitException ex) {
LOGGER.log(Level.SEVERE, "Error determining MIME type of " + getContentPathSafe(file), ex);//NON-NLS LOGGER.log(Level.SEVERE, "Error determining MIME type of " + getContentPathSafe(file), ex);//NON-NLS
return false; return false;
} }

View File

@ -21,10 +21,14 @@ package org.sleuthkit.autopsy.ingest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.TskCoreException;
/** /**
* This class manages a sequence of file level ingest modules for a data source * This class manages a sequence of file level ingest modules for a data source
@ -136,10 +140,17 @@ final class FileIngestPipeline {
break; break;
} }
} }
file.close();
if (!this.job.isCancelled()) { if (!this.job.isCancelled()) {
// Save any properties that have not already been saved to the database
try{
file.save();
} catch (TskCoreException ex){
Logger.getLogger(FileIngestPipeline.class.getName()).log(Level.SEVERE, "Failed to save data for file " + file.getId(), ex); //NON-NLS
}
IngestManager.getInstance().fireFileIngestDone(file); IngestManager.getInstance().fireFileIngestDone(file);
} }
file.close();
} }
FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task); FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task);
return errors; return errors;

View File

@ -28,7 +28,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.poi.hwpf.usermodel.Picture; import org.apache.poi.hwpf.usermodel.Picture;
@ -135,27 +134,22 @@ class MSOfficeEmbeddedContentExtractor {
* supported. Else it returns false. * supported. Else it returns false.
*/ */
boolean isContentExtractionSupported(AbstractFile abstractFile) { boolean isContentExtractionSupported(AbstractFile abstractFile) {
try { String abstractFileMimeType = fileTypeDetector.detectMIMEType(abstractFile);
String abstractFileMimeType = fileTypeDetector.getFileType(abstractFile); for (SupportedExtractionFormats s : SupportedExtractionFormats.values()) {
for (SupportedExtractionFormats s : SupportedExtractionFormats.values()) { if (s.toString().equals(abstractFileMimeType)) {
if (s.toString().equals(abstractFileMimeType)) { abstractFileExtractionFormat = s;
abstractFileExtractionFormat = s; return true;
return true;
}
} }
return false;
} catch (TskCoreException ex) {
LOGGER.log(Level.SEVERE, "Error executing FileTypeDetector.getFileType()", ex); // NON-NLS
return false;
} }
return false;
} }
/** /**
* This method selects the appropriate process of extracting embedded * This method selects the appropriate process of extracting embedded
* content from files using either Tika or POI classes. Once the content has * content from files using either Tika or POI classes. Once the content has
* been extracted as files, the method adds them to the DB and fires a * been extracted as files, the method adds them to the DB and fires a
* ModuleContentEvent. ModuleContent Event is not fired if no content * ModuleContentEvent. ModuleContent Event is not fired if no content was
* was extracted from the processed file. * extracted from the processed file.
* *
* @param abstractFile The abstract file to be processed. * @param abstractFile The abstract file to be processed.
*/ */

View File

@ -131,9 +131,7 @@ class SevenZipExtractor {
} }
/** /**
* This method returns true if the file format is currently supported. Else * Checks whether extraction is supported for a file, based on MIME type.
* it returns false. Attempt extension based detection in case Apache Tika
* based detection fails.
* *
* @param abstractFile The AbstractFilw whose mimetype is to be determined. * @param abstractFile The AbstractFilw whose mimetype is to be determined.
* *
@ -141,26 +139,12 @@ class SevenZipExtractor {
* supported. Else it returns false. * supported. Else it returns false.
*/ */
boolean isSevenZipExtractionSupported(AbstractFile abstractFile) { boolean isSevenZipExtractionSupported(AbstractFile abstractFile) {
try { String abstractFileMimeType = fileTypeDetector.detectMIMEType(abstractFile);
String abstractFileMimeType = fileTypeDetector.getFileType(abstractFile); for (SupportedArchiveExtractionFormats s : SupportedArchiveExtractionFormats.values()) {
for (SupportedArchiveExtractionFormats s : SupportedArchiveExtractionFormats.values()) { if (s.toString().equals(abstractFileMimeType)) {
if (s.toString().equals(abstractFileMimeType)) {
return true;
}
}
return false;
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Error executing FileTypeDetector.getFileType()", ex); // NON-NLS
}
// attempt extension matching
final String extension = abstractFile.getNameExtension();
for (String supportedExtension : SUPPORTED_EXTENSIONS) {
if (extension.equals(supportedExtension)) {
return true; return true;
} }
} }
return false; return false;
} }

View File

@ -188,13 +188,9 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter
/* /*
* Qualify the MIME type. * Qualify the MIME type.
*/ */
try { String mimeType = fileTypeDetector.detectMIMEType(file);
String mimeType = fileTypeDetector.getFileType(file); if (mimeType.equals("application/octet-stream")) {
if (mimeType != null && mimeType.equals("application/octet-stream")) { possiblyEncrypted = true;
possiblyEncrypted = true;
}
} catch (TskCoreException ex) {
throw new TskCoreException("Failed to detect the file type.", ex);
} }
} }
} }

View File

@ -104,8 +104,8 @@ public final class ExifParserFileIngestModule implements FileIngestModule {
blackboard = Case.getCurrentCase().getServices().getBlackboard(); blackboard = Case.getCurrentCase().getServices().getBlackboard();
//skip unalloc //skip unalloc
if ((content.getType().equals(TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS) || if ((content.getType().equals(TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS)
(content.getType().equals(TSK_DB_FILES_TYPE_ENUM.SLACK)))) { || (content.getType().equals(TSK_DB_FILES_TYPE_ENUM.SLACK)))) {
return ProcessResult.OK; return ProcessResult.OK;
} }
@ -250,17 +250,8 @@ public final class ExifParserFileIngestModule implements FileIngestModule {
* @return true if to be processed * @return true if to be processed
*/ */
private boolean parsableFormat(AbstractFile f) { private boolean parsableFormat(AbstractFile f) {
try { String mimeType = fileTypeDetector.detectMIMEType(f);
String mimeType = fileTypeDetector.getFileType(f); return supportedMimeTypes.contains(mimeType);
if (mimeType != null) {
return supportedMimeTypes.contains(mimeType);
} else {
return false;
}
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Failed to detect file type", ex); //NON-NLS
return false;
}
} }
@Override @Override

View File

@ -39,7 +39,6 @@ import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE; import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TskData;
import org.sleuthkit.datamodel.TskData.FileKnown; import org.sleuthkit.datamodel.TskData.FileKnown;
import org.sleuthkit.datamodel.TskException; import org.sleuthkit.datamodel.TskException;
@ -163,17 +162,14 @@ public class FileExtMismatchIngestModule implements FileIngestModule {
* *
* @return false if the two match. True if there is a mismatch. * @return false if the two match. True if there is a mismatch.
*/ */
private boolean compareSigTypeToExt(AbstractFile abstractFile) throws TskCoreException { private boolean compareSigTypeToExt(AbstractFile abstractFile) {
String currActualExt = abstractFile.getNameExtension(); String currActualExt = abstractFile.getNameExtension();
// If we are skipping names with no extension // If we are skipping names with no extension
if (settings.skipFilesWithNoExtension() && currActualExt.isEmpty()) { if (settings.skipFilesWithNoExtension() && currActualExt.isEmpty()) {
return false; return false;
} }
String currActualSigType = detector.getFileType(abstractFile); String currActualSigType = detector.detectMIMEType(abstractFile);
if (currActualSigType == null) {
return false;
}
if (settings.getCheckType() != CHECK_TYPE.ALL) { if (settings.getCheckType() != CHECK_TYPE.ALL) {
if (settings.getCheckType() == CHECK_TYPE.NO_TEXT_FILES) { if (settings.getCheckType() == CHECK_TYPE.NO_TEXT_FILES) {
if (!currActualExt.isEmpty() && currActualSigType.equals("text/plain")) { //NON-NLS if (!currActualExt.isEmpty() && currActualSigType.equals("text/plain")) { //NON-NLS

View File

@ -18,7 +18,6 @@
*/ */
package org.sleuthkit.autopsy.modules.filetypeid; package org.sleuthkit.autopsy.modules.filetypeid;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -30,12 +29,9 @@ import java.util.stream.Collectors;
import org.apache.tika.Tika; import org.apache.tika.Tika;
import org.apache.tika.io.TikaInputStream; import org.apache.tika.io.TikaInputStream;
import org.apache.tika.mime.MimeTypes; import org.apache.tika.mime.MimeTypes;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.services.Blackboard; import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
@ -175,61 +171,16 @@ public class FileTypeDetector {
} }
/** /**
* Gets the MIME type of a file, detecting it if it is not already known. If * Detects the MIME type of a file.
* detection is necessary, the result is added to the case database.
*
* IMPORTANT: This method should only be called by ingest modules. All other
* clients should call AbstractFile.getMIMEType, and may call
* FileTypeDetector.detect, if AbstractFile.getMIMEType returns null.
*
* @param file The file.
*
* @return A MIME type name. If file type could not be detected or results
* were uncertain, octet-stream is returned.
*
* @throws TskCoreException if detection is required and there is a problem
* writing the result to the case database.
*/
public String getFileType(AbstractFile file) throws TskCoreException {
return detect(file, true);
}
/**
* Detects the MIME type of a file. The result is not added to the case
* database.
* *
* @param file The file to test. * @param file The file to test.
* *
* @return A MIME type name. If file type could not be detected or results * @return A MIME type name. If file type could not be detected, or results
* were uncertain, octet-stream is returned. * were uncertain, octet-stream is returned.
*
* @throws TskCoreException If there is a problem writing the result to the
* case database.
*/ */
public String detect(AbstractFile file) throws TskCoreException { public String detectMIMEType(AbstractFile file) {
return detect(file, false);
}
/**
* Detects the MIME type of a file. The result is saved to the case database
* only if the add to case database flag is set.
*
* @param file The file to test.
* @param addToCaseDb Whether the MIME type should be added to the case
* database. This flag is part of a partial workaround
* for a check-then-act-race condition (see notes in
* comments for details).
*
* @return A MIME type name. If file type could not be detected or results
* were uncertain, octet-stream is returned.
*
* @throws TskCoreException If there is a problem writing the result to the
* case database.
*/
private String detect(AbstractFile file, boolean addToCaseDb) throws TskCoreException {
/* /*
* Check to see if the file has already been typed. This is the "check" * Check to see if the file has already been typed.
* part of a check-then-act race condition (see note below).
*/ */
String mimeType = file.getMIMEType(); String mimeType = file.getMIMEType();
if (null != mimeType) { if (null != mimeType) {
@ -274,10 +225,10 @@ public class FileTypeDetector {
*/ */
if (null == mimeType) { if (null == mimeType) {
ReadContentInputStream stream = new ReadContentInputStream(file); ReadContentInputStream stream = new ReadContentInputStream(file);
try (TikaInputStream tikaInputStream = TikaInputStream.get(stream)) { try (TikaInputStream tikaInputStream = TikaInputStream.get(stream)) {
String tikaType = tika.detect(tikaInputStream, file.getName()); String tikaType = tika.detect(tikaInputStream, file.getName());
/* /*
* Remove the Tika suffix from the MIME type name. * Remove the Tika suffix from the MIME type name.
*/ */
@ -299,30 +250,6 @@ public class FileTypeDetector {
} }
} }
/*
* If adding the result to the case database, do so now.
*
* NOTE: This condtional is a way to deal with the check-then-act race
* condition created by the gap between querying the MIME type and
* recording it. It is not really a problem for the mime_type column of
* the tsk_files table, but it can lead to duplicate blackboard posts,
* and the posts are required to maintain backward compatibility.
* Various mitigation strategies were considered. It was decided to go
* with the policy that only ingest modules are allowed to add file
* types to the case database, at least until such time as file types
* are no longer posted to the blackboard. Of course, this is not a
* perfect solution. It's not really enforceable for community
* contributed plug ins and it does not handle the unlikely but possible
* scenario of multiple processes typing the same file for a multi-user
* case.
*/
if (addToCaseDb) {
/*
* Add the MIME type to the files table in the case database.
*/
Case.getCurrentCase().getSleuthkitCase().setFileMIMEType(file, mimeType);
}
return mimeType; return mimeType;
} }
@ -344,7 +271,9 @@ public class FileTypeDetector {
/** /**
* Determines whether or not the a file matches a user-defined custom file * Determines whether or not the a file matches a user-defined custom file
* type. * type. If the file matches and corresponds to an interesting files type
* rule, this method has the side effect of creating an interesting files
* hit artifact and indexing that artifact for keyword search.
* *
* @param file The file to test. * @param file The file to test.
* *
@ -352,37 +281,28 @@ public class FileTypeDetector {
* *
* @throws TskCoreException * @throws TskCoreException
*/ */
private String detectUserDefinedType(AbstractFile file) throws TskCoreException { private String detectUserDefinedType(AbstractFile file) {
for (FileType fileType : userDefinedFileTypes) { for (FileType fileType : userDefinedFileTypes) {
if (fileType.matches(file)) { if (fileType.matches(file)) {
if (fileType.createInterestingFileHit()) { if (fileType.createInterestingFileHit()) {
BlackboardArtifact artifact;
artifact = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
Collection<BlackboardAttribute> attributes = new ArrayList<>();
BlackboardAttribute setNameAttribute = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, FileTypeIdModuleFactory.getModuleName(), fileType.getInterestingFilesSetName());
attributes.add(setNameAttribute);
/*
* Use the MIME type as the category attribute, i.e., the
* rule that determined this file belongs to the interesting
* files set.
*/
BlackboardAttribute ruleNameAttribute = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, FileTypeIdModuleFactory.getModuleName(), fileType.getMimeType());
attributes.add(ruleNameAttribute);
artifact.addAttributes(attributes);
/*
* Index the artifact for keyword search.
*/
try { try {
Case.getCurrentCase().getServices().getBlackboard().indexArtifact(artifact); BlackboardArtifact artifact;
} catch (Blackboard.BlackboardException ex) { artifact = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
logger.log(Level.SEVERE, String.format("Unable to index blackboard artifact %d", artifact.getArtifactID()), ex); //NON-NLS Collection<BlackboardAttribute> attributes = new ArrayList<>();
MessageNotifyUtil.Notify.error( BlackboardAttribute setNameAttribute = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, FileTypeIdModuleFactory.getModuleName(), fileType.getInterestingFilesSetName());
NbBundle.getMessage(Blackboard.class, "Blackboard.unableToIndexArtifact.exception.msg"), artifact.getDisplayName()); attributes.add(setNameAttribute);
BlackboardAttribute ruleNameAttribute = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, FileTypeIdModuleFactory.getModuleName(), fileType.getMimeType());
attributes.add(ruleNameAttribute);
artifact.addAttributes(attributes);
try {
Case.getCurrentCase().getServices().getBlackboard().indexArtifact(artifact);
} catch (Blackboard.BlackboardException ex) {
logger.log(Level.SEVERE, String.format("Unable to index TSK_INTERESTING_FILE_HIT blackboard artifact %d (file obj_id=%d)", artifact.getArtifactID(), file.getId()), ex); //NON-NLS
}
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, String.format("Unable to create TSK_INTERESTING_FILE_HIT artifact for file (obj_id=%d)", file.getId()), ex); //NON-NLS
} }
} }
return fileType.getMimeType(); return fileType.getMimeType();
} }
} }
@ -396,10 +316,8 @@ public class FileTypeDetector {
* @param file The file to test. * @param file The file to test.
* *
* @return The file type name string or null, if no match is detected. * @return The file type name string or null, if no match is detected.
*
* @throws TskCoreException
*/ */
private String detectAutopsyDefinedType(AbstractFile file) throws TskCoreException { private String detectAutopsyDefinedType(AbstractFile file) {
for (FileType fileType : autopsyDefinedFileTypes) { for (FileType fileType : autopsyDefinedFileTypes) {
if (fileType.matches(file)) { if (fileType.matches(file)) {
return fileType.getMimeType(); return fileType.getMimeType();
@ -469,12 +387,58 @@ public class FileTypeDetector {
* *
* @throws TskCoreException if detection is required and there is a problem * @throws TskCoreException if detection is required and there is a problem
* writing the result to the case database. * writing the result to the case database.
* @deprecated Use getFileType instead and use AbstractFile.getMIMEType * @deprecated Use detectMIMEType instead, and call AbstractFile.setMIMEType
* instead of querying the blackboard. * and AbstractFile.save to save the result to the file object and the
* database.
*/ */
@Deprecated @Deprecated
public String detectAndPostToBlackboard(AbstractFile file) throws TskCoreException { public String detectAndPostToBlackboard(AbstractFile file) throws TskCoreException {
return getFileType(file); String fileType = detectMIMEType(file);
file.setMIMEType(fileType);
file.save();
return fileType;
}
/**
* Gets the MIME type of a file, detecting it if it is not already known. If
* detection is necessary, the result is added to the case database.
*
* @param file The file.
*
* @return A MIME type name. If file type could not be detected or results
* were uncertain, octet-stream is returned.
*
* @throws TskCoreException if detection is required and there is a problem
* writing the result to the case database.
*
* @deprecated Use detectMIMEType instead, and call AbstractFile.setMIMEType
* and AbstractFile.save to save the result to the file object and the
* database.
*/
@Deprecated
public String getFileType(AbstractFile file) throws TskCoreException {
String fileType = detectMIMEType(file);
file.setMIMEType(fileType);
file.save();
return fileType;
}
/**
* Detects the MIME type of a file. The result is not added to the case
* database.
*
* @param file The file to test.
*
* @return A MIME type name. If file type could not be detected or results
* were uncertain, octet-stream is returned.
*
* @throws TskCoreException
* @deprecated Use detectMIMEType instead.
*/
@Deprecated
public String detect(AbstractFile file) throws TskCoreException {
String fileType = detectMIMEType(file);
return fileType;
} }
} }

View File

@ -91,7 +91,7 @@ public class FileTypeIdIngestModule implements FileIngestModule {
*/ */
try { try {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
fileTypeDetector.getFileType(file); file.setMIMEType(fileTypeDetector.detectMIMEType(file));
addToTotals(jobId, (System.currentTimeMillis() - startTime)); addToTotals(jobId, (System.currentTimeMillis() - startTime));
return ProcessResult.OK; return ProcessResult.OK;
} catch (Exception e) { } catch (Exception e) {

View File

@ -176,7 +176,8 @@ public class HashDbIngestModule implements FileIngestModule {
if (md5Hash == null || md5Hash.isEmpty()) { if (md5Hash == null || md5Hash.isEmpty()) {
try { try {
long calcstart = System.currentTimeMillis(); long calcstart = System.currentTimeMillis();
md5Hash = HashUtility.calculateMd5(file); md5Hash = HashUtility.calculateMd5Hash(file);
file.setMd5Hash(md5Hash);
long delta = (System.currentTimeMillis() - calcstart); long delta = (System.currentTimeMillis() - calcstart);
totals.totalCalctime.addAndGet(delta); totals.totalCalctime.addAndGet(delta);
@ -205,20 +206,8 @@ public class HashDbIngestModule implements FileIngestModule {
foundBad = true; foundBad = true;
totals.totalKnownBadCount.incrementAndGet(); totals.totalKnownBadCount.incrementAndGet();
try { file.setKnown(TskData.FileKnown.BAD);
skCase.setKnown(file, TskData.FileKnown.BAD);
} catch (TskException ex) {
logger.log(Level.WARNING, "Couldn't set notable state for file " + name + " - see sleuthkit log for details", ex); //NON-NLS
services.postMessage(IngestMessage.createErrorMessage(
HashLookupModuleFactory.getModuleName(),
NbBundle.getMessage(this.getClass(),
"HashDbIngestModule.hashLookupErrorMsg",
name),
NbBundle.getMessage(this.getClass(),
"HashDbIngestModule.settingKnownBadStateErr",
name)));
ret = ProcessResult.ERROR;
}
String hashSetName = db.getDisplayName(); String hashSetName = db.getDisplayName();
String comment = ""; String comment = "";
@ -262,13 +251,8 @@ public class HashDbIngestModule implements FileIngestModule {
try { try {
long lookupstart = System.currentTimeMillis(); long lookupstart = System.currentTimeMillis();
if (db.lookupMD5Quick(file)) { if (db.lookupMD5Quick(file)) {
try { file.setKnown(TskData.FileKnown.KNOWN);
skCase.setKnown(file, TskData.FileKnown.KNOWN); break;
break;
} catch (TskException ex) {
logger.log(Level.WARNING, "Couldn't set known state for file " + name + " - see sleuthkit log for details", ex); //NON-NLS
ret = ProcessResult.ERROR;
}
} }
long delta = (System.currentTimeMillis() - lookupstart); long delta = (System.currentTimeMillis() - lookupstart);
totals.totalLookuptime.addAndGet(delta); totals.totalLookuptime.addAndGet(delta);

View File

@ -5,7 +5,7 @@ netbeans-plat-version=8.1
suite.dir=${basedir} suite.dir=${basedir}
nbplatform.active.dir=${suite.dir}/netbeans-plat/${netbeans-plat-version} nbplatform.active.dir=${suite.dir}/netbeans-plat/${netbeans-plat-version}
harness.dir=${nbplatform.active.dir}/harness harness.dir=${nbplatform.active.dir}/harness
bootstrap.url=http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/netbeans/harness/tasks.jar bootstrap.url=http://bits.netbeans.org/dev/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/netbeans/harness/tasks.jar
# Where we get the platform from. To see what versions are available, open URL in browser up to the .../updates part of the URL # Where we get the platform from. To see what versions are available, open URL in browser up to the .../updates part of the URL
autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/${netbeans-plat-version}/uc/final/distribution/catalog.xml.gz autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/${netbeans-plat-version}/uc/final/distribution/catalog.xml.gz
cluster.path=\ cluster.path=\

View File

@ -190,7 +190,7 @@ public enum FileTypeUtils {
* *
* @return true if this file is supported or false if not * @return true if this file is supported or false if not
*/ */
public static boolean isDrawable(AbstractFile file) throws TskCoreException, FileTypeDetector.FileTypeDetectorInitException { public static boolean isDrawable(AbstractFile file) throws FileTypeDetector.FileTypeDetectorInitException {
return hasDrawableMIMEType(file); return hasDrawableMIMEType(file);
} }
@ -219,8 +219,8 @@ public enum FileTypeUtils {
* type. False if a non image/video mimetype. empty Optional if a * type. False if a non image/video mimetype. empty Optional if a
* mimetype could not be detected. * mimetype could not be detected.
*/ */
static boolean hasDrawableMIMEType(AbstractFile file) throws TskCoreException, FileTypeDetector.FileTypeDetectorInitException { static boolean hasDrawableMIMEType(AbstractFile file) throws FileTypeDetector.FileTypeDetectorInitException {
String mimeType = getFileTypeDetector().detect(file).toLowerCase(); String mimeType = getFileTypeDetector().detectMIMEType(file).toLowerCase();
return isDrawableMimeType(mimeType) || (mimeType.equals("audio/x-aiff") && "tiff".equalsIgnoreCase(file.getNameExtension())); return isDrawableMimeType(mimeType) || (mimeType.equals("audio/x-aiff") && "tiff".equalsIgnoreCase(file.getNameExtension()));
} }
@ -235,9 +235,9 @@ public enum FileTypeUtils {
*/ */
public static boolean hasVideoMIMEType(AbstractFile file) { public static boolean hasVideoMIMEType(AbstractFile file) {
try { try {
String mimeType = getFileTypeDetector().detect(file).toLowerCase(); String mimeType = getFileTypeDetector().detectMIMEType(file).toLowerCase();
return mimeType.startsWith("video/") || videoMimeTypes.contains(mimeType); return mimeType.startsWith("video/") || videoMimeTypes.contains(mimeType);
} catch (FileTypeDetector.FileTypeDetectorInitException | TskCoreException ex) { } catch (FileTypeDetector.FileTypeDetectorInitException ex) {
LOGGER.log(Level.SEVERE, "Error determining MIME type of " + getContentPathSafe(file), ex); LOGGER.log(Level.SEVERE, "Error determining MIME type of " + getContentPathSafe(file), ex);
return false; return false;
} }

View File

@ -771,7 +771,7 @@ public final class ImageGalleryController {
} }
@Override @Override
void processFile(AbstractFile f, DrawableDB.DrawableTransaction tr) throws TskCoreException { void processFile(AbstractFile f, DrawableDB.DrawableTransaction tr) {
final boolean known = f.getKnown() == TskData.FileKnown.KNOWN; final boolean known = f.getKnown() == TskData.FileKnown.KNOWN;
if (known) { if (known) {

View File

@ -41,7 +41,6 @@ import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException;
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TskData;
import org.sleuthkit.datamodel.TskData.FileKnown; import org.sleuthkit.datamodel.TskData.FileKnown;
@ -509,16 +508,10 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
return; return;
} }
String fileType; if (context.fileIngestIsCancelled()) {
try {
if (context.fileIngestIsCancelled()) {
return;
}
fileType = fileTypeDetector.getFileType(aFile);
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, String.format("Could not detect format using fileTypeDetector for file: %s", aFile), ex); //NON-NLS
return; return;
} }
String fileType = fileTypeDetector.detectMIMEType(aFile);
// we skip archive formats that are opened by the archive module. // we skip archive formats that are opened by the archive module.
// @@@ We could have a check here to see if the archive module was enabled though... // @@@ We could have a check here to see if the archive module was enabled though...

View File

@ -6,7 +6,7 @@ netbeans-plat-version=8.1
suite.dir=${basedir} suite.dir=${basedir}
nbplatform.active.dir=${suite.dir}/netbeans-plat/${netbeans-plat-version} nbplatform.active.dir=${suite.dir}/netbeans-plat/${netbeans-plat-version}
harness.dir=${nbplatform.active.dir}/harness harness.dir=${nbplatform.active.dir}/harness
bootstrap.url=http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/netbeans/harness/tasks.jar bootstrap.url=http://bits.netbeans.org/dev/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/netbeans/harness/tasks.jar
# Where we get the platform from. To see what versions are available, open URL in browser up to the .../updates part of the URL # Where we get the platform from. To see what versions are available, open URL in browser up to the .../updates part of the URL
autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/${netbeans-plat-version}/uc/final/distribution/catalog.xml.gz autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/${netbeans-plat-version}/uc/final/distribution/catalog.xml.gz
cluster.path=\ cluster.path=\

View File

@ -1,5 +1,5 @@
#Updated by build script #Updated by build script
#Mon, 18 Dec 2017 14:43:20 -0500 #Fri, 05 Jan 2018 10:31:22 -0500
LBL_splash_window_title=Starting Autopsy LBL_splash_window_title=Starting Autopsy
SPLASH_HEIGHT=314 SPLASH_HEIGHT=314
SPLASH_WIDTH=538 SPLASH_WIDTH=538

View File

@ -1,4 +1,4 @@
#Updated by build script #Updated by build script
#Mon, 18 Dec 2017 14:43:20 -0500 #Fri, 05 Jan 2018 10:31:22 -0500
CTL_MainWindow_Title=Autopsy 4.5.0 CTL_MainWindow_Title=Autopsy 4.5.0
CTL_MainWindow_Title_No_Project=Autopsy 4.5.0 CTL_MainWindow_Title_No_Project=Autopsy 4.5.0

View File

@ -5,7 +5,7 @@ netbeans-plat-version=8.2
suite.dir=${basedir} suite.dir=${basedir}
nbplatform.active.dir=${suite.dir}/netbeans-plat/${netbeans-plat-version} nbplatform.active.dir=${suite.dir}/netbeans-plat/${netbeans-plat-version}
harness.dir=${nbplatform.active.dir}/harness harness.dir=${nbplatform.active.dir}/harness
bootstrap.url=http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/netbeans/harness/tasks.jar bootstrap.url=http://bits.netbeans.org/dev/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/netbeans/harness/tasks.jar
# Where we get the platform from. To see what versions are available, open URL in browser up to the .../updates part of the URL # Where we get the platform from. To see what versions are available, open URL in browser up to the .../updates part of the URL
autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/${netbeans-plat-version}/uc/final/distribution/catalog.xml.gz autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/${netbeans-plat-version}/uc/final/distribution/catalog.xml.gz
cluster.path=\ cluster.path=\
@ -132,4 +132,4 @@ org.apache.tools.ant.module,\
org.netbeans.modules.whitelist,\ org.netbeans.modules.whitelist,\
org.netbeans.modules.xml.jaxb,\ org.netbeans.modules.xml.jaxb,\
org.netbeans.modules.xml.tools.java,\ org.netbeans.modules.xml.tools.java,\
org.netbeans.spi.java.hints org.netbeans.spi.java.hints