Skip to content

Commit e491353

Browse files
author
Francisco Martínez Lasaca
committed
Prepare the package to the rosin project
1 parent 1dc3005 commit e491353

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

README.md

+31-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
# Automatic fuzzing for ROS 2
22

3-
![Python tests](https://github.com/JnxF/automatic_fuzzing/workflows/Python%20tests/badge.svg)
3+
![Python tests](https://github.com/rosin-project/ros2_fuzz/workflows/Python%20tests/badge.svg)
44
![Hits](https://visitor-badge.glitch.me/badge?page_id=jnxf._automatic_fuzzing)
5-
[![GitHub stars](https://img.shields.io/github/stars/JnxF/automatic_fuzzing.svg)](https://GitHub.com/JnxF/automatic_fuzzing/stargazers/)
6-
[![GitHub forks](https://img.shields.io/github/forks/JnxF/automatic_fuzzing.svg)](https://GitHub.com/JnxF/automatic_fuzzing/network/)
7-
[![GitHub repo size in bytes](https://img.shields.io/github/repo-size/JnxF/automatic_fuzzing.svg)](https://github.com/JnxF/automatic_fuzzing)
8-
[![GitHub contributors](https://img.shields.io/github/contributors/JnxF/automatic_fuzzing.svg)](https://GitHub.com/JnxF/automatic_fuzzing/graphs/contributors/)
9-
[![GitHub license](http://img.shields.io/github/license/JnxF/automatic_fuzzing.svg)](https://github.com/JnxF/automatic_fuzzing/blob/master/LICENSE)
5+
[![GitHub stars](https://img.shields.io/github/stars/rosin-project/ros2_fuzz.svg)](https://GitHub.com/rosin-project/ros2_fuzz/stargazers/)
6+
[![GitHub forks](https://img.shields.io/github/forks/rosin-project/ros2_fuzz.svg)](https://GitHub.com/rosin-project/ros2_fuzz/network/)
7+
[![GitHub repo size in bytes](https://img.shields.io/github/repo-size/rosin-project/ros2_fuzz.svg)](https://github.com/rosin-project/ros2_fuzz)
8+
[![GitHub contributors](https://img.shields.io/github/contributors/rosin-project/ros2_fuzz.svg)](https://GitHub.com/rosin-project/ros2_fuzz/graphs/contributors/)
9+
[![GitHub license](http://img.shields.io/github/license/rosin-project/ros2_fuzz.svg)](https://github.com/rosin-project/ros2_fuzz/blob/master/LICENSE)
1010

1111
An automatic fuzzing tool for ROS 2 C++ projects. The tool comprises two different commands: `auto_detector` and `ros2_fuzzer`.
1212

1313
## Installation
1414

15-
TODO (pending to be published at pip). Meanwhile execute `pip install .` at the ros2_automatic_fuzzer folder.
15+
Install the `ros_automatic_fuzzer` folder with pip:
1616

1717
```bash
18-
pip install ros2_fuzzer
18+
pip3 install -e ros2_automatic_fuzzer
1919
```
2020

21+
Alternatively, start the `start.sh` command, which spawn a Docker container with both the examples and the tool.
22+
2123
## Usage
2224

2325
1. Navigate to your ROS working space.
@@ -35,13 +37,16 @@ Check the following sections for detailed instructions for each step.
3537
The `auto_detector` command generates a YAML file called `fuzz.yaml` which contains descriptions for three types of artifacts: topics, services, and action servers. The detection process relies on regular expressions in C++, and therefore it is not bullet-proof.
3638

3739
Optional arguments:
38-
* `--path PATH`. The path where to search for ROS artifacts. By default it is the working directory.
40+
41+
- `--path PATH`. The path where to search for ROS artifacts. By default it is the working directory.
3942

4043
Optional flags:
41-
* `-f` or `--overwrite` to force overwriting the file.
42-
* `-v` or `--verbose` to increase the output verbosity.
44+
45+
- `-f` or `--overwrite` to force overwriting the file.
46+
- `-v` or `--verbose` to increase the output verbosity.
4347

4448
Typical bash invocation:
49+
4550
```bash
4651
auto_detector
4752
```
@@ -52,10 +57,10 @@ The `fuzz.yaml` file contains descriptions for topics, services, and action serv
5257

5358
The format is simple: there are three optional categories: `topics`, `services` and `actions`. Each of those is a dictionary, with the keys being the name of the artifact. Each artifact contains the following descriptors:
5459

55-
* `headers_file` (compulsory). A string pointing to the `hpp` file where the type of the artifact is defined (the topic type, the service type, or the action type). Sometimes it can be directly inferred.
56-
* `source` (compulsory). A relative path to the `fuzz.yaml` file where the artifact to be fuzzed is located. It must be a C++ source code file.
57-
* `type` (compulsory). The type of the fuzzed artifact. It must conform to the `ros2 interface show` syntax. That is, with `::` as a separator and providing the full type. Correct examples are `example_interfaces::srv::AddTwoInts` and `std_msgs::msg::String`, but not `example_interfaces/srv/AddTwoInts` nor `String`.
58-
* `parameters` (optional). A list with all the parameters of the artifact. It can be inferred with the `auto_detector` command.
60+
- `headers_file` (compulsory). A string pointing to the `hpp` file where the type of the artifact is defined (the topic type, the service type, or the action type). Sometimes it can be directly inferred.
61+
- `source` (compulsory). A relative path to the `fuzz.yaml` file where the artifact to be fuzzed is located. It must be a C++ source code file.
62+
- `type` (compulsory). The type of the fuzzed artifact. It must conform to the `ros2 interface show` syntax. That is, with `::` as a separator and providing the full type. Correct examples are `example_interfaces::srv::AddTwoInts` and `std_msgs::msg::String`, but not `example_interfaces/srv/AddTwoInts` nor `String`.
63+
- `parameters` (optional). A list with all the parameters of the artifact. It can be inferred with the `auto_detector` command.
5964

6065
Follows a concrete example. You can also check the syntax that is followed in [the YAML schema](ros2_automatic_fuzzer/yaml_utils/schema.yaml), which all `fuzz.yaml` files must conform to.
6166

@@ -90,20 +95,25 @@ services:
9095
It consumes the `fuzz.yaml` file to generate C++ fuzzers for the selected artifacts. It allows generating fuzzers for all or some of them. Simply follow the steps on the screen. It may require calling `ros2 interface show`, and thus sourcing the ROS setup bash (with `. install/setup.bash`) may be required.
9196

9297
Optional arguments:
93-
* `--path PATH`. The path where to search for a `fuzz.yaml` file. By default it is on the working directory.
98+
99+
- `--path PATH`. The path where to search for a `fuzz.yaml` file. By default it is on the working directory.
94100

95101
Optional flags:
96-
* `-v` or `--verbose` to increase the output verbosity.
102+
103+
- `-v` or `--verbose` to increase the output verbosity.
97104

98105
Typical bash invocation:
106+
99107
```bash
100108
ros2_fuzzer
101109
```
102110

103111
### Step 5. Adding the fuzzers to the `CMakeLists.txt` files
112+
104113
The `ros2_fuzzer` command generates files of the `*_generated.cpp` form, which have to be linked to their `CMakeList.txt` files to be compiled.
105114

106115
For example, for the following `fuzz.yaml` file:
116+
107117
```yaml
108118
services:
109119
add_three_ints:
@@ -117,11 +127,12 @@ The following code can be added into its `CMakeLists.txt` file (the `generated_f
117127

118128
```cmake
119129
add_executable(generated_fuzzer src/add_three_ints_server_generated.cpp)
120-
ament_target_dependencies(generated_fuzzer rclcpp tutorial_interfaces)
130+
ament_target_dependencies(generated_fuzzer rclcpp tutorial_interfaces)
121131
install(TARGETS generated_fuzzer DESTINATION lib/${PROJECT_NAME})
122132
```
123133

124134
### Step 6. Rebuilding with AFL
135+
125136
To fuzz your C++ artifacts, it is necessary to recompile the projects so that they include instrumentalization annotations on the byte code to be used in the fuzzing search. We have decided to use [AFL](https://github.com/google/AFL), an state-of-the-art fuzzer backed by Google.
126137

127138
If you haven't done so, you can install AFL with
@@ -133,12 +144,13 @@ apt install afl
133144
To use it, set the `CC` and `CXX` environment variables to point to AFL and build the projects. We add the `--cmake-clean-cache` flag to prevent stale build files. Of course, you can use a more sofisticated way to build your projects, but make sure that the AFL's instrumentalization takes place.
134145

135146
```bash
136-
export CC=afl-gcc
147+
export CC=afl-gcc
137148
export CXX=afl-g++
138149
colcon build --cmake-clean-cache
139150
```
140151

141152
### Step 7. Running the fuzzers
153+
142154
Navigate to `install/<package>/lib/<package>/`, where `<package>` is the name of your ROS package (or wherever the installation files are placed) and start the fuzzing search.
143155

144156
The command requires an `inputs/` folder, with some files with content. You can use random values extracted from `/dev/urandom`, for instance:

ros2_automatic_fuzzer/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
description="An automatic ROS 2 fuzzer for C++ nodes",
1616
long_description=long_description,
1717
long_description_content_type="text/markdown",
18-
url="https://github.com/JnxF/automatic_fuzzing",
18+
url="https://github.com/rosin-project/ros2_fuzz",
1919
packages=setuptools.find_packages(),
2020
install_requires=["Jinja2", "yamale", "PyInquirer", "zenlog"],
2121
entry_points={

0 commit comments

Comments
 (0)