Skip to content

Commit b0f3d66

Browse files
authored
Merge pull request #1837 from CybercentreCanada/untrusted_mimes
Fallback to mimetype when yara identification yielded no conclusive result
2 parents 1fab191 + 568a30c commit b0f3d66

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

assemblyline/common/identify.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from assemblyline.common.digests import DEFAULT_BLOCKSIZE, get_digests_for_file
2424
from assemblyline.common.forge import get_cachestore, get_config, get_constants, get_datastore
25-
from assemblyline.common.identify_defaults import OLE_CLSID_GUIDs
25+
from assemblyline.common.identify_defaults import OLE_CLSID_GUIDs, untrusted_mimes
2626
from assemblyline.common.identify_defaults import magic_patterns as default_magic_patterns
2727
from assemblyline.common.identify_defaults import trusted_mimes as default_trusted_mimes
2828
from assemblyline.common.str_utils import dotdump, safe_str
@@ -392,6 +392,10 @@ def fileinfo(
392392
# Only if the file was not identified as a csv or a json
393393
data["type"] = self.yara_ident(path, data, fallback=data["type"])
394394

395+
if ("unknown" in data["type"] or data["type"] == "text/plain") and data["mime"] in untrusted_mimes:
396+
# Rely on untrusted mimes
397+
data["type"] = untrusted_mimes[data["mime"]]
398+
395399
# Extra checks for office documents
396400
# - Check for encryption
397401
if data["type"] in [

assemblyline/common/identify_defaults.py

+9
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,12 @@
447447
# Android
448448
"application/vnd.android.package-archive": "android/apk",
449449
}
450+
451+
# LibMagic mimetypes that we will fallback to when we can't determine a type
452+
untrusted_mimes = {
453+
"application/javascript": "code/javascript",
454+
"text/x-java": "code/java",
455+
"text/html": "code/html",
456+
"text/x-c++": "code/c++",
457+
"text/x-c": "code/c",
458+
}

0 commit comments

Comments
 (0)