Skip to content

Commit

Permalink
Make adjustments for Zeek 4.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiwek committed Mar 2, 2021
1 parent 518a5ae commit f72d154
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
# loaded automatically at that point.
#

# @load ./bar.bro

@ifdef ( zeek_init )
event zeek_init()
@else
event bro_init()
@endif
{
print "loaded bro-test-package scripts";
print "loaded zeek-test-package scripts";
}
10 changes: 3 additions & 7 deletions plugin/scripts/__load__.bro → plugin/scripts/__load__.zeek
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
#
# Normally, that will be only code that initializes built-in elements. Load
# your standard scripts in
# scripts/<plugin-namespace>/<plugin-name>/__load__.bro instead.
# scripts/<plugin-namespace>/<plugin-name>/__load__.zeek instead.
#

@load ./init.bro
@load ./init.zeek

@ifdef ( zeek_init )
event zeek_init() &priority=10
@else
event bro_init() &priority=10
@endif
{
print "loaded bro-test-package plugin";
print "loaded zeek-test-package plugin";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#
# This is primarily for defining types that BiFs already depend on. If you need
# to do any other unconditional initialization (usually that's just for other BiF
# elemets), that should go into __load__.bro instead.
# elemets), that should go into __load__.zeek instead.
#

@load ./types.bro
@load ./types.zeek


File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions plugin/src/Plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace plugin { namespace Demo_Rot13 { Plugin plugin; } }

using namespace plugin::Demo_Rot13;

plugin::Configuration Plugin::Configure()
zeek::plugin::Configuration Plugin::Configure()
{
plugin::Configuration config;
zeek::plugin::Configuration config;
config.name = "Demo::Rot13";
config.description = "<Insert description>";
config.version.major = 0;
Expand Down
11 changes: 4 additions & 7 deletions plugin/src/Plugin.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@

#ifndef BRO_PLUGIN_DEMO_ROT13
#define BRO_PLUGIN_DEMO_ROT13
#pragma once

#include <plugin/Plugin.h>
#include <zeek/plugin/Plugin.h>

namespace plugin {
namespace Demo_Rot13 {

class Plugin : public ::plugin::Plugin
class Plugin : public zeek::plugin::Plugin
{
protected:
// Overridden from plugin::Plugin.
virtual plugin::Configuration Configure();
virtual zeek::plugin::Configuration Configure();
};

extern Plugin plugin;

}
}

#endif
12 changes: 7 additions & 5 deletions plugin/src/rot13.bif
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
%%{
#include "BroString.h"
#include "zeek/util.h"
#include "zeek/ZeekString.h"
#include "zeek/Val.h"
%%}

module Demo;

function rot13%(s: string%) : string
%{
char* rot13 = copy_string(s->CheckString());
char* rot13 = util::copy_string(s->CheckString());

for ( char* p = rot13; *p; p++ )
{
char b = islower(*p) ? 'a' : 'A';
*p = (*p - b + 13) % 26 + b;
}

BroString* bs = new BroString(1, reinterpret_cast<byte_vec>(rot13),
strlen(rot13));
return new StringVal(bs);
auto zs = new zeek::String(1, reinterpret_cast<byte_vec>(rot13),
strlen(rot13));
return make_intrusive<StringVal>(zs);
%}
File renamed without changes.
4 changes: 2 additions & 2 deletions testing/Baseline/tests.main/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
loaded bro-test-package plugin
loaded bro-test-package scripts
loaded zeek-test-package plugin
loaded zeek-test-package scripts
2 changes: 1 addition & 1 deletion testing/Baseline/tests.rot13/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Uryyb
loaded bro-test-package plugin
loaded zeek-test-package plugin

0 comments on commit f72d154

Please sign in to comment.