Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a2294f

Browse files
committed
Improvefuzz_submodule.py coverage & efficacy
The fuzzer was having trouble analyzing `fuzz_submodule.py` when usingthe `atheris.instrument_imports()` context manager. Switching to`atheris.instrument_all()` instead slightly increases the startup timefor the fuzzer, but significantly improves the fuzzing engines abilityto identify new coverage.The changes here also disable warnings that are logged to `stdout` fromthe SUT. These warnings are expected to happen with some inputs andclutter the fuzzer output logs. They can be optionally re-enabled fordebugging by passing a flag o the Python interpreter command line orsetting the `PYTHONWARNINGS` environment variable.
1 parent6c00ce6 commit2a2294f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

‎fuzzing/fuzz-targets/fuzz_submodule.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44
importtempfile
55
fromconfigparserimportParsingError
66
fromutilsimportis_expected_exception_message,get_max_filename_length
7+
fromgitimportRepo,GitCommandError,InvalidGitRepositoryError
78

8-
ifgetattr(sys,"frozen",False)andhasattr(sys,"_MEIPASS"):
9+
ifgetattr(sys,"frozen",False)andhasattr(sys,"_MEIPASS"):# pragma: no cover
910
path_to_bundled_git_binary=os.path.abspath(os.path.join(os.path.dirname(__file__),"git"))
1011
os.environ["GIT_PYTHON_GIT_EXECUTABLE"]=path_to_bundled_git_binary
1112

12-
withatheris.instrument_imports():
13-
fromgitimportRepo,GitCommandError,InvalidGitRepositoryError
13+
ifnotsys.warnoptions:# pragma: no cover
14+
# The warnings filter below can be overridden by passing the -W option
15+
# to the Python interpreter command line or setting the `PYTHONWARNINGS` environment variable.
16+
importwarnings
17+
importlogging
18+
19+
# Fuzzing data causes some plugins to generate a large number of warnings
20+
# which are not usually interesting and make the test output hard to read, so we ignore them.
21+
warnings.simplefilter("ignore")
22+
logging.getLogger().setLevel(logging.ERROR)
1423

1524

1625
defTestOneInput(data):
@@ -92,6 +101,7 @@ def TestOneInput(data):
92101

93102

94103
defmain():
104+
atheris.instrument_all()
95105
atheris.Setup(sys.argv,TestOneInput)
96106
atheris.Fuzz()
97107

‎fuzzing/fuzz-targets/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
importatheris# pragma: no cover
2-
importos
2+
importos# pragma: no cover
33
fromtypingimportList# pragma: no cover
44

55

@@ -24,7 +24,7 @@ def is_expected_exception_message(exception: Exception, error_message_list: List
2424

2525

2626
@atheris.instrument_func
27-
defget_max_filename_length(path:str)->int:
27+
defget_max_filename_length(path:str)->int:# pragma: no cover
2828
"""
2929
Get the maximum filename length for the filesystem containing the given path.
3030

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp