Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detect-file-type

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-file-type - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

157

index.js

@@ -17,4 +17,2 @@ 'use strict';

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var customFunctions = [];

@@ -25,2 +23,27 @@

function getRuleDetection() {
var v = false;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
for (var i = 0, len = args.length; i < len; i++) {
var detection = args[i];
if (typeof detection === 'boolean') {
v = detection ? v || detection : false;
} else {
v = typeof v === 'boolean' ? {} : v;
if ('ext' in detection) v.ext = detection.ext;
if ('mime' in detection) v.mime = detection.mime;
if ('iana' in detection) v.iana = detection.iana;
}
}
return v;
}
var validatedSignaturesCache = false;
exports.default = {

@@ -82,18 +105,18 @@ fromFile: function fromFile(filePath, bufferLength, callback) {

var invalidSignaturesList = this.validateSigantures();
if (invalidSignaturesList.length) {
return callback(invalidSignaturesList);
if (!validatedSignaturesCache) {
validatedSignaturesCache = this.validateSigantures();
}
if (Array.isArray(validatedSignaturesCache)) {
return callback(validatedSignaturesCache);
}
_signatures2.default.every(function (signature) {
if (_this3.detect(buffer, signature.rules)) {
result = {
ext: signature.ext,
mime: signature.mime
};
var detection = _this3.detect(buffer, signature.rules);
if (signature.iana) result.iana = signature.iana;
if (detection) {
result = getRuleDetection({}, signature, detection);
return false;
}
return true;

@@ -115,3 +138,3 @@ });

},
detect: function detect(buffer, receivedRules, type) {
detect: function detect(buffer, rules, type) {
var _this4 = this;

@@ -123,5 +146,4 @@

var rules = [].concat(_toConsumableArray(receivedRules));
var detectedRule = true;
var isDetected = true;
rules.every(function (rule) {

@@ -131,4 +153,6 @@ if (rule.type === 'equal') {

var end = Math.min(typeof rule.end === 'number' ? rule.end : buffer.length, buffer.length);
isDetected = buffer.compare(rule.bytes, undefined, undefined, rule.start || 0, end) === 0;
return _this4.isReturnFalse(isDetected, type);
detectedRule = getRuleDetection(detectedRule, buffer.compare(rule.bytes, undefined, undefined, rule.start || 0, end) === 0 ? rule : false);
return _this4.isReturnFalse(detectedRule, type);
}

@@ -139,4 +163,6 @@

var _end = Math.min(typeof rule.end === 'number' ? rule.end : buffer.length, buffer.length);
isDetected = buffer.compare(rule.bytes, undefined, undefined, rule.start || 0, _end) !== 0;
return _this4.isReturnFalse(isDetected, type);
detectedRule = getRuleDetection(detectedRule, buffer.compare(rule.bytes, undefined, undefined, rule.start || 0, _end) !== 0 ? rule : false);
return _this4.isReturnFalse(detectedRule, type);
}

@@ -146,4 +172,6 @@

if (!(rule.bytes instanceof Buffer)) rule.bytes = Buffer.from(rule.bytes, typeof rule.bytes === 'string' ? 'hex' : null);
isDetected = buffer.slice(rule.start || 0, rule.end || buffer.length).includes(rule.bytes);
return _this4.isReturnFalse(isDetected, type);
detectedRule = getRuleDetection(detectedRule, buffer.slice(rule.start || 0, rule.end || buffer.length).includes(rule.bytes) ? rule : false);
return _this4.isReturnFalse(detectedRule, type);
}

@@ -153,20 +181,27 @@

if (!(rule.bytes instanceof Buffer)) rule.bytes = Buffer.from(rule.bytes, typeof rule.bytes === 'string' ? 'hex' : null);
isDetected = !buffer.slice(rule.start || 0, rule.end || buffer.length).includes(rule.bytes);
return _this4.isReturnFalse(isDetected, type);
detectedRule = getRuleDetection(detectedRule, !buffer.slice(rule.start || 0, rule.end || buffer.length).includes(rule.bytes) ? rule : false);
return _this4.isReturnFalse(detectedRule, type);
}
if (rule.type === 'or') {
isDetected = _this4.detect(buffer, rule.rules, 'or');
return _this4.isReturnFalse(isDetected, type);
detectedRule = getRuleDetection(detectedRule, _this4.detect(buffer, rule.rules, 'or'));
return _this4.isReturnFalse(detectedRule, type);
}
if (rule.type === 'and') {
isDetected = _this4.detect(buffer, rule.rules, 'and');
return _this4.isReturnFalse(isDetected, type);
detectedRule = getRuleDetection(detectedRule, _this4.detect(buffer, rule.rules, 'and'));
return _this4.isReturnFalse(detectedRule, type);
}
if (rule.type === 'default') {
detectedRule = getRuleDetection(detectedRule, rule);
return _this4.isReturnFalse(detectedRule, type);
}
return true;
});
return isDetected;
return detectedRule;
},

@@ -185,4 +220,3 @@ isReturnFalse: function isReturnFalse(isDetected, type) {

validateRuleType: function validateRuleType(rule) {
var types = ['or', 'and', 'contains', 'notContains', 'equal', 'notEqual'];
var types = ['or', 'and', 'contains', 'notContains', 'equal', 'notEqual', 'default'];
return types.indexOf(rule.type) !== -1;

@@ -195,6 +229,4 @@ },

return _this5.validateSignature(signature);
});
}).filter(Boolean);
invalidSignatures = this.cleanArray(invalidSignatures);
if (invalidSignatures.length) {

@@ -215,5 +247,5 @@ return invalidSignatures;

if (!('ext' in signature)) {
if (!('rules' in signature)) {
return {
message: 'signature does not contain "ext" field',
message: 'signature does not contain "rules" field',
signature: signature

@@ -223,5 +255,7 @@ };

if (!('mime' in signature)) {
var validations = this.validateRules(signature.rules);
if (!('ext' in signature) && !validations.hasExt) {
return {
message: 'signature does not contain "mime" field',
message: 'signature does not contain "ext" field',
signature: signature

@@ -231,5 +265,5 @@ };

if (!('rules' in signature)) {
if (!('mime' in signature) && !validations.hasMime) {
return {
message: 'signature does not contain "rules" field',
message: 'signature does not contain "mime" field',
signature: signature

@@ -239,9 +273,7 @@ };

var invalidRules = this.validateRules(signature.rules);
if (invalidRules && invalidRules.length) {
if (Array.isArray(validations)) {
return {
message: 'signature has invalid rule',
signature: signature,
rules: invalidRules
rules: validations
};

@@ -253,3 +285,3 @@ }

var invalidRules = rules.map(function (rule) {
var validations = rules.map(function (rule) {
var isRuleTypeValid = _this6.validateRuleType(rule);

@@ -259,3 +291,3 @@

return {
message: 'rule type does not supported',
message: 'rule type not supported',
rule: rule

@@ -276,21 +308,28 @@ };

return false;
return {
hasExt: 'ext' in rule,
hasMime: 'mime' in rule
};
});
invalidRules = this.cleanArray(invalidRules);
var invalid = validations.filter(function (x) {
return x.message;
});
var valid = validations.filter(function (x) {
return !x.message;
});
if (invalidRules.length) {
return invalidRules;
}
if (!invalid) return invalid;
return {
hasExt: valid.some(function (x) {
return x.hasExt;
}),
hasMime: valid.some(function (x) {
return x.hasMime;
})
};
},
cleanArray: function cleanArray(actual) {
var newArray = new Array();
for (var i = 0; i < actual.length; i++) {
if (actual[i]) {
newArray.push(actual[i]);
}
}
return newArray;
},
addSignature: function addSignature(signature) {
validatedSignaturesCache = false;
_signatures2.default.push(signature);

@@ -297,0 +336,0 @@ },

{
"name": "detect-file-type",
"version": "0.2.1",
"version": "0.2.2",
"description": "Detect file type by signature",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,3 +7,3 @@ [

"rules": [
{ "type": "equal", "start": 0, "end": 2, "bytes": "ffd8" }
{ "type": "equal", "start": 0, "end": 3, "bytes": "ffd8ff" }
]

@@ -31,10 +31,2 @@ },

{
"type": "bmp",
"ext": "bmp",
"mime": "image/bmp",
"rules": [
{ "type": "equal", "start": 0,"end": 2, "bytes": "424d" }
]
},
{
"type": "webp",

@@ -49,16 +41,25 @@ "ext": "webp",

{
"type": "tif",
"ext": "tif",
"mime": "image/tiff",
"type": "flif",
"ext": "flif",
"mime": "image/flif",
"rules": [
{ "type": "equal", "start": 0, "end": 4, "bytes": "464c4946" }
]
},
{
"type": "cr2",
"ext": "cr2",
"mime": "image/x-canon-cr2",
"rules": [
{ "type": "and", "rules":
[
{ "type": "or", "rules":
[
{ "type": "or", "rules":
[
{ "type": "equal", "start": 0, "end": 4, "bytes": "49492a00" },
{ "type": "equal", "start": 0, "end": 4, "bytes": "4d4d002a" }
]
},
{ "type": "notEqual", "start": 8, "end": 10, "bytes": "4352" }
{ "type": "equal", "start": 0, "end": 4, "bytes": "49492a00" },
{ "type": "equal", "start": 0, "end": 4, "bytes": "4d4d002a" }
]
},
{ "type": "equal", "start": 8, "end": 10, "bytes": "4352" }
]
}

@@ -69,5 +70,5 @@ ]

{
"type": "cr2",
"ext": "cr2",
"mime": "image/x-canon-cr2",
"type": "tif",
"ext": "tif",
"mime": "image/tiff",
"rules": [

@@ -82,3 +83,3 @@ { "type": "and", "rules":

},
{ "type": "equal", "start": 8, "end": 10, "bytes": "4352" }
{ "type": "notEqual", "start": 8, "end": 10, "bytes": "4352" }
]

@@ -90,2 +91,11 @@ }

{
"type": "bmp",
"ext": "bmp",
"mime": "image/bmp",
"rules": [
{ "type": "equal", "start": 0,"end": 2, "bytes": "424d" }
]
},
{
"type": "jxr",

@@ -109,11 +119,2 @@ "ext": "jxr",

{
"type": "flif",
"ext": "flif",
"mime": "image/flif",
"rules": [
{ "type": "equal", "start": 0, "end": 4, "bytes": "464c4946" }
]
},
{
"type": "zip",

@@ -171,2 +172,3 @@ "ext": "zip",

},
{

@@ -186,2 +188,3 @@ "type": "rar",

},
{

@@ -195,2 +198,3 @@ "type": "gz",

},
{

@@ -204,2 +208,3 @@ "type": "bz2",

},
{

@@ -213,2 +218,3 @@ "type": "7z",

},
{

@@ -224,81 +230,2 @@ "type": "dmg",

{
"type": "mp4",
"ext": "mp4",
"mime": "video/mp4",
"rules": [
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "or", "rules": [
{ "type": "and", "rules": [
{ "type": "equal", "start": 4, "end": 11, "bytes": "667479704d3456", "desc": "ftypM4V" },
{ "type": "equal", "start": 16, "end": 24, "bytes": "4d3456204d344120", "desc": "M4V M4A " }
]},
{ "type": "equal", "start": 4, "end": 11, "bytes": "667479706d7034", "desc": "ftypmp4" },
{ "type": "equal", "start": 4, "end": 12, "bytes": "6674797069736f6d", "desc": "ftypisom" }
]}
]
}
]
},
{
"type": "m4a",
"ext": "m4a",
"mime": "audio/x-m4a",
"iana": "audio/mp4",
"rules": [
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "equal", "start": 4, "end": 11, "bytes": "667479704d3441", "desc": "ftypM4A" }
]
}
]
},
{
"type": "m4b",
"ext": "m4b",
"mime": "audio/mp4",
"rules": [
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "equal", "start": 4, "end": 11, "bytes": "667479704d3442", "desc": "ftypM4B" }
]
}
]
},
{
"type": "m4p",
"ext": "m4p",
"mime": "audio/mp4",
"rules": [
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "equal", "start": 4, "end": 11, "bytes": "667479704d3450", "desc": "ftypM4P" }
]
}
]
},
{
"type": "m4v",
"ext": "m4v",
"mime": "video/x-m4v",
"iana": "video/mp4",
"rules": [
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "equal", "start": 4, "end": 11, "bytes": "667479704d3456", "desc": "ftypM4V" }
]
}
]
},
{
"type": "mov",

@@ -320,38 +247,63 @@ "ext": "mov",

}
]
],
"desc": "must come before mp4"
},
{
"type": "avi",
"ext": "avi",
"mime": "video/x-msvideo",
"type": "mp4",
"ext": "mp4",
"mime": "video/mp4",
"rules": [
{ "type": "equal", "start": 0, "end": 4, "bytes": "52494646", "desc": "RIFF" },
{ "type": "equal", "start": 8, "end": 11, "bytes": "415649", "desc": "AVI" }
]
},
{
"type": "3g2",
"ext": "3g2",
"mime": "video/3gpp2",
"rules": [
{ "type": "and", "rules":
{ "type": "or", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "equal", "start": 4, "end": 11, "bytes": "66747970336732", "desc": "ftyp3g2" }
]
}
]
},
{ "type": "equal", "start": 0, "end": 4, "bytes": "33677035", "desc": "3gp5" },
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "equal", "start": 4, "end": 8, "bytes": "66747970", "desc": "ftyp" },
{ "type": "or", "rules":
[
{ "type": "equal", "start": 8, "end": 12, "bytes": "6d703431", "desc": "mp41" },
{ "type": "equal", "start": 8, "end": 12, "bytes": "6d703432", "desc": "mp42" },
{ "type": "equal", "start": 8, "end": 12, "bytes": "69736f6d", "desc": "isom" },
{ "type": "equal", "start": 8, "end": 12, "bytes": "69736f32", "desc": "iso2" },
{ "type": "equal", "start": 8, "end": 12, "bytes": "6d6d7034", "desc": "mmp4" },
{
"type": "3gp",
"ext": "3gp",
"mime": "video/3gpp",
"rules": [
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "equal", "start": 4, "end": 10, "bytes": "667479703367", "desc": "ftyp3g" }
{ "type": "and", "rules": [
{ "type": "equal", "start": 8, "end": 11, "bytes": "4d3456", "desc": "M4V" },
{ "type": "equal", "start": 16, "end": 24, "bytes": "4d3456204d344120", "desc": "M4V M4A " }
], "desc": "m4v+m4a, extension is default mp4"
},
{ "type": "equal", "start": 8, "end": 11, "bytes": "4d3456", "desc": "M4V",
"ext": "m4v", "mime": "video/mp4"
},
{ "type": "equal", "start": 8, "end": 11, "bytes": "4d3441", "desc": "M4A",
"ext": "m4a", "mime": "audio/mp4"
},
{ "type": "equal", "start": 8, "end": 11, "bytes": "4d3450", "desc": "M4P",
"ext": "mp4", "mime": "audio/mp4a-latm"
},
{ "type": "equal", "start": 8, "end": 11, "bytes": "4d3442", "desc": "M4B",
"ext": "mp4", "mime": "audio/mp4a-latm"
},
{ "type": "equal", "start": 8, "end": 11, "bytes": "336732", "desc": "3g2",
"ext": "3g2", "mime": "video/3gpp2"
},
{ "type": "equal", "start": 8, "end": 10, "bytes": "3367", "desc": "3g",
"ext": "3gp", "mime": "video/3gpp"
},
{ "type": "equal", "start": 8, "end": 12, "bytes": "64617368", "desc": "dash" },
{ "type": "default", "mime": "video/mpeg4-generic" }
]
}
]
}
]

@@ -361,12 +313,18 @@ }

},
{
"type": "mp4",
"ext": "mp4",
"mime": "video/mpeg4-generic",
"type": "riff",
"rules": [
{ "type": "and", "rules":
{ "type": "equal", "start": 0, "end": 4, "bytes": "52494646", "desc": "RIFF" },
{ "type": "or", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "equal", "start": 4, "end": 8, "bytes": "66747970", "desc": "ftyp" }
{ "type": "equal", "start": 8, "end": 11, "bytes": "415649", "desc": "AVI",
"ext": "avi", "mime": "video/x-msvideo"
},
{ "type": "equal", "start": 8, "end": 12, "bytes": "57415645", "desc": "WAVE",
"ext": "wav", "mime": "audio/x-wav"
},
{ "type": "equal", "start": 8, "end": 12, "bytes": "514c434d", "desc": "QLCM",
"ext": "qcp", "mime": "audio/qcelp"
}
]

@@ -468,17 +426,2 @@ }

{
"type": "m4a",
"ext": "m4a",
"mime": "audio/x-m4a",
"iana": "audio/mp4",
"rules": [
{ "type": "or", "rules":
[
{ "type": "equal", "start": 4, "end": 11, "bytes": "667479704d3441" },
{ "type": "equal", "start": 0, "end": 4, "bytes": "4d344120" }
]
}
]
},
{
"type": "opus",

@@ -497,3 +440,23 @@ "ext": "opus",

"rules": [
{ "type": "equal", "start": 0, "end": 4, "bytes": "4f676753" },
{ "type": "equal", "start": 0, "end": 4, "bytes": "4f676753", "desc": "OggS" },
{ "type": "or", "rules":
[
{ "type": "equal", "start": 28, "end": 35, "bytes": "807468656f7261", "desc": "\u0080theora",
"ext": "ogv", "mime": "video/ogg"
},
{ "type": "equal", "start": 28, "end": 35, "bytes": "01766964656f00", "desc": "\u0001video\u0000",
"ext": "ogm", "mime": "video/ogg"
},
{ "type": "equal", "start": 28, "end": 33, "bytes": "7f464c4143", "desc": "FLAC",
"ext": "oga", "mime": "audio/ogg"
},
{ "type": "equal", "start": 28, "end": 35, "bytes": "53706565782020", "desc": "Speex ",
"ext": "spx", "mime": "audio/ogg"
},
{ "type": "equal", "start": 28, "end": 35, "bytes": "01766f72626973", "desc": "\u0001vorbis",
"ext": "ogg", "mime": "audio/ogg"
},
{ "type": "default", "ext": "ogx", "mime": "application/ogg" }
]
},
{ "type": "notEqual", "start": 28, "end": 36, "bytes": "4f70757348656164" }

@@ -513,8 +476,7 @@ ]

{
"type": "wav",
"ext": "wav",
"mime": "audio/x-wav",
"type": "ape",
"ext": "ape",
"mime": "audio/ape",
"rules": [
{ "type": "equal", "start": 0, "end": 4, "bytes": "52494646" },
{ "type": "equal", "start": 8, "end": 12, "bytes": "57415645" }
{ "type": "equal", "start": 0, "end": 4, "bytes": "4d414320" }
]

@@ -524,7 +486,7 @@ },

{
"type": "amr",
"ext": "amr",
"mime": "audio/amr",
"type": "wv",
"ext": "wv",
"mime": "audio/wavpack",
"rules": [
{ "type": "equal", "start": 0, "end": 6, "bytes": "2321414d520a" }
{ "type": "equal", "start": 0, "end": 4, "bytes": "7776706b" }
]

@@ -534,7 +496,7 @@ },

{
"type": "mxf",
"ext": "mxf",
"mime": "application/mxf",
"type": "amr",
"ext": "amr",
"mime": "audio/amr",
"rules": [
{ "type": "equal", "start": 0, "end": 5, "bytes": "060e2b3402" }
{ "type": "equal", "start": 0, "end": 6, "bytes": "2321414d520a" }
]

@@ -553,11 +515,2 @@ },

{
"type": "blend",
"ext": "blend",
"mime": "application/x-blender",
"rules": [
{ "type": "equal", "start": 0, "end": 7, "bytes": "424c454e444552", "desc": "BLENDER" }
]
},
{
"type": "exe",

@@ -608,2 +561,3 @@ "ext": "exe",

"mime": "application/font-woff",
"iana": "font/woff",
"rules": [

@@ -624,2 +578,3 @@ { "type": "equal", "start": 0, "end": 4, "bytes": "774f4646" },

"mime": "application/font-woff",
"iana": "font/woff2",
"rules": [

@@ -639,3 +594,3 @@ { "type": "equal", "start": 0, "end": 4, "bytes": "774f4632" },

"ext": "eot",
"mime": "application/octet-stream",
"mime": "application/vnd.ms-fontobject",
"rules": [

@@ -657,2 +612,3 @@ { "type": "equal", "start": 34, "end": 36, "bytes": "4c50" },

"mime": "application/font-sfnt",
"iana": "font/ttf",
"rules": [

@@ -667,2 +623,3 @@ { "type": "equal", "start": 0, "end": 5, "bytes": "0001000000" }

"mime": "application/font-sfnt",
"iana": "font/otf",
"rules": [

@@ -676,3 +633,3 @@ { "type": "equal", "start": 0, "end": 5, "bytes": "4f54544f00" }

"ext": "ico",
"mime": "application/x-icon",
"mime": "image/x-icon",
"iana": "image/vnd.microsoft.icon",

@@ -685,5 +642,15 @@ "rules": [

{
"type": "cur",
"ext": "cur",
"mime": "image/x-icon",
"iana": "image/vnd.microsoft.icon",
"rules": [
{ "type": "equal", "start": 0, "end": 4, "bytes": "00000200" }
]
},
{
"type": "flv",
"ext": "flv",
"mime": "application/x-flv",
"mime": "video/x-flv",
"rules": [

@@ -773,2 +740,11 @@ { "type": "equal", "start": 0, "end": 4, "bytes": "464c5601" }

{
"type": "deb",
"ext": "deb",
"mime": "application/x-deb",
"rules": [
{ "type": "equal", "start": 0, "end": 21, "bytes": "213c617263683e0a64656269616e2d62696e617279" }
]
},
{
"type": "ar",

@@ -784,11 +760,2 @@ "ext": "ar",

{
"type": "deb",
"ext": "deb",
"mime": "application/x-deb",
"rules": [
{ "type": "equal", "start": 0, "end": 21, "bytes": "213c617263683e0a64656269616e2d62696e617279" }
]
},
{
"type": "rpm",

@@ -835,2 +802,94 @@ "ext": "rpm",

{
"type": "mxf",
"ext": "mxf",
"mime": "application/mxf",
"rules": [
{ "type": "equal", "start": 0, "end": 14, "bytes": "060e2b34020501010d0102010102" }
]
},
{
"type": "mts",
"ext": "mts",
"mime": "video/mp2t",
"rules": [
{ "type": "and", "rules":
[
{ "type": "equal", "start": 4, "end": 5, "bytes": "47" },
{ "type": "or", "rules":
[
{ "type": "equal", "start": 192, "end": 193, "bytes": "47" },
{ "type": "equal", "start": 196, "end": 197, "bytes": "47" }
]
}
]
}
]
},
{
"type": "blend",
"ext": "blend",
"mime": "application/x-blender",
"rules": [
{ "type": "equal", "start": 0, "end": 7, "bytes": "424c454e444552", "desc": "BLENDER" }
]
},
{
"type": "bpg",
"ext": "bpg",
"mime": "image/bpg",
"rules": [
{ "type": "equal", "start": 0, "end": 4, "bytes": "425047fb" }
]
},
{
"type": "jpeg-2000",
"rules": [
{ "type": "and", "rules": [
{ "type": "equal", "start": 0, "end": 12, "bytes": "0000000c6a5020200d0a870a" },
{ "type": "or", "rules": [
{ "type": "equal", "start": 20, "end": 24, "bytes": "6a703220",
"ext": "jp2", "mime": "image/jp2"
},
{ "type": "equal", "start": 20, "end": 24, "bytes": "6a707820",
"ext": "jpx", "mime": "image/jpx"
},
{ "type": "equal", "start": 20, "end": 24, "bytes": "6a706d20",
"ext": "jpm", "mime": "image/jpm"
},
{ "type": "equal", "start": 20, "end": 24, "bytes": "6d6a7032",
"ext": "mj2", "mime": "image/mj2"
}
] }
] }
]
},
{
"type": "aif",
"ext": "aif",
"mime": "audio/aiff",
"rules": [
{ "type": "equal", "start": 0, "end": 4, "bytes": "464f524d" }
]
},
{
"type": "xml",
"ext": "xml",
"mime": "application/xml",
"rules": [
{ "type": "equal", "start": 0, "end": 6, "bytes": "3c3f786d6c20", "desc": "<?xml " }
]
},
{
"type": "svg",

@@ -845,2 +904,109 @@ "ext": "svg",

{
"type": "mobi",
"ext": "mobi",
"mime": "application/x-mobipocket-ebook",
"rules": [
{ "type": "equal", "start": 60, "end": 68, "bytes": "424f4f4b4d4f4249" }
]
},
{
"type": "heic",
"rules": [
{ "type": "and", "rules":
[
{ "type": "equal", "start": 4, "end": 8, "bytes": "66747970" },
{ "type": "or", "rules":
[
{ "type": "equal", "start": 8, "end": 12, "bytes": "6d696631",
"ext": "heic", "mime": "image/heif" },
{ "type": "equal", "start": 8, "end": 12, "bytes": "6d736631",
"ext": "heic", "mime": "image/heif-sequence" },
{ "type": "or", "rules":
[
{ "type": "equal", "start": 8, "end": 12, "bytes": "68656963" },
{ "type": "equal", "start": 8, "end": 12, "bytes": "68656978" }
], "ext": "heic", "mime": "image/heic"
},
{ "type": "or", "rules":
[
{ "type": "equal", "start": 8, "end": 12, "bytes": "68657663" },
{ "type": "equal", "start": 8, "end": 12, "bytes": "68657678" }
], "ext": "heic", "mime": "image/heic-sequence"
}
]
}
]
}
]
},
{
"type": "ktx",
"ext": "ktx",
"mime": "image/ktx",
"rules": [
{ "type": "equal", "start": 0, "end": 12, "bytes": "ab4b5458203131bb0d0a1a0a" }
]
},
{
"type": "dcm",
"ext": "dcm",
"mime": "application/dicom",
"rules": [
{ "type": "equal", "start": 128, "end": 132, "bytes": "4449434d" }
]
},
{
"type": "mpc",
"ext": "mpc",
"mime": "audio/x-musepack",
"rules": [
{ "type": "or", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "4d502b" },
{ "type": "equal", "start": 0, "end": 4, "bytes": "4d50434b" }
]
}
]
},
{
"type": "ics",
"ext": "ics",
"mime": "text/calendar",
"rules": [
{ "type": "equal", "start": 0, "end": 6, "bytes": "424547494e3a" }
]
},
{
"type": "glb",
"ext": "glb",
"mime": "model/gltf-binary",
"rules": [
{ "type": "equal", "start": 0, "end": 8, "bytes": "676c544602000000" }
]
},
{
"type": "pcap",
"ext": "pcap",
"mime": "application/vnd.tcpdump.pcap",
"rules": [
{ "type": "or", "rules":
[
{ "type": "equal", "start": 0, "end": 4, "bytes": "d4c3b2a1" },
{ "type": "equal", "start": 0, "end": 4, "bytes": "a1b2c3d4" }
]
}
]
},
{
"type": "html",

@@ -858,2 +1024,2 @@ "ext": "html",

}
]
]
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc