Dataset Viewer
Auto-converted to Parquet
idx
int64
0
7.85k
idx_lca
int64
0
223
offset
int64
162
55k
repo
stringclasses
62 values
commit_hash
stringclasses
113 values
target_file
stringclasses
134 values
line_type_lca
stringclasses
7 values
ground_truth
stringlengths
1
46
in_completions
bool
1 class
completion_type
stringclasses
6 values
non_dunder_count_intellij
int64
0
529
non_dunder_count_jedi
int64
0
128
start_with_
bool
2 classes
first_occurrence
bool
2 classes
intellij_completions
listlengths
1
532
jedi_completions
listlengths
3
148
prefix
stringlengths
162
55k
0
0
1,007
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
AnalysisInterface
true
class
8
13
false
true
[ "List", "AnalysisInterface", "analysis_coverage_runtime_analysis", "logger", "Tuple", "get_all_analyses", "overlay_calltree_with_coverage", "Dict" ]
[ { "name": "abc", "type": "module" }, { "name": "analysis_coverage_runtime_analysis", "type": "function" }, { "name": "AnalysisInterface", "type": "class" }, { "name": "Dict", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_data_loader", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "get_all_analyses", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "overlay_calltree_with_coverage", "type": "function" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.
2
0
1,333
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
MergedProjectProfile
true
class
14
19
false
true
[ "FuzzerProfile", "List", "MergedProjectProfile", "logger", "None", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.
3
0
1,409
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
FuzzerProfile
true
class
14
19
false
true
[ "FuzzerProfile", "MergedProjectProfile", "List", "logger", "None", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.
4
0
1,758
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
FuzzerProfile
true
class
14
19
false
false
[ "FuzzerProfile", "MergedProjectProfile", "None", "Set", "List", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "logger", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.
5
0
2,009
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
extract_all_callsites
true
function
8
9
false
true
[ "extract_all_callsites", "CalltreeCallsite", "List", "logger", "Optional", "data_file_read_calltree", "extract_all_callsites_recursive", "print_ctcs_tree" ]
[ { "name": "CalltreeCallsite", "type": "class" }, { "name": "data_file_read_calltree", "type": "function" }, { "name": "extract_all_callsites", "type": "function" }, { "name": "extract_all_callsites_recursive", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "Optional", "type": "class" }, { "name": "print_ctcs_tree", "type": "function" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.
7
0
2,166
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
demangle_cpp_func
true
function
13
18
false
true
[ "List", "logger", "Optional", "demangle_cpp_func", "scan_executables_for_fuzz_introspector_logs", "data_file_read_yaml", "get_all_files_in_tree_with_regex", "get_target_coverage_url", "longest_common_prefix", "normalise_str", "safe_decode", "Any", "Dict" ]
[ { "name": "Any", "type": "class" }, { "name": "cxxfilt", "type": "module" }, { "name": "data_file_read_yaml", "type": "function" }, { "name": "demangle_cpp_func", "type": "function" }, { "name": "Dict", "type": "class" }, { "name": "get_all_files_in_tree_with_regex", "type": "function" }, { "name": "get_target_coverage_url", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "longest_common_prefix", "type": "function" }, { "name": "normalise_str", "type": "function" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "re", "type": "module" }, { "name": "safe_decode", "type": "function" }, { "name": "scan_executables_for_fuzz_introspector_logs", "type": "function" }, { "name": "yaml", "type": "module" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.
8
0
2,189
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
dst_function_name
true
statement
17
17
false
true
[ "depth", "cov_ct_idx", "cov_forward_reds", "cov_largest_blocked_func", "cov_link", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.
9
0
2,625
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_color
true
statement
17
17
false
true
[ "depth", "cov_link", "cov_ct_idx", "cov_callsite_link", "cov_forward_reds", "children", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.
10
0
2,668
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
random
cov_callsite_link
true
statement
17
17
false
true
[ "cov_link", "depth", "cov_color", "cov_ct_idx", "cov_callsite_link", "children", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.
11
0
2,710
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_link
true
statement
17
17
false
true
[ "cov_callsite_link", "depth", "cov_color", "cov_ct_idx", "cov_forward_reds", "children", "cov_hitcount", "cov_largest_blocked_func", "cov_link", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.
12
0
2,749
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
create_str_node_ctx_idx
true
function
7
7
false
true
[ "create_str_node_ctx_idx", "get_fuzz_blockers", "name", "create_fuzz_blocker_table", "html_create_dedicated_calltree_file", "__init__", "analysis_func", "create_calltree", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.
13
0
2,782
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
cov_ct_idx
true
statement
17
17
false
true
[ "cov_ct_idx", "depth", "dst_function_name", "cov_forward_reds", "cov_link", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.
14
0
2,907
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
dst_function_source_file
true
statement
17
17
false
true
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_callsite_link", "children", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.
15
0
3,174
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
true
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_forward_reds", "children", "cov_callsite_link", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.
16
0
3,188
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_forward_reds", "children", "cov_callsite_link", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.
17
0
3,291
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_callsite_link", "children", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.
18
0
3,304
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_forward_reds", "children", "cov_callsite_link", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.
19
0
3,744
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_forward_reds", "children", "cov_callsite_link", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.
20
0
4,254
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_callsite_link", "children", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.
28
0
5,388
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
FuzzerProfile
true
class
14
19
false
false
[ "FuzzerProfile", "MergedProjectProfile", "None", "List", "logger", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.
29
0
5,761
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
html_get_header
true
function
9
9
false
true
[ "html_create_table_head", "html_table_add_row", "html_get_header", "html_get_navbar", "List", "html_add_header_with_link", "html_get_table_of_contents", "Any", "Tuple" ]
[ { "name": "Any", "type": "class" }, { "name": "html_add_header_with_link", "type": "function" }, { "name": "html_create_table_head", "type": "function" }, { "name": "html_get_header", "type": "function" }, { "name": "html_get_navbar", "type": "function" }, { "name": "html_get_table_of_contents", "type": "function" }, { "name": "html_table_add_row", "type": "function" }, { "name": "List", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.
31
0
6,077
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
get_fuzz_blockers
true
function
7
7
false
true
[ "get_fuzz_blockers", "create_fuzz_blocker_table", "name", "create_str_node_ctx_idx", "html_create_dedicated_calltree_file", "__init__", "analysis_func", "create_calltree", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.
32
0
6,201
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
create_fuzz_blocker_table
true
function
7
7
false
true
[ "get_fuzz_blockers", "name", "create_fuzz_blocker_table", "create_str_node_ctx_idx", "html_create_dedicated_calltree_file", "__init__", "analysis_func", "create_calltree", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.
33
0
6,814
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
create_str_node_ctx_idx
true
function
7
7
false
false
[ "get_fuzz_blockers", "name", "create_fuzz_blocker_table", "create_str_node_ctx_idx", "create_calltree", "__init__", "analysis_func", "html_create_dedicated_calltree_file", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.
34
0
6,847
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
cov_ct_idx
true
statement
17
17
false
false
[ "cov_ct_idx", "depth", "cov_forward_reds", "dst_function_name", "dst_function_source_file", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_link", "cov_parent", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.
35
0
7,754
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
FuzzerProfile
true
class
14
19
false
false
[ "FuzzerProfile", "MergedProjectProfile", "List", "None", "logger", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.
36
0
7,895
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
CalltreeCallsite
true
class
9
9
false
true
[ "extract_all_callsites", "List", "None", "logger", "Optional", "CalltreeCallsite", "data_file_read_calltree", "extract_all_callsites_recursive", "print_ctcs_tree" ]
[ { "name": "CalltreeCallsite", "type": "class" }, { "name": "data_file_read_calltree", "type": "function" }, { "name": "extract_all_callsites", "type": "function" }, { "name": "extract_all_callsites_recursive", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "Optional", "type": "class" }, { "name": "print_ctcs_tree", "type": "function" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.
37
0
8,028
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
extract_all_callsites
true
function
8
9
false
false
[ "extract_all_callsites", "CalltreeCallsite", "List", "logger", "extract_all_callsites_recursive", "data_file_read_calltree", "print_ctcs_tree", "Optional" ]
[ { "name": "CalltreeCallsite", "type": "class" }, { "name": "data_file_read_calltree", "type": "function" }, { "name": "extract_all_callsites", "type": "function" }, { "name": "extract_all_callsites_recursive", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "Optional", "type": "class" }, { "name": "print_ctcs_tree", "type": "function" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.
39
0
8,501
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_forward_reds
true
statement
17
17
false
true
[ "depth", "cov_ct_idx", "dst_function_source_file", "cov_forward_reds", "cov_callsite_link", "children", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_link", "cov_parent", "dst_function_name", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.
40
0
8,752
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
FuzzerProfile
true
class
14
19
false
false
[ "FuzzerProfile", "MergedProjectProfile", "logger", "List", "None", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.
End of preview. Expand in Data Studio
Downloads last month
7