mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
Use zeek::detail namespace for fuzzer utils
This commit is contained in:
parent
5a2d25c954
commit
2d0b8c0b8e
7 changed files with 17 additions and 16 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "FuzzBuffer.h"
|
#include "FuzzBuffer.h"
|
||||||
|
|
||||||
bool zeek::FuzzBuffer::Valid() const
|
bool zeek::detail::FuzzBuffer::Valid() const
|
||||||
{
|
{
|
||||||
if ( end - begin < PKT_MAGIC_LEN + 2 )
|
if ( end - begin < PKT_MAGIC_LEN + 2 )
|
||||||
return false;
|
return false;
|
||||||
|
@ -17,7 +17,7 @@ bool zeek::FuzzBuffer::Valid() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<zeek::FuzzBuffer::Chunk> zeek::FuzzBuffer::Next()
|
std::optional<zeek::detail::FuzzBuffer::Chunk> zeek::detail::FuzzBuffer::Next()
|
||||||
{
|
{
|
||||||
if ( begin == end )
|
if ( begin == end )
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace zeek {
|
namespace zeek { namespace detail {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This structure helps chunk/simulate protocol conversions from arbitrary
|
* This structure helps chunk/simulate protocol conversions from arbitrary
|
||||||
|
@ -54,4 +54,4 @@ private:
|
||||||
const unsigned char* end;
|
const unsigned char* end;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace zeek
|
}} // namespace zeek::detail
|
||||||
|
|
|
@ -36,15 +36,15 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
|
||||||
options.ignore_checksums = true;
|
options.ignore_checksums = true;
|
||||||
options.abort_on_scripting_errors = true;
|
options.abort_on_scripting_errors = true;
|
||||||
|
|
||||||
if ( zeek::setup(*argc, *argv, &options).code )
|
if ( zeek::detail::setup(*argc, *argv, &options).code )
|
||||||
abort();
|
abort();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace zeek {
|
namespace zeek { namespace detail {
|
||||||
|
|
||||||
void fuzz_cleanup_one_input()
|
void fuzzer_cleanup_one_input()
|
||||||
{
|
{
|
||||||
terminating = true;
|
terminating = true;
|
||||||
broker_mgr->ClearStores();
|
broker_mgr->ClearStores();
|
||||||
|
@ -58,4 +58,4 @@ void fuzz_cleanup_one_input()
|
||||||
terminating = false;
|
terminating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace zeek
|
}} // namespace zeek::detail
|
||||||
|
|
|
@ -45,7 +45,7 @@ static analyzer::Analyzer* add_analyzer(Connection* conn)
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
zeek::FuzzBuffer fb{data, size};
|
zeek::detail::FuzzBuffer fb{data, size};
|
||||||
|
|
||||||
if ( ! fb.Valid() )
|
if ( ! fb.Valid() )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -72,6 +72,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
mgr.Drain();
|
mgr.Drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
zeek::fuzz_cleanup_one_input();
|
zeek::detail::fuzzer_cleanup_one_input();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
auto time_start = current_time(true);
|
auto time_start = current_time(true);
|
||||||
auto setup_result = zeek::setup(argc, argv);
|
auto setup_result = zeek::detail::setup(argc, argv);
|
||||||
|
|
||||||
if ( setup_result.code )
|
if ( setup_result.code )
|
||||||
return setup_result.code;
|
return setup_result.code;
|
||||||
|
@ -78,5 +78,5 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return zeek::cleanup(do_net_run);
|
return zeek::detail::cleanup(do_net_run);
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,8 @@ static std::vector<std::string> get_script_signature_files()
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
zeek::SetupResult zeek::setup(int argc, char** argv, zeek::Options* zopts)
|
zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
|
zeek::Options* zopts)
|
||||||
{
|
{
|
||||||
ZEEK_LSAN_DISABLE();
|
ZEEK_LSAN_DISABLE();
|
||||||
std::set_new_handler(bro_new_handler);
|
std::set_new_handler(bro_new_handler);
|
||||||
|
@ -866,7 +867,7 @@ zeek::SetupResult zeek::setup(int argc, char** argv, zeek::Options* zopts)
|
||||||
return {0, std::move(options)};
|
return {0, std::move(options)};
|
||||||
}
|
}
|
||||||
|
|
||||||
int zeek::cleanup(bool did_net_run)
|
int zeek::detail::cleanup(bool did_net_run)
|
||||||
{
|
{
|
||||||
if ( did_net_run )
|
if ( did_net_run )
|
||||||
done_with_network();
|
done_with_network();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
|
|
||||||
namespace zeek {
|
namespace zeek { namespace detail {
|
||||||
|
|
||||||
struct SetupResult {
|
struct SetupResult {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
|
@ -28,4 +28,4 @@ SetupResult setup(int argc, char** argv, zeek::Options* options = nullptr);
|
||||||
*/
|
*/
|
||||||
int cleanup(bool did_net_run);
|
int cleanup(bool did_net_run);
|
||||||
|
|
||||||
}
|
}} // namespace zeek::detail
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue