{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader."}}},{"rowIdx":26,"cells":{"idx":{"kind":"number","value":36,"string":"36"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":7895,"string":"7,895"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"CalltreeCallsite"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"class"},"non_dunder_count_intellij":{"kind":"number","value":9,"string":"9"},"non_dunder_count_jedi":{"kind":"number","value":9,"string":"9"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["extract_all_callsites","List","None","logger","Optional","CalltreeCallsite","data_file_read_calltree","extract_all_callsites_recursive","print_ctcs_tree"],"string":"[\n \"extract_all_callsites\",\n \"List\",\n \"None\",\n \"logger\",\n \"Optional\",\n \"CalltreeCallsite\",\n \"data_file_read_calltree\",\n \"extract_all_callsites_recursive\",\n \"print_ctcs_tree\"\n]"},"jedi_completions":{"kind":"list like","value":[{"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"}],"string":"[\n {\n \"name\": \"CalltreeCallsite\",\n \"type\": \"class\"\n },\n {\n \"name\": \"data_file_read_calltree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"extract_all_callsites\",\n \"type\": \"function\"\n },\n {\n \"name\": \"extract_all_callsites_recursive\",\n \"type\": \"function\"\n },\n {\n \"name\": \"List\",\n \"type\": \"class\"\n },\n {\n \"name\": \"logger\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"logging\",\n \"type\": \"module\"\n },\n {\n \"name\": \"Optional\",\n \"type\": \"class\"\n },\n {\n \"name\": \"print_ctcs_tree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__file__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__name__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__package__\",\n \"type\": \"instance\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"
\" # To close \"calltree-line-wrapper\"\n closing_divs = \"
\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"
\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load."}}},{"rowIdx":27,"cells":{"idx":{"kind":"number","value":37,"string":"37"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":8028,"string":"8,028"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"extract_all_callsites"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":8,"string":"8"},"non_dunder_count_jedi":{"kind":"number","value":9,"string":"9"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["extract_all_callsites","CalltreeCallsite","List","logger","extract_all_callsites_recursive","data_file_read_calltree","print_ctcs_tree","Optional"],"string":"[\n \"extract_all_callsites\",\n \"CalltreeCallsite\",\n \"List\",\n \"logger\",\n \"extract_all_callsites_recursive\",\n \"data_file_read_calltree\",\n \"print_ctcs_tree\",\n \"Optional\"\n]"},"jedi_completions":{"kind":"list like","value":[{"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"}],"string":"[\n {\n \"name\": \"CalltreeCallsite\",\n \"type\": \"class\"\n },\n {\n \"name\": \"data_file_read_calltree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"extract_all_callsites\",\n \"type\": \"function\"\n },\n {\n \"name\": \"extract_all_callsites_recursive\",\n \"type\": \"function\"\n },\n {\n \"name\": \"List\",\n \"type\": \"class\"\n },\n {\n \"name\": \"logger\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"logging\",\n \"type\": \"module\"\n },\n {\n \"name\": \"Optional\",\n \"type\": \"class\"\n },\n {\n \"name\": \"print_ctcs_tree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__file__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__name__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__package__\",\n \"type\": \"instance\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load."}}},{"rowIdx":28,"cells":{"idx":{"kind":"number","value":39,"string":"39"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":8501,"string":"8,501"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"cov_forward_reds"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":17,"string":"17"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["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__"],"string":"[\n \"depth\",\n \"cov_ct_idx\",\n \"dst_function_source_file\",\n \"cov_forward_reds\",\n \"cov_callsite_link\",\n \"children\",\n \"cov_color\",\n \"cov_hitcount\",\n \"cov_largest_blocked_func\",\n \"cov_link\",\n \"cov_parent\",\n \"dst_function_name\",\n \"hitcount\",\n \"parent_calltree_callsite\",\n \"src_function_name\",\n \"src_function_source_file\",\n \"src_linenumber\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"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"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_callsite_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_color\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_ct_idx\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_forward_reds\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_largest_blocked_func\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_parent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"depth\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"parent_calltree_callsite\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_linenumber\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node."}}},{"rowIdx":29,"cells":{"idx":{"kind":"number","value":40,"string":"40"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":8752,"string":"8,752"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"FuzzerProfile"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"class"},"non_dunder_count_intellij":{"kind":"number","value":14,"string":"14"},"non_dunder_count_jedi":{"kind":"number","value":19,"string":"19"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["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"],"string":"[\n \"FuzzerProfile\",\n \"MergedProjectProfile\",\n \"logger\",\n \"List\",\n \"None\",\n \"add_func_to_reached_and_clone\",\n \"FunctionProfile\",\n \"load_all_profiles\",\n \"read_fuzzer_data_file_to_profile\",\n \"Any\",\n \"Dict\",\n \"Optional\",\n \"Set\",\n \"Tuple\"\n]"},"jedi_completions":{"kind":"list like","value":[{"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"}],"string":"[\n {\n \"name\": \"add_func_to_reached_and_clone\",\n \"type\": \"function\"\n },\n {\n \"name\": \"Any\",\n \"type\": \"class\"\n },\n {\n \"name\": \"copy\",\n \"type\": \"module\"\n },\n {\n \"name\": \"Dict\",\n \"type\": \"class\"\n },\n {\n \"name\": \"FunctionProfile\",\n \"type\": \"class\"\n },\n {\n \"name\": \"fuzz_cfg_load\",\n \"type\": \"module\"\n },\n {\n \"name\": \"fuzz_cov_load\",\n \"type\": \"module\"\n },\n {\n \"name\": \"fuzz_utils\",\n \"type\": \"module\"\n },\n {\n \"name\": \"FuzzerProfile\",\n \"type\": \"class\"\n },\n {\n \"name\": \"List\",\n \"type\": \"class\"\n },\n {\n \"name\": \"load_all_profiles\",\n \"type\": \"function\"\n },\n {\n \"name\": \"logger\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"logging\",\n \"type\": \"module\"\n },\n {\n \"name\": \"MergedProjectProfile\",\n \"type\": \"class\"\n },\n {\n \"name\": \"Optional\",\n \"type\": \"class\"\n },\n {\n \"name\": \"os\",\n \"type\": \"module\"\n },\n {\n \"name\": \"read_fuzzer_data_file_to_profile\",\n \"type\": \"function\"\n },\n {\n \"name\": \"Set\",\n \"type\": \"class\"\n },\n {\n \"name\": \"Tuple\",\n \"type\": \"class\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__file__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__name__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__package__\",\n \"type\": \"instance\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader."}}}],"truncated":true},"paginationData":{"pageIndex":0,"numItemsPerPage":100,"numTotalItems":5531,"offset":0,"length":100}},"jwt":"eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sImlhdCI6MTc1NzQ2NTk2Niwic3ViIjoiL2RhdGFzZXRzL0RhbkNpcC9sY2EtU3RhcnRpbmdQb2ludHMtZXhwYW5kZWQiLCJleHAiOjE3NTc0Njk1NjYsImlzcyI6Imh0dHBzOi8vaHVnZ2luZ2ZhY2UuY28ifQ.JgiHKsFS16Rw2hLdJUe7MQjM-aCKBRv7uLUcOwOgkuWlh3dPom_--W1ry8_RPkS9ESXlJj3Ez2biw8a8P3i9DA","displayUrls":true},"dataset":"DanCip/lca-StartingPoints-expanded","isGated":false,"isPrivate":false,"hasParquetFormat":true,"author":{"_id":"6554e2dcfcb10ad33d88dcea","avatarUrl":"https://aifasthub.com/avatars/v1/production/uploads/6554e2dcfcb10ad33d88dcea/V4WnB358ciZ0Ry3APDF57.png","fullname":"Daniele Cipollone","name":"DanCip","type":"user","isPro":false,"isHf":false,"isHfAdmin":false,"isMod":false,"followerCount":2},"compact":true}">
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

Full paper: https://arxiv.org/abs/2508.02455

Downloads last month
76
Size of downloaded dataset files:
8.55 MB
Size of the auto-converted Parquet files:
8.55 MB
Number of rows:
5,531