Skip to content

Commit 9cd80af

Browse files
end-to-end: enable agent-based build generation (#1027)
Sample way of running this: `oss-fuzz-generator -i input.txt -w workdir-7 -mr 5 -m gpt-4o -a -o david-out-3` Signed-off-by: David Korczynski <[email protected]>
1 parent ceb5b09 commit 9cd80af

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

experimental/end_to_end/cli.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def setup_workdirs(defined_dir):
6161
subprocess.check_call('git clone https://github.com/google/oss-fuzz oss-fuzz',
6262
shell=True,
6363
cwd=workdir)
64+
os.mkdir(os.path.join(workdir, 'oss-fuzz', 'venv'))
6465

6566
# Clone Fuzz Introspector
6667
subprocess.check_call('git clone https://github.com/ossf/fuzz-introspector',
@@ -214,7 +215,7 @@ def run_ofg_generation(projects_to_run, workdir, args):
214215
cmd.append('http://127.0.0.1:8080/api')
215216
cmd.append('-mr')
216217
cmd.append(str(args.max_round))
217-
if args.agent:
218+
if args.hg_agent:
218219
cmd.append('--agent')
219220

220221
environ = os.environ.copy()
@@ -443,13 +444,20 @@ def run_analysis(args):
443444

444445
oss_fuzz_dir = os.path.join(abs_workdir, 'oss-fuzz-1')
445446
target_repositories = runner.extract_target_repositories(args.input)
446-
runner.run_parallels(os.path.abspath(oss_fuzz_dir),
447-
target_repositories,
448-
args.model,
449-
'all',
450-
out_folder,
451-
parallel_jobs=args.build_jobs,
452-
max_timeout=args.build_timeout)
447+
if args.agent:
448+
# Prepare arguments used deeper in OFG core.
449+
# TODO(David) make this cleaner.
450+
args.oss_fuzz = oss_fuzz_dir
451+
args.work_dirs = 'work_dirs'
452+
runner.run_agent(target_repositories, args)
453+
else:
454+
runner.run_parallels(os.path.abspath(oss_fuzz_dir),
455+
target_repositories,
456+
args.model,
457+
'all',
458+
out_folder,
459+
parallel_jobs=args.build_jobs,
460+
max_timeout=args.build_timeout)
453461

454462
# Exit if only builds are required.
455463
if args.build_only:
@@ -487,6 +495,10 @@ def parse_commandline():
487495
'-a',
488496
help='Enable agent workflow',
489497
action='store_true')
498+
parser.add_argument('--hg-agent',
499+
'-ha',
500+
help='Enable agent harness generation',
501+
action='store_true')
490502
parser.add_argument('-gm',
491503
'--generate-benchmarks-max',
492504
help='Max targets to generate per benchmark heuristic.',

0 commit comments

Comments
 (0)