Skip to content
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

analyses: avoid dumping files if not asked for #2068

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self) -> None:
self.only_easy_fuzz_params = False
self.max_functions = 10
self.min_complexity = 0
self.dump_files = True

@classmethod
def get_name(cls):
Expand Down Expand Up @@ -179,11 +180,12 @@ def standalone_analysis(self,
function.function_name)))

self.json_results['functions'] = result_list
result_json_path = os.path.join(out_dir, 'result.json')
logger.info('Found %d function candidiates.', len(result_list))
logger.info('Dumping result to %s', result_json_path)
with open(result_json_path, 'w') as f:
json.dump(self.json_results, f)
if self.dump_files:
result_json_path = os.path.join(out_dir, 'result.json')
logger.info('Found %d function candidiates.', len(result_list))
logger.info('Dumping result to %s', result_json_path)
with open(result_json_path, 'w') as f:
json.dump(self.json_results, f)

def _get_cross_reference_dict(
self, functions: List[function_profile.FunctionProfile]
Expand Down
12 changes: 7 additions & 5 deletions src/fuzz_introspector/analyses/public_candidate_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class PublicCandidateAnalyser(analysis.AnalysisInterface):
def __init__(self) -> None:
self.json_results: Dict[str, Any] = {}
self.json_string_result = ''
self.dump_files = True

@classmethod
def get_name(cls):
Expand Down Expand Up @@ -102,11 +103,12 @@ def standalone_analysis(self,
for function in sorted_functions
]

result_json_path = os.path.join(out_dir, 'result.json')
logger.info('Found %d function candidiates.', len(result_list))
logger.info('Dumping result to %s', result_json_path)
with open(result_json_path, 'w') as f:
json.dump(result_list, f)
if self.dump_files:
result_json_path = os.path.join(out_dir, 'result.json')
logger.info('Found %d function candidiates.', len(result_list))
logger.info('Dumping result to %s', result_json_path)
with open(result_json_path, 'w') as f:
json.dump(result_list, f)

def _filter_functions(
self, functions: list[function_profile.FunctionProfile]
Expand Down
3 changes: 2 additions & 1 deletion src/fuzz_introspector/analyses/source_code_line_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self) -> None:
# Default value for standalone analysis
self.source_file = ''
self.source_line = -1
self.dump_files = True

@classmethod
def get_name(cls):
Expand Down Expand Up @@ -138,7 +139,7 @@ def standalone_analysis(self,
proj_profile.get_func_hit_percentage(
func.function_name)))

if result_list:
if result_list and self.dump_files:
self.json_results['functions'] = result_list
result_json_path = os.path.join(out_dir, 'functions.json')
logger.info('Dumping result to %s', result_json_path)
Expand Down
Loading