Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Replace the Suboptimalfuzz_tree.py
Harness With a Better Alternative#1910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import atheris | ||
import io | ||
import sys | ||
import os | ||
import tempfile | ||
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"): | ||
path_to_bundled_git_binary = os.path.abspath(os.path.join(os.path.dirname(__file__), "git")) | ||
os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = path_to_bundled_git_binary | ||
with atheris.instrument_imports(): | ||
import git | ||
def TestOneInput(data): | ||
fdp = atheris.FuzzedDataProvider(data) | ||
with tempfile.TemporaryDirectory() as temp_dir: | ||
repo = git.Repo.init(path=temp_dir) | ||
# Generate a minimal set of files based on fuzz data to minimize I/O operations. | ||
file_paths = [os.path.join(temp_dir, f"File{i}") for i in range(min(3, fdp.ConsumeIntInRange(1, 3)))] | ||
for file_path in file_paths: | ||
with open(file_path, "wb") as f: | ||
# The chosen upperbound for count of bytes we consume by writing to these | ||
# files is somewhat arbitrary and may be worth experimenting with if the | ||
# fuzzer coverage plateaus. | ||
f.write(fdp.ConsumeBytes(fdp.ConsumeIntInRange(1, 512))) | ||
repo.index.add(file_paths) | ||
repo.index.commit(fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(1, 80))) | ||
fuzz_tree = git.Tree(repo, git.Tree.NULL_BIN_SHA, 0, "") | ||
try: | ||
fuzz_tree._deserialize(io.BytesIO(data)) | ||
except IndexError: | ||
return -1 | ||
def main(): | ||
atheris.Setup(sys.argv, TestOneInput) | ||
atheris.Fuzz() | ||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.