|
11 | 11 | from scubalspy.scubalspy_config import ScubalspyConfig |
12 | 12 | from scubalspy.scubalspy_logger import ScubalspyLogger |
13 | 13 |
|
14 | | -from . import joern |
15 | 14 | from . import language as lang |
16 | | -from .call import Call |
17 | 15 | from .file import File |
18 | 16 | from .function import Function, FunctionDeclaration |
19 | 17 | from .parser import Parser |
@@ -98,26 +96,9 @@ def __init__( |
98 | 96 | path: str, |
99 | 97 | language: type[lang.Language], |
100 | 98 | enable_lsp: bool = True, |
101 | | - enable_joern: bool = False, |
102 | 99 | ): |
103 | 100 | self.path = path |
104 | 101 | self.language = language |
105 | | - if enable_joern: |
106 | | - if language == lang.C: |
107 | | - joern_language = joern.Language.C |
108 | | - elif language == lang.JAVA: |
109 | | - joern_language = joern.Language.JAVA |
110 | | - elif language == lang.PYTHON: |
111 | | - joern_language = joern.Language.PYTHON |
112 | | - elif language == lang.JAVASCRIPT: |
113 | | - joern_language = joern.Language.JAVASCRIPT |
114 | | - else: |
115 | | - raise ValueError("Joern unsupported language") |
116 | | - self.joern = joern.Joern( |
117 | | - path, |
118 | | - joern_language, |
119 | | - ) |
120 | | - self.joern.export_with_preprocess() |
121 | 102 | if enable_lsp: |
122 | 103 | self.start_lsp() |
123 | 104 |
|
@@ -160,13 +141,6 @@ def start_lsp(self): |
160 | 141 | atexit.register(os.remove, self.conf_file) |
161 | 142 | self.lsp.sync_start_server() |
162 | 143 |
|
163 | | - def close(self): |
164 | | - if "joern" in self.__dict__: |
165 | | - self.joern.close() |
166 | | - |
167 | | - def __exit__(self, exc_type, exc_value, traceback): |
168 | | - self.close() |
169 | | - |
170 | 144 | @property |
171 | 145 | def abspath(self) -> str: |
172 | 146 | """ |
@@ -289,69 +263,6 @@ def callgraph(self) -> nx.MultiDiGraph: |
289 | 263 | cg = self.__build_callgraph(entry) |
290 | 264 | return cg |
291 | 265 |
|
292 | | - @cached_property |
293 | | - def callgraph_joern(self) -> nx.MultiDiGraph: |
294 | | - if self.joern is None: |
295 | | - raise ValueError("Joern is not enabled for this project.") |
296 | | - joern_cg = self.joern.callgraph |
297 | | - cg = nx.MultiDiGraph() |
298 | | - for node in joern_cg.nodes: |
299 | | - if joern_cg.nodes[node]["NODE_TYPE"] != "METHOD": |
300 | | - continue |
301 | | - if joern_cg.nodes[node]["IS_EXTERNAL"] == "true": |
302 | | - continue |
303 | | - func = self.search_function( |
304 | | - joern_cg.nodes[node]["FILENAME"], |
305 | | - int(joern_cg.nodes[node]["LINE_NUMBER"]), |
306 | | - ) |
307 | | - if func is None: |
308 | | - continue |
309 | | - func.set_joernid(node) |
310 | | - cg.add_node( |
311 | | - func, |
312 | | - label=func.dot_text, |
313 | | - ) |
314 | | - for u, v, data in joern_cg.edges(data=True): |
315 | | - if joern_cg.nodes[u]["NODE_TYPE"] != "METHOD": |
316 | | - continue |
317 | | - if joern_cg.nodes[v]["NODE_TYPE"] != "METHOD": |
318 | | - continue |
319 | | - |
320 | | - # search by joern_id |
321 | | - src_func: Function | None = None |
322 | | - dst_func: Function | None = None |
323 | | - for node in cg.nodes: |
324 | | - if node.joern_id == u: |
325 | | - src_func = node |
326 | | - if node.joern_id == v: |
327 | | - dst_func = node |
328 | | - if src_func is None or dst_func is None: |
329 | | - continue |
330 | | - if src_func == dst_func: |
331 | | - continue |
332 | | - src_func.callees_joern.append( |
333 | | - Call( |
334 | | - src_func, |
335 | | - dst_func, |
336 | | - int(data["LINE_NUMBER"]), |
337 | | - int(data["COLUMN_NUMBER"]), |
338 | | - ) |
339 | | - ) |
340 | | - dst_func.callers_joern.append( |
341 | | - Call( |
342 | | - src_func, |
343 | | - dst_func, |
344 | | - int(data["LINE_NUMBER"]), |
345 | | - int(data["COLUMN_NUMBER"]), |
346 | | - ) |
347 | | - ) |
348 | | - cg.add_edge( |
349 | | - src_func, |
350 | | - dst_func, |
351 | | - **data, |
352 | | - ) |
353 | | - return cg |
354 | | - |
355 | 266 | def export_callgraph(self, output_path: str): |
356 | 267 | """ |
357 | 268 | Exports the call graph of the project to a DOT file. |
|
0 commit comments