mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Allow File analyzers to direcly pass mime type.
This makes it much easier for protocols where the mime type is known in advance like, for example, TLS. We now do no longer have to perform deep script-level magic.
This commit is contained in:
parent
1b19ab78b6
commit
9fd7816501
12 changed files with 89 additions and 26 deletions
|
@ -110,7 +110,7 @@ void Manager::SetHandle(const string& handle)
|
|||
|
||||
string Manager::DataIn(const u_char* data, uint64 len, uint64 offset,
|
||||
analyzer::Tag tag, Connection* conn, bool is_orig,
|
||||
const string& precomputed_id)
|
||||
const string& precomputed_id, const string& mime_type)
|
||||
{
|
||||
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
|
||||
File* file = GetFile(id, conn, tag, is_orig);
|
||||
|
@ -118,6 +118,9 @@ string Manager::DataIn(const u_char* data, uint64 len, uint64 offset,
|
|||
if ( ! file )
|
||||
return "";
|
||||
|
||||
if ( ! mime_type.empty() )
|
||||
file->SetMime(mime_type);
|
||||
|
||||
file->DataIn(data, len, offset);
|
||||
|
||||
if ( file->IsComplete() )
|
||||
|
@ -130,7 +133,8 @@ string Manager::DataIn(const u_char* data, uint64 len, uint64 offset,
|
|||
}
|
||||
|
||||
string Manager::DataIn(const u_char* data, uint64 len, analyzer::Tag tag,
|
||||
Connection* conn, bool is_orig, const string& precomputed_id)
|
||||
Connection* conn, bool is_orig, const string& precomputed_id,
|
||||
const string& mime_type)
|
||||
{
|
||||
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
|
||||
// Sequential data input shouldn't be going over multiple conns, so don't
|
||||
|
@ -140,6 +144,9 @@ string Manager::DataIn(const u_char* data, uint64 len, analyzer::Tag tag,
|
|||
if ( ! file )
|
||||
return "";
|
||||
|
||||
if ( ! mime_type.empty() )
|
||||
file->SetMime(mime_type);
|
||||
|
||||
file->DataIn(data, len);
|
||||
|
||||
if ( file->IsComplete() )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue