mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
Replace libmagic w/ Bro signatures for file MIME type identification.
Notable changes: - libmagic is no longer used at all. All MIME type detection is done through new Bro signatures, and there's no longer a means to get verbose file type descriptions (e.g. "PNG image data, 1435 x 170"). The majority of the default file magic signatures are derived from the default magic database of libmagic ~5.17. - File magic signatures consist of two new constructs in the signature rule parsing grammar: "file-magic" gives a regular expression to match against, and "file-mime" gives the MIME type string of content that matches the magic and an optional strength value for the match. - Modified signature/rule syntax for identifiers: they can no longer start with a '-', which made for ambiguous syntax when doing negative strength values in "file-mime". Also brought syntax for Bro script identifiers in line with reality (they can't start with numbers or include '-' at all). - A new Built-In Function, "file_magic", can be used to get all file magic matches and their corresponding strength against a given chunk of data - The second parameter of the "identify_data" Built-In Function can no longer be used to get verbose file type descriptions, though it can still be used to get the strongest matching file magic signature. - The "file_transferred" event's "descr" parameter no longer contains verbose file type descriptions. - The BROMAGIC environment variable no longer changes any behavior in Bro as magic databases are no longer used/installed. - Reverted back to minimum requirement of CMake 2.6.3 from 2.8.0 (it's back to being the same requirement as the Bro v2.2 release). The bump was to accomodate building libmagic as an external project, which is no longer needed. Addresses BIT-1143.
This commit is contained in:
parent
f2f817c8b1
commit
b22ca5d0a3
40 changed files with 4636 additions and 173 deletions
|
@ -34,6 +34,7 @@ static uint8_t mask_to_len(uint32_t mask)
|
|||
%token TOK_ENABLE
|
||||
%token TOK_EVAL
|
||||
%token TOK_EVENT
|
||||
%token TOK_MIME
|
||||
%token TOK_HEADER
|
||||
%token TOK_IDENT
|
||||
%token TOK_INT
|
||||
|
@ -61,9 +62,9 @@ static uint8_t mask_to_len(uint32_t mask)
|
|||
|
||||
%type <str> TOK_STRING TOK_IDENT TOK_POLICY_SYMBOL TOK_PATTERN pattern string
|
||||
%type <val> TOK_INT TOK_TCP_STATE_SYM TOK_IP_OPTION_SYM TOK_COMP
|
||||
%type <val> integer ipoption_list tcpstate_list
|
||||
%type <val> integer ipoption_list tcpstate_list opt_strength
|
||||
%type <rule> rule
|
||||
%type <bl> TOK_BOOL
|
||||
%type <bl> TOK_BOOL opt_negate
|
||||
%type <hdr_test> hdr_expr
|
||||
%type <range> range rangeopt
|
||||
%type <vallist> value_list
|
||||
|
@ -186,6 +187,9 @@ rule_attr:
|
|||
| TOK_EVENT string
|
||||
{ current_rule->AddAction(new RuleActionEvent($2)); }
|
||||
|
||||
| TOK_MIME string opt_strength
|
||||
{ current_rule->AddAction(new RuleActionMIME($2, $3)); }
|
||||
|
||||
| TOK_ENABLE TOK_STRING
|
||||
{ current_rule->AddAction(new RuleActionEnable($2)); }
|
||||
|
||||
|
@ -359,6 +363,20 @@ integer:
|
|||
{ $$ = id_to_uint($1); }
|
||||
;
|
||||
|
||||
opt_negate:
|
||||
'-'
|
||||
{ $$ = true; }
|
||||
|
|
||||
{ $$ = false; }
|
||||
;
|
||||
|
||||
opt_strength:
|
||||
',' opt_negate TOK_INT
|
||||
{ $$ = $2 ? -$3 : $3; }
|
||||
|
|
||||
{ $$ = 0; }
|
||||
;
|
||||
|
||||
string:
|
||||
TOK_STRING
|
||||
{ $$ = $1; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue