Skip to content

Commit

Permalink
analyses: optimal-targets: output to file
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <david@adalogics.com>
  • Loading branch information
DavidKorczynski committed Jan 17, 2025
1 parent fa0eb38 commit 49aceee
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/fuzz_introspector/analyses/optimal_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
"""Analysis for identifying optimal targets"""

import os
import copy
import json
import logging
Expand Down Expand Up @@ -166,10 +167,13 @@ def analysis_func(self,

# Create section for how the state of the project will be if
# the optimal target functions are hit.
html_string += self.get_consequential_section(new_profile, conclusions,
html_string += self.get_consequential_section(new_profile,
conclusions,
tables,
table_of_contents,
coverage_url, basefolder)
coverage_url,
basefolder,
out_dir=out_dir)

logger.info(f" - Completed analysis {self.get_name()}")
html_string += "</div>" # .collapsible
Expand Down Expand Up @@ -379,10 +383,14 @@ def create_top_summary_info(
return html_string

def get_consequential_section(
self, new_profile: project_profile.MergedProjectProfile,
conclusions: List[html_helpers.HTMLConclusion], tables: List[str],
self,
new_profile: project_profile.MergedProjectProfile,
conclusions: List[html_helpers.HTMLConclusion],
tables: List[str],
table_of_contents: html_helpers.HtmlTableOfContents,
coverage_url: str, basefolder: str) -> str:
coverage_url: str,
basefolder: str,
out_dir: str = '') -> str:
"""Create section showing state of project if optimal targets are hit"""
html_string = (
"<p>Implementing fuzzers that target the above functions "
Expand All @@ -406,8 +414,10 @@ def get_consequential_section(

# Write all functions to the .js file
if self.dump_files:
with open(constants.OPTIMAL_TARGETS_ALL_FUNCTIONS,
'w') as func_file:
with open(
os.path.join(out_dir,
constants.OPTIMAL_TARGETS_ALL_FUNCTIONS),
'w') as func_file:
func_file.write("var analysis_1_data = ")
func_file.write(json.dumps(all_functions_json))
return html_string

0 comments on commit 49aceee

Please sign in to comment.