Skip to content

Get and log the source code of the fuzz target and build script. #1065

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AmPaschal
Copy link
Collaborator

@AmPaschal AmPaschal commented May 19, 2025

This Pull Request modifies oss-fuzz-gen to retrieve and log the fuzz target and build script, used in each fuzzing cycle, in the experiment's final report.
This is to facilitate debugging and improve fuzzing transparency during fuzz target generation.

This commit also modifies the create_ossfuzz_project to return the path of the generated oss-fuzz project so it can read the files from the project.
Finally, this commit adds the retrieved sources to the report log.
fuzz_target_path, build_script_path)

status_path = os.path.join(last_result.work_dirs.status,
f'{last_result.trial:02}')
os.makedirs(status_path, exist_ok=True)

# Get the source code of the fuzz target and build script from the generated oss-fuzz projects.
fuzz_target_source_path = os.path.join(generated_project_path, f'{last_result.trial:02d}.fuzz_target')
Copy link
Collaborator Author

@AmPaschal AmPaschal May 19, 2025

Choose a reason for hiding this comment

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

I could have just reused the existing fuzz_target_path. However, I wanted to actually log the version of the fuzz_target in the generated_oss_fuzz project (in case it differed with the version produced in the last_result.work_dirs.fuzz_targets path and stored in the current fuzz_target_path variables).

I could revert and use fuzz_target_path directly if necessary.

@@ -280,7 +280,8 @@ def create_ossfuzz_project(self,
f'{self.benchmark.target_path}\n')

if not build_script_path or os.path.getsize(build_script_path) == 0:
return name
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I checked callers of this function to see if this returned name variable is being used. I didn't find any usage, hence believed it was safe to change it.

Copy link
Collaborator

@oliverchang oliverchang left a comment

Choose a reason for hiding this comment

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

hey @AmPaschal , thanks for this change! Can you please add some context / reasoning behind this change in the PR description?

@AmPaschal
Copy link
Collaborator Author

AmPaschal commented May 23, 2025

hey @AmPaschal , thanks for this change! Can you please add some context / reasoning behind this change in the PR description?

I have updated the PR description.

@AmPaschal AmPaschal requested review from jonathanmetzman and removed request for jonathanmetzman May 23, 2025 13:18
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