zeek/testing/btest/plugins/hooks-plugin/src/Plugin.h
Johanna Amann 91dcefe104 Fix and extend behavior of HookLoadFile
This commit fixes and extends the behavior of HookLoadFile. Before this
change, HookLoadFile appended ".bro" to each path that was @loaded, even
if the path specified directory names. Furthermore it only gave the path
of the file as it was specified in the Bro script without revealing the
final path of the file that it was going to load.

This patch changes this behavior - in addition to giving the unmodified
path given in the @load command, the hook now returns the resolved path
of the file or directory it is going to load (if found). The hook is
furthermore raises for @load-sigs and @load-plugin; a enum specifies the
kind of load that is happening.
2017-11-16 12:31:27 -08:00

36 lines
1.4 KiB
C++

#ifndef BRO_PLUGIN_Demo_Hooks
#define BRO_PLUGIN_Demo_Hooks
#include <plugin/Plugin.h>
namespace plugin {
namespace Demo_Hooks {
class Plugin : public ::plugin::Plugin
{
protected:
int HookLoadFile(const LoadType type, const std::string& file, const std::string& resolved) override;
std::pair<bool, Val*> HookCallFunction(const Func* func, Frame* frame, val_list* args) override;
bool HookQueueEvent(Event* event) override;
void HookDrainEvents() override;
void HookUpdateNetworkTime(double network_time) override;
void HookBroObjDtor(void* obj) override;
void HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields) override;
bool HookLogWrite(const std::string& writer, const std::string& filter, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields, threading::Value** vals) override;
void HookSetupAnalyzerTree(Connection *conn) override;
void MetaHookPre(HookType hook, const HookArgumentList& args) override;
void MetaHookPost(HookType hook, const HookArgumentList& args, HookArgument result) override;
void RenderVal(const threading::Value* val, ODesc &d) const;
// Overridden from plugin::Plugin.
plugin::Configuration Configure() override;
};
extern Plugin plugin;
}
}
#endif