mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00

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.
102 lines
2.3 KiB
C++
102 lines
2.3 KiB
C++
#ifndef ruleaction_h
|
|
#define ruleaction_h
|
|
|
|
#include "BroString.h"
|
|
#include "List.h"
|
|
#include "util.h"
|
|
|
|
#include "analyzer/Tag.h"
|
|
|
|
class Rule;
|
|
class RuleEndpointState;
|
|
|
|
// Base class of all rule actions.
|
|
class RuleAction {
|
|
public:
|
|
RuleAction() { }
|
|
virtual ~RuleAction() { }
|
|
|
|
virtual void DoAction(const Rule* parent, RuleEndpointState* state,
|
|
const u_char* data, int len) = 0;
|
|
virtual void PrintDebug() = 0;
|
|
};
|
|
|
|
// Implements the "event" keyword.
|
|
class RuleActionEvent : public RuleAction {
|
|
public:
|
|
RuleActionEvent(const char* arg_msg) { msg = copy_string(arg_msg); }
|
|
virtual ~RuleActionEvent() { delete [] msg; }
|
|
|
|
virtual void DoAction(const Rule* parent, RuleEndpointState* state,
|
|
const u_char* data, int len);
|
|
|
|
virtual void PrintDebug();
|
|
|
|
private:
|
|
const char* msg;
|
|
};
|
|
|
|
class RuleActionMIME : public RuleAction {
|
|
public:
|
|
RuleActionMIME(const char* arg_mime, int arg_strength = 0)
|
|
{ mime = copy_string(arg_mime); strength = arg_strength; }
|
|
|
|
virtual ~RuleActionMIME()
|
|
{ delete [] mime; }
|
|
|
|
virtual void DoAction(const Rule* parent, RuleEndpointState* state,
|
|
const u_char* data, int len)
|
|
{ }
|
|
|
|
virtual void PrintDebug();
|
|
|
|
string GetMIME() const
|
|
{ return mime; }
|
|
|
|
int GetStrength() const
|
|
{ return strength; }
|
|
|
|
private:
|
|
const char* mime;
|
|
int strength;
|
|
};
|
|
|
|
// Base class for enable/disable actions.
|
|
class RuleActionAnalyzer : public RuleAction {
|
|
public:
|
|
RuleActionAnalyzer(const char* analyzer);
|
|
|
|
virtual void DoAction(const Rule* parent, RuleEndpointState* state,
|
|
const u_char* data, int len) = 0;
|
|
|
|
virtual void PrintDebug();
|
|
|
|
analyzer::Tag Analyzer() const { return analyzer; }
|
|
analyzer::Tag ChildAnalyzer() const { return child_analyzer; }
|
|
|
|
private:
|
|
analyzer::Tag analyzer;
|
|
analyzer::Tag child_analyzer;
|
|
};
|
|
|
|
class RuleActionEnable : public RuleActionAnalyzer {
|
|
public:
|
|
RuleActionEnable(const char* analyzer) : RuleActionAnalyzer(analyzer) {}
|
|
|
|
virtual void DoAction(const Rule* parent, RuleEndpointState* state,
|
|
const u_char* data, int len);
|
|
|
|
virtual void PrintDebug();
|
|
};
|
|
|
|
class RuleActionDisable : public RuleActionAnalyzer {
|
|
public:
|
|
RuleActionDisable(const char* analyzer) : RuleActionAnalyzer(analyzer) {}
|
|
|
|
virtual void DoAction(const Rule* parent, RuleEndpointState* state,
|
|
const u_char* data, int len);
|
|
|
|
virtual void PrintDebug();
|
|
};
|
|
|
|
#endif
|