Skip to content

Commit e6754fc

Browse files
authored
[Go] Fix frontend output (#1886)
* [Go] Fix frontend output Signed-off-by: Arthur Chan <[email protected]> * Fix formatting Signed-off-by: Arthur Chan <[email protected]> --------- Signed-off-by: Arthur Chan <[email protected]>
1 parent 0e8eb62 commit e6754fc

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/fuzz_introspector/frontends/src/frontend_go.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,19 @@ def __init__(self, source_code_files: list[str]):
175175
for item in src.functions + src.methods
176176
]
177177

178-
def dump_module_logic(self, report_name: str):
178+
def dump_module_logic(self, report_name: str, entry_function: str = ''):
179179
"""Dumps the data for the module in full."""
180180
logger.info('Dumping project-wide logic.')
181181
report = {'report': 'name'}
182182
report['sources'] = []
183183

184+
# Log entry function if provided
185+
if entry_function:
186+
report['Fuzzing method'] = entry_function
187+
184188
# Find all functions
185189
function_list = []
186190
for source_code in self.source_code_files:
187-
188191
report['sources'].append({
189192
'source_file':
190193
source_code.source_file,

src/fuzz_introspector/frontends/src/oss_fuzz.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,18 @@ def process_go_project(target_dir, out):
125125
# Create and dump project
126126
logger.info('Creating base project.')
127127
project = frontend_go.Project(source_codes)
128-
project.dump_module_logic(os.path.join(out, 'report.yaml'))
129128

130129
# Process calltree
131-
for idx, harness in enumerate(project.get_source_codes_with_harnesses()):
132-
logger.info('Extracting calltree for %s', harness.source_file)
130+
for harness in project.get_source_codes_with_harnesses():
131+
harness_name = harness.source_file.split('/')[-1].split('.')[0]
132+
logger.info(f'Dump functions/methods for {harness_name}')
133+
target = os.path.join(out, f'fuzzerLogFile-{harness_name}.data.yaml')
134+
project.dump_module_logic(target, harness.get_entry_function_name())
135+
136+
logger.info(f'Extracting calltree for {harness_name}')
133137
calltree = project.extract_calltree(harness.source_file, harness)
134-
with open(os.path.join(out, f'fuzzer-calltree-{idx}'),
135-
'w',
136-
encoding='utf-8') as f:
138+
target = os.path.join(out, f'fuzzerLogFile-{harness_name}.data')
139+
with open(target, 'w', encoding='utf-8') as f:
137140
f.write(calltree)
138141

139142

0 commit comments

Comments
 (0)