]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Fix tests and jpeg case
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 21 Sep 2019 12:47:55 +0000 (13:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 21 Sep 2019 12:47:55 +0000 (13:47 +0100)
lualib/lua_magic/heuristics.lua
lualib/lua_magic/types.lua
test/functional/cases/350_magic.robot
test/functional/messages/gargantua.eml

index d8c134e57ce0eb8643c775596bc3e5cff6ae5a93..04c89ba6996f6ba3061802ed13645e3c4f74ea22 100644 (file)
@@ -74,9 +74,6 @@ local txt_patterns = {
   csv = {
     [[(?:[-a-zA-Z0-9_]+\s*,){2,}(?:[-a-zA-Z0-9_]+[\r\n])]]
   },
-  js = {
-    [[\s*function\s*\(]],
-  },
 }
 
 -- Used to match pattern index and extension
@@ -303,7 +300,10 @@ exports.mime_part_heuristic = function(part, log_obj)
 
   if part:is_image() then
     local img = part:get_image()
-    return img:get_type():lower(),60
+    local img_type = img:get_type():lower()
+
+    if img_type == 'jpeg' then img_type = 'jpg' end
+    return img_type,60
   end
 
   if part:is_archive() then
index 93bfa6641a9db55016754e123c3c187803ca7c85..32c7cd1314d078171ac9c7563c14689fbec7a5f6 100644 (file)
@@ -258,10 +258,6 @@ local types = {
     type = 'message',
     ct = 'message/rfc822',
   },
-  js = {
-    type = 'application',
-    ct = 'application/javascript',
-  },
 }
 
 return types
\ No newline at end of file
index 02c4e89a2b974c2147470abb0ed0a5964dbe079c..5ef0dc172c581386ad6cfa798b3405d688cd738d 100644 (file)
@@ -63,8 +63,6 @@ Magic detections bundle 1
   Should Contain  ${result.stdout}  MAGIC_SYM_TXT_48
   Should Contain  ${result.stdout}  MAGIC_SYM_HTML_49
   Should Contain  ${result.stdout}  MAGIC_SYM_CSV_50
-  Should Contain  ${result.stdout}  MAGIC_SYM_EML_52
-  Should Contain  ${result.stdout}  MAGIC_SYM_JS_51
   Should Contain  ${result.stdout}  MAGIC_SYM_JPG_45
 
 
index bc13b8cf6f6c24dc292a76f16f7121df13be699c..bc7883490b7a3524687c49318e97f6a0a2057af4 100644 (file)
@@ -23256,73 +23256,7 @@ Content-Type: application/octet-stream
 Content-Transfer-Encoding: base64
 X-Real-Type: csv
 
-Ozs7Ozs7DQo7YXNzYWQ7Ozs7Ow0KO3NhbGFkczs7Ozs7DQo7Ozs7OzsNCjs7Ozs7
-Ow0KOzs7Ozs7DQo7Ozs7OzsNCjs7Ozs7Ow0KOzthc2Rhc2Q7Ozs7DQo=
-
---XXX
-Content-Type: application/octet-stream
-Content-Transfer-Encoding: base64
-X-Real-Type: js
-
-LyogZ2xvYmFsIGQzOnRydWUsIHJlcXVpcmU6ZmFsc2UsIHJlcXVpcmVqczpmYWxz
-ZSAqLyAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG5vLXVudXNlZC12YXJzCgpyZXF1
-aXJlanMuY29uZmlnKHsKICAgIGJhc2VVcmw6ICJqcy9saWIiLAogICAgcGF0aHM6
-IHsKICAgICAgICBhcHA6ICIuLi9hcHAiLAogICAgICAgIGpxdWVyeTogImpxdWVy
-eS0zLjQuMS5taW4iLAogICAgICAgIHZpc2liaWxpdHk6ICJ2aXNpYmlsaXR5Lm1p
-biIsCiAgICAgICAgaHVtYW5pemU6ICJodW1hbml6ZS5taW4iLAogICAgICAgIGJv
-b3RzdHJhcDogImJvb3RzdHJhcC5taW4iLAogICAgICAgIGQzOiAiZDMubWluIiwK
-ICAgICAgICBkM2V2b2x1dGlvbjogImQzZXZvbHV0aW9uLm1pbiIsCiAgICAgICAg
-ZDNwaWU6ICJkM3BpZS5taW4iLAogICAgICAgIGZvb3RhYmxlOiAiZm9vdGFibGUu
-bWluIiwKICAgICAgICBucHJvZ3Jlc3M6ICJucHJvZ3Jlc3MubWluIiwKICAgICAg
-ICBzdGlja3l0YWJzOiAianF1ZXJ5LnN0aWNreXRhYnMubWluIgogICAgfSwKICAg
-IHNoaW06IHsKICAgICAgICBib290c3RyYXA6I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YXRpb24tYXJlYSIpWzBdLmlubmVySFRNTCA9CiAgICAgICAgIjxkaXYg
-Y2xhc3M9XCJhbGVydCBhbGVydC1lcnJvclwiPiIgKwogICAgICAgICAgICAiPHN0
-cm9uZz5Nb2R1bGUgbG9hZGluZyBlcnJvcjogIiArIGUucmVxdWlyZVR5cGUgKyAi
-LCBtb2R1bGU6ICIgKyBlLnJlcXVpcmVNb2R1bGVzICsgIjwvc3Ryb25nPiIgKwog
-ICAgICAgICAgICAiPGJ1dHRvbiB0eXBlPVwiYnV0dG9uXCIgY2xhc3M9XCJidG4g
-YnRuLWluZm8gYnRuLXhzIHB1bGwtcmlnaHRcIiAiICsKICAgICAgICAgICAgICAg
-ICJvbkNsaWNrPVwid2luZG93LmxvY2F0aW9uLnJlbG9hZCgpOyB0aGlzLnBhcmVu
-dE5vZGUucGFyZW50Tm9kZS5yZW1vdmVDaGlsZCh0aGlzLnBhcmVudE5vZGUpO1wi
-ICIgKwogICAgICAgICAgICAgICAgInRpdGxlPVwiUmVsb2FkIGN1cnJlbnQgcGFn
-ZVwiPiIgKwogICAgICAgICAgICAgICAgIjxpIGNsYXNzPVwiZ2x5cGhpY29uIGds
-eXBoaWNvbi1yZXBlYXRcIj48L2k+IFJlbG9hZCIgKwogICAgICAgICAgICAiPC9i
-dXR0b24+IiArCiAgICAgICAgIjwvZGl2PiI7CiAgICB0aHJvdyBlOwp9OwoKLy8g
-TG9hZCBtYWluIFVJCnJlcXVpcmUoWyJhcHAvcnNwYW1kIl0sCiAgICBmdW5jdGlv
-biAocnNwYW1kKSB7CiAgICAgICAgInVzZSBzdHJpY3QiOwogICAgICAgIHJzcGFt
-ZC5zZXR1cCgpOwogICAgICAgIHJzcGFtZC5jb25uZWN0KCk7CiAgICB9Cik7Cg==
-
---XXX
-Content-Type: message/rfc822
-Content-Transfer-Encoding: base64
-X-Real-Type: eml
-
-UmVjZWl2ZWQ6ICoNCkZyb206IDwqPg0KVG86ICIqIiA8Kj4NClJlcGx5LVRvO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