Skip to content

Commit b480757

Browse files
authored
Moved OSS-Fuzz target file under tests (#234)
1 parent b3525b4 commit b480757

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ doc = [
5353
benchmarks = [
5454
"pytest-benchmark==4.0.0",
5555
]
56+
fuzz = [
57+
"atheris",
58+
]
5659

5760
[tool.setuptools.packages.find]
5861
include = ["cbor2"]

tests/fuzzers/loads_fuzzer.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import sys
2+
3+
import atheris
4+
5+
# _cbor2 ensures the C library is imported
6+
from _cbor2 import loads
7+
8+
9+
def test_one_input(data: bytes):
10+
try:
11+
loads(data)
12+
except Exception:
13+
# We're searching for memory corruption, not Python exceptions
14+
pass
15+
16+
17+
if __name__ == "__main__":
18+
atheris.Setup(sys.argv, test_one_input)
19+
atheris.Fuzz()

0 commit comments

Comments
 (0)