Skip to content

Commit 06384d4

Browse files
committed
Ran black formatter
1 parent 9ed352f commit 06384d4

14 files changed

Lines changed: 48 additions & 47 deletions

src/agent/dfbscan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def start_scan_sequential(self) -> None:
544544
sink_values,
545545
call_statements,
546546
ret_values,
547-
non_locals=[]
547+
non_locals=[],
548548
)
549549

550550
# Invoke the intra-procedural data-flow analysis

src/llmtool/dfbscan/intra_dataflow_analyzer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(
1919
sink_values: List[Tuple[str, int]],
2020
call_statements: List[Tuple[str, int]],
2121
ret_values: List[Tuple[str, int]],
22-
non_locals: List[Tuple[str, int]]
22+
non_locals: List[Tuple[str, int]],
2323
) -> None:
2424
self.function = function
2525
self.summary_start = summary_start
@@ -110,15 +110,15 @@ def _get_prompt(self, input: LLMToolInput) -> str:
110110
for ret_val in input.ret_values:
111111
rets_str += f"- {ret_val[0]} at line {ret_val[1]}\n"
112112
prompt = prompt.replace("<RETURN_VALUES>", rets_str)
113-
113+
114114
if input.non_locals:
115115
non_local_str = "Non local variables relevant to this function:\n"
116116
for non_local in input.non_locals:
117117
non_local_str += f"- {non_local[0]} at line {non_local[1]}\n"
118118
prompt = prompt.replace("<NONLOCAL_VALUES>", non_local_str)
119119
else:
120120
prompt = prompt.replace("<NONLOCAL_VALUES>", "")
121-
121+
122122
return prompt
123123

124124
def _parse_response(
@@ -236,7 +236,9 @@ def _parse_response(
236236
)
237237
elif detail["type"] == "Nonlocal":
238238
reachable_values_per_path.add(
239-
Value(detail["name"], line_number, ValueLabel.NONLOCAL, file_path)
239+
Value(
240+
detail["name"], line_number, ValueLabel.NONLOCAL, file_path
241+
)
240242
)
241243
reachable_values.append(reachable_values_per_path)
242244

src/tstool/analyzer/Cpp_TS_analyzer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class Cpp_TSAnalyzer(TSAnalyzer):
1515
TSAnalyzer for C/C++ source files using tree-sitter.
1616
Implements language-specific parsing and analysis.
1717
"""
18-
18+
1919
def extract_scope_info(self, tree: tree_sitter.Tree) -> None:
2020
"""
2121
Parse source code to extract scope topography.
2222
Currently Not implemented.
2323
:param tree: Parsed syntax tree
2424
"""
2525
pass
26-
26+
2727
def extract_nonlocal_info(self) -> None:
2828
"""
2929
Traverse the scopes to identify declarations of non locals.
@@ -431,7 +431,7 @@ def get_loop_statements(
431431
loop_body_end_line,
432432
)
433433
return loop_statements
434-
434+
435435
def get_global_expressions_by_identifier(
436436
self, identifier: str, program_root: Node
437437
) -> List[Node]:

src/tstool/analyzer/Go_TS_analyzer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class Go_TSAnalyzer(TSAnalyzer):
1515
TSAnalyzer for Go source files using tree-sitter.
1616
Implements Go-specific parsing and analysis.
1717
"""
18-
18+
1919
def extract_scope_info(self, tree: tree_sitter.Tree) -> None:
2020
"""
2121
Parse source code to extract scope topography.
2222
Currently Not implemented.
2323
:param tree: Parsed syntax tree
2424
"""
2525
pass
26-
26+
2727
def extract_nonlocal_info(self) -> None:
2828
"""
2929
Traverse the scopes to identify declarations of non locals.
@@ -375,4 +375,4 @@ def get_global_expressions_by_identifier(
375375
:param program_root: Program root node
376376
:return: A list of extracted nodes
377377
"""
378-
return []
378+
return []

src/tstool/analyzer/Java_TS_analyzer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class Java_TSAnalyzer(TSAnalyzer):
1515
TSAnalyzer for Java source files using tree-sitter.
1616
Implements Java-specific parsing and analysis.
1717
"""
18-
18+
1919
def extract_scope_info(self, tree: tree_sitter.Tree) -> None:
2020
"""
2121
Parse source code to extract scope topography.
2222
Currently Not implemented.
2323
:param tree: Parsed syntax tree
2424
"""
2525
pass
26-
26+
2727
def extract_nonlocal_info(self) -> None:
2828
"""
2929
Traverse the scopes to identify declarations of non locals.
@@ -387,4 +387,4 @@ def get_global_expressions_by_identifier(
387387
:param program_root: Program root node
388388
:return: A list of extracted nodes
389389
"""
390-
return []
390+
return []

src/tstool/analyzer/Javascript_TS_analyzer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ def extract_nonlocal_info(self) -> None:
161161
if (
162162
candidate_parent is not None
163163
and candidate_parent.type == "variable_declarator"
164-
and candidate_parent.child_by_field_name("name") is candidate_node
164+
and candidate_parent.child_by_field_name("name")
165+
is candidate_node
165166
):
166167
continue
167168

src/tstool/analyzer/Python_TS_analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class Python_TSAnalyzer(TSAnalyzer):
1515
TSAnalyzer for Python source files using tree-sitter.
1616
Implements Python-specific parsing and analysis.
1717
"""
18-
18+
1919
def extract_scope_info(self, tree: tree_sitter.Tree) -> None:
2020
"""
2121
Parse source code to extract scope topography
2222
:param tree: Parsed syntax tree
2323
"""
2424
# TODO: Add scope extraction if needed
2525
pass
26-
26+
2727
def extract_nonlocal_info(self) -> None:
2828
"""
2929
Traverse the scopes to identify declarations of non locals
@@ -294,7 +294,7 @@ def get_loop_statements(
294294
end_line,
295295
)
296296
return loops
297-
297+
298298
def get_global_expressions_by_identifier(
299299
self, identifier: str, program_root: Node
300300
) -> List[Node]:
@@ -305,4 +305,4 @@ def get_global_expressions_by_identifier(
305305
:return: A list of extracted nodes
306306
"""
307307
# TODO: implement if needed
308-
return []
308+
return []

src/tstool/analyzer/TS_analyzer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,16 @@ def __init__(
177177
self.globals_env: Dict[int, Value] = {}
178178
self.scope_env: Dict[int, Tuple[Node, Set[int]]] = {}
179179
self.api_env: Dict[int, API] = {}
180-
180+
181181
# Dictionary storing mapping from the root node of the scope to its scope id
182182
self.scope_root_to_scope_id: Dict[Node, int] = {}
183-
183+
184184
# Dictionary storing mapping from function root node to its scope id
185185
self.function_root_to_scope_id: Dict[Node, int] = {}
186-
186+
187187
# Dictionary storing mapping from a scope id to all the non locals it is depended on
188188
self.child_scope_id_to_non_locals: Dict[int, Set[Value]] = {}
189-
189+
190190
# Dictionary storing mapping from a non local value to its child scopes
191191
self.non_local_to_child_scopes: Dict[Value, Set[int]] = {}
192192

@@ -266,9 +266,9 @@ def parse_project(self) -> None:
266266
self.fileContentDic[file_path] = source
267267
pbar.update(1)
268268
pbar.close()
269-
269+
270270
self.extract_nonlocal_info()
271-
271+
272272
# Analyzes extracted functions
273273
with concurrent.futures.ThreadPoolExecutor(
274274
max_workers=self.max_symbolic_workers_num
@@ -288,7 +288,7 @@ def parse_project(self) -> None:
288288
self.function_env[func_id] = current_function
289289
pbar.update(1)
290290
pbar.close()
291-
291+
292292
# Analyzes extracted global variables
293293
pbar = tqdm(
294294
total=len(self.globalsRawDataDic), desc="Analyzing Global Variables"
@@ -343,14 +343,14 @@ def extract_scope_info(self, tree: tree_sitter.Tree) -> None:
343343
:param tree: Parsed syntax tree
344344
"""
345345
pass
346-
346+
347347
@abstractmethod
348348
def extract_nonlocal_info(self) -> None:
349349
"""
350350
Traverse the scopes to identify declarations of non locals
351351
"""
352352
pass
353-
353+
354354
@abstractmethod
355355
def extract_function_info(
356356
self, file_path: str, source_code: str, tree: Tree
@@ -730,7 +730,7 @@ def get_loop_statements(
730730
:return: A dictionary mapping (start_line, end_line) to loop statement info.
731731
"""
732732
pass
733-
733+
734734
@abstractmethod
735735
def get_global_expressions_by_identifier(
736736
self, identifier: str, program_root: Node
@@ -871,7 +871,7 @@ def get_function_global_value_reference(
871871
references.setdefault(function, []).append(ref_value)
872872

873873
return references
874-
874+
875875
def get_function_from_localvalue(self, value: Value) -> Optional[Function]:
876876
"""
877877
Retrieve the function corresponding to a local value.

src/tstool/dfbscan_extractor/Cpp/Cpp_MLK_extractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def is_global_source(self, global_declarator_node: Node) -> bool:
1010
Currently not implemented.
1111
"""
1212
return False
13-
13+
1414
def extract_sources(self, function: Function) -> List[Value]:
1515
"""
1616
Extract the sources that can cause the memory leak bugs from C/C++ programs.

src/tstool/dfbscan_extractor/Cpp/Cpp_UAF_extractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def is_global_source(self, global_declarator_node: Node) -> bool:
1212
Currently not implemented.
1313
"""
1414
return False
15-
15+
1616
def extract_sources(self, function: Function) -> List[Value]:
1717
"""
1818
Extract the sources that can cause the use-after-free bugs from C/C++ programs.

0 commit comments

Comments
 (0)