mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 18:08:53 +00:00
1642382ff9
This commit creates a new osquery/main/harnesses directory and moves fuzz-config there. It removes OSQUERY_FUZZ for a new option OSQUERY_ENABLE_FUZZER_SANITIZERS It creates a new option OSQUERY_ENABLE_ADDRESS_SANITIZER The following behaviors are intended: OSQUERY_BUILD_TESTS=ON will build the fuzzing harness. This configuration is not intended for fuzzing purposes. OSQUERY_ENABLE_FUZZER_SANITIZERS=ON will also build the fuzzing harness. However if this variable is true, it also requires OSQUERY_ENABLE_ADDRESS_SANITIZER=ON and either CMAKE_BUILD_TYPE=Release or RelWithDebInfo This configuration is actually intended for fuzzing.
38 lines
1011 B
C++
38 lines
1011 B
C++
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed in accordance with the terms specified in
|
|
* the LICENSE file found in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <osquery/config/config.h>
|
|
#include <osquery/database.h>
|
|
#include <osquery/logger.h>
|
|
#include <osquery/registry.h>
|
|
#include <osquery/sql.h>
|
|
|
|
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
|
osquery::registryAndPluginInit();
|
|
osquery::DatabasePlugin::setAllowOpen(true);
|
|
osquery::Registry::get().setActive("database", "ephemeral");
|
|
osquery::DatabasePlugin::initPlugin().ok();
|
|
|
|
osquery::PluginRequest r;
|
|
r["action"] = "detach";
|
|
r["table"] = "file";
|
|
|
|
osquery::PluginResponse rsp;
|
|
osquery::Registry::get().call("sql", r, rsp);
|
|
FLAGS_minloglevel = 4;
|
|
|
|
return 0;
|
|
}
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
std::string q((const char*)data, size);
|
|
osquery::Config::get().update({{"fuzz", q}});
|
|
|
|
return 0;
|
|
}
|