def setupProject(project): USE_STDOUT = True time = ProcessTimeWatch( project, too_slow=3.0, too_slow_score=0.10, too_fast=0.100, too_fast_score=-0.80, ) orig_filename = project.application().getInputFilename("PDF document") if AUTO_MANGLE: mangle = AutoMangle(project, orig_filename) mangle.hard_max_op = 1000 else: mangle = MangleFile(project, orig_filename) mangle.config.max_op = 1000 options = {'timeout': 5.0} if not USE_STDOUT: options['stdout'] = 'null' process = PopplerProcess(project, ['pdftotext'], **options) WatchProcess(process, exitcode_score=-0.10) if USE_STDOUT: stdout = WatchStdout(process) def cleanupLine(line): match = re.match(r"Error(?: \([0-9]+\))?: (.*)", line) if match: line = match.group(1) return line stdout.cleanup_func = cleanupLine del stdout.words['unknown'] # stdout.show_not_matching = True # stdout.ignoreRegex(r"Unknown operator 'allocate'$") # stdout.ignoreRegex(r" operator is wrong type \(error\)$") # stdout.ignoreRegex(r'^No current point in lineto$') # stdout.ignoreRegex(r'^No current point in lineto') # stdout.ignoreRegex(r'^Unknown operator ') # stdout.ignoreRegex(r"^Couldn't open 'nameToUnicode' file ") # stdout.ignoreRegex(r"^Illegal character ") # stdout.ignoreRegex(r"^No font in show$") # stdout.ignoreRegex(r"^Element of show/space array must be number or string$") # stdout.ignoreRegex(r"^No current point in curveto$") # stdout.ignoreRegex(r"^Badly formatted number$") # stdout.ignoreRegex(r"^Dictionary key must be a name object$") # stdout.ignoreRegex(r"^End of file inside array$") # stdout.ignoreRegex(r"^Too few \([0-9]+\) args to .* operator$") # stdout.ignoreRegex(r"Too many args in content stream") stdout.max_nb_line = (100, 0.20)
def setupProject(project): USE_STDOUT = True time = ProcessTimeWatch(project, too_slow=3.0, too_slow_score=0.10, too_fast=0.100, too_fast_score=-0.80, ) orig_filename = project.application().getInputFilename("PDF document") if AUTO_MANGLE: mangle = AutoMangle(project, orig_filename) mangle.hard_max_op = 1000 else: mangle = MangleFile(project, orig_filename) mangle.config.max_op = 1000 options = {'timeout': 5.0} if not USE_STDOUT: options['stdout'] = 'null' process = PopplerProcess(project, ['pdftotext'], **options) WatchProcess(process, exitcode_score=-0.10) if USE_STDOUT: stdout = WatchStdout(process) def cleanupLine(line): match = re.match(r"Error(?: \([0-9]+\))?: (.*)", line) if match: line = match.group(1) return line stdout.cleanup_func = cleanupLine del stdout.words['unknown'] # stdout.show_not_matching = True # stdout.ignoreRegex(r"Unknown operator 'allocate'$") # stdout.ignoreRegex(r" operator is wrong type \(error\)$") # stdout.ignoreRegex(r'^No current point in lineto$') # stdout.ignoreRegex(r'^No current point in lineto') # stdout.ignoreRegex(r'^Unknown operator ') # stdout.ignoreRegex(r"^Couldn't open 'nameToUnicode' file ") # stdout.ignoreRegex(r"^Illegal character ") # stdout.ignoreRegex(r"^No font in show$") # stdout.ignoreRegex(r"^Element of show/space array must be number or string$") # stdout.ignoreRegex(r"^No current point in curveto$") # stdout.ignoreRegex(r"^Badly formatted number$") # stdout.ignoreRegex(r"^Dictionary key must be a name object$") # stdout.ignoreRegex(r"^End of file inside array$") # stdout.ignoreRegex(r"^Too few \([0-9]+\) args to .* operator$") # stdout.ignoreRegex(r"Too many args in content stream") stdout.max_nb_line = (100, 0.20)
def setupProject(project): for filename in FILENAMES: if path_exists(filename): continue raise ValueError("File doesn't exist: %s! Fix FILENAMES constant" % filename) module_name = project.application().getInputFilename( 'Module name (use "ALL" to test all modules)') project.error("Use python interpreter: %s" % PYTHON) project.error("Use filenames: %s" % ', '.join(FILENAMES)) source = PythonSource(project, module_name) process = PythonProcess(project, [PYTHON, '-u', '<source.py>'], timeout=10.0, stdin='null') WatchProcess(process, exitcode_score=0) stdout = WatchStdout(process) stdout.max_nb_line = (1000, 1.0) # Disable dummy error messages stdout.words = { 'oops': 0.30, 'bug': 0.30, 'memory': 0.40, 'overflow': 0.40, 'fatal': 1.0, 'assert': 1.0, 'assertion': 1.0, 'critical': 1.0, 'panic': 1.0, 'glibc detected': 1.0, 'segfault': 1.0, 'segmentation fault': 1.0, } # PyPy messages stdout.addRegex("Fatal RPython error", 1.0) if DEBUG: stdout.show_matching = True stdout.show_not_matching = True
def setupProject(project): for filename in FILENAMES: if path_exists(filename): continue raise ValueError("File doesn't exist: %s! Fix FILENAMES constant" % filename) module_name = project.application().getInputFilename('Module name (use "ALL" to test all modules)') project.error("Use python interpreter: %s" % PYTHON) project.error("Use filenames: %s" % ', '.join(FILENAMES)) source = PythonSource(project, module_name) process = PythonProcess(project, [PYTHON, '-u', '<source.py>'], timeout=10.0, stdin='null') WatchProcess(process, exitcode_score=0) stdout = WatchStdout(process) stdout.max_nb_line = (1000, 1.0) # Disable dummy error messages stdout.words = { 'oops': 0.30, 'bug': 0.30, 'memory': 0.40, 'overflow': 0.40, 'fatal': 1.0, 'assert': 1.0, 'assertion': 1.0, 'critical': 1.0, 'panic': 1.0, 'glibc detected': 1.0, 'segfault': 1.0, 'segmentation fault': 1.0, } # PyPy messages stdout.addRegex("Fatal RPython error", 1.0) if DEBUG: stdout.show_matching = True stdout.show_not_matching = True
def setupProject(project): global CMDLINE_ARG_POS orig_filename = project.application().getInputFilename("Image") mangle = ImageMangle(project, orig_filename) if INCR_MANGLE: mangle.operation_per_version = 1 mangle.max_version = 50 else: mangle.fixed_size_factor = 0.5 options = {'timeout': 2.0} if USE_CONVERT: cmdline = ['convert', '<source>', '/tmp/output.bmp'] CMDLINE_ARG_POS = 1 else: cmdline = ['identify', '-verbose', '<source>'] CMDLINE_ARG_POS = -1 if not USE_STDOUT: options['stdout'] = 'null' process = IdentifyProcess(project, cmdline, **options) options = {'exitcode_score': -0.25} if orig_filename.endswith(".jpg"): # Don't care about libjpeg stdout flooding options['timeout_score'] = -0.25 WatchProcess(process, **options) if USE_STDOUT: stdout = WatchStdout(process) stdout.max_nb_line = (3000, 0.20) stdout.patterns['memory allocation failed'] = 1.0 stdout.patterns['no decode delegate for this image format'] = -1.0 stdout.addRegex('Corrupt', 0.05) stdout.addRegex('Unsupported', 0.05) stdout.addRegex('Not a JPEG file', -0.50) stdout.addRegex('JPEG datastream contains no image', -0.50) stdout.show_not_matching = False
def setupProject(project): # Command line MAX_FILESIZE = 1*1024*1024 ARGUMENTS = ['-quiet'] MPLAYER_BIN = 'mplayer' NULL_VIDEO = True if NULL_VIDEO: ARGUMENTS.extend(['-vo', 'null', '-ao', 'null']) if True: SECONDS = 5 TIMEOUT = SECONDS + 1.0 ARGUMENTS.extend(['-endpos', str(SECONDS)]) else: TIMEOUT = 7.0 # Create buggy input file orig_filename = project.application().getInputFilename("Audio or video file") mangle = AutoMangle(project, orig_filename) mangle.max_size = MAX_FILESIZE process = MplayerProcess(project, [MPLAYER_BIN] + ARGUMENTS + ["<movie_filename>"], timeout=TIMEOUT) if not NULL_VIDEO: setupX11Process(process) else: process.env.copy('HOME') watch = WatchProcess(process, timeout_score=0) if watch.cpu: watch.cpu.weight = 0.20 watch.cpu.max_load = 0.50 watch.cpu.max_duration = min(3, TIMEOUT-0.5) watch.cpu.max_score = 0.50 stdout = WatchStdout(process) # Ignore input errors stdout.ignoreRegex('^Failed to open LIRC support') stdout.ignoreRegex("^Can't init input joystick$") stdout.ignoreRegex("^Can't open joystick device ") # Ignore codec loading errors stdout.ignoreRegex('^Failed to create DirectShow filter$') stdout.ignoreRegex('^Win32 LoadLibrary failed') stdout.ignoreRegex('^Error loading dll$') stdout.ignoreRegex('^ERROR: Could not open required DirectShow codec ') stdout.ignoreRegex("could not open DirectShow") # Ignore other errors stdout.ignoreRegex("^Terminal type `unknown' is not defined.$") stdout.ignoreRegex('^VDecoder init failed') stdout.ignoreRegex("Read error at pos\. [0-9]+") stdout.ignoreRegex("could not connect to socket") stdout.ignoreRegex('^ADecoder init failed') stdout.ignoreRegex('^error while decoding block:') stdout.ignoreRegex('^Error while decoding frame!$') stdout.ignoreRegex('^\[(mpeg4|msmpeg4|wmv1|h264|NULL) @ ') stdout.patterns['overflow'] = 0.10 # stdout.words['error'] = 0.10 # stdout.words["can't"] = 0 stdout.addRegex('MPlayer interrupted by signal', 1.0) stdout.addRegex('AVI: Missing video stream', -0.50) stdout.max_nb_line = None # Restore terminal state TerminalEcho(project)
def setupProject(self): self.project.debugger.enabled = False self.config.use_cpu_probe = False self.config.process_max_user_process = 50 port = 8848 seed = random.randint(0, 60000) timeout = 60 * 60 server_process = ProjectProcess(self.project, [ 'python3', '-m', 'huhhttp', '--port', str(port), '--seed', str(seed), '--fuzz-period', '500', '--restart-interval', '250', ], timeout=timeout) WatchProcess(server_process) process = ProjectProcess(self.project, [ 'python3', '-X', 'faulthandler', '-m', 'wpull', '127.0.0.1:{0}'.format(port), '--timeout', '5', '--warc-file', 'fusil-test', '-r', '--debug', '--page-requisites', '--delete-after', '--tries', '2', '--retry-connrefused', '--database', 'wpull.db', '--span-hosts-allow', 'page-requisites,linked-pages', '--no-check-certificate', '--concurrent', str(random.randint(1, 10)), ], timeout=timeout) process.env.set( 'PYTHONPATH', os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', '..')) process.env.set('OBJGRAPH_DEBUG', '1') process.env.set('FILE_LEAK_DEBUG', '1') WatchProcessSpecificStatusCode(process) stdout_watcher = WatchStdout(process) stdout_watcher.max_nb_line = None stdout_watcher.ignoreRegex( r'WARNING Invalid content length: invalid literal for int') stdout_watcher.ignoreRegex(r'WARNING Unable to parse URL ') stdout_watcher.ignoreRegex(r'WARNING Failed to read document at ') stdout_watcher.ignoreRegex(r'WARNING Content overrun') stdout_watcher.ignoreRegex(r'ERROR Fetching ') stdout_watcher.ignoreRegex(r'DEBUG ') stdout_watcher.ignoreRegex(r'INFO Fetch(ed|ing) ') stdout_watcher.ignoreRegex(r'lsof: WARNING: ')
def setupProject(project): # Command line MAX_FILESIZE = 1 * 1024 * 1024 ARGUMENTS = ['-quiet'] MPLAYER_BIN = 'mplayer' NULL_VIDEO = True if NULL_VIDEO: ARGUMENTS.extend(['-vo', 'null', '-ao', 'null']) if True: SECONDS = 5 TIMEOUT = SECONDS + 1.0 ARGUMENTS.extend(['-endpos', str(SECONDS)]) else: TIMEOUT = 7.0 # Create buggy input file orig_filename = project.application().getInputFilename( "Audio or video file") mangle = AutoMangle(project, orig_filename) mangle.max_size = MAX_FILESIZE process = MplayerProcess(project, [MPLAYER_BIN] + ARGUMENTS + ["<movie_filename>"], timeout=TIMEOUT) if not NULL_VIDEO: setupX11Process(process) else: process.env.copy('HOME') watch = WatchProcess(process, timeout_score=0) if watch.cpu: watch.cpu.weight = 0.20 watch.cpu.max_load = 0.50 watch.cpu.max_duration = min(3, TIMEOUT - 0.5) watch.cpu.max_score = 0.50 stdout = WatchStdout(process) # Ignore input errors stdout.ignoreRegex('^Failed to open LIRC support') stdout.ignoreRegex("^Can't init input joystick$") stdout.ignoreRegex("^Can't open joystick device ") # Ignore codec loading errors stdout.ignoreRegex('^Failed to create DirectShow filter$') stdout.ignoreRegex('^Win32 LoadLibrary failed') stdout.ignoreRegex('^Error loading dll$') stdout.ignoreRegex('^ERROR: Could not open required DirectShow codec ') stdout.ignoreRegex("could not open DirectShow") # Ignore other errors stdout.ignoreRegex("^Terminal type `unknown' is not defined.$") stdout.ignoreRegex('^VDecoder init failed') stdout.ignoreRegex("Read error at pos\. [0-9]+") stdout.ignoreRegex("could not connect to socket") stdout.ignoreRegex('^ADecoder init failed') stdout.ignoreRegex('^error while decoding block:') stdout.ignoreRegex('^Error while decoding frame!$') stdout.ignoreRegex('^\[(mpeg4|msmpeg4|wmv1|h264|NULL) @ ') stdout.patterns['overflow'] = 0.10 # stdout.words['error'] = 0.10 # stdout.words["can't"] = 0 stdout.addRegex('MPlayer interrupted by signal', 1.0) stdout.addRegex('AVI: Missing video stream', -0.50) stdout.max_nb_line = None # Restore terminal state TerminalEcho(project)
def setupProject(self): self.project.debugger.enabled = False self.config.use_cpu_probe = False self.config.process_max_user_process = 50 port = 8848 seed = random.randint(0, 60000) timeout = 60 * 60 server_process = ProjectProcess( self.project, [ 'python3', '-m', 'huhhttp', '--port', str(port), '--seed', str(seed), '--fuzz-period', '500', '--restart-interval', '250', ], timeout=timeout ) WatchProcess(server_process) process = ProjectProcess( self.project, [ 'python3', '-X', 'faulthandler', '-m', 'wpull', '127.0.0.1:{0}'.format(port), '--timeout', '5', '--warc-file', 'fusil-test', '-r', '--debug', '--page-requisites', '--delete-after', '--tries', '2', '--retry-connrefused', '--database', 'wpull.db', '--span-hosts-allow', 'page-requisites,linked-pages', '--no-check-certificate', '--concurrent', str(random.randint(1, 10)), ], timeout=timeout ) process.env.set( 'PYTHONPATH', os.path.join( os.path.abspath(os.path.dirname(__file__)), '..', '..') ) process.env.set('OBJGRAPH_DEBUG', '1') process.env.set('FILE_LEAK_DEBUG', '1') WatchProcessSpecificStatusCode(process) stdout_watcher = WatchStdout(process) stdout_watcher.max_nb_line = None stdout_watcher.ignoreRegex( r'WARNING Invalid content length: invalid literal for int' ) stdout_watcher.ignoreRegex( r'WARNING Unable to parse URL ' ) stdout_watcher.ignoreRegex( r'WARNING Failed to read document at ' ) stdout_watcher.ignoreRegex( r'WARNING Content overrun' ) stdout_watcher.ignoreRegex( r'ERROR Fetching ' ) stdout_watcher.ignoreRegex( r'DEBUG ' ) stdout_watcher.ignoreRegex( r'INFO Fetch(ed|ing) ' ) stdout_watcher.ignoreRegex( r'lsof: WARNING: ' )