Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move OSS-Fuzz target file under tests #234

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
23 changes: 23 additions & 0 deletions tests/fuzzers/loads_fuzzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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()