mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 13:38:19 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/file-signatures'
* origin/topic/jsiwek/file-signatures: File type detection changes and fix https.log {orig,resp}_fuids fields. Various minor changes related to file mime type detection. Refactor common MIME magic matching code. Replace libmagic w/ Bro signatures for file MIME type identification. Conflicts: scripts/base/init-default.bro testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log BIT-1143 #merged
This commit is contained in:
commit
9efb549236
57 changed files with 4841 additions and 201 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "Val.h"
|
||||
#include "Type.h"
|
||||
#include "Event.h"
|
||||
#include "RuleMatcher.h"
|
||||
|
||||
#include "analyzer/Analyzer.h"
|
||||
#include "analyzer/Manager.h"
|
||||
|
@ -52,6 +53,7 @@ int File::timeout_interval_idx = -1;
|
|||
int File::bof_buffer_size_idx = -1;
|
||||
int File::bof_buffer_idx = -1;
|
||||
int File::mime_type_idx = -1;
|
||||
int File::mime_types_idx = -1;
|
||||
|
||||
void File::StaticInit()
|
||||
{
|
||||
|
@ -72,6 +74,7 @@ void File::StaticInit()
|
|||
bof_buffer_size_idx = Idx("bof_buffer_size");
|
||||
bof_buffer_idx = Idx("bof_buffer");
|
||||
mime_type_idx = Idx("mime_type");
|
||||
mime_types_idx = Idx("mime_types");
|
||||
}
|
||||
|
||||
File::File(const string& file_id, Connection* conn, analyzer::Tag tag,
|
||||
|
@ -279,20 +282,17 @@ bool File::BufferBOF(const u_char* data, uint64 len)
|
|||
|
||||
bool File::DetectMIME(const u_char* data, uint64 len)
|
||||
{
|
||||
const char* mime = bro_magic_buffer(magic_mime_cookie, data, len);
|
||||
RuleMatcher::MIME_Matches matches;
|
||||
file_mgr->DetectMIME(data, len, &matches);
|
||||
|
||||
if ( mime )
|
||||
{
|
||||
const char* mime_end = strchr(mime, ';');
|
||||
if ( matches.empty() )
|
||||
return false;
|
||||
|
||||
if ( mime_end )
|
||||
// strip off charset
|
||||
val->Assign(mime_type_idx, new StringVal(mime_end - mime, mime));
|
||||
else
|
||||
val->Assign(mime_type_idx, new StringVal(mime));
|
||||
}
|
||||
val->Assign(mime_type_idx,
|
||||
new StringVal(*(matches.begin()->second.begin())));
|
||||
val->Assign(mime_types_idx, file_analysis::GenMIMEMatchesVal(matches));
|
||||
|
||||
return mime;
|
||||
return true;
|
||||
}
|
||||
|
||||
void File::ReplayBOF()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue