Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions test/fuzz_rdflib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/python3

import atheris

with atheris.instrument_imports():
import sys
from xml.sax import SAXParseException

from rdflib import Graph
from rdflib.exceptions import ParserError
from rdflib.plugins.parsers.notation3 import BadSyntax


def test_one_input(data):
# arbitrary byte 'data' created by atheris that mutates each time
# this allows you to manipulate the 'data' into strings, integers, lists of integers etc.
fdp = atheris.FuzzedDataProvider(data)

format_list = ["xml", "trix", "turtle", "n3", "nt"]
g = Graph()
try:
g.parse(
format=fdp.PickValueInList(format_list),
data=fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(1, 100)),
)
# Data generated is not appropriate, so ignore BadSyntax, SAXParseException and ParserError
except (BadSyntax, SAXParseException, ParserError):
pass


atheris.Setup(sys.argv, test_one_input)
atheris.Fuzz()