Skip to content
This repository was archived by the owner on Aug 31, 2020. It is now read-only.

Commit 27ba601

Browse files
authored
Merge branch 'master' into doc_fixes
2 parents 0ff3f91 + ef1b732 commit 27ba601

File tree

6 files changed

+86
-1
lines changed

6 files changed

+86
-1
lines changed

docs/source/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Welcome to ROS Fuzzer's documentation!
1414
usage
1515
module
1616

17+
This is the documentation for the ROS1 Fuzzer developed by Alias Robotics.
18+
This fuzzer allows to test ROS applications against limit cases that could cause failures or pose a security risk.
19+
Currently the fuzzer allows to test ROS messages of any type by dynamically setting up the fuzz cases for each of the
20+
message elements.
21+
1722

1823
Indices and tables
1924
==================

docs/source/install.rst

+6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
Installation
22
============
33

4+
45
Install the ROS fuzzer by directly downloading from PyPi:
56

7+
.. toctree::
8+
:maxdepth: 4
9+
:caption: Contents:
10+
11+
612
::
713

814
pip install ros_fuzzer

docs/source/module.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ ROS fuzzer modules
44
==================
55

66
.. toctree::
7-
:maxdepth: 4
7+
:maxdepth: 4
8+
:caption: Contents
9+
810

911
.. automodule:: ros1_fuzzer.ros_basic_strategies
1012
:members:

docs/source/usage.rst

+36
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
Fuzzer usage
22
============
33

4+
45
The fuzzer works in a standalone manner, by calling it to fuzz a full message structure via CLI,
56
or by designing custom tests that fuzz or exclude different fields of the messages.
67

8+
.. toctree::
9+
:maxdepth: 4
10+
:caption: Contents:
11+
12+
713

814
CLI Usage
915
---------
@@ -59,3 +65,33 @@ The :func:`hypothesis.given` decorator runs the decorated function with all the
5965
self.pub.publish(log)
6066
6167
68+
The following examples show a trajectory message fuzzer utilized for fuzzing the ABB control
69+
node of the `Link ROS Industrial <https://github.com/ros-industrial>`project.
70+
Notice the settings block, which serves as a way to set the fuzz cases to launch and the output of the fuzzer.
71+
The :class:`ros_commons.ProcessHandler` class serves to detect changes in the target node,
72+
detecting when this node has crashed.
73+
74+
.. code-block:: python
75+
:caption: Joint Trajectory message fuzzing used on REDROS-I ROSIN project for ABB node fuzzing.
76+
77+
@settings(max_examples=5000, verbosity=Verbosity.verbose)
78+
@given(array(elements=float64(), min_size=6, max_size=6))
79+
def fuzz_message_jointstate_effort(process_handler, fuzzed_fields):
80+
joint_state_message.effort = fuzzed_fields
81+
pub.publish(joint_state_message)
82+
assert process_handler.check_if_alive() is True
83+
84+
@settings(max_examples=5000, verbosity=Verbosity.verbose)
85+
@given(array(elements=float64(), min_size=6, max_size=6),
86+
array(elements=float64(), min_size=6, max_size=6),
87+
array(elements=float64(), min_size=6, max_size=6))
88+
def fuzz_message_jointstate_all(process_handler, positions, velocities, efforts):
89+
joint_state_message.position = positions
90+
joint_state_message.velocity = velocities
91+
joint_state_message.effort = efforts
92+
pub.publish(joint_state_message)
93+
assert process_handler.check_if_alive() is True
94+
95+
96+
97+

ros1_fuzzer/process_handling.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
try:
2+
from xmlrpc.client import ServerProxy
3+
except ImportError:
4+
from xmlrpclib import ServerProxy
5+
import psutil
6+
7+
8+
class FuzzedLocalProcessHandler:
9+
def __init__(self, node_name):
10+
self.node_name = node_name
11+
self.node_pid = -1
12+
self.master_conn = ServerProxy('http://127.0.0.1:11311')
13+
self.get_node_pid()
14+
15+
16+
def get_node_pid(self):
17+
18+
code, msg, val = self.master_conn.lookupNode('', self.node_name)
19+
if code == 1:
20+
node_conn = ServerProxy(val)
21+
node_code, node_msg, node_val = node_conn.getPid('')
22+
if code == 1:
23+
self.node_pid = int(node_val)
24+
else:
25+
raise Exception(msg)
26+
27+
28+
def check_if_alive(self):
29+
return psutil.pid_exists(self.node_pid)
30+
31+
32+
33+
34+
35+

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
'hypothesis==3.82',
1818
'attrs==19.1.0',
1919
'enum34==1.1.6',
20+
'psutil==5.6.2'
2021
],
2122
include_package_data=True,
2223
)

0 commit comments

Comments
 (0)