()
| 25 | |
| 26 | |
| 27 | def main(): |
| 28 | parser = argparse.ArgumentParser( |
| 29 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
| 30 | description='''Run the fuzz targets with all inputs from the corpus_dir once.''', |
| 31 | ) |
| 32 | parser.add_argument( |
| 33 | "-l", |
| 34 | "--loglevel", |
| 35 | dest="loglevel", |
| 36 | default="INFO", |
| 37 | help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console.", |
| 38 | ) |
| 39 | parser.add_argument( |
| 40 | '--valgrind', |
| 41 | action='store_true', |
| 42 | help='If true, run fuzzing binaries under the valgrind memory error detector', |
| 43 | ) |
| 44 | parser.add_argument( |
| 45 | '-x', |
| 46 | '--exclude', |
| 47 | help="A comma-separated list of targets to exclude", |
| 48 | ) |
| 49 | parser.add_argument( |
| 50 | '--par', |
| 51 | '-j', |
| 52 | type=int, |
| 53 | default=4, |
| 54 | help='How many targets to merge or execute in parallel.', |
| 55 | ) |
| 56 | parser.add_argument( |
| 57 | 'corpus_dir', |
| 58 | help='The corpus to run on (must contain subfolders for each fuzz target).', |
| 59 | ) |
| 60 | parser.add_argument( |
| 61 | 'target', |
| 62 | nargs='*', |
| 63 | help='The target(s) to run. Default is to run all targets.', |
| 64 | ) |
| 65 | parser.add_argument( |
| 66 | '--m_dir', |
| 67 | help='Merge inputs from this directory into the corpus_dir.', |
| 68 | ) |
| 69 | parser.add_argument( |
| 70 | '-g', |
| 71 | '--generate', |
| 72 | action='store_true', |
| 73 | help='Create new corpus (or extend the existing ones) by running' |
| 74 | ' the given targets for a finite number of times. Outputs them to' |
| 75 | ' the passed corpus_dir.' |
| 76 | ) |
| 77 | |
| 78 | args = parser.parse_args() |
| 79 | |
| 80 | # Set up logging |
| 81 | logging.basicConfig( |
| 82 | format='%(message)s', |
| 83 | level=int(args.loglevel) if args.loglevel.isdigit() else args.loglevel.upper(), |
| 84 | ) |
no test coverage detected