-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
analysis: Change analysis interface to allow passing in properties
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
- Loading branch information
1 parent
fa0eb38
commit 2f54f67
Showing
7 changed files
with
164 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/fuzz_introspector/analyses/source_code_line_analyser.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Copyright 2025 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. | ||
"""Analysis plugin for introspection of the function on target line in target source file.""" | ||
|
||
import json | ||
import logging | ||
|
||
from bs4 import BeautifulSoup as bs | ||
|
||
from typing import (Any, List, Tuple, Dict, Optional) | ||
|
||
from fuzz_introspector import (analysis, code_coverage, constants, cfg_load, | ||
html_helpers, json_report, utils) | ||
|
||
from fuzz_introspector.datatypes import (project_profile, fuzzer_profile, | ||
function_profile) | ||
|
||
logger = logging.getLogger(name=__name__) | ||
|
||
|
||
class SourceCodeLineFunctionAnalyser(analysis.AnalysisInterface): | ||
name: str = 'SourceCodeLineFunctionAnalyser' | ||
|
||
def __init__(self): | ||
self.json_results: Dict[str, Any] = dict() | ||
self.json_string_result = '' | ||
|
||
@classmethod | ||
def get_name(cls): | ||
"""Return the analyser identifying name for processing. | ||
:return: The identifying name of this analyser | ||
:rtype: str | ||
""" | ||
return cls.name | ||
|
||
def get_json_string_result(self) -> str: | ||
"""Return the stored json string result. | ||
:return: The json string result processed and stored | ||
by this analyser | ||
:rtype: str | ||
""" | ||
if self.json_string_result: | ||
return self.json_string_result | ||
return json.dumps(self.json_results) | ||
|
||
def set_json_string_result(self, json_string): | ||
"""Store the result of this analyser as json string result | ||
for further processing in a later time. | ||
:param json_string: A json string variable storing the | ||
processing result of the analyser for future use | ||
:type json_string: str | ||
""" | ||
self.json_string_result = json_string | ||
|
||
def analysis_func(self, | ||
table_of_contents: html_helpers.HtmlTableOfContents, | ||
tables: List[str], | ||
proj_profile: project_profile.MergedProjectProfile, | ||
profiles: List[fuzzer_profile.FuzzerProfile], | ||
basefolder: str, coverage_url: str, | ||
conclusions: List[html_helpers.HTMLConclusion], | ||
out_dir) -> str: | ||
logger.info(f" - Running analysis {self.get_name()}") | ||
logger.info(self.properties) | ||
# Get all functions from the profiles | ||
all_functions = list(proj_profile.all_functions.values()) | ||
all_functions.extend(proj_profile.all_constructors.values()) | ||
|
||
# Generate a Source File to Function Profile map and store in JSON Result | ||
for function in all_functions: | ||
func_list = self.json_results.get(function.function_source_file, | ||
[]) | ||
func_list.append(function) | ||
self.json_results[function.function_source_file] = func_list | ||
|
||
return '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters