Skip to content

feat: Python OSS-Fuzz build and fuzz scripts#20

Merged
joyguoguo merged 78 commits intomainfrom
python-branch
Aug 7, 2025
Merged

feat: Python OSS-Fuzz build and fuzz scripts#20
joyguoguo merged 78 commits intomainfrom
python-branch

Conversation

@joyguoguo
Copy link
Contributor

No description provided.

@joyguoguo joyguoguo requested a review from EYH0602 July 22, 2025 20:29
Copy link
Member

@EYH0602 EYH0602 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will read through run_fuzz_target.py after the meeting.


# --- Global configuration ---
HOME_DIR = Path.home()
OSS_FUZZ_DIR = HOME_DIR / "FuzzAug" / "fuzz" / "oss-fuzz"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@EYH0602 EYH0602 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For run_fuzz_target.py, we should first collect all fuzz targets, then run each fuzz target in one process. Please see collect_fuzz.py in the same directory for example.

print(f"❌ Critical logging setup error: {e}")
sys.exit(1)

def run_command(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is repeated, just import from the other file.

async_results = []
for p in projects:
try:
async_results.append(pool.apply_async(run_project, (p, args.timeout)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why async?

import shutil
from datetime import datetime
from pathlib import Path
from typing import List, Optional, Tuple
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@joyguoguo joyguoguo requested a review from EYH0602 July 29, 2025 01:13
Copy link
Member

@EYH0602 EYH0602 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

)

output_lines: list[str] = []
start_time = time.time()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the timeout command in Shell directly, see

f"timeout {timeout} cargo fuzz run {target_name}",
.

Logger for real-time printouts
Return: (Exit Code, Output Line List)
"""
process = subprocess.Popen(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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函数定义及其函数体
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use ast instead of regex.

@joyguoguo joyguoguo requested a review from EYH0602 August 5, 2025 07:16
@joyguoguo
Copy link
Contributor Author

the new script is collect_fuzz_python

@EYH0602 EYH0602 changed the title Python branch - Modify the logging method feat: Python OSS-Fuzz build and fuzz scripts Aug 5, 2025
@joyguoguo joyguoguo merged commit 3d686dd into main Aug 7, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants