mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00

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.
30 lines
1,019 B
C++
30 lines
1,019 B
C++
#include "Foo.h"
|
|
|
|
#include <zeek/file_analysis/File.h>
|
|
#include <zeek/file_analysis/Manager.h>
|
|
#include <algorithm>
|
|
|
|
#include "events.bif.h"
|
|
|
|
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* 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));
|
|
}
|
|
|
|
return true;
|
|
}
|