mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge branch 'topic/bbannier/bump-spicy'
This commit is contained in:
commit
8910415659
12 changed files with 70 additions and 29 deletions
16
CHANGES
16
CHANGES
|
@ -1,3 +1,19 @@
|
||||||
|
7.2.0-dev.72 | 2025-01-11 17:36:31 +0100
|
||||||
|
|
||||||
|
* Mark `swap` specialization `noexcept` (Benjamin Bannier, Corelight)
|
||||||
|
|
||||||
|
* Clean up some includes (Benjamin Bannier, Corelight)
|
||||||
|
|
||||||
|
* Prevent exception in `noexcept` function. (Benjamin Bannier, Corelight)
|
||||||
|
|
||||||
|
* Prevent exception escape. (Benjamin Bannier, Corelight)
|
||||||
|
|
||||||
|
* Prevent unnecessary copies in Spicy bindings (Benjamin Bannier, Corelight)
|
||||||
|
|
||||||
|
* Bump auxil/spicy to latest development snapshot (Benjamin Bannier, Corelight)
|
||||||
|
|
||||||
|
* Update doc submodule [nomail] [skip ci] (zeek-bot)
|
||||||
|
|
||||||
7.2.0-dev.64 | 2025-01-10 11:15:24 -0800
|
7.2.0-dev.64 | 2025-01-10 11:15:24 -0800
|
||||||
|
|
||||||
* GH-4102: Harden flaky test based on creating a file (Evan Typanski, Corelight)
|
* GH-4102: Harden flaky test based on creating a file (Evan Typanski, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
7.2.0-dev.64
|
7.2.0-dev.72
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4c2cd8c3d7dbff98c95bf69824ed642ae40b1ecd
|
Subproject commit 5f1e39698d8b2e16ae860620e82adb281d500017
|
|
@ -7,18 +7,21 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <variant>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <hilti/rt/backtrace.h>
|
||||||
|
|
||||||
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/Val.h"
|
#include "zeek/Val.h"
|
||||||
#include "zeek/analyzer/Analyzer.h"
|
#include "zeek/analyzer/Analyzer.h"
|
||||||
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
|
||||||
#include "zeek/file_analysis/Analyzer.h"
|
#include "zeek/file_analysis/Analyzer.h"
|
||||||
#include "zeek/packet_analysis/Analyzer.h"
|
#include "zeek/packet_analysis/Analyzer.h"
|
||||||
|
#include "zeek/packet_analysis/protocol/tcp/TCPSessionAdapter.h"
|
||||||
|
|
||||||
namespace zeek::spicy::rt {
|
namespace zeek::spicy::rt {
|
||||||
|
|
||||||
|
@ -129,10 +132,25 @@ struct Cookie {
|
||||||
Cookie(cookie::ProtocolAnalyzer&& c) : data(std::move(c)) { protocol = &data.protocol; }
|
Cookie(cookie::ProtocolAnalyzer&& c) : data(std::move(c)) { protocol = &data.protocol; }
|
||||||
Cookie(cookie::FileAnalyzer&& c) : data(std::move(c)) { file = &data.file; }
|
Cookie(cookie::FileAnalyzer&& c) : data(std::move(c)) { file = &data.file; }
|
||||||
Cookie(cookie::PacketAnalyzer&& c) : data(std::move(c)) { packet = &data.packet; }
|
Cookie(cookie::PacketAnalyzer&& c) : data(std::move(c)) { packet = &data.packet; }
|
||||||
Cookie(Cookie&& other) noexcept : data(other.tag(), std::move(other.data)) { _initLike(other); }
|
|
||||||
|
Cookie(Cookie&& other) noexcept
|
||||||
|
: data(
|
||||||
|
[&]() {
|
||||||
|
try {
|
||||||
|
return other.tag();
|
||||||
|
} catch ( const std::exception& e ) {
|
||||||
|
auto type = hilti::rt::demangle(typeid(e).name());
|
||||||
|
reporter->FatalError("terminating with uncaught exception of type %s: %s", type.c_str(),
|
||||||
|
e.what());
|
||||||
|
}
|
||||||
|
}(),
|
||||||
|
std::move(other.data)) {
|
||||||
|
_initLike(other);
|
||||||
|
}
|
||||||
|
|
||||||
~Cookie() { _delete(); }
|
~Cookie() { _delete(); }
|
||||||
|
|
||||||
Cookie& operator=(Cookie&& other) noexcept {
|
Cookie& operator=(Cookie&& other) noexcept try {
|
||||||
if ( this == &other )
|
if ( this == &other )
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
@ -141,6 +159,9 @@ struct Cookie {
|
||||||
|
|
||||||
new (&data) Data(tag(), std::move(other.data));
|
new (&data) Data(tag(), std::move(other.data));
|
||||||
return *this;
|
return *this;
|
||||||
|
} catch ( const std::exception& e ) {
|
||||||
|
auto type = hilti::rt::demangle(typeid(e).name());
|
||||||
|
reporter->FatalError("terminating with uncaught exception of type %s: %s", type.c_str(), e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache of values that can be expensive to compute.
|
// Cache of values that can be expensive to compute.
|
||||||
|
@ -224,7 +245,7 @@ private:
|
||||||
Cookie(const Cookie& other) = delete;
|
Cookie(const Cookie& other) = delete;
|
||||||
Cookie& operator=(const Cookie& other) = delete;
|
Cookie& operator=(const Cookie& other) = delete;
|
||||||
|
|
||||||
friend inline void swap(Cookie& lhs, Cookie& rhs) {
|
friend inline void swap(Cookie& lhs, Cookie& rhs) noexcept {
|
||||||
Cookie tmp = std::move(lhs);
|
Cookie tmp = std::move(lhs);
|
||||||
lhs = std::move(rhs);
|
lhs = std::move(rhs);
|
||||||
rhs = std::move(tmp);
|
rhs = std::move(tmp);
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -29,7 +28,6 @@
|
||||||
#include <zeek/file_analysis/Manager.h>
|
#include <zeek/file_analysis/Manager.h>
|
||||||
#include <zeek/packet_analysis/Manager.h>
|
#include <zeek/packet_analysis/Manager.h>
|
||||||
|
|
||||||
#include "zeek/DebugLogger.h"
|
|
||||||
#include "zeek/spicy/file-analyzer.h"
|
#include "zeek/spicy/file-analyzer.h"
|
||||||
#include "zeek/spicy/packet-analyzer.h"
|
#include "zeek/spicy/packet-analyzer.h"
|
||||||
#include "zeek/spicy/protocol-analyzer.h"
|
#include "zeek/spicy/protocol-analyzer.h"
|
||||||
|
@ -244,7 +242,7 @@ void Manager::registerType(const std::string& id, const TypePtr& type) {
|
||||||
zeek_id->SetType(type);
|
zeek_id->SetType(type);
|
||||||
zeek_id->MakeType();
|
zeek_id->MakeType();
|
||||||
|
|
||||||
detail::zeekygen_mgr->Identifier(zeek_id);
|
detail::zeekygen_mgr->Identifier(std::move(zeek_id));
|
||||||
|
|
||||||
if ( _module_info )
|
if ( _module_info )
|
||||||
_module_info->AddBifItem(id, ::zeek::plugin::BifItem::TYPE);
|
_module_info->AddBifItem(id, ::zeek::plugin::BifItem::TYPE);
|
||||||
|
@ -281,7 +279,7 @@ void Manager::registerEvent(const std::string& name) {
|
||||||
if ( auto id = detail::lookup_ID(name.c_str(), mod.c_str(), false, false, false) ) {
|
if ( auto id = detail::lookup_ID(name.c_str(), mod.c_str(), false, false, false) ) {
|
||||||
// Auto-export IDs that already exist.
|
// Auto-export IDs that already exist.
|
||||||
id->SetExport();
|
id->SetExport();
|
||||||
_events[name] = id;
|
_events[name] = std::move(id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// This installs & exports the ID, but it doesn't set its type yet.
|
// This installs & exports the ID, but it doesn't set its type yet.
|
||||||
|
@ -632,7 +630,7 @@ void Manager::InitPostScript() {
|
||||||
hilti_config.abort_on_exceptions = id::find_const("Spicy::abort_on_exceptions")->AsBool();
|
hilti_config.abort_on_exceptions = id::find_const("Spicy::abort_on_exceptions")->AsBool();
|
||||||
hilti_config.show_backtraces = id::find_const("Spicy::show_backtraces")->AsBool();
|
hilti_config.show_backtraces = id::find_const("Spicy::show_backtraces")->AsBool();
|
||||||
|
|
||||||
hilti::rt::configuration::set(hilti_config);
|
hilti::rt::configuration::set(std::move(hilti_config));
|
||||||
|
|
||||||
auto spicy_config = ::spicy::rt::configuration::get();
|
auto spicy_config = ::spicy::rt::configuration::get();
|
||||||
spicy_config.hook_accept_input = hook_accept_input;
|
spicy_config.hook_accept_input = hook_accept_input;
|
||||||
|
@ -686,7 +684,7 @@ void Manager::InitPostScript() {
|
||||||
if ( ! tag )
|
if ( ! tag )
|
||||||
reporter->InternalError("cannot get analyzer tag for '%s'", p.name_analyzer.c_str());
|
reporter->InternalError("cannot get analyzer tag for '%s'", p.name_analyzer.c_str());
|
||||||
|
|
||||||
auto register_analyzer_for_port = [&](auto tag, const hilti::rt::Port& port_) {
|
auto register_analyzer_for_port = [&](const auto& tag, const hilti::rt::Port& port_) {
|
||||||
SPICY_DEBUG(hilti::rt::fmt(" Scheduling analyzer for port %s", port_));
|
SPICY_DEBUG(hilti::rt::fmt(" Scheduling analyzer for port %s", port_));
|
||||||
|
|
||||||
// Well-known ports are registered in scriptland, so we'll raise an
|
// Well-known ports are registered in scriptland, so we'll raise an
|
||||||
|
@ -695,7 +693,7 @@ void Manager::InitPostScript() {
|
||||||
vals.emplace_back(tag.AsVal());
|
vals.emplace_back(tag.AsVal());
|
||||||
vals.emplace_back(zeek::spicy::rt::to_val(port_, base_type(TYPE_PORT)));
|
vals.emplace_back(zeek::spicy::rt::to_val(port_, base_type(TYPE_PORT)));
|
||||||
EventHandlerPtr handler = event_registry->Register("spicy_analyzer_for_port");
|
EventHandlerPtr handler = event_registry->Register("spicy_analyzer_for_port");
|
||||||
event_mgr.Enqueue(handler, vals);
|
event_mgr.Enqueue(handler, std::move(vals));
|
||||||
};
|
};
|
||||||
|
|
||||||
for ( const auto& ports : p.ports ) {
|
for ( const auto& ports : p.ports ) {
|
||||||
|
@ -717,7 +715,7 @@ void Manager::InitPostScript() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( p.parser_resp ) {
|
if ( p.parser_resp ) {
|
||||||
for ( auto port : p.parser_resp->ports ) {
|
for ( const auto& port : p.parser_resp->ports ) {
|
||||||
if ( port.direction != ::spicy::rt::Direction::Both &&
|
if ( port.direction != ::spicy::rt::Direction::Both &&
|
||||||
port.direction != ::spicy::rt::Direction::Responder )
|
port.direction != ::spicy::rt::Direction::Responder )
|
||||||
continue;
|
continue;
|
||||||
|
@ -742,7 +740,7 @@ void Manager::InitPostScript() {
|
||||||
if ( ! tag )
|
if ( ! tag )
|
||||||
reporter->InternalError("cannot get analyzer tag for '%s'", p.name_analyzer.c_str());
|
reporter->InternalError("cannot get analyzer tag for '%s'", p.name_analyzer.c_str());
|
||||||
|
|
||||||
auto register_analyzer_for_mime_type = [&](auto tag, const std::string& mt) {
|
auto register_analyzer_for_mime_type = [&](const auto& tag, const std::string& mt) {
|
||||||
SPICY_DEBUG(hilti::rt::fmt(" Scheduling analyzer for MIME type %s", mt));
|
SPICY_DEBUG(hilti::rt::fmt(" Scheduling analyzer for MIME type %s", mt));
|
||||||
|
|
||||||
// MIME types are registered in scriptland, so we'll raise an
|
// MIME types are registered in scriptland, so we'll raise an
|
||||||
|
@ -751,7 +749,7 @@ void Manager::InitPostScript() {
|
||||||
vals.emplace_back(tag.AsVal());
|
vals.emplace_back(tag.AsVal());
|
||||||
vals.emplace_back(make_intrusive<StringVal>(mt));
|
vals.emplace_back(make_intrusive<StringVal>(mt));
|
||||||
EventHandlerPtr handler = event_registry->Register("spicy_analyzer_for_mime_type");
|
EventHandlerPtr handler = event_registry->Register("spicy_analyzer_for_mime_type");
|
||||||
event_mgr.Enqueue(handler, vals);
|
event_mgr.Enqueue(handler, std::move(vals));
|
||||||
};
|
};
|
||||||
|
|
||||||
for ( const auto& mt : p.mime_types )
|
for ( const auto& mt : p.mime_types )
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <spicy/rt/driver.h>
|
#include <spicy/rt/driver.h>
|
||||||
#include <spicy/rt/parser.h>
|
#include <spicy/rt/parser.h>
|
||||||
|
|
||||||
|
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
||||||
#include "zeek/spicy/cookie.h"
|
#include "zeek/spicy/cookie.h"
|
||||||
|
|
||||||
namespace zeek::spicy::rt {
|
namespace zeek::spicy::rt {
|
||||||
|
|
|
@ -120,7 +120,7 @@ TypePtr rt::create_enum_type(
|
||||||
etype->AddName(ns, name.c_str(), lval, true);
|
etype->AddName(ns, name.c_str(), lval, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return etype;
|
return std::move(etype);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypePtr rt::create_record_type(const std::string& ns, const std::string& id,
|
TypePtr rt::create_record_type(const std::string& ns, const std::string& id,
|
||||||
|
@ -289,7 +289,7 @@ void rt::debug(const Cookie& cookie, const std::string& msg) {
|
||||||
hilti::rt::fmt("[%s/%" PRIu32 "/%s] %s", name, p->analyzer->GetID(), (p->is_orig ? "orig" : "resp"), msg));
|
hilti::rt::fmt("[%s/%" PRIu32 "/%s] %s", name, p->analyzer->GetID(), (p->is_orig ? "orig" : "resp"), msg));
|
||||||
}
|
}
|
||||||
else if ( const auto f = cookie.file ) {
|
else if ( const auto f = cookie.file ) {
|
||||||
auto name = file_mgr->GetComponentName(f->analyzer->Tag());
|
const auto& name = file_mgr->GetComponentName(f->analyzer->Tag());
|
||||||
SPICY_DEBUG(hilti::rt::fmt("[%s/%" PRIu32 "] %s", name, f->analyzer->GetID(), msg));
|
SPICY_DEBUG(hilti::rt::fmt("[%s/%" PRIu32 "] %s", name, f->analyzer->GetID(), msg));
|
||||||
}
|
}
|
||||||
else if ( const auto f = cookie.packet ) {
|
else if ( const auto f = cookie.packet ) {
|
||||||
|
|
|
@ -705,7 +705,7 @@ inline ValPtr to_val(const hilti::rt::Vector<T>& v, const TypePtr& target) {
|
||||||
for ( const auto& i : v )
|
for ( const auto& i : v )
|
||||||
zv->Assign(zv->Size(), to_val(i, vt->Yield()));
|
zv->Assign(zv->Size(), to_val(i, vt->Yield()));
|
||||||
|
|
||||||
return zv;
|
return std::move(zv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,5 +56,5 @@ function Spicy::__resource_usage%(%) : Spicy::ResourceUsage
|
||||||
r->Assign(n++, ru.max_fiber_stack_size);
|
r->Assign(n++, ru.max_fiber_stack_size);
|
||||||
r->Assign(n++, ru.cached_fibers);
|
r->Assign(n++, ru.cached_fibers);
|
||||||
|
|
||||||
return r;
|
return std::move(r);
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -137,7 +137,7 @@ hilti::Result<hilti::Nothing> Driver::loadFile(hilti::rt::filesystem::path file,
|
||||||
hilti::util::fmt("error computing path of %s relative to %s: %s", file, relative_to, ec.message()));
|
hilti::util::fmt("error computing path of %s relative to %s: %s", file, relative_to, ec.message()));
|
||||||
|
|
||||||
if ( exists )
|
if ( exists )
|
||||||
file = p;
|
file = std::move(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto exists = hilti::rt::filesystem::exists(file, ec);
|
auto exists = hilti::rt::filesystem::exists(file, ec);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "glue-compiler.h"
|
#include "glue-compiler.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
@ -422,7 +421,7 @@ void GlueCompiler::preprocessEvtFile(hilti::rt::filesystem::path& path, std::ist
|
||||||
// Output empty line to keep line numbers the same
|
// Output empty line to keep line numbers the same
|
||||||
out << '\n';
|
out << '\n';
|
||||||
|
|
||||||
auto m = hilti::util::split1(trimmed);
|
auto m = hilti::util::split1(std::move(trimmed));
|
||||||
|
|
||||||
if ( auto rc = pp.processLine(m.first, m.second); ! rc )
|
if ( auto rc = pp.processLine(m.first, m.second); ! rc )
|
||||||
throw ParseError(rc.error());
|
throw ParseError(rc.error());
|
||||||
|
@ -517,7 +516,7 @@ bool GlueCompiler::loadEvtFile(hilti::rt::filesystem::path& path) {
|
||||||
else
|
else
|
||||||
SPICY_DEBUG(hilti::util::fmt(" Got module %s to import", module));
|
SPICY_DEBUG(hilti::util::fmt(" Got module %s to import", module));
|
||||||
|
|
||||||
_imports.emplace_back(hilti::ID(module), std::move(scope));
|
_imports.emplace_back(hilti::ID(std::move(module)), std::move(scope));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( looking_at(*chunk, 0, "export") ) {
|
else if ( looking_at(*chunk, 0, "export") ) {
|
||||||
|
@ -699,7 +698,7 @@ glue::ProtocolAnalyzer GlueCompiler::parseProtocolAnalyzer(const std::string& ch
|
||||||
|
|
||||||
case both:
|
case both:
|
||||||
a.unit_name_orig = unit;
|
a.unit_name_orig = unit;
|
||||||
a.unit_name_resp = unit;
|
a.unit_name_resp = std::move(unit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1359,7 +1358,10 @@ bool GlueCompiler::CreateSpicyHook(glue::Event* ev) {
|
||||||
|
|
||||||
body.addCall("zeek_rt::raise_event", {handler_expr, builder()->move(builder()->id("args"))}, meta);
|
body.addCall("zeek_rt::raise_event", {handler_expr, builder()->move(builder()->id("args"))}, meta);
|
||||||
|
|
||||||
#if SPICY_VERSION_NUMBER >= 11200
|
#if SPICY_VERSION_NUMBER >= 11300
|
||||||
|
auto attrs = builder()->attributeSet(
|
||||||
|
{builder()->attribute(hilti::attribute::Kind::Priority, builder()->integer(ev->priority))});
|
||||||
|
#elif SPICY_VERSION_NUMBER >= 11200
|
||||||
auto attrs = builder()->attributeSet(
|
auto attrs = builder()->attributeSet(
|
||||||
{builder()->attribute(hilti::Attribute::Kind::Priority, builder()->integer(ev->priority))});
|
{builder()->attribute(hilti::Attribute::Kind::Priority, builder()->integer(ev->priority))});
|
||||||
#else
|
#else
|
||||||
|
@ -1367,7 +1369,7 @@ bool GlueCompiler::CreateSpicyHook(glue::Event* ev) {
|
||||||
#endif
|
#endif
|
||||||
auto parameters = hilti::util::transform(ev->parameters, [](const auto& p) { return p.get(); });
|
auto parameters = hilti::util::transform(ev->parameters, [](const auto& p) { return p.get(); });
|
||||||
auto unit_hook = builder()->declarationHook(parameters, body.block(), attrs, meta);
|
auto unit_hook = builder()->declarationHook(parameters, body.block(), attrs, meta);
|
||||||
auto hook_decl = builder()->declarationUnitHook(ev->hook, unit_hook, meta);
|
auto hook_decl = builder()->declarationUnitHook(ev->hook, unit_hook, std::move(meta));
|
||||||
ev->spicy_module->spicy_module->add(context(), hook_decl);
|
ev->spicy_module->spicy_module->add(context(), hook_decl);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -235,7 +235,7 @@ static hilti::Result<Nothing> parseOptions(int argc, char** argv, hilti::driver:
|
||||||
return Nothing();
|
return Nothing();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) try {
|
||||||
Driver driver(std::make_unique<GlueCompiler>(), "", configuration::LibraryPath(),
|
Driver driver(std::make_unique<GlueCompiler>(), "", configuration::LibraryPath(),
|
||||||
configuration::ZeekVersionNumber());
|
configuration::ZeekVersionNumber());
|
||||||
|
|
||||||
|
@ -271,4 +271,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
} catch ( const std::exception& e ) {
|
||||||
|
hilti::logger().fatalError(hilti::util::fmt("terminating with uncaught exception of type %s: %s",
|
||||||
|
hilti::util::demangle(typeid(e).name()), e.what()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue