|
Packit Service |
084de1 |
#!/usr/bin/python
|
|
Packit Service |
084de1 |
#
|
|
Packit Service |
084de1 |
# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
|
Packit Service |
084de1 |
#
|
|
Packit Service |
084de1 |
# Licensed under the OpenSSL license (the "License"). You may not use
|
|
Packit Service |
084de1 |
# this file except in compliance with the License. You can obtain a copy
|
|
Packit Service |
084de1 |
# in the file LICENSE in the source distribution or at
|
|
Packit Service |
084de1 |
# https://www.openssl.org/source/license.html
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
"""Fuzzing helper, creates and uses corpus/crash directories.
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
fuzzer.py <fuzzer> <extra fuzzer arguments>
|
|
Packit Service |
084de1 |
"""
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
import os
|
|
Packit Service |
084de1 |
import subprocess
|
|
Packit Service |
084de1 |
import sys
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
FUZZER = sys.argv[1]
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
|
|
Packit Service |
084de1 |
CORPORA_DIR = os.path.abspath(os.path.join(THIS_DIR, "corpora"))
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
FUZZER_DIR = os.path.abspath(os.path.join(CORPORA_DIR, FUZZER))
|
|
Packit Service |
084de1 |
if not os.path.isdir(FUZZER_DIR):
|
|
Packit Service |
084de1 |
os.mkdir(FUZZER_DIR)
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
corpora = []
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
def _create(d):
|
|
Packit Service |
084de1 |
dd = os.path.abspath(os.path.join(CORPORA_DIR, d))
|
|
Packit Service |
084de1 |
if not os.path.isdir(dd):
|
|
Packit Service |
084de1 |
os.mkdir(dd)
|
|
Packit Service |
084de1 |
corpora.append(dd)
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
def _add(d):
|
|
Packit Service |
084de1 |
dd = os.path.abspath(os.path.join(CORPORA_DIR, d))
|
|
Packit Service |
084de1 |
if os.path.isdir(dd):
|
|
Packit Service |
084de1 |
corpora.append(dd)
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
def main():
|
|
Packit Service |
084de1 |
_create(FUZZER)
|
|
Packit Service |
084de1 |
_create(FUZZER + "-crash")
|
|
Packit Service |
084de1 |
_add(FUZZER + "-seed")
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
cmd = ([os.path.abspath(os.path.join(THIS_DIR, FUZZER))] + sys.argv[2:]
|
|
Packit Service |
084de1 |
+ ["-artifact_prefix=" + corpora[1] + "/"] + corpora)
|
|
Packit Service |
084de1 |
print(" ".join(cmd))
|
|
Packit Service |
084de1 |
subprocess.call(cmd)
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
if __name__ == "__main__":
|
|
Packit Service |
084de1 |
main()
|