Reformat Zeek in Spicy style

This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
This commit is contained in:
Benjamin Bannier 2023-10-10 21:13:34 +02:00
parent 7b8e7ed72c
commit f5a76c1aed
786 changed files with 131714 additions and 153609 deletions

View file

@ -9,28 +9,22 @@
using namespace btest::plugin::Demo_Foo;
Foo::Foo(zeek::RecordValPtr args, zeek::file_analysis::File* file)
: zeek::file_analysis::Analyzer(zeek::file_mgr->GetComponentTag("FOO"), std::move(args), file)
{
}
: zeek::file_analysis::Analyzer(zeek::file_mgr->GetComponentTag("FOO"), std::move(args), file) {}
zeek::file_analysis::Analyzer* Foo::Instantiate(zeek::RecordValPtr args,
zeek::file_analysis::File* file)
{
return new Foo(std::move(args), file);
}
zeek::file_analysis::Analyzer* Foo::Instantiate(zeek::RecordValPtr args, zeek::file_analysis::File* file) {
return new Foo(std::move(args), file);
}
bool Foo::DeliverStream(const u_char* data, uint64_t len)
{
static int i = 0;
AnalyzerConfirmation();
zeek::event_mgr.Enqueue(foo_piece, GetFile()->ToVal(),
zeek::make_intrusive<zeek::StringVal>(new zeek::String(data, len, 0)));
if ( ++i % 3 == 0 )
{
uint64_t threshold = 16;
AnalyzerViolation(zeek::util::fmt("test violation %d", i),
reinterpret_cast<const char*>(data), std::min(len, threshold));
}
bool Foo::DeliverStream(const u_char* data, uint64_t len) {
static int i = 0;
AnalyzerConfirmation();
zeek::event_mgr.Enqueue(foo_piece, GetFile()->ToVal(),
zeek::make_intrusive<zeek::StringVal>(new zeek::String(data, len, 0)));
if ( ++i % 3 == 0 ) {
uint64_t threshold = 16;
AnalyzerViolation(zeek::util::fmt("test violation %d", i), reinterpret_cast<const char*>(data),
std::min(len, threshold));
}
return true;
}
return true;
}

View file

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

View file

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

View file

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