# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import atheris import socket import sys import time import threading with atheris.instrument_imports(): import requests fuzzed_input = b"" # somehow ugly as fuzzing cannot be run in parallel def SetFuzzedInput(input_bytes): global fuzzed_input fuzzed_input = input_bytes class ServerThread(threading.Thread): def __init__(self): self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys import atheris with atheris.instrument_imports(enable_loader_override=False): import xdg.Menu from xdg.Exceptions import ParsingError @atheris.instrument_func def TestOneInput(input_bytes): # We need to make the file an absolute path testfile_path = os.path.join(os.getcwd(), "test.menu") with open(testfile_path, "wb") as f: f.write(input_bytes) try: xdg.Menu.parse(filename=testfile_path) except ParsingError: None os.remove(testfile_path)