Files
jwt-cpp/tests/fuzz/BaseDecodeFuzz.cpp
Chris Mc 7fd8470cf1 🧷 Fuzz testing (#98)
* Update coverage.yml

* adding a fuzz test

* adding more fuzzing

TBA how to handle input requirement of decode

* base64 encoding input to avoid "obvious" exceptions

trying out the EVP_ interface from #89

* fixing decode fuzz

* accepting exceptions are normal

After comparing with https://github.com/nlohmann/json/blob/v3.9.0/test/src/fuzzer-parse_json.cpp I must agree data can be random so it should be accepted

* decoding twice should produce the same result

again based on https://github.com/nlohmann/json/blob/v3.9.0/test/src/fuzzer-parse_json.cpp

* fixing token decode fuzzer

* adding corpus for fuzz tests + adding them to ci

* removing numbers with more meaning descriptions

* Update BaseEncodeFuzz.cpp

* Update coverage.yml

* Update coverage.yml

* shrink interations

* cleaning cmake

* Update and rename coverage.yml to jwt.yml

* Update lint.yml

* Update jwt.yml

* Update jwt.yml
2021-09-17 20:01:38 -04:00

15 lines
395 B
C++

#include <jwt-cpp/base.h>
extern "C" {
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
try {
const auto bin = jwt::base::decode<jwt::alphabet::base64>(
std::string{(char *)Data, Size});
} catch (const std::runtime_error &) {
// parse errors are ok, because input may be random bytes
}
return 0; // Non-zero return values are reserved for future use.
}
}