Skip to content

Commit

Permalink
Move OSS-Fuzz target file under tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwager committed Apr 23, 2024
1 parent e1b65f2 commit 88e4b90
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ doc = [
benchmarks = [
"pytest-benchmark==4.0.0",
]
fuzz = [
"atheris",
]

[project.scripts]
cbor2 = "cbor2.tool:main"
Expand Down
22 changes: 22 additions & 0 deletions tests/fuzzers/loads_fuzzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys
import atheris

# _cbor2 ensures the C library is imported
from _cbor2 import loads


def test_one_input(data: bytes):
try:
loads(data)
except Exception:
# We're searching for memory corruption, not Python exceptions
pass


def main():
atheris.Setup(sys.argv, test_one_input)
atheris.Fuzz()


if __name__ == "__main__":
main()

0 comments on commit 88e4b90

Please sign in to comment.