Commit 4c61d35f authored by Jost Rossel's avatar Jost Rossel
Browse files

Fix main test

parent e72d9512
"""Wrapper that uses the AFL++ mutator API to run different XML mutators."""
"""Wrapper that uses the AFL++ mutator API to run different XML mutators.
This is just an example, you can use it to write your own wrapper."""
import logging
import os
......
import os
import timeit
from .afl_interface import fuzz, init
from .mutators.destructive import DestructiveMutator
from .mutators.nondestructive import NonDestructiveMutator
# simple test run
if __name__ == "__main__":
os.environ["XML_MUTATOR_LOG_FILE"] = "error.log"
os.environ["XML_MUTATOR_TYPE"] = "destructive"
init("RANDOM")
# mutator = DestructiveMutator(seed="seed", number_of_mutations_between=(1, 5))
mutator = NonDestructiveMutator(seed="seed", number_of_mutations=2)
in_1 = bytearray(
b"""<?xml version="1.0" encoding="utf-8"?><model xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02" unit="millimeter" xml:lang="en-US" xmlns:m="http://schemas.microsoft.com/3dmanufacturing/material/2015/02"><resources><object id="1" name="dummy" type="model"><mesh><vertices><vertex x="0" y="0" z="0" /><vertex x="0" y="0" z="1.000000" /><vertex x="0" y="1.000000" z="0" /><vertex x="0" y="1.000000" z="1.000000" /><vertex x="1.000000" y="0" z="0" /><vertex x="1.000000" y="0" z="1.000000" /><vertex x="1.000000" y="1.000000" z="0" /><vertex x="1.000000" y="1.000000" z="1.000000" /></vertices><triangles><triangle v1="0" v2="1" v3="3" /><triangle v1="0" v2="2" v3="6" /><triangle v1="0" v2="3" v3="2" /><triangle v1="0" v2="4" v3="5" /><triangle v1="0" v2="5" v3="1" /><triangle v1="0" v2="6" v3="4" /><triangle v1="1" v2="5" v3="3" /><triangle v1="2" v2="3" v3="6" /><triangle v1="3" v2="5" v3="7" /><triangle v1="3" v2="7" v3="6" /><triangle v1="4" v2="6" v3="5" /><triangle v1="5" v2="6" v3="7" /></triangles></mesh></object></resources><build><item objectid="1" /></build></model>"""
......@@ -17,7 +16,12 @@ if __name__ == "__main__":
in_2 = bytearray(b"<abc abc123='456' abcCBA='ppppppppppppppppppppppppppppp'/>")
starttime = timeit.default_timer()
for i in range(30000):
in_1 = fuzz(in_1, in_2, target_len)
try:
mutator.init(in_1)
in_1 = mutator.mutate(target_len)
except Exception as err:
pass
assert len(in_1) <= target_len
# if i % 1000 == 0:
# print(len(in_1)) # , in_1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment