file_analysis: include cleanup

This commit is contained in:
Max Kellermann 2020-02-12 10:30:21 +01:00
parent 653b3f43e0
commit 0cf5799ca6
16 changed files with 52 additions and 20 deletions

View file

@ -15,6 +15,7 @@
#include "Net.h" #include "Net.h"
#include "Conn.h" #include "Conn.h"
#include "Timer.h" #include "Timer.h"
#include "Var.h" // for internal_val()
#include "EventHandler.h" #include "EventHandler.h"
#include "plugin/Plugin.h" #include "plugin/Plugin.h"
#include "plugin/Manager.h" #include "plugin/Manager.h"

View file

@ -1,5 +1,6 @@
%extern{ %extern{
#include "Sessions.h" #include "Sessions.h"
#include "Conn.h"
%} %}
connection AYIYA_Conn(bro_analyzer: BroAnalyzer) connection AYIYA_Conn(bro_analyzer: BroAnalyzer)

View file

@ -2,6 +2,7 @@
#include "Analyzer.h" #include "Analyzer.h"
#include "Manager.h" #include "Manager.h"
#include "Val.h"
file_analysis::ID file_analysis::Analyzer::id_counter = 0; file_analysis::ID file_analysis::Analyzer::id_counter = 0;
@ -17,3 +18,13 @@ void file_analysis::Analyzer::SetAnalyzerTag(const file_analysis::Tag& arg_tag)
assert(! tag || tag == arg_tag); assert(! tag || tag == arg_tag);
tag = arg_tag; tag = arg_tag;
} }
file_analysis::Analyzer::Analyzer(file_analysis::Tag arg_tag, RecordVal* arg_args, File* arg_file)
: tag(arg_tag),
args(arg_args->Ref()->AsRecordVal()),
file(arg_file),
got_stream_delivery(false),
skip(false)
{
id = ++id_counter;
}

View file

@ -2,11 +2,11 @@
#pragma once #pragma once
#include "Val.h"
#include "NetVar.h"
#include "Tag.h" #include "Tag.h"
#include "file_analysis/file_analysis.bif.h" #include <sys/types.h> // for u_char
class RecordVal;
namespace file_analysis { namespace file_analysis {
@ -146,15 +146,7 @@ protected:
* tunable options, if any, related to a particular analyzer type. * tunable options, if any, related to a particular analyzer type.
* @param arg_file the file to which the the analyzer is being attached. * @param arg_file the file to which the the analyzer is being attached.
*/ */
Analyzer(file_analysis::Tag arg_tag, RecordVal* arg_args, File* arg_file) Analyzer(file_analysis::Tag arg_tag, RecordVal* arg_args, File* arg_file);
: tag(arg_tag),
args(arg_args->Ref()->AsRecordVal()),
file(arg_file),
got_stream_delivery(false),
skip(false)
{
id = ++id_counter;
}
/** /**
* Constructor. Only derived classes are meant to be instantiated. * Constructor. Only derived classes are meant to be instantiated.

View file

@ -4,6 +4,9 @@
#include "File.h" #include "File.h"
#include "Analyzer.h" #include "Analyzer.h"
#include "Manager.h" #include "Manager.h"
#include "CompHash.h"
#include "Val.h"
#include "file_analysis/file_analysis.bif.h"
using namespace file_analysis; using namespace file_analysis;
@ -106,6 +109,12 @@ bool AnalyzerSet::AddMod::Perform(AnalyzerSet* set)
return true; return true;
} }
void AnalyzerSet::AddMod::Abort()
{
delete a;
delete key;
}
bool AnalyzerSet::Remove(const file_analysis::Tag& tag, RecordVal* args) bool AnalyzerSet::Remove(const file_analysis::Tag& tag, RecordVal* args)
{ {
return Remove(tag, GetKey(tag, args)); return Remove(tag, GetKey(tag, args));

View file

@ -4,14 +4,17 @@
#include <queue> #include <queue>
#include "Analyzer.h"
#include "Dict.h" #include "Dict.h"
#include "CompHash.h"
#include "Val.h"
#include "Tag.h" #include "Tag.h"
using std::queue;
class CompositeHash;
class RecordVal;
namespace file_analysis { namespace file_analysis {
class Analyzer;
class File; class File;
/** /**
@ -173,7 +176,7 @@ private:
: Modification(), a(arg_a), key(arg_key) {} : Modification(), a(arg_a), key(arg_key) {}
~AddMod() override {} ~AddMod() override {}
bool Perform(AnalyzerSet* set) override; bool Perform(AnalyzerSet* set) override;
void Abort() override { delete a; delete key; } void Abort() override;
protected: protected:
file_analysis::Analyzer* a; file_analysis::Analyzer* a;

View file

@ -2,17 +2,22 @@
#pragma once #pragma once
#include <list>
#include <string> #include <string>
#include <utility> #include <utility>
#include "analyzer/Tag.h"
#include "AnalyzerSet.h" #include "AnalyzerSet.h"
#include "BroString.h" #include "BroString.h"
#include "BroList.h" // for val_list
#include "WeirdState.h" #include "WeirdState.h"
using std::string; using std::string;
class Connection; class Connection;
class RecordType;
class RecordVal; class RecordVal;
class EventHandlerPtr;
namespace file_analysis { namespace file_analysis {

View file

@ -10,6 +10,7 @@
#include "plugin/Manager.h" #include "plugin/Manager.h"
#include "analyzer/Manager.h" #include "analyzer/Manager.h"
#include "file_analysis/file_analysis.bif.h"
#include <openssl/md5.h> #include <openssl/md5.h>

View file

@ -12,7 +12,7 @@
#include "plugin/ComponentManager.h" #include "plugin/ComponentManager.h"
#include "file_analysis/file_analysis.bif.h" #include "analyzer/Tag.h"
using std::map; using std::map;
using std::set; using std::set;

View file

@ -5,6 +5,7 @@
#include "DataEvent.h" #include "DataEvent.h"
#include "EventRegistry.h" #include "EventRegistry.h"
#include "Event.h" #include "Event.h"
#include "Func.h"
#include "util.h" #include "util.h"
#include "file_analysis/Manager.h" #include "file_analysis/Manager.h"

View file

@ -7,6 +7,7 @@
#include "Val.h" #include "Val.h"
#include "File.h" #include "File.h"
#include "Analyzer.h" #include "Analyzer.h"
#include "EventHandler.h"
namespace file_analysis { namespace file_analysis {

View file

@ -4,6 +4,7 @@ module FileExtract;
%%{ %%{
#include "file_analysis/Manager.h" #include "file_analysis/Manager.h"
#include "file_analysis/file_analysis.bif.h"
%%} %%}
## :zeek:see:`FileExtract::set_limit`. ## :zeek:see:`FileExtract::set_limit`.

View file

@ -10,6 +10,7 @@
#include "types.bif.h" #include "types.bif.h"
#include "ocsp_events.bif.h" #include "ocsp_events.bif.h"
#include "file_analysis/File.h"
#include "file_analysis/Manager.h" #include "file_analysis/Manager.h"
#include <openssl/x509.h> #include <openssl/x509.h>

View file

@ -4,14 +4,14 @@
#include <string> #include <string>
#include "../File.h"
#include "Analyzer.h"
#include "X509Common.h" #include "X509Common.h"
#include <openssl/ocsp.h> #include <openssl/ocsp.h>
namespace file_analysis { namespace file_analysis {
class File;
class OCSP : public file_analysis::X509Common { class OCSP : public file_analysis::X509Common {
public: public:
bool DeliverStream(const u_char* data, uint64_t len) override; bool DeliverStream(const u_char* data, uint64_t len) override;

View file

@ -8,6 +8,7 @@
#include "events.bif.h" #include "events.bif.h"
#include "types.bif.h" #include "types.bif.h"
#include "file_analysis/File.h"
#include "file_analysis/Manager.h" #include "file_analysis/Manager.h"
#include <broker/error.hh> #include <broker/error.hh>

View file

@ -5,16 +5,20 @@
#pragma once #pragma once
#include "file_analysis/File.h"
#include "Analyzer.h" #include "Analyzer.h"
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
class EventHandlerPtr;
class Reporter; class Reporter;
class StringVal;
namespace file_analysis { namespace file_analysis {
class Tag;
class File;
class X509Common : public file_analysis::Analyzer { class X509Common : public file_analysis::Analyzer {
public: public:
~X509Common() override {}; ~X509Common() override {};