Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork947
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
Merged
Byron merged 1 commit intogitpython-developers:mainfromDaveLak:replace-flaky-fuzz-tree-testApr 29, 2024
+57 −90
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletionsREADME.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletionsfuzzing/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletionsfuzzing/dictionaries/fuzz_tree.dict
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
47 changes: 47 additions & 0 deletionsfuzzing/fuzz-targets/fuzz_repo.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
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() |
67 changes: 0 additions & 67 deletionsfuzzing/fuzz-targets/fuzz_tree.py
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.