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

Fix pylint #2100

Merged
merged 1 commit into from
Feb 17, 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
2 changes: 1 addition & 1 deletion src/fuzz_introspector/analyses/bug_digestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def analysis_func(self,
conclusions: List[html_helpers.HTMLConclusion],
out_dir) -> str:
"""Digests and creates HTML about bugs found by the fuzzers."""
logger.info(f" - Running analysis {self.get_name()}")
logger.info(' - Running analysis %s', self.get_name())
input_bugs = data_loader.try_load_input_bugs()
if len(input_bugs) == 0:
return ""
Expand Down
7 changes: 4 additions & 3 deletions src/fuzz_introspector/analyses/engine_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ def analysis_func(self,
"Fuzz engine guidance", html_helpers.HTML_HEADING.H1,
table_of_contents)
html_string += "<div class=\"collapsible\">"
html_string += "<p>This sections provides heuristics that can be used as input " \
"to a fuzz engine when running a given fuzz target. The current " \
"focus is on providing input that is usable by libFuzzer.</p>"
html_string += ("<p>This sections provides heuristics that can be used"
" as input to a fuzz engine when running a given fuzz "
"target. The current focus is on providing input that "
"is usable by libFuzzer.</p>")

for prof in profiles:
logger.info('Generating input for %s', prof.identifier)
Expand Down
55 changes: 32 additions & 23 deletions src/fuzz_introspector/analyses/optimal_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ def add_func_to_reached_and_clone(
# set complexity fields in the function
f_profile.new_unreached_complexity = uncovered_cc
if f_profile.hitcount == 0:
f_profile.new_unreached_complexity += f_profile.cyclomatic_complexity
f_profile.total_cyclomatic_complexity = cc + f_profile.cyclomatic_complexity
f_profile.new_unreached_complexity += (
f_profile.cyclomatic_complexity)
f_profile.total_cyclomatic_complexity = (
cc + f_profile.cyclomatic_complexity)

if merged_profile.all_functions[func_to_add.function_name].hitcount == 0:
logger.info("Error. Hitcount did not get set for some reason. Exiting")
Expand Down Expand Up @@ -153,7 +155,7 @@ def analysis_func(self,
*not hit* by any fuzzers. This means it can be used to expand the
current fuzzing harness rather than substitute it.
"""

# pylint: disable=unused-argument
logger.info('- Running analysis %s', self.get_name())

html_string = ""
Expand All @@ -162,8 +164,8 @@ def analysis_func(self,
table_of_contents)

# Create optimal target section
new_profile, optimal_target_functions = self.iteratively_get_optimal_targets(
proj_profile)
new_profile, optimal_target_functions = (
self.iteratively_get_optimal_targets(proj_profile))
html_string += self.get_optimal_target_section(
optimal_target_functions, table_of_contents, tables, coverage_url,
out_dir, profiles[0].target_lang)
Expand Down Expand Up @@ -226,7 +228,7 @@ def analysis_get_optimal_targets(
"""
logger.info(" - in analysis_get_optimal_targets")

target_fds: List[function_profile.FunctionProfile] = list()
target_fds: List[function_profile.FunctionProfile] = []
logger.info('Filtering optimal functions from %d functions',
len(merged_profile.all_functions.values()))
for fd in merged_profile.all_functions.values():
Expand All @@ -241,12 +243,12 @@ def iteratively_get_optimal_targets(
) -> Tuple[project_profile.MergedProjectProfile,
List[function_profile.FunctionProfile]]:
'''
Function for synthesizing fuzz targets. The way this one works is by finding
optimal targets that don't overlap too much with each other. The fuzz targets
are created to target functions in specific files, so all functions targeted
in each fuzzer will be from the same source file.
In a sense, this is more of a PoC wy to do some analysis on the data we have.
It is likely that we could do something much better.
Function for synthesizing fuzz targets. The way this one works is by
finding optimal targets that don't overlap too much with each other.
The fuzz targets are created to target functions in specific files,
so all functions targeted in each fuzzer will be from the same source
file. In a sense, this is more of a PoC wy to do some analysis on the
data we have. It is likely that we could do something much better.
'''
logger.info(" - in iteratively_get_optimal_targets")
new_merged_profile = copy.deepcopy(merged_profile)
Expand Down Expand Up @@ -302,14 +304,15 @@ def get_optimal_target_section(
coverage_url: str,
out_dir,
target_lang: str = 'c-cpp') -> str:
"""Create optimal taget section in html report."""
# Table with details about optimal target functions
html_string = html_helpers.html_add_header_with_link(
"Remaining optimal interesting functions",
html_helpers.HTML_HEADING.H3, table_of_contents)
html_string += "<p> The following table shows a list of functions that " \
"are optimal targets. Optimal targets are identified by " \
"finding the functions that in combination, yield a high " \
"code coverage. </p>"
html_string += ("<p> The following table shows a list of functions "
"that are optimal targets. Optimal targets are "
"identified by finding the functions that in "
"combination, yield a high code coverage. </p>")
table_id = "remaining_optimal_interesting_functions"
tables.append(table_id)
html_string += html_helpers.html_create_table_head(
Expand All @@ -327,10 +330,11 @@ def get_optimal_target_section(
fd.function_linenumber,
fd.function_name,
target_lang)
demangled = utils.demangle_cpp_func(fd.function_name)
demangled = utils.demangle_rust_func(demangled)
html_func_row = (
f"<a href=\"{ func_cov_url }\"><code class='language-clike'>"
f"{utils.demangle_rust_func(utils.demangle_cpp_func(fd.function_name))}"
f"</code></a>")
f"{demangled}</code></a>")
html_string += html_helpers.html_table_add_row([
html_func_row, fd.function_source_file, fd.arg_count,
fd.arg_types, fd.function_depth, fd.hitcount, fd.i_count,
Expand All @@ -340,7 +344,7 @@ def get_optimal_target_section(
fd.new_unreached_complexity
])

json_dict = list()
json_dict = []
for fd in optimal_target_functions:
json_dict.append({
'name':
Expand All @@ -367,6 +371,8 @@ def get_optimal_target_section(
def create_top_summary_info(
self, tables: List[str],
proj_profile: project_profile.MergedProjectProfile) -> str:
"""Create summary info in html report."""
# pylint: disable=unused-argument
html_string = ""

# Display reachability information
Expand Down Expand Up @@ -394,6 +400,7 @@ def get_consequential_section(
basefolder: str,
out_dir: str = '') -> str:
"""Create section showing state of project if optimal targets are hit"""
# pylint: disable=unused-argument
html_string = (
"<p>Implementing fuzzers that target the above functions "
"will improve reachability such that it becomes:</p>")
Expand All @@ -405,12 +412,14 @@ def get_consequential_section(
html_string += html_helpers.html_add_header_with_link(
"All functions overview", html_helpers.HTML_HEADING.H4,
table_of_contents)
html_string += "<p> If you implement fuzzers for these functions, the status of all " \
"functions in the project will be:</p>"
html_string += ("<p> If you implement fuzzers for these functions, the"
" status of all functions in the project will be:</p>")
table_id = "all_functions_overview_table"
tables.append(table_id)
all_function_table, all_functions_json, _ = html_report.create_all_function_table(
tables, new_profile, coverage_url, basefolder, table_id)
all_function_table, all_functions_json, _ = (
html_report.create_all_function_table(tables, new_profile,
coverage_url, basefolder,
table_id))
html_string += all_function_table
html_string += "</div>" # close report-box

Expand Down
4 changes: 2 additions & 2 deletions src/fuzz_introspector/analyses/public_candidate_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def get_json_string_result(self) -> str:
return self.json_string_result
return json.dumps(self.json_results)

def set_json_string_result(self, string):
def set_json_string_result(self, json_string):
"""Store the result of this analyser as json string result
for further processing in a later time.

:param json_string: A json string variable storing the
processing result of the analyser for future use
:type json_string: str
"""
self.json_string_result = string
self.json_string_result = json_string

def analysis_func(self,
table_of_contents: html_helpers.HtmlTableOfContents,
Expand Down
Loading