|
| 1 | +OSS-Fuzz |
| 2 | +======== |
| 3 | + |
| 4 | +Platform overview |
| 5 | +----------------- |
| 6 | + |
| 7 | +`OSS-Fuzz <https://google.github.io/oss-fuzz/>`_ is Google's free fuzzing platform for open source |
| 8 | +software. |
| 9 | +It runs librsvg's `fuzz targets <https://gitlab.gnome.org/GNOME/librsvg/-/tree/main/fuzz>`_ to help |
| 10 | +detect reliability issues. |
| 11 | + |
| 12 | +Google provides public `build logs <https://oss-fuzz-build-logs.storage.googleapis.com/index.html#librsvg>`_ |
| 13 | +and `fuzzing stats <https://introspector.oss-fuzz.com/project-profile?project=librsvg>`_, but most |
| 14 | +of the details about bug reports and fuzzed testcases require approved access. |
| 15 | + |
| 16 | +Gaining access |
| 17 | +^^^^^^^^^^^^^^ |
| 18 | + |
| 19 | +The configuration files for the OSS-Fuzz integration can be found in the |
| 20 | +`OSS-Fuzz repository <https://github.com/google/oss-fuzz/tree/master/projects/librsvg>`_. |
| 21 | +The ``project.yaml`` file controls who has access to bug reports and testcases. |
| 22 | +Ping the maintainer if you'd like to be added to the list (note: a Google account is required for |
| 23 | +access). |
| 24 | + |
| 25 | +Fuzzing progress |
| 26 | +---------------- |
| 27 | + |
| 28 | +Once you have access to OSS-Fuzz, you can log in to https://oss-fuzz.com/ with your Google account |
| 29 | +to see a dashboard of librsvg's fuzzing progress. |
| 30 | + |
| 31 | +Testcases |
| 32 | +^^^^^^^^^ |
| 33 | + |
| 34 | +The dashboard contains a link to a `testcases page <https://oss-fuzz.com/testcases?project=librsvg&open=yes>`_ |
| 35 | +that lists all testcases that currently trigger a bug in librsvg. |
| 36 | + |
| 37 | +Every testcase has a dedicated page with links to view and download a minimized testcase for |
| 38 | +reproducing the failure. |
| 39 | +Each testcase page also contains a stacktrace for the failure and stats about how often the failure |
| 40 | +is encountered while fuzzing. |
| 41 | + |
| 42 | +Reproducing a failure |
| 43 | +""""""""""""""""""""" |
| 44 | + |
| 45 | +You can download a minimized testcase and run it with a local fuzz target to debug a failure on your |
| 46 | +machine. |
| 47 | +For example, to reproduce a failure with the ``render_document`` fuzz target, you can run a command |
| 48 | +like this: ``cargo fuzz run render_document minimized.svg`` |
| 49 | + |
| 50 | +Individual fuzz targets can also be run inside of a debugger for further debugging information: |
| 51 | + |
| 52 | +.. code:: bash |
| 53 | +
|
| 54 | + FUZZ_TARGET=$(find ./target/*/release/ -type f -name render_document) |
| 55 | + gdb --args "$FUZZ_TARGET" minimized.svg |
| 56 | +
|
| 57 | +
|
| 58 | +Code coverage |
| 59 | +^^^^^^^^^^^^^ |
| 60 | + |
| 61 | +The dashboard also links to code coverage data for individual fuzz targets and combined code |
| 62 | +coverage data for all targets (click on the "TOTAL COVERAGE" link for the combined data). |
| 63 | + |
| 64 | +The combined coverage data is helpful for identifying coverage gaps, insufficient corpus data, and |
| 65 | +potential candidates for future fuzz targets. |
| 66 | + |
| 67 | +Bug reports |
| 68 | +^^^^^^^^^^^ |
| 69 | + |
| 70 | +Bug reports for new failures are automatically filed in the OSS-Fuzz bug tracker with a |
| 71 | +`librsvg label <https://bugs.chromium.org/p/oss-fuzz/issues/list?q=label:Proj-librsvg>`_. |
| 72 | +Make sure you are logged in to view all existing issues. |
| 73 | + |
| 74 | +Build maintenance |
| 75 | +----------------- |
| 76 | + |
| 77 | +Google runs compiled fuzz targets on Google Compute Engine VMs. |
| 78 | +This architecture requires each project to provide a ``Dockerfile`` and ``build.sh`` script to |
| 79 | +download code, configure dependencies, compile fuzz targets, and package any corpus files. |
| 80 | + |
| 81 | +librsvg's build files can be found in the |
| 82 | +`OSS-Fuzz repo <https://github.com/google/oss-fuzz/blob/master/projects/librsvg/>`_. |
| 83 | + |
| 84 | +If dependencies change or if new fuzz targets are added, then you may need to modify the build files |
| 85 | +and build a new Docker image for OSS-Fuzz. |
| 86 | + |
| 87 | +Building an image |
| 88 | +^^^^^^^^^^^^^^^^^ |
| 89 | + |
| 90 | +Use the following commands to build librsvg's OSS-Fuzz image and fuzz targets: |
| 91 | + |
| 92 | +.. code:: bash |
| 93 | +
|
| 94 | + git clone https://github.com/google/oss-fuzz.git |
| 95 | + cd oss-fuzz |
| 96 | +
|
| 97 | + python infra/helper.py build_image librsvg |
| 98 | + python infra/helper.py build_fuzzers librsvg |
| 99 | +
|
| 100 | +Any changes you make to the build files must be submitted as pull requests to the OSS-Fuzz repo. |
| 101 | + |
| 102 | +Debugging build failures |
| 103 | +"""""""""""""""""""""""" |
| 104 | + |
| 105 | +You can debug build failures during the ``build_fuzzers`` stage by creating a container and manually |
| 106 | +running the ``compile`` command: |
| 107 | + |
| 108 | +.. code:: bash |
| 109 | +
|
| 110 | + # Create a container for building fuzz targets |
| 111 | + python infra/helper.py shell librsvg |
| 112 | +
|
| 113 | + # Run this command inside the container to build the fuzz targets |
| 114 | + compile |
| 115 | +
|
| 116 | +This approach is faster than re-running the ``build_fuzzers`` command, which recompiles everything |
| 117 | +from scratch each time the command is run. |
| 118 | + |
| 119 | +The ``build.sh`` script will be located at ``/src/build.sh`` inside the container. |
| 120 | + |
| 121 | +Quick links |
| 122 | +----------- |
| 123 | + |
| 124 | +* `OSS-Fuzz dashboard <https://oss-fuzz.com/>`_ |
| 125 | +* `OSS-Fuzz configuration files and build scripts for librsvg <https://github.com/google/oss-fuzz/tree/master/projects/librsvg>`_ |
| 126 | +* `All bugs found by OSS-Fuzz in librsvg <https://bugs.chromium.org/p/oss-fuzz/issues/list?q=label:Proj-librsvg>`_ |
| 127 | +* `Google's OSS-Fuzz documentation <https://google.github.io/oss-fuzz/>`_ |
0 commit comments