feat: Python OSS-Fuzz build and fuzz scripts#20
Conversation
EYH0602
left a comment
There was a problem hiding this comment.
I will read through run_fuzz_target.py after the meeting.
fuzz/build_oss_fuzz.py
Outdated
|
|
||
| # --- Global configuration --- | ||
| HOME_DIR = Path.home() | ||
| OSS_FUZZ_DIR = HOME_DIR / "FuzzAug" / "fuzz" / "oss-fuzz" |
There was a problem hiding this comment.
This path is wrong; we cannot assume FuzzAug is placed in the user's home directory.
Please use a CLI argument to the main function pointing to "oss-fuzz" as a relative path from where the user runs the script.
That being said, I also recommend placing the oss-fuzz submodule at the root of this project, on the same level as the other modules.
fuzz/run_fuzz_target.py
Outdated
| print(f"❌ Critical logging setup error: {e}") | ||
| sys.exit(1) | ||
|
|
||
| def run_command( |
There was a problem hiding this comment.
This function is repeated, just import from the other file.
fuzz/run_fuzz_target.py
Outdated
| async_results = [] | ||
| for p in projects: | ||
| try: | ||
| async_results.append(pool.apply_async(run_project, (p, args.timeout))) |
fuzz/run_fuzz_target.py
Outdated
| import shutil | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import List, Optional, Tuple |
There was a problem hiding this comment.
Types like List and Tuple are built-in in Python 3.10 with lower cases, no need to import them. If Optional is needed, please use Maybe from returns.maybe.
EYH0602
left a comment
There was a problem hiding this comment.
This PR took too long. Since the functionality is working, we should merge it after these required changes. I will refactor it if necessary in the future.
fuzz/command_util.py
Outdated
| ) | ||
|
|
||
| output_lines: list[str] = [] | ||
| start_time = time.time() |
There was a problem hiding this comment.
Please use the timeout command in Shell directly, see
Line 46 in c594f6c
fuzz/command_util.py
Outdated
| Logger for real-time printouts | ||
| Return: (Exit Code, Output Line List) | ||
| """ | ||
| process = subprocess.Popen( |
There was a problem hiding this comment.
You should return the Popen object directly, then use the parallel_subprocess to run them in parallel.
| with open(file_path, 'r') as f: | ||
| content = f.read() | ||
|
|
||
| # 正则表达式匹配TestOneInput或TestInput函数定义及其函数体 |
There was a problem hiding this comment.
Please use ast instead of regex.
|
the new script is collect_fuzz_python |
No description provided.