fuzz/decode_ndr_X_crash: -f to filter crashes by regex
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 5 Dec 2019 22:10:05 +0000 (11:10 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 10 Dec 2019 07:50:29 +0000 (07:50 +0000)
If you go:

$ ./lib/fuzzing/decode_ndr_X_crash -H HONGGFUZZ_REPORT.txt -f 'SIG[^V]' > ./crash.sh

you will get all the crashes and not the timeouts (which have SIGVTALARM).

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/fuzzing/decode_ndr_X_crash

index a6c5158859b84bf582313232118d2fa793bc4943..8ca5922449f729fec342540c0cd21929aef6c2d0 100755 (executable)
@@ -75,6 +75,8 @@ def main():
                         help='say more')
     parser.add_argument('-H', '--honggfuzz-file',
                         help="extract crashes from this honggfuzz report")
+    parser.add_argument('-f', '--crash-filter',
+                        help="only print crashes matching this rexexp")
 
     args = parser.parse_args()
 
@@ -89,6 +91,10 @@ def main():
         sys.exit(1)
 
     for fn in args.FILES:
+        if args.crash_filter is not None:
+            if not re.search(args.crash_filter, fn):
+                print_if_verbose(f"skipping {fn}")
+                continue
         try:
             if fn == '-':
                 process_one_file(sys.stdin)
@@ -114,6 +120,12 @@ def main():
                 m = re.match(r'^FUZZ_FNAME: (\S+)$', line)
                 if m:
                     crash = m.group(1)
+                    if args.crash_filter is not None:
+                        if not re.search(args.crash_filter, crash):
+                            print_if_verbose(f"skipping {crash}")
+                            pipe = None
+                            crash = None
+                            continue
                     print_if_verbose(f"found crash {crash}")
                 if pipe is not None and crash is not None:
                     with open(crash, 'rb') as f: