-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Add a fuzzer for Py_CompileStringExFlags
#111721
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ebf163
Add a fuzzer for `Py_CompileStringExFlags`
bradlarsen 3701f3b
Fix buffer indexing error in fuzzer
bradlarsen 9ff4067
Merge branch 'main' into main
bradlarsen 96d6c0e
Merge branch 'main' into main
bradlarsen ce5ca48
Simplify how the input gets NUL-terminated
bradlarsen 3d8147e
Apply suggestions from code review
bradlarsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,165 @@ | ||
# bits of syntax | ||
"( " | ||
") " | ||
"[ " | ||
"] " | ||
": " | ||
", " | ||
"; " | ||
"{ " | ||
"} " | ||
|
||
# operators | ||
"+ " | ||
"- " | ||
"* " | ||
"** " | ||
"/ " | ||
"// " | ||
"| " | ||
"& " | ||
"< " | ||
"> " | ||
"= " | ||
". " | ||
"% " | ||
"` " | ||
"^ " | ||
"~ " | ||
"@ " | ||
"== " | ||
"!= " | ||
"<> " | ||
"<< " | ||
"<= " | ||
">= " | ||
">> " | ||
"+= " | ||
"-= " | ||
"*= " | ||
"** " | ||
"/= " | ||
"//= " | ||
"|= " | ||
"%= " | ||
"&= " | ||
"^= " | ||
"<<= " | ||
">>= " | ||
"**= " | ||
":= " | ||
"@= " | ||
|
||
# whitespace | ||
" " | ||
":\\n " | ||
|
||
# type signatures and functions | ||
"-> " | ||
": List[int]" | ||
": Dict[int, str]" | ||
|
||
"# type:" | ||
"# type: List[int]" | ||
"# type: Dict[int, str]" | ||
|
||
", *" | ||
", /" | ||
", *args" | ||
", **kwargs" | ||
", x=42" | ||
|
||
|
||
# literals | ||
"0x0a" | ||
"0b0000" | ||
"42" | ||
"0o70" | ||
"42j" | ||
"42.01" | ||
"-5" | ||
"+42e-3" | ||
"0_0_0" | ||
"1e1_0" | ||
".1_4" | ||
|
||
"{}" | ||
|
||
# variable names | ||
"x" | ||
"y" | ||
|
||
# strings | ||
"r'x'" | ||
|
||
"b'x'" | ||
|
||
"rb\"x\"" | ||
|
||
"br\"x\"" | ||
|
||
"f'{x + 5}'" | ||
"f\"{x + 5}\"" | ||
|
||
"'''" | ||
"\"\"\"" | ||
|
||
"\\u" | ||
"\\x" | ||
|
||
# keywords | ||
"def " | ||
"del " | ||
"pass " | ||
"break " | ||
"continue " | ||
"return " | ||
"raise " | ||
"from " | ||
"import " | ||
".. " | ||
"... " | ||
"__future__ " | ||
"as " | ||
"global " | ||
"nonlocal " | ||
"assert " | ||
"print " | ||
"if " | ||
"elif " | ||
"else: " | ||
"while " | ||
"try: " | ||
"except " | ||
"finally: " | ||
"with " | ||
"lambda " | ||
"or " | ||
"and " | ||
"not " | ||
"None " | ||
"__peg_parser__" | ||
"True " | ||
"False " | ||
"yield " | ||
"async " | ||
"await " | ||
"for " | ||
"in " | ||
"is " | ||
"class " | ||
|
||
# shebangs and encodings | ||
"#!" | ||
"# coding:" | ||
"# coding=" | ||
"# coding: latin-1" | ||
"# coding=latin-1" | ||
"# coding: utf-8" | ||
"# coding=utf-8" | ||
"# coding: ascii" | ||
"# coding=ascii" | ||
"# coding: cp860" | ||
"# coding=cp860" | ||
"# coding: gbk" | ||
"# coding=gbk" |
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,7 @@ | ||
from __future__ import annotations | ||
|
||
def test() -> None: | ||
x: list[int] = [] | ||
x: dict[int, str] = {} | ||
x: set[bytes] = {} | ||
print(5 + 42 * 3, x) |
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,5 @@ | ||
class Foo(metaclass=42): | ||
__slots__ = ['x'] | ||
pass | ||
|
||
foo = Foo() |
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,6 @@ | ||
def evens(): | ||
i = 0 | ||
while True: | ||
i += 1 | ||
if i % 2 == 0: | ||
yield i |
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,3 @@ | ||
async def hello(name: str): | ||
await name | ||
print(name) |
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,7 @@ | ||
try: | ||
eval('importer exporter... really long matches') | ||
except SyntaxError: | ||
print("nothing to see here") | ||
finally: | ||
print("all done here") | ||
raise |
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,8 @@ | ||
"""Some module docstring""" | ||
import sys | ||
|
||
def main(): | ||
print("Hello world!", file=sys.stderr) | ||
|
||
if __name__ == '__main__': | ||
main() |
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ fuzz_csv_reader | |
fuzz_struct_unpack | ||
fuzz_ast_literal_eval | ||
fuzz_elementtree_parsewhole | ||
fuzz_pycompile |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.