Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions Core/src/org/sleuthkit/autopsy/coreutils/FileTypeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@
*/
public final class FileTypeUtils {

// lists augmented with https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
private static final ImmutableSet<String> IMAGE_MIME_TYPES
= new ImmutableSet.Builder<String>()
.addAll(removeAll(
asList(
// remove any empty mime types provided by ImageIO.getReaderMIMETypes()
// This prevents mime types added by SPI implementations from causing errors
// (i.e. 'jai-imageio' utilized with IcePDF)
Arrays.stream(ImageIO.getReaderMIMETypes())
.filter((mimeType) -> StringUtils.isNotBlank(mimeType))
.toArray(String[]::new)),
// remove any empty mime types provided by ImageIO.getReaderMIMETypes()
// This prevents mime types added by SPI implementations from causing errors
// (i.e. 'jai-imageio' utilized with IcePDF)
Arrays.stream(ImageIO.getReaderMIMETypes())
.filter((mimeType) -> StringUtils.isNotBlank(mimeType))
.toArray(String[]::new)),
asList("application/octet-stream"))) //this claims to be supported, but is not really an image.
.add("image/bmp", //NON-NLS
"image/gif", //NON-NLS
Expand All @@ -59,7 +60,9 @@ public final class FileTypeUtils {
"image/x-ms-bmp", //NON-NLS
"image/x-xbitmap", //NON-NLS
"image/x-portable-graymap", //NON-NLS
"image/x-portable-bitmap" //NON-NLS
"image/x-portable-bitmap", //NON-NLS
"image/avif", //NON-NLS
"image/svg+xml" //NON-NLS
).build();
private static final ImmutableSet<String> AUDIO_MIME_TYPES
= new ImmutableSet.Builder<String>()
Expand All @@ -69,7 +72,13 @@ public final class FileTypeUtils {
"audio/ogg", //NON-NLS
"audio/wav", //NON-NLS
"audio/vnd.wave", //NON-NLS
"audio/x-ms-wma"//NON-NLS
"audio/x-ms-wma",//NON-NLS
"application/x-cdf",//NON-NLS
"audio/aac",//NON-NLS
"audio/x-midi",//NON-NLS
"audio/opus",//NON-NLS
"audio/3gpp", //NON-NLS
"audio/3gpp2" //NON-NLS
).build();
private static final ImmutableSet<String> VIDEO_MIME_TYPES
= new ImmutableSet.Builder<String>()
Expand All @@ -83,7 +92,9 @@ public final class FileTypeUtils {
"video/x-msvideo", //NON-NLS
"video/x-flv", //NON-NLS
"video/x-m4v", //NON-NLS
"video/x-ms-wmv"//NON-NLS
"video/x-ms-wmv",//NON-NLS
"video/mp2t", //NON-NLS
"video/webm" //NON-NLS
).build();
private static final ImmutableSet<String> DOCUMENT_MIME_TYPES
= new ImmutableSet.Builder<String>()
Expand Down Expand Up @@ -112,7 +123,21 @@ 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
"application/epub+zip",//NON-NLS
"application/ld+json",//NON-NLS
"application/vnd.amazon.ebook",//NON-NLS
"application/vnd.visio",//NON-NLS
"application/x-abiword",//NON-NLS
"text/xml",//NON-NLS
"application/atom+xml",//NON-NLS
"text/calendar",//NON-NLS
"text/javascript",//NON-NLS
"application/vnd.mozilla.xul+xml",//NON-NLS
"application/x-csh",//NON-NLS
"application/x-httpd-php",//NON-NLS
"application/x-sh"//NON-NLS

Comment on lines +126 to +140
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FT_FILE="$(fd -i '^FileTypeUtils\.java$' | head -n1)"
SD_FILE="$(fd -i '^SearchData\.java$' | head -n1)"

echo "FileTypeUtils: ${FT_FILE}"
echo "SearchData:   ${SD_FILE}"

for mime in \
  "application/epub+zip" \
  "application/ld+json" \
  "application/vnd.amazon.ebook" \
  "application/vnd.visio" \
  "application/x-abiword" \
  "application/atom+xml" \
  "text/calendar" \
  "text/javascript" \
  "application/vnd.mozilla.xul+xml" \
  "application/x-csh" \
  "application/x-httpd-php" \
  "application/x-sh"
do
  echo "== ${mime} =="
  rg -n --fixed-strings "\"${mime}\"" "${FT_FILE}" "${SD_FILE}" || true
done

Repository: sleuthkit/autopsy

Length of output: 2044


🏁 Script executed:

# Check SearchData.java's DOCUMENT_MIME_TYPES list around lines 453-460
rg -A 30 'DOCUMENT_MIME_TYPES' Core/src/org/sleuthkit/autopsy/discovery/search/SearchData.java | head -50

Repository: sleuthkit/autopsy

Length of output: 2937


🏁 Script executed:

# Also check FileTypeUtils.java's full DOCUMENT_MIME_TYPES declaration to understand scope
rg -B 5 -A 50 'DOCUMENT_MIME_TYPES' Core/src/org/sleuthkit/autopsy/coreutils/FileTypeUtils.java | head -100

Repository: sleuthkit/autopsy

Length of output: 4593


SearchData.java must be updated to include the newly added document MIME types.

The 12 newly added MIME types to FileTypeUtils.DOCUMENT_MIME_TYPES (lines 126–140) are missing from SearchData.java's separate DOCUMENT_MIME_TYPES list (lines 453–460). This divergence will cause document categorization inconsistencies: files matching the new MIME types will be recognized as documents in FileTypeUtils but not in the Discovery search module.

Add the following to SearchData.java's DOCUMENT_MIME_TYPES:

  • application/epub+zip
  • application/ld+json
  • application/vnd.amazon.ebook
  • application/vnd.visio
  • application/x-abiword
  • application/atom+xml
  • text/calendar
  • text/javascript
  • application/vnd.mozilla.xul+xml
  • application/x-csh
  • application/x-httpd-php
  • application/x-sh
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Core/src/org/sleuthkit/autopsy/coreutils/FileTypeUtils.java` around lines 126
- 140, SearchData.java's DOCUMENT_MIME_TYPES must be updated to mirror
FileTypeUtils.DOCUMENT_MIME_TYPES so document categorization is consistent: add
the 12 missing MIME strings (application/epub+zip, application/ld+json,
application/vnd.amazon.ebook, application/vnd.visio, application/x-abiword,
application/atom+xml, text/calendar, text/javascript,
application/vnd.mozilla.xul+xml, application/x-csh, application/x-httpd-php,
application/x-sh) into the SearchData class's DOCUMENT_MIME_TYPES array/list
(the symbol to change is DOCUMENT_MIME_TYPES in SearchData.java) ensuring you
don't create duplicates and keep the same string formatting/ordering style as
FileTypeUtils.DOCUMENT_MIME_TYPES.

).build();
private static final ImmutableSet<String> EXECUTABLE_MIME_TYPES
= new ImmutableSet.Builder<String>()
Expand All @@ -126,7 +151,8 @@ public final class FileTypeUtils {
"vms/exe",//NON-NLS
"application/x-winexe",//NON-NLS
"application/msdos-windows",//NON-NLS
"application/x-msdos-program"//NON-NLS
"application/x-msdos-program",//NON-NLS,
"application/java-archive" //NON-NLS
).build();
private static final ImmutableSet<String> MULTI_MEDIA_MIME_TYPES
= new ImmutableSet.Builder<String>()
Expand Down