mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 11:08:20 +00:00
Add OSS-Fuzz Zeek script search path to fuzzers
This commit is contained in:
parent
a4244bc72b
commit
98845e89aa
4 changed files with 57 additions and 32 deletions
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "zeek-setup.h"
|
||||
|
@ -11,6 +12,22 @@
|
|||
|
||||
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
|
||||
{
|
||||
auto zeekpath = getenv("ZEEKPATH");
|
||||
|
||||
if ( ! zeekpath )
|
||||
{
|
||||
// Set up an expected script search path for use with OSS-Fuzz
|
||||
auto constexpr oss_fuzz_scripts = "oss-fuzz-zeek-scripts";
|
||||
auto fuzzer_path = get_exe_path(*argv[0]);
|
||||
auto fuzzer_dir = SafeDirname(fuzzer_path).result;
|
||||
std::string fs = fmt("%s/%s", fuzzer_dir.data(), oss_fuzz_scripts);
|
||||
auto p = fs.data();
|
||||
auto oss_fuzz_zeekpath = fmt(".:%s:%s/policy:%s/site", p, p, p);
|
||||
|
||||
if ( setenv("ZEEKPATH", oss_fuzz_zeekpath, true) == -1 )
|
||||
abort();
|
||||
}
|
||||
|
||||
zeek::Options options;
|
||||
options.scripts_to_load.emplace_back("local.zeek");
|
||||
options.script_options_to_set.emplace_back("Site::local_nets={10.0.0.0/8}");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue