Skip to content

Commit 48abb1c

Browse files
committed
Add git.Blob fuzz target
Based on the `test_blob.py` unit test.
1 parent 5f26779 commit 48abb1c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

fuzzing/dictionaries/fuzz_blob.dict

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"\\377\\377\\377\\377\\377\\377\\377\\377"

fuzzing/fuzz-targets/fuzz_blob.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import atheris
2+
import sys
3+
import os
4+
import tempfile
5+
6+
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
7+
path_to_bundled_git_binary = os.path.abspath(os.path.join(os.path.dirname(__file__), "git"))
8+
os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = path_to_bundled_git_binary
9+
10+
with atheris.instrument_imports():
11+
import git
12+
13+
14+
def TestOneInput(data):
15+
fdp = atheris.FuzzedDataProvider(data)
16+
17+
with tempfile.TemporaryDirectory() as temp_dir:
18+
repo = git.Repo.init(path=temp_dir)
19+
blob = git.Blob(
20+
repo,
21+
**{
22+
"binsha": git.Blob.NULL_BIN_SHA,
23+
"path": fdp.ConsumeUnicodeNoSurrogates(fdp.remaining_bytes()),
24+
},
25+
)
26+
27+
_ = blob.mime_type
28+
29+
30+
def main():
31+
atheris.Setup(sys.argv, TestOneInput)
32+
atheris.Fuzz()
33+
34+
35+
if __name__ == "__main__":
36+
main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy