@@ -27,11 +27,27 @@ async def java_get_used_artefacts(
2727 code = file .read ()
2828 current_line = 1
2929 used_artefacts = await get_child_artefacts (import_names , code , cve_description , affected_artefacts , set ())
30+ inside_block_comment = False
3031 for line in code .split ("\n " ):
31- if "import" not in line :
32- for (artefact , _type , source ) in used_artefacts :
33- if artefact in line :
34- used_artefacts [(artefact , _type , source )].append (str (current_line ))
32+ stripped = line .strip ()
33+ if inside_block_comment :
34+ if "*/" in stripped :
35+ inside_block_comment = False
36+ current_line += 1
37+ continue
38+ if stripped .startswith ("/*" ):
39+ inside_block_comment = True
40+ current_line += 1
41+ continue
42+ if stripped .startswith ("//" ):
43+ current_line += 1
44+ continue
45+ if "import" in stripped :
46+ current_line += 1
47+ continue
48+ for (artefact , _type , source ) in used_artefacts :
49+ if artefact in line :
50+ used_artefacts [(artefact , _type , source )].append (str (current_line ))
3551 current_line += 1
3652 used_artefacts = {
3753 (artefact , _type , source ): lines
@@ -61,7 +77,9 @@ async def get_child_artefacts(
6177) -> dict [tuple [str , str , str ], list [str ]]:
6278 used_artefacts : dict [tuple [str , str , str ], list [str ]] = {}
6379 known_aliases : set [str ] = set ()
64- assignment_pattern = compile (r"(?:(?:[\w<>]+\s+)|this\.)?(\w+)\s*=\s*new\s+(\w+)\s*\(" )
80+ assignment_pattern = compile (
81+ r"(?:(?:[\w<>]+\s+)|this\.)?(\w+)\s*=\s*[\w\.]+\([^)]*\)"
82+ )
6583 for line in code .splitlines ():
6684 match = assignment_pattern .search (line )
6785 if match :
0 commit comments