mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Updated to use new mime type field of abstract file
This commit is contained in:
parent
ad7c704b65
commit
b0d69166ca
@ -69,31 +69,6 @@ class SampleFileIngestModule implements FileIngestModule {
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
this.context = context;
|
||||
refCounter.incrementAndGet(context.getJobId());
|
||||
|
||||
synchronized (SampleFileIngestModule.class) {
|
||||
if (attrId == -1) {
|
||||
// For this sample, make a new attribute type to use to post
|
||||
// results to the blackboard. There are many standard blackboard
|
||||
// artifact and attribute types and you should use them instead
|
||||
// creating new ones to facilitate use of your results by other
|
||||
// modules.
|
||||
Case autopsyCase = Case.getCurrentCase();
|
||||
SleuthkitCase sleuthkitCase = autopsyCase.getSleuthkitCase();
|
||||
try {
|
||||
// See if the attribute type has already been defined.
|
||||
attrId = sleuthkitCase.getAttrTypeID("ATTR_SAMPLE");
|
||||
if (attrId == -1) {
|
||||
attrId = sleuthkitCase.addAttrType("ATTR_SAMPLE", "Sample Attribute");
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
IngestServices ingestServices = IngestServices.getInstance();
|
||||
Logger logger = ingestServices.getLogger(SampleIngestModuleFactory.getModuleName());
|
||||
logger.log(Level.SEVERE, "Failed to create blackboard attribute", ex);
|
||||
attrId = -1;
|
||||
throw new IngestModuleException(ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -245,15 +245,7 @@ class SevenZipExtractor {
|
||||
private ArchiveFormat get7ZipOptions(AbstractFile archiveFile) {
|
||||
// try to get the file type from the BB
|
||||
String detectedFormat = null;
|
||||
try {
|
||||
ArrayList<BlackboardAttribute> attributes = archiveFile.getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG);
|
||||
for (BlackboardAttribute attribute : attributes) {
|
||||
detectedFormat = attribute.getValueString();
|
||||
break;
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.WARNING, "Couldn't obtain file attributes for file: " + archiveFile.toString(), ex); //NON-NLS
|
||||
}
|
||||
detectedFormat = archiveFile.getMIMEType();
|
||||
|
||||
if (detectedFormat == null) {
|
||||
logger.log(Level.WARNING, "Could not detect format for file: {0}", archiveFile); //NON-NLS
|
||||
|
@ -148,7 +148,6 @@ public class FileExtMismatchIngestModule implements FileIngestModule {
|
||||
* @return false if the two match. True if there is a mismatch.
|
||||
*/
|
||||
private boolean compareSigTypeToExt(AbstractFile abstractFile) {
|
||||
try {
|
||||
String currActualExt = abstractFile.getNameExtension();
|
||||
|
||||
// If we are skipping names with no extension
|
||||
@ -158,9 +157,7 @@ public class FileExtMismatchIngestModule implements FileIngestModule {
|
||||
|
||||
// find file_sig value.
|
||||
// check the blackboard for a file type attribute
|
||||
ArrayList<BlackboardAttribute> attributes = abstractFile.getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG);
|
||||
for (BlackboardAttribute attribute : attributes) {
|
||||
String currActualSigType = attribute.getValueString();
|
||||
String currActualSigType = abstractFile.getMIMEType();
|
||||
if (settings.skipFilesWithTextPlainMimeType()) {
|
||||
if (!currActualExt.isEmpty() && currActualSigType.equals("text/plain")) { //NON-NLS
|
||||
return false;
|
||||
@ -182,10 +179,6 @@ public class FileExtMismatchIngestModule implements FileIngestModule {
|
||||
return true; //potential mismatch
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.WARNING, "Error while getting file signature from blackboard.", ex); //NON-NLS
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -122,17 +122,10 @@ public class FileTypeDetector {
|
||||
* @throws TskCoreException
|
||||
*/
|
||||
public String getFileType(AbstractFile file) throws TskCoreException {
|
||||
String fileType;
|
||||
ArrayList<BlackboardAttribute> attributes = file.getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG);
|
||||
for (BlackboardAttribute attribute : attributes) {
|
||||
/**
|
||||
* Get the first TSK_FILE_TYPE_SIG attribute.
|
||||
*/
|
||||
fileType = attribute.getValueString();
|
||||
if (null != fileType && !fileType.isEmpty()) {
|
||||
String fileType = file.getMIMEType();
|
||||
if(null != fileType) {
|
||||
return fileType;
|
||||
}
|
||||
}
|
||||
return detectAndPostToBlackboard(file);
|
||||
}
|
||||
|
||||
@ -158,6 +151,7 @@ public class FileTypeDetector {
|
||||
*/
|
||||
BlackboardArtifact getInfoArt = file.getGenInfoArtifact();
|
||||
BlackboardAttribute batt = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG.getTypeID(), FileTypeIdModuleFactory.getModuleName(), mimeType);
|
||||
file.setMIMEType(mimeType);
|
||||
getInfoArt.addAttribute(batt);
|
||||
}
|
||||
return mimeType;
|
||||
|
@ -236,8 +236,8 @@ class ReportGenerator {
|
||||
*
|
||||
* @param artifactTypeSelections the enabled/disabled state of the artifact
|
||||
* types to be included in the report
|
||||
* @param tagSelections the enabled/disabled state of the tag names
|
||||
* to be included in the report
|
||||
* @param tagSelections the enabled/disabled state of the tag names to be
|
||||
* included in the report
|
||||
*/
|
||||
public void generateTableReports(Map<ARTIFACT_TYPE, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) {
|
||||
if (!tableProgress.isEmpty() && null != artifactTypeSelections) {
|
||||
@ -1841,13 +1841,7 @@ class ReportGenerator {
|
||||
AbstractFile file = skCase.getAbstractFileById(getObjectID());
|
||||
if (file != null) {
|
||||
orderedRowData.add(file.getName());
|
||||
orderedRowData.add(file.getNameExtension());
|
||||
List<BlackboardAttribute> attrs = file.getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG);
|
||||
if (!attrs.isEmpty()) {
|
||||
orderedRowData.add(attrs.get(0).getValueString());
|
||||
} else {
|
||||
orderedRowData.add("");
|
||||
}
|
||||
orderedRowData.add(file.getMIMEType());
|
||||
orderedRowData.add(file.getUniquePath());
|
||||
} else {
|
||||
// Make empty rows to make sure the formatting is correct
|
||||
|
@ -123,7 +123,8 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
file.getGid(),
|
||||
file.getMd5Hash(),
|
||||
file.getKnown(),
|
||||
file.getParentPath());
|
||||
file.getParentPath(),
|
||||
null);
|
||||
this.analyzed = new SimpleBooleanProperty(analyzed);
|
||||
this.file = file;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user