Move file_analysis code to zeek namespaces

This commit is contained in:
Tim Wojtulewicz 2020-08-01 10:47:36 -07:00
parent 8411adf9e1
commit 14408235b8
66 changed files with 554 additions and 410 deletions

View file

@ -9,18 +9,18 @@
#include "util.h"
#include "file_analysis/Manager.h"
using namespace file_analysis;
namespace zeek::file_analysis::detail {
DataEvent::DataEvent(zeek::RecordValPtr args, File* file,
DataEvent::DataEvent(zeek::RecordValPtr args, zeek::file_analysis::File* file,
zeek::EventHandlerPtr ce, zeek::EventHandlerPtr se)
: file_analysis::Analyzer(file_mgr->GetComponentTag("DATA_EVENT"),
: file_analysis::Analyzer(zeek::file_mgr->GetComponentTag("DATA_EVENT"),
std::move(args), file),
chunk_event(ce), stream_event(se)
{
}
file_analysis::Analyzer* DataEvent::Instantiate(zeek::RecordValPtr args,
File* file)
zeek::file_analysis::Analyzer* DataEvent::Instantiate(zeek::RecordValPtr args,
zeek::file_analysis::File* file)
{
const auto& chunk_val = args->GetField("chunk_event");
const auto& stream_val = args->GetField("stream_event");
@ -63,3 +63,5 @@ bool DataEvent::DeliverStream(const u_char* data, uint64_t len)
return true;
}
} // namespace zeek::file_analysis::detail

View file

@ -9,12 +9,12 @@
#include "Analyzer.h"
#include "EventHandler.h"
namespace file_analysis {
namespace zeek::file_analysis::detail {
/**
* An analyzer to send file data to script-layer via events.
*/
class DataEvent : public file_analysis::Analyzer {
class DataEvent : public zeek::file_analysis::Analyzer {
public:
/**
@ -43,8 +43,8 @@ public:
* @return the new DataEvent analyzer instance or a null pointer if
* no "chunk_event" or "stream_event" field was specfied in \a args.
*/
static file_analysis::Analyzer* Instantiate(zeek::RecordValPtr args,
File* file);
static zeek::file_analysis::Analyzer* Instantiate(zeek::RecordValPtr args,
zeek::file_analysis::File* file);
protected:
@ -57,7 +57,7 @@ protected:
* @param se pointer to event handler which will be called to receive
* sequential file data.
*/
DataEvent(zeek::RecordValPtr args, File* file,
DataEvent(zeek::RecordValPtr args, zeek::file_analysis::File* file,
zeek::EventHandlerPtr ce, zeek::EventHandlerPtr se);
private:
@ -65,4 +65,10 @@ private:
zeek::EventHandlerPtr stream_event;
};
} // namespace zeek::file_analysis::detail
namespace file_analysis {
using DataEvent [[deprecated("Remove in v4.1. Use zeek::file_analysis::detail::DataEvent.")]] = zeek::file_analysis::detail::DataEvent;
} // namespace file_analysis

View file

@ -4,14 +4,13 @@
#include "plugin/Plugin.h"
#include "file_analysis/Component.h"
namespace plugin {
namespace Zeek_FileDataEvent {
namespace zeek::plugin::detail::Zeek_FileDataEvent {
class Plugin : public zeek::plugin::Plugin {
public:
zeek::plugin::Configuration Configure() override
{
AddComponent(new ::file_analysis::Component("DATA_EVENT", ::file_analysis::DataEvent::Instantiate));
AddComponent(new zeek::file_analysis::Component("DATA_EVENT", zeek::file_analysis::detail::DataEvent::Instantiate));
zeek::plugin::Configuration config;
config.name = "Zeek::FileDataEvent";
@ -20,5 +19,4 @@ public:
}
} plugin;
}
}
} // namespace zeek::plugin::detail::Zeek_FileDataEvent