Skip to content

Commit 8be1ab3

Browse files
committed
analyser: Separate entrypoint for standalone analysis
Signed-off-by: Arthur Chan <[email protected]>
1 parent 24a4da0 commit 8be1ab3

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

src/fuzz_introspector/analyses/far_reach_low_coverage_analyser.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ def analysis_func(self,
9595
basefolder: str, coverage_url: str,
9696
conclusions: List[html_helpers.HTMLConclusion],
9797
out_dir: str) -> str:
98+
self.standalone_analysis(proj_profile, profiles, out_dir)
99+
return ''
100+
101+
def standalone_analysis(self,
102+
proj_profile: project_profile.MergedProjectProfile,
103+
profiles: List[fuzzer_profile.FuzzerProfile],
104+
out_dir: str) -> None:
105+
super().standalone_analysis(proj_profile, profiles, out_dir)
106+
98107
logger.info(' - Running analysis %s', self.get_name())
99108
logger.info(
100109
' - Settings: exclude_static_functions: %s, '
@@ -159,8 +168,6 @@ def analysis_func(self,
159168
with open(result_json_path, 'w') as f:
160169
json.dump(self.json_results, f)
161170

162-
return ''
163-
164171
def _get_cross_reference_dict(
165172
self, functions: List[function_profile.FunctionProfile]
166173
) -> Dict[str, int]:

src/fuzz_introspector/analyses/public_candidate_analyser.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ def analysis_func(self,
7575
basefolder: str, coverage_url: str,
7676
conclusions: List[html_helpers.HTMLConclusion],
7777
out_dir: str) -> str:
78+
self.standalone_analysis(proj_profile, profiles, out_dir)
79+
return ''
80+
81+
def standalone_analysis(self,
82+
proj_profile: project_profile.MergedProjectProfile,
83+
profiles: List[fuzzer_profile.FuzzerProfile],
84+
out_dir: str) -> None:
85+
super().standalone_analysis(proj_profile, profiles, out_dir)
86+
7887
logger.info(' - Running analysis %s', self.get_name())
7988

8089
# Get all functions from the profiles
@@ -99,8 +108,6 @@ def analysis_func(self,
99108
with open(result_json_path, 'w') as f:
100109
json.dump(result_list, f)
101110

102-
return ''
103-
104111
def _filter_functions(
105112
self, functions: list[function_profile.FunctionProfile]
106113
) -> list[function_profile.FunctionProfile]:

src/fuzz_introspector/analysis.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,23 @@ def analysis_func(self,
217217
html report.
218218
"""
219219

220+
def standalone_analysis(self,
221+
proj_profile: project_profile.MergedProjectProfile,
222+
profiles: List[fuzzer_profile.FuzzerProfile],
223+
out_dir: str) -> None:
224+
"""Second entrypoint for analysis instance which are meant to run
225+
alone without html or json report generation.
226+
:param proj_profile: project profile involved in the analysis.
227+
:type proj_profile: project_profile.MergedProjectProfile
228+
229+
:param profiles: all fuzzer profiles involved in the current analysis.
230+
:type profiles: List[fuzzer_profile.FuzzerProfile]
231+
232+
:param out_dir: Output directory of analysis report.
233+
:type out_dir: str
234+
"""
235+
self.set_display_html(False)
236+
220237
@classmethod
221238
@abc.abstractmethod
222239
def get_name(cls):

src/fuzz_introspector/commands.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from fuzz_introspector import analysis
2424
from fuzz_introspector import constants
2525
from fuzz_introspector import diff_report
26-
from fuzz_introspector import html_helpers
2726
from fuzz_introspector import html_report
2827
from fuzz_introspector import utils
2928

@@ -263,9 +262,7 @@ def analyse(args) -> int:
263262
target_analyser.set_introspection_project(introspection_proj)
264263

265264
# Run the analyser
266-
target_analyser.analysis_func(html_helpers.HtmlTableOfContents(), [],
267-
introspection_proj.proj_profile,
268-
introspection_proj.profiles, '', '', [],
269-
out_dir)
265+
target_analyser.standalone_analysis(introspection_proj.proj_profile,
266+
introspection_proj.profiles, out_dir)
270267

271268
return constants.APP_EXIT_SUCCESS

0 commit comments

Comments
 (0)