Files
An interface for driving the analysis of files, possibly independent of any network protocol over which they’re transported.
Namespace: | Files |
---|---|
Imports: | base/bif/file_analysis.bif.bro, base/frameworks/analyzer, base/frameworks/logging, base/utils/site.bro |
Source File: | /scripts/base/frameworks/files/main.bro |
Files::analyze_by_mime_type_automatically : bool &redef |
Decide if you want to automatically attached analyzers to files based on the detected mime type of the file. |
Files::disable : table &redef |
A table that can be used to disable file analysis completely for any files transferred over given network protocol analyzers. |
Files::enable_reassembler : bool &redef |
The default setting for file reassembly. |
Files::reassembly_buffer_size : count &redef |
The default per-file reassembly buffer size. |
Files::salt : string &redef |
The salt concatenated to unique file handle strings generated by
get_file_handle before hashing them in to a file id
(the id field of fa_file ). |
Files::AnalyzerArgs : record &redef |
A structure which parameterizes a type of file analysis. |
Files::Info : record &redef |
Contains all metadata related to the analysis of a given file. |
Files::ProtoRegistration : record |
Files::log_files : event |
Event that can be handled to access the Info record as it is sent on to the logging framework. |
Files::add_analyzer : function |
Adds an analyzer to the analysis of a given file. |
Files::all_registered_mime_types : function |
Returns a table of all MIME-type-to-analyzer mappings currently registered. |
Files::analyzer_name : function |
Translates a file analyzer enum value to a string with the analyzer’s name. |
Files::describe : function |
Provides a text description regarding metadata of the file. |
Files::disable_reassembly : function |
Disables the file reassembler on this file. |
Files::enable_reassembly : function |
Allows the file reassembler to be used if it’s necessary because the file is transferred out of order. |
Files::register_analyzer_add_callback : function |
Register a callback for file analyzers to use if they need to do some manipulation when they are being added to a file before the core code takes over. |
Files::register_for_mime_type : function |
Registers a MIME type for an analyzer. |
Files::register_for_mime_types : function |
Registers a set of MIME types for an analyzer. |
Files::register_protocol : function |
Register callbacks for protocols that work with the Files framework. |
Files::registered_mime_types : function |
Returns a set of all MIME types currently registered for a specific analyzer. |
Files::remove_analyzer : function |
Removes an analyzer from the analysis of a given file. |
Files::set_reassembly_buffer_size : function |
Set the maximum size the reassembly buffer is allowed to grow for the given file. |
Files::set_timeout_interval : function |
Sets the timeout_interval field of fa_file , which is
used to determine the length of inactivity that is allowed for a file
before internal state related to it is cleaned up. |
Files::stop : function |
Stops/ignores any further analysis of a given file. |
Files::analyze_by_mime_type_automatically
Type: | bool |
---|---|
Attributes: | &redef |
Default: | T |
Decide if you want to automatically attached analyzers to files based on the detected mime type of the file.
Files::disable
Type: | table [Files::Tag ] of bool |
---|---|
Attributes: | &redef |
Default: | {} |
A table that can be used to disable file analysis completely for any files transferred over given network protocol analyzers.
Files::enable_reassembler
Type: | bool |
---|---|
Attributes: | &redef |
Default: | T |
The default setting for file reassembly.
Files::reassembly_buffer_size
Type: | count |
---|---|
Attributes: | &redef |
Default: | 524288 |
The default per-file reassembly buffer size.
Files::salt
Type: | string |
---|---|
Attributes: | &redef |
Default: | "I recommend changing this." |
The salt concatenated to unique file handle strings generated by
get_file_handle
before hashing them in to a file id
(the id field of fa_file
).
Provided to help mitigate the possibility of manipulating parts of
network connections that factor in to the file handle in order to
generate two handles that would hash to the same file id.
Files::AnalyzerArgs
Type: |
|
---|---|
Attributes: |
A structure which parameterizes a type of file analysis.
Files::Info
Type: |
|
---|---|
Attributes: |
Contains all metadata related to the analysis of a given file.
For the most part, fields here are derived from ones of the same name
in fa_file
.
Files::ProtoRegistration
Type: |
|
---|
Files::log_files
Type: | event (rec: Files::Info ) |
---|
Event that can be handled to access the Info record as it is sent on to the logging framework.
Files::add_analyzer
Type: | function (f: fa_file , tag: Files::Tag , args: Files::AnalyzerArgs &default = [chunk_event=<uninitialized>, stream_event=<uninitialized>, extract_filename=<uninitialized>, extract_limit=104857600] &optional ) : bool |
---|
Adds an analyzer to the analysis of a given file.
F: | the file. |
---|---|
Tag: | the analyzer type. |
Args: | any parameters the analyzer takes. |
Returns: | true if the analyzer will be added, or false if analysis for the file isn’t currently active or the args were invalid for the analyzer type. |
Files::all_registered_mime_types
Type: | function () : table [Files::Tag ] of set [string ] |
---|
Returns a table of all MIME-type-to-analyzer mappings currently registered.
Returns: | A table mapping each analyzer to the set of MIME types registered for it. |
---|
Files::analyzer_name
Type: | function (tag: Files::Tag ) : string |
---|
Translates a file analyzer enum value to a string with the analyzer’s name.
Tag: | The analyzer tag. |
---|---|
Returns: | The analyzer name corresponding to the tag. |
Files::describe
Type: | function (f: fa_file ) : string |
---|
Provides a text description regarding metadata of the file. For example, with HTTP it would return a URL.
F: | The file to be described. |
---|---|
Returns: | a text description regarding metadata of the file. |
Files::disable_reassembly
Type: | function (f: fa_file ) : void |
---|
Disables the file reassembler on this file. If the file is not transferred out of order this will have no effect.
F: | the file. |
---|
Files::enable_reassembly
Type: | function (f: fa_file ) : void |
---|
Allows the file reassembler to be used if it’s necessary because the file is transferred out of order.
F: | the file. |
---|
Files::register_analyzer_add_callback
Type: | function (tag: Files::Tag , callback: function (f: fa_file , args: Files::AnalyzerArgs ) : void ) : void |
---|
Register a callback for file analyzers to use if they need to do some manipulation when they are being added to a file before the core code takes over. This is unlikely to be interesting for users and should only be called by file analyzer authors but is not required.
Tag: | Tag for the file analyzer. |
---|---|
Callback: | Function to execute when the given file analyzer is being added. |
Files::register_for_mime_type
Type: | function (tag: Files::Tag , mt: string ) : bool |
---|
Registers a MIME type for an analyzer. If a future file with this type is seen, the analyzer will be automatically assigned to parsing it. The function adds to all MIME types already registered, it doesn’t replace them.
Tag: | The tag of the analyzer. |
---|---|
Mt: | The MIME type in the form “foo/bar” (case-insensitive). |
Returns: | True if the MIME type was successfully registered. |
Files::register_for_mime_types
Type: | function (tag: Files::Tag , mime_types: set [string ]) : bool |
---|
Registers a set of MIME types for an analyzer. If a future connection on one of these types is seen, the analyzer will be automatically assigned to parsing it. The function adds to all MIME types already registered, it doesn’t replace them.
Tag: | The tag of the analyzer. |
---|---|
Mts: | The set of MIME types, each in the form “foo/bar” (case-insensitive). |
Returns: | True if the MIME types were successfully registered. |
Files::register_protocol
Type: | function (tag: Analyzer::Tag , reg: Files::ProtoRegistration ) : bool |
---|
Register callbacks for protocols that work with the Files framework. The callbacks must uniquely identify a file and each protocol can only have a single callback registered for it.
Tag: | Tag for the protocol analyzer having a callback being registered. |
---|---|
Reg: | A Files::ProtoRegistration record. |
Returns: | true if the protocol being registered was not previously registered. |
Files::registered_mime_types
Type: | function (tag: Files::Tag ) : set [string ] |
---|
Returns a set of all MIME types currently registered for a specific analyzer.
Tag: | The tag of the analyzer. |
---|---|
Returns: | The set of MIME types. |
Files::remove_analyzer
Type: | function (f: fa_file , tag: Files::Tag , args: Files::AnalyzerArgs &default = [chunk_event=<uninitialized>, stream_event=<uninitialized>, extract_filename=<uninitialized>, extract_limit=104857600] &optional ) : bool |
---|
Removes an analyzer from the analysis of a given file.
F: | the file. |
---|---|
Tag: | the analyzer type. |
Args: | the analyzer (type and args) to remove. |
Returns: | true if the analyzer will be removed, or false if analysis for the file isn’t currently active. |
Files::set_reassembly_buffer_size
Type: | function (f: fa_file , max: count ) : void |
---|
Set the maximum size the reassembly buffer is allowed to grow for the given file.
F: | the file. |
---|---|
Max: | Maximum allowed size of the reassembly buffer. |
Files::set_timeout_interval
Type: | function (f: fa_file , t: interval ) : bool |
---|
Sets the timeout_interval field of fa_file
, which is
used to determine the length of inactivity that is allowed for a file
before internal state related to it is cleaned up. When used within
a file_timeout
handler, the analysis will delay timing out
again for the period specified by t.
F: | the file. |
---|---|
T: | the amount of time the file can remain inactive before discarding. |
Returns: | true if the timeout interval was set, or false if analysis for the file isn’t currently active. |