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

Commit799b9ca

Browse files
committed
Improvecheck_exception_against_list matching logic using regex
Changes: - `match_exception_with_traceback` uses regular expressions for more flexible matching of file paths and line numbers. This allows for partial matches and more complex patterns. - Improve `check_exception_against_list` by delegating to `match_exception_with_traceback` for checking tracebacks against exception list entries. - `load_exception_list`: Remains largely unchanged, as it correctly parses the file and line number from each exception entry. However, we ensure the set consists of regex patterns to match against tracebacks.
1 parent7de1556 commit799b9ca

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

‎fuzzing/fuzz-targets/fuzz_submodule.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,27 @@ def load_exception_list(file_path):
3131
exception_list.add((file_path,line_number))
3232
returnexception_list
3333
exceptFileNotFoundError:
34-
print("File not found:%s",file_path)
34+
print(f"File not found:{file_path}")
3535
returnset()
3636
exceptExceptionase:
37-
print("Error loading exception list:%s",e)
37+
print(f"Error loading exception list:{e}")
3838
returnset()
3939

4040

41-
defcheck_exception_against_list(exception_list,exc_traceback):
42-
"""Check if theexception tracebackmatches any entry in the exception list."""
41+
defmatch_exception_with_traceback(exception_list,exc_traceback):
42+
"""Matchexception tracebackwith the entries in the exception list."""
4343
forfilename,lineno,_,_intraceback.extract_tb(exc_traceback):
44-
if (filename,lineno)inexception_list:
45-
returnTrue
44+
forfile_pattern,line_patterninexception_list:
45+
ifre.fullmatch(file_pattern,filename)andre.fullmatch(line_pattern,str(lineno)):
46+
returnTrue
4647
returnFalse
4748

4849

50+
defcheck_exception_against_list(exception_list,exc_traceback):
51+
"""Check if the exception traceback matches any entry in the exception list."""
52+
returnmatch_exception_with_traceback(exception_list,exc_traceback)
53+
54+
4955
ifnotsys.warnoptions:# pragma: no cover
5056
# The warnings filter below can be overridden by passing the -W option
5157
# to the Python interpreter command line or setting the `PYTHONWARNINGS` environment variable.
@@ -128,10 +134,8 @@ def TestOneInput(data):
128134
exc_traceback=e.__traceback__
129135
exception_list=load_exception_list(os.path.join(bundle_dir,"explicit-exceptions-list.txt"))
130136
ifcheck_exception_against_list(exception_list,exc_traceback):
131-
print("Exception matches an entry in the exception list.")
132137
return-1
133138
else:
134-
print("Exception does not match any entry in the exception list.")
135139
raisee
136140

137141

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp