| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a915adf commit 989ae1a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | 1 | import sys | |
| 2 | 2 | import os | |
| 3 | + import io | ||
| 3 | 4 | import tempfile | |
| 4 | 5 | from binascii import Error as BinasciiError | |
| 5 | 6 | ||
@@ -13,13 +14,26 @@ | |||
| 13 | 14 | from git import Repo, Diff | |
| 14 | 15 | ||
| 15 | 16 | ||
| 17 | + class BytesProcessAdapter: | ||
| 18 | + """Allows bytes to be used as process objects returned by subprocess.Popen.""" | ||
| 19 | + | ||
| 20 | + def __init__(self, input_string): | ||
| 21 | + self.stdout = io.BytesIO(input_string) | ||
| 22 | + self.stderr = io.BytesIO() | ||
| 23 | + | ||
| 24 | + def wait(self): | ||
| 25 | + return 0 | ||
| 26 | + | ||
| 27 | + poll = wait | ||
| 28 | + | ||
| 29 | + | ||
| 16 | 30 | def TestOneInput(data): | |
| 17 | 31 | fdp = atheris.FuzzedDataProvider(data) | |
| 18 | 32 | ||
| 19 | 33 | with tempfile.TemporaryDirectory() as temp_dir: | |
| 20 | 34 | repo = Repo.init(path=temp_dir) | |
| 21 | 35 | try: | |
| 22 | - Diff( | ||
| 36 | + diff = Diff( | ||
| 23 | 37 | repo, | |
| 24 | 38 | a_rawpath=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())), | |
| 25 | 39 | b_rawpath=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())), | |
@@ -44,6 +58,21 @@ def TestOneInput(data): | |||
| 44 | 58 | else: | |
| 45 | 59 | raise e | |
| 46 | 60 | ||
| 61 | + _ = diff.__str__() | ||
| 62 | + _ = diff.a_path | ||
| 63 | + _ = diff.b_path | ||
| 64 | + _ = diff.rename_from | ||
| 65 | + _ = diff.rename_to | ||
| 66 | + _ = diff.renamed_file | ||
| 67 | + | ||
| 68 | + diff_index = diff._index_from_patch_format( | ||
| 69 | + repo, proc=BytesProcessAdapter(fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes()))) | ||
| 70 | + ) | ||
| 71 | + | ||
| 72 | + diff._handle_diff_line( | ||
| 73 | + lines_bytes=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())), repo=repo, index=diff_index | ||
| 74 | + ) | ||
| 75 | + | ||
| 47 | 76 | ||
| 48 | 77 | def main(): | |
| 49 | 78 | atheris.Setup(sys.argv, TestOneInput) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments