Update plugin btests for namespace changes

This commit is contained in:
Tim Wojtulewicz 2020-08-21 18:10:39 +00:00
parent 70c2397f69
commit 874e170341
43 changed files with 420 additions and 317 deletions

View file

@ -5,23 +5,22 @@
#include <events.bif.h>
#include <file_analysis/Manager.h>
using namespace plugin::Demo_Foo;
using namespace btest::plugin::Demo_Foo;
Foo::Foo(RecordVal* args, file_analysis::File* file)
: file_analysis::Analyzer(file_mgr->GetComponentTag("FOO"), args, file)
Foo::Foo(zeek::RecordValPtr args, zeek::file_analysis::File* file)
: zeek::file_analysis::Analyzer(zeek::file_mgr->GetComponentTag("FOO"), std::move(args), file)
{
}
file_analysis::Analyzer* Foo::Instantiate(RecordVal* args, file_analysis::File* file)
zeek::file_analysis::Analyzer* Foo::Instantiate(zeek::RecordValPtr args, zeek::file_analysis::File* file)
{
return new Foo(args, file);
return new Foo(std::move(args), file);
}
bool Foo::DeliverStream(const u_char* data, uint64 len)
bool Foo::DeliverStream(const u_char* data, uint64_t len)
{
val_list* args = new val_list;
args->append(GetFile()->GetVal()->Ref());
args->append(new StringVal(new BroString(data, len, 0)));
mgr.QueueEvent(foo_piece, args);
zeek::event_mgr.Enqueue(foo_piece,
GetFile()->ToVal(),
zeek::make_intrusive<zeek::StringVal>(new zeek::String(data, len, 0)));
return true;
}

View file

@ -4,17 +4,16 @@
#include <Val.h>
#include <file_analysis/Analyzer.h>
namespace plugin {
namespace Demo_Foo {
namespace btest::plugin::Demo_Foo {
class Foo : public file_analysis::Analyzer {
class Foo : public zeek::file_analysis::Analyzer {
public:
virtual bool DeliverStream(const u_char* data, uint64 len);
virtual bool DeliverStream(const u_char* data, uint64_t len);
static file_analysis::Analyzer* Instantiate(RecordVal* args, file_analysis::File* file);
static zeek::file_analysis::Analyzer* Instantiate(zeek::RecordValPtr args, zeek::file_analysis::File* file);
protected:
Foo(RecordVal* args, file_analysis::File* file);
Foo(zeek::RecordValPtr args, zeek::file_analysis::File* file);
};
} }
}

View file

@ -4,15 +4,15 @@
#include "file_analysis/Component.h"
#include "file_analysis/File.h"
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
namespace btest::plugin::Demo_Foo { Plugin plugin; }
using namespace plugin::Demo_Foo;
using namespace btest::plugin::Demo_Foo;
plugin::Configuration Plugin::Configure()
zeek::plugin::Configuration Plugin::Configure()
{
AddComponent(new ::file_analysis::Component("Foo", ::plugin::Demo_Foo::Foo::Instantiate));
AddComponent(new zeek::file_analysis::Component("Foo", btest::plugin::Demo_Foo::Foo::Instantiate));
plugin::Configuration config;
zeek::plugin::Configuration config;
config.name = "Demo::Foo";
config.description = "A Foo test analyzer";
config.version.major = 1;

View file

@ -0,0 +1,16 @@
#pragma once
#include <zeek/plugin/Plugin.h>
namespace btest::plugin::Demo_Foo {
class Plugin : public zeek::plugin::Plugin
{
protected:
// Overridden from zeek::plugin::Plugin.
zeek::plugin::Configuration Configure() override;
};
extern Plugin plugin;
}