Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Add fuzz target for msgpack tovalue #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .code-intelligence/fuzz_targets/msgpack_tovalue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <stddef.h>
#include <stdint.h>
#include <tao/json.hpp>

// extern "C" int FUZZ_INIT_WITH_ARGS(int *argc, char ***argv) {
extern "C" int FUZZ_INIT()
{
// Add global setup code here - called once before fuzzing starts

return 0; // Non-zero return values are reserved for future use.
}

extern "C" int FUZZ( const char* Data, size_t Size )
{
// process fuzzer input (*Data) and setup local objects necessary to call the function under test

std::string input( Data, Size );

try {
tao::json::events::limit_nesting_depth< tao::json::events::to_value, 15 > consumer;
tao::json::msgpack::events::from_string( consumer, input );
const tao::json::value v = std::move( consumer.value );
}
catch( const tao::pegtl::parse_error& ) {
}
catch( const std::logic_error& ) {
}
catch( const std::runtime_error& rtex ) {
}

// reset state and free all locally allocated resources

return 0; // Non-zero return values are reserved for future use.
}
27 changes: 27 additions & 0 deletions .code-intelligence/fuzz_targets/msgpack_tovalue.cpp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## The fuzz target type. If unspecified, the type is deduced from the
## extension of the fuzz target source file.
type: "c++"

## If set to true, do not use the generic input corpus for this
## fuzz target.
# no_initial_corpus: false

## Additional arguments to pass to the compiler during build
compiler_extra_args:
- "-Ibuild/src/example/json"
- "-Iinclude"
- "-Iexternal/PEGTL/include"
- "-Iinclude/tao/json/events"
- "-Lbuild/src/example/json"
- "-std=c++17"

## Additional arguments to pass to the fuzz target when it is executed
# run_extra_args:

##### This section is only for Java fuzz targets #####

## Package filters to apply when instrumenting the source code.
# instrumentation_filters:

## List of jar dependencies needed by the fuzz target
# jars:
13 changes: 7 additions & 6 deletions .code-intelligence/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run_container: "gcr.io/code-intelligence/pegtl-builder-v2"

## A relative path to the build script that executes inside the container
## and builds the project. Relative to the project root directory.
# build_script: ".code-intelligence/build.sh"
build_script: ".code-intelligence/build.sh"

## Paths to the fuzz tests belonging to this test collection
fuzz_tests:
Expand All @@ -16,25 +16,26 @@ fuzz_tests:
- .code-intelligence/fuzz_targets/json_validation.cpp
- .code-intelligence/fuzz_targets/msgpack_validation.cpp
- .code-intelligence/fuzz_targets/ubjson_validation.cpp
- .code-intelligence/fuzz_targets/msgpack_tovalue.cpp

## The sanitizers to use for the fuzz tests in this collection.
## By default, only address sanitizer is used.
# sanitizers:
# - address
sanitizers:
- address

## The fuzzing engines to use for the fuzz tests in this collection.
## By default, only libfuzzer is used. Note that because Java and Go
## are only supported by libfuzzer, libfuzzer will always be used for
## Java and Go fuzz tests, independent of this setting.
# engines:
# - libfuzzer
engines:
- libfuzzer

## The run time after which the fuzz tests are cancelled and
## considered as having passed. Default value is 30 minutes.
runtime: "30m0s"

## The number of parallel executions per fuzz test
# parallel_executions: 1
parallel_executions: 1

## If true, do not initialize the seed corpus of the fuzz tests.
# skip_initial_corpus: false