-
Notifications
You must be signed in to change notification settings - Fork 179
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,13 +60,34 @@ def execute(self, result_history: list[Result]) -> Result: | |
f'{last_result.trial:02d}.fuzz_target') | ||
build_script_path = os.path.join(last_result.work_dirs.fuzz_targets, | ||
f'{last_result.trial:02d}.build_script') | ||
evaluator.create_ossfuzz_project(generated_oss_fuzz_project, | ||
generated_project_path = evaluator.create_ossfuzz_project(generated_oss_fuzz_project, | ||
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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
if fuzz_target_source_path and os.path.isfile(fuzz_target_source_path): | ||
with open(fuzz_target_source_path, 'r') as f: | ||
fuzz_target_source = f.read() | ||
else: | ||
fuzz_target_source = '' | ||
|
||
build_script_source_path = os.path.join(generated_project_path, f'{last_result.trial:02d}.build_script') | ||
|
||
if build_script_source_path and os.path.isfile(build_script_source_path): | ||
with open(build_script_source_path, 'r') as f: | ||
build_script_source = f.read() | ||
else: | ||
build_script_source = '' | ||
|
||
# log the fuzz target and build script's source code. | ||
self.logger.info('\nFuzz target source: \n%s\n', fuzz_target_source) | ||
self.logger.info('\nBuild script source: \n%s\n', build_script_source) | ||
|
||
# Try building and running the new target. | ||
|
||
# TODO: Log build failure. | ||
|
@@ -136,6 +157,12 @@ def execute(self, result_history: list[Result]) -> Result: | |
else: | ||
run_log_content = '' | ||
|
||
# Add fuzz_target_source and build_script_source to the report log. | ||
run_log_content = ( | ||
f'Fuzz target source:\n{fuzz_target_source}\n' | ||
f'Build script source:\n{build_script_source}\n' | ||
f'{run_log_content}') | ||
|
||
runresult = RunResult( | ||
benchmark=benchmark, | ||
trial=last_result.trial, | ||
|
There was a problem hiding this comment.
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.