Skip to content

Commit 2943f18

Browse files
committed
fix: fix golang transitive code search test case 6
Signed-off-by: Zvi Grinberg <[email protected]>
1 parent 75a1116 commit 2943f18

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/vuln_analysis/utils/functions_parsers/golang_functions_parsers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,14 @@ def parse_all_type_struct_class_to_fields(self, types: list[Document]) -> dict[t
327327
next_struct = current_line_stripped.find("struct")
328328
if next_eol > - 1 and (next_struct == -1 or next_struct > next_eol):
329329
if not self.is_comment_line(current_line_stripped[:next_eol + 1]):
330-
331330
declaration_parts = current_line_stripped[:next_eol + 1].split()
331+
# If row inside block contains func, then it's a function type and need to parse it in a
332+
# special way.
333+
if current_line_stripped[:next_eol + 1].__contains__("func"):
334+
declaration_parts = current_line_stripped[:next_eol + 1].split("func")
335+
declaration_parts = [part.strip() for part in declaration_parts]
336+
if len(declaration_parts) == 2:
337+
declaration_parts[1] = f"func {declaration_parts[1]}"
332338
# ignore alias' "equals" notation
333339
if len(declaration_parts) == 3:
334340
[name, _, type_name] = declaration_parts

0 commit comments

Comments
 (0)