1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 15:47:57 +02:00
pdf.js/test/fuzz
Tim van der Meij c08b09d3b9
Fix JpxImage API issues (PR 17946 follow-up)
This commit changes the `JpxImage.decode` method signature to define the
`ignoreColorSpace` argument as optional with a default value. Note that
we already set this default value in the `getBytes` method of the
`src/core/decode_stream.js` file since this option only seems useful for
certain special cases and therefore shouldn't be mandatory to provide.

Moreover, the JPX fuzzer is changed to use the new `JpxImage` API.
2024-04-16 18:02:47 +02:00
..
.eslintrc fuzz: initial integration 2023-12-03 18:52:48 +05:30
jbig2_image.fuzz.js Limit the amount of console "spam" during fuzz tests (PR 17337 follow-up) 2023-12-04 16:39:45 +01:00
jpeg_image.fuzz.js Limit the amount of console "spam" during fuzz tests (PR 17337 follow-up) 2023-12-04 16:39:45 +01:00
jpx_image.fuzz.js Fix JpxImage API issues (PR 17946 follow-up) 2024-04-16 18:02:47 +02:00
README.md fuzz: initial integration 2023-12-03 18:52:48 +05:30

Fuzz Testing

Fuzz testing is:

An automated software testing technique that involves providing invalid, unexpected, or random data as inputs to a program.

We use coverage guided fuzz testing to automatically discover bugs in PDF.js.

This fuzz/ directory contains the configuration and the fuzz tests for PDF.js. To generate and run fuzz tests, we use the Jazzer.js library.

Running a fuzzer

This directory contains fuzzers like for example jpeg_image.fuzz. You can run it with:

Generate image decoders:

$ gulp image_decoders

Run fuzz target:

$ npx jazzer fuzz/jpeg_image.fuzz --sync

You should see output that looks something like this:

#2      INITED exec/s: 0 rss: 128Mb
#65536  pulse  corp: 1/1b lim: 652 exec/s: 32768 rss: 140Mb
#131072 pulse  corp: 1/1b lim: 1300 exec/s: 32768 rss: 140Mb
#262144 pulse  corp: 1/1b lim: 2611 exec/s: 32768 rss: 140Mb
#524288 pulse  corp: 1/1b lim: 4096 exec/s: 30840 rss: 140Mb
#1048576        pulse  corp: 1/1b lim: 4096 exec/s: 29959 rss: 140Mb
#2097152        pulse  corp: 1/1b lim: 4096 exec/s: 29537 rss: 140Mb

It will continue to generate random inputs forever, until it finds a bug or is terminated. The testcases for bugs it finds can be seen in the form of crash-* or timeout-* at the place from where command is run. You can rerun the fuzzer on a single input by passing it on the command line npx jazzer fuzz/jpeg_image.fuzz /path/to/testcase.