mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Spicy: Query Zeek scriptland for file handles.
Like traditional file analyzers, we now query Zeek's `get_file_handle()` event for handles when a connection begins analyzing an embedded file. That means that Spicy-side protocol analyzers that are forwarding data into file analysis now need to call Zeek's `Files::register_protocol()` and provide a callback for computing file handles. If that's missing, Zeek will now issue a warning. This aligns with the requirements Zeek's traditional protocol analyzers. (If the EVT file defines a protocol analyzer to `replace` an existing one, that one's `register_protocol()` will be consulted.) Because Zeek's `get_file_handle()` event requires a current connection, if a Spicy file analyzer isn't directly part of a connection context (e.g., with nested files), we continue to use hardcoded, built-in file handle. Scriptland won't be consulted in that case, just like before. Closes #3440.
This commit is contained in:
parent
966d411ed5
commit
56b9a79a65
13 changed files with 91 additions and 37 deletions
|
@ -351,6 +351,19 @@ public:
|
|||
*/
|
||||
std::string DetectMIME(const u_char* data, uint64_t len) const;
|
||||
|
||||
/**
|
||||
* Sets #current_file_id to a hash of a unique file handle string based on
|
||||
* what the \c get_file_handle event derives from the connection params.
|
||||
* Event queue is flushed so that we can get the handle value immediately.
|
||||
* @param tag network protocol over which the file is transferred.
|
||||
* @param conn network connection over which the file is transferred.
|
||||
* @param is_orig true if the file is being sent from connection originator
|
||||
* or false if is being sent in the opposite direction.
|
||||
* @return #current_file_id, which is a hash of a unique file handle string
|
||||
* set by a \c get_file_handle event handler.
|
||||
*/
|
||||
std::string GetFileID(const zeek::Tag& tag, Connection* c, bool is_orig);
|
||||
|
||||
uint64_t CurrentFiles() { return id_map.size(); }
|
||||
|
||||
uint64_t MaxFiles() { return max_files; }
|
||||
|
@ -399,19 +412,6 @@ protected:
|
|||
*/
|
||||
bool RemoveFile(const std::string& file_id);
|
||||
|
||||
/**
|
||||
* Sets #current_file_id to a hash of a unique file handle string based on
|
||||
* what the \c get_file_handle event derives from the connection params.
|
||||
* Event queue is flushed so that we can get the handle value immediately.
|
||||
* @param tag network protocol over which the file is transferred.
|
||||
* @param conn network connection over which the file is transferred.
|
||||
* @param is_orig true if the file is being sent from connection originator
|
||||
* or false if is being sent in the opposite direction.
|
||||
* @return #current_file_id, which is a hash of a unique file handle string
|
||||
* set by a \c get_file_handle event handler.
|
||||
*/
|
||||
std::string GetFileID(const zeek::Tag& tag, Connection* c, bool is_orig);
|
||||
|
||||
/**
|
||||
* Check if analysis is available for files transferred over a given
|
||||
* network protocol.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue