{"action":"created","comment":{"url":"https://api.github.com/repos/inliniac/suricata/pulls/comments/45765603","id":45765603,"diff_hunk":"@@ -0,0 +1,233 @@\n+/* Copyright (C) 2015 Open Information Security Foundation\n+ *\n+ * You can copy, redistribute or modify this Program under the terms of\n+ * the GNU General Public License version 2 as published by the Free\n+ * Software Foundation.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * version 2 along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n+ * 02110-1301, USA.\n+ */\n+\n+/** \\file\n+ *\n+ * \\author Giuseppe Longo <giuseppe@glongo.it>\n+ *\n+ * \\brief Decompress files transfered via HTTP corresponding to file_data\n+ * keyword.\n+ *\n+ */\n+\n+#include \"suricata-common.h\"\n+#include \"suricata.h\"\n+\n+#include \"app-layer-htp.h\"\n+\n+#include \"util-file-decompression.h\"\n+#include \"util-file-flash-decompression.h\"\n+#include \"util-misc.h\"\n+#include \"util-print.h\"\n+\n+#define FLASH_ZLIB_MIN_VERSION    0x06\n+#define FLASH_LZMA_MIN_VERSION    0x0D\n+\n+SCEnumCharMap file_decoder_event_table[ ] = {\n+    { \"NO MEMORY\",                  FILE_DECODER_EVENT_NO_MEM },\n+    { \"NO FLASH SUPPORT\",           FILE_DECODER_EVENT_NO_FLASH_SUPPORT },\n+    { \"INVALID FLASH VERSION\",      FILE_DECODER_EVENT_INVALID_FLASH_VERSION },\n+    { \"Z_STREAM_END\",               FILE_DECODER_EVENT_Z_STREAM_END },\n+    { \"Z_OK\",                       FILE_DECODER_EVENT_Z_OK },\n+    { \"Z_DATA_ERROR\",               FILE_DECODER_EVENT_Z_DATA_ERROR },\n+    { \"Z_STREAM_ERROR\",             FILE_DECODER_EVENT_Z_STREAM_ERROR },\n+    { \"Z_BUF_ERROR\",                FILE_DECODER_EVENT_Z_BUF_ERROR },\n+    { \"Z_UNKNOWN_ERROR\",            FILE_DECODER_EVENT_Z_UNKNOWN_ERROR },\n+    { \"LZMA_DECODER_ERROR\",         FILE_DECODER_EVENT_LZMA_DECODER_ERROR },\n+    { \"LZMA_STREAM_END\",            FILE_DECODER_EVENT_LZMA_STREAM_END },\n+    { \"LZMA_OK\",                    FILE_DECODER_EVENT_LZMA_OK },\n+    { \"LZMA_MEMLIMIT_ERROR\",        FILE_DECODER_EVENT_LZMA_MEMLIMIT_ERROR },\n+    { \"LZMA_OPTIONS_ERROR\",         FILE_DECODER_EVENT_LZMA_OPTIONS_ERROR },\n+    { \"LZMA_FORMAT_ERROR\",          FILE_DECODER_EVENT_LZMA_FORMAT_ERROR },\n+    { \"LZMA_DATA_ERROR\",            FILE_DECODER_EVENT_LZMA_DATA_ERROR },\n+    { \"LZMA_BUF_ERROR\",             FILE_DECODER_EVENT_LZMA_BUF_ERROR },\n+    { \"LZMA_UNKNOWN_ERROR\",         FILE_DECODER_EVENT_LZMA_UNKNOWN_ERROR },\n+    { NULL,                         -1 },\n+};\n+\n+int FileIsFlashFile(const uint8_t *buffer, uint32_t buffer_len)\n+{\n+    if (buffer_len >= 3 && buffer[1] == 'W' && buffer[2] == 'S') {\n+        if (buffer[0] == 'F')\n+            return FILE_FLASH_NO_COMPRESSION;\n+        else if (buffer[0] == 'C')\n+            return FILE_FLASH_ZLIB_COMPRESSION;\n+        else if (buffer[0] == 'Z')\n+            return FILE_FLASH_LZMA_COMPRESSION;\n+        else\n+            return FILE_IS_NOT_FLASH;\n+    }\n+\n+    return FILE_IS_NOT_FLASH;\n+}\n+\n+int FileDecompressFlashFile(const uint8_t *buffer, uint32_t *buffer_len,","path":"src/util-file-decompression.c","position":78,"original_position":78,"commit_id":"8284b091c875ce051ee337d5396b1a1168f8edd7","original_commit_id":"8284b091c875ce051ee337d5396b1a1168f8edd7","user":{"login":"inliniac","id":719366,"avatar_url":"https://avatars.githubusercontent.com/u/719366?v=3","gravatar_id":"","url":"https://api.github.com/users/inliniac","html_url":"https://github.com/inliniac","followers_url":"https://api.github.com/users/inliniac/followers","following_url":"https://api.github.com/users/inliniac/following{/other_user}","gists_url":"https://api.github.com/users/inliniac/gists{/gist_id}","starred_url":"https://api.github.com/users/inliniac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inliniac/subscriptions","organizations_url":"https://api.github.com/users/inliniac/orgs","repos_url":"https://api.github.com/users/inliniac/repos","events_url":"https://api.github.com/users/inliniac/events{/privacy}","received_events_url":"https://api.github.com/users/inliniac/received_events","type":"User","site_admin":false},"body":"Function docs/comments missing.","created_at":"2015-11-24T17:17:07Z","updated_at":"2015-11-24T17:17:07Z","html_url":"https://github.com/inliniac/suricata/pull/1756#discussion_r45765603","pull_request_url":"https://api.github.com/repos/inliniac/suricata/pulls/1756","_links":{"self":{"href":"https://api.github.com/repos/inliniac/suricata/pulls/comments/45765603"},"html":{"href":"https://github.com/inliniac/suricata/pull/1756#discussion_r45765603"},"pull_request":{"href":"https://api.github.com/repos/inliniac/suricata/pulls/1756"}}},"pull_request":{"url":"https://api.github.com/repos/inliniac/suricata/pulls/1756","id":51518473,"html_url":"https://github.com/inliniac/suricata/pull/1756","diff_url":"https://github.com/inliniac/suricata/pull/1756.diff","patch_url":"https://github.com/inliniac/suricata/pull/1756.patch","issue_url":"https://api.github.com/repos/inliniac/suricata/issues/1756","number":1756,"state":"open","locked":false,"title":"flash decompression v2","user":{"login":"glongo","id":101933,"avatar_url":"https://avatars.githubusercontent.com/u/101933?v=3","gravatar_id":"","url":"https://api.github.com/users/glongo","html_url":"https://github.com/glongo","followers_url":"https://api.github.com/users/glongo/followers","following_url":"https://api.github.com/users/glongo/following{/other_user}","gists_url":"https://api.github.com/users/glongo/gists{/gist_id}","starred_url":"https://api.github.com/users/glongo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glongo/subscriptions","organizations_url":"https://api.github.com/users/glongo/orgs","repos_url":"https://api.github.com/users/glongo/repos","events_url":"https://api.github.com/users/glongo/events{/privacy}","received_events_url":"https://api.github.com/users/glongo/received_events","type":"User","site_admin":false},"body":"This adds new decompression API for flash files compressed with zlib/lzma.\r\n\r\nThis PR adds events handling for detect engine.\r\nCurrently, events functions are added but they are not used\r\nsince equivalent register functions for app layer are missing.\r\n\r\nUpdates:\r\nComment of last PR addressed: https://github.com/inliniac/suricata/pull/1642\r\n\r\nTicket: [1600](https://redmine.openinfosecfoundation.org/issues/1600)\r\n\r\nPrscript:\r\n- PR glongo: https://buildbot.openinfosecfoundation.org/builders/glongo/builds/83\r\n- PR glongo-pcap: https://buildbot.openinfosecfoundation.org/builders/glongo-pcap/builds/82","created_at":"2015-11-23T12:42:57Z","updated_at":"2015-11-24T17:17:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"386c91d04ec0659bf3bde717f41abf3b856e8949","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/inliniac/suricata/pulls/1756/commits","review_comments_url":"https://api.github.com/repos/inliniac/suricata/pulls/1756/comments","review_comment_url":"https://api.github.com/repos/inliniac/suricata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inliniac/suricata/issues/1756/comments","statuses_url":"https://api.github.com/repos/inliniac/suricata/statuses/8284b091c875ce051ee337d5396b1a1168f8edd7","head":{"label":"glongo:dev-decompress-swf-v2","ref":"dev-decompress-swf-v2","sha":"8284b091c875ce051ee337d5396b1a1168f8edd7","user":{"login":"glongo","id":101933,"avatar_url":"https://avatars.githubusercontent.com/u/101933?v=3","gravatar_id":"","url":"https://api.github.com/users/glongo","html_url":"https://github.com/glongo","followers_url":"https://api.github.com/users/glongo/followers","following_url":"https://api.github.com/users/glongo/following{/other_user}","gists_url":"https://api.github.com/users/glongo/gists{/gist_id}","starred_url":"https://api.github.com/users/glongo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glongo/subscriptions","organizations_url":"https://api.github.com/users/glongo/orgs","repos_url":"https://api.github.com/users/glongo/repos","events_url":"https://api.github.com/users/glongo/events{/privacy}","received_events_url":"https://api.github.com/users/glongo/received_events","type":"User","site_admin":false},"repo":{"id":13040040,"name":"suricata","full_name":"glongo/suricata","owner":{"login":"glongo","id":101933,"avatar_url":"https://avatars.githubusercontent.com/u/101933?v=3","gravatar_id":"","url":"https://api.github.com/users/glongo","html_url":"https://github.com/glongo","followers_url":"https://api.github.com/users/glongo/followers","following_url":"https://api.github.com/users/glongo/following{/other_user}","gists_url":"https://api.github.com/users/glongo/gists{/gist_id}","starred_url":"https://api.github.com/users/glongo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glongo/subscriptions","organizations_url":"https://api.github.com/users/glongo/orgs","repos_url":"https://api.github.com/users/glongo/repos","events_url":"https://api.github.com/users/glongo/events{/privacy}","received_events_url":"https://api.github.com/users/glongo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/glongo/suricata","description":"Mirror of the official OISF Suricata git repository","fork":true,"url":"https://api.github.com/repos/glongo/suricata","forks_url":"https://api.github.com/repos/glongo/suricata/forks","keys_url":"https://api.github.com/repos/glongo/suricata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/glongo/suricata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/glongo/suricata/teams","hooks_url":"https://api.github.com/repos/glongo/suricata/hooks","issue_events_url":"https://api.github.com/repos/glongo/suricata/issues/events{/number}","events_url":"https://api.github.com/repos/glongo/suricata/events","assignees_url":"https://api.github.com/repos/glongo/suricata/assignees{/user}","branches_url":"https://api.github.com/repos/glongo/suricata/branches{/branch}","tags_url":"https://api.github.com/repos/glongo/suricata/tags","blobs_url":"https://api.github.com/repos/glongo/suricata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/glongo/suricata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/glongo/suricata/git/refs{/sha}","trees_url":"https://api.github.com/repos/glongo/suricata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/glongo/suricata/statuses/{sha}","languages_url":"https://api.github.com/repos/glongo/suricata/languages","stargazers_url":"https://api.github.com/repos/glongo/suricata/stargazers","contributors_url":"https://api.github.com/repos/glongo/suricata/contributors","subscribers_url":"https://api.github.com/repos/glongo/suricata/subscribers","subscription_url":"https://api.github.com/repos/glongo/suricata/subscription","commits_url":"https://api.github.com/repos/glongo/suricata/commits{/sha}","git_commits_url":"https://api.github.com/repos/glongo/suricata/git/commits{/sha}","comments_url":"https://api.github.com/repos/glongo/suricata/comments{/number}","issue_comment_url":"https://api.github.com/repos/glongo/suricata/issues/comments{/number}","contents_url":"https://api.github.com/repos/glongo/suricata/contents/{+path}","compare_url":"https://api.github.com/repos/glongo/suricata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/glongo/suricata/merges","archive_url":"https://api.github.com/repos/glongo/suricata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/glongo/suricata/downloads","issues_url":"https://api.github.com/repos/glongo/suricata/issues{/number}","pulls_url":"https://api.github.com/repos/glongo/suricata/pulls{/number}","milestones_url":"https://api.github.com/repos/glongo/suricata/milestones{/number}","notifications_url":"https://api.github.com/repos/glongo/suricata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/glongo/suricata/labels{/name}","releases_url":"https://api.github.com/repos/glongo/suricata/releases{/id}","created_at":"2013-09-23T15:52:17Z","updated_at":"2015-05-02T21:15:07Z","pushed_at":"2015-11-23T10:36:01Z","git_url":"git://github.com/glongo/suricata.git","ssh_url":"git@github.com:glongo/suricata.git","clone_url":"https://github.com/glongo/suricata.git","svn_url":"https://github.com/glongo/suricata","homepage":"http://suricata-ids.org/","size":41026,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"inliniac:master","ref":"master","sha":"bec913b40cf9153fd6a021b33cecda97ff76be47","user":{"login":"inliniac","id":719366,"avatar_url":"https://avatars.githubusercontent.com/u/719366?v=3","gravatar_id":"","url":"https://api.github.com/users/inliniac","html_url":"https://github.com/inliniac","followers_url":"https://api.github.com/users/inliniac/followers","following_url":"https://api.github.com/users/inliniac/following{/other_user}","gists_url":"https://api.github.com/users/inliniac/gists{/gist_id}","starred_url":"https://api.github.com/users/inliniac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inliniac/subscriptions","organizations_url":"https://api.github.com/users/inliniac/orgs","repos_url":"https://api.github.com/users/inliniac/repos","events_url":"https://api.github.com/users/inliniac/events{/privacy}","received_events_url":"https://api.github.com/users/inliniac/received_events","type":"User","site_admin":false},"repo":{"id":5410234,"name":"suricata","full_name":"inliniac/suricata","owner":{"login":"inliniac","id":719366,"avatar_url":"https://avatars.githubusercontent.com/u/719366?v=3","gravatar_id":"","url":"https://api.github.com/users/inliniac","html_url":"https://github.com/inliniac","followers_url":"https://api.github.com/users/inliniac/followers","following_url":"https://api.github.com/users/inliniac/following{/other_user}","gists_url":"https://api.github.com/users/inliniac/gists{/gist_id}","starred_url":"https://api.github.com/users/inliniac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inliniac/subscriptions","organizations_url":"https://api.github.com/users/inliniac/orgs","repos_url":"https://api.github.com/users/inliniac/repos","events_url":"https://api.github.com/users/inliniac/events{/privacy}","received_events_url":"https://api.github.com/users/inliniac/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/inliniac/suricata","description":"Mirror of the official OISF Suricata git repository","fork":false,"url":"https://api.github.com/repos/inliniac/suricata","forks_url":"https://api.github.com/repos/inliniac/suricata/forks","keys_url":"https://api.github.com/repos/inliniac/suricata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inliniac/suricata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inliniac/suricata/teams","hooks_url":"https://api.github.com/repos/inliniac/suricata/hooks","issue_events_url":"https://api.github.com/repos/inliniac/suricata/issues/events{/number}","events_url":"https://api.github.com/repos/inliniac/suricata/events","assignees_url":"https://api.github.com/repos/inliniac/suricata/assignees{/user}","branches_url":"https://api.github.com/repos/inliniac/suricata/branches{/branch}","tags_url":"https://api.github.com/repos/inliniac/suricata/tags","blobs_url":"https://api.github.com/repos/inliniac/suricata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inliniac/suricata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inliniac/suricata/git/refs{/sha}","trees_url":"https://api.github.com/repos/inliniac/suricata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inliniac/suricata/statuses/{sha}","languages_url":"https://api.github.com/repos/inliniac/suricata/languages","stargazers_url":"https://api.github.com/repos/inliniac/suricata/stargazers","contributors_url":"https://api.github.com/repos/inliniac/suricata/contributors","subscribers_url":"https://api.github.com/repos/inliniac/suricata/subscribers","subscription_url":"https://api.github.com/repos/inliniac/suricata/subscription","commits_url":"https://api.github.com/repos/inliniac/suricata/commits{/sha}","git_commits_url":"https://api.github.com/repos/inliniac/suricata/git/commits{/sha}","comments_url":"https://api.github.com/repos/inliniac/suricata/comments{/number}","issue_comment_url":"https://api.github.com/repos/inliniac/suricata/issues/comments{/number}","contents_url":"https://api.github.com/repos/inliniac/suricata/contents/{+path}","compare_url":"https://api.github.com/repos/inliniac/suricata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inliniac/suricata/merges","archive_url":"https://api.github.com/repos/inliniac/suricata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inliniac/suricata/downloads","issues_url":"https://api.github.com/repos/inliniac/suricata/issues{/number}","pulls_url":"https://api.github.com/repos/inliniac/suricata/pulls{/number}","milestones_url":"https://api.github.com/repos/inliniac/suricata/milestones{/number}","notifications_url":"https://api.github.com/repos/inliniac/suricata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inliniac/suricata/labels{/name}","releases_url":"https://api.github.com/repos/inliniac/suricata/releases{/id}","created_at":"2012-08-14T08:30:06Z","updated_at":"2015-11-23T13:04:24Z","pushed_at":"2015-11-24T16:25:27Z","git_url":"git://github.com/inliniac/suricata.git","ssh_url":"git@github.com:inliniac/suricata.git","clone_url":"https://github.com/inliniac/suricata.git","svn_url":"https://github.com/inliniac/suricata","homepage":"http://suricata-ids.org/","size":51133,"stargazers_count":213,"watchers_count":213,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":198,"mirror_url":null,"open_issues_count":38,"forks":198,"open_issues":38,"watchers":213,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inliniac/suricata/pulls/1756"},"html":{"href":"https://github.com/inliniac/suricata/pull/1756"},"issue":{"href":"https://api.github.com/repos/inliniac/suricata/issues/1756"},"comments":{"href":"https://api.github.com/repos/inliniac/suricata/issues/1756/comments"},"review_comments":{"href":"https://api.github.com/repos/inliniac/suricata/pulls/1756/comments"},"review_comment":{"href":"https://api.github.com/repos/inliniac/suricata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inliniac/suricata/pulls/1756/commits"},"statuses":{"href":"https://api.github.com/repos/inliniac/suricata/statuses/8284b091c875ce051ee337d5396b1a1168f8edd7"}}}}