Header-only library to generate C++ type primitives for fuzzing ROS 2. This library conforms to the official documentation.
Clone this repository and link it appropriately in a CMakeLists.txt
file with the fuzzing_api_library
cmake library.
Import the fuzzing_api.hpp file and pass the variable by reference to be read. All the functions return a boolean indicating whether the reading was successful or not, so using them inside of if
and while
statements is useful. Check the file for the whole list.
Read one value:
#include <iostream>
#include "fuzzing_api.hpp"
int main() {
float f;
if (getFloat32(f)) {
std::cout << "I read: " << f << std::endl;
} else {
std::cerr << "Couldn't read a float" << std::endl;
}
}
Read as many pairs of values as possible:
#include <iostream>
#include "fuzzing_api.hpp"
int main() {
int8_t a, b;
while (getInt8(a) && getInt8(b)) {
std::cout << "Pair: (a, b) = (" << a << ", " << b << ")" std::endl;
}
}
Reading a string of a constrained size (always recommended with string
s):
#include <iostream>
#include "fuzzing_api.hpp"
int main() {
uint8_t length;
getUInt8(length);
std::string s;
if (getString(s, length % 30)) {
std::cout << "A string shorter than 30 characters:";
std::cout << s << std::endl;
} else {
std::cerr << "Couldn't read the string" << std::endl;
}
}
Run the fuzz.sh
command with source fuzz.sh
to start a 10 minute fuzzing session. If you haven't installed it yet, install AFL (apt-get install afl
or brew install afl
on Mac).
Supported by ROSIN - ROS-Industrial Quality-Assured Robot Software Components. More information: rosin-project.eu
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement no. 732287.