joern icon indicating copy to clipboard operation
joern copied to clipboard

Multiple wildcard import

Open Arash444 opened this issue 8 months ago • 4 comments

Is your feature request related to a problem? Please describe. I'm writing an import optimization script for java programs, yet when I have more than one wildcard import in java (such as java.aws.*) it does not add any of the wildcard imports as import nodes. Based on the asteriskImportNodes function in javasrc2cpg's front-end, it seems like when there isn't only one wildcard import, it returns an empty sequence. This means that I do not have the full list of imports for my import optimization program, bringing it to a halt since optimizing wildcard imports is one of the most important aspects of it.

Describe the solution you'd like Apparently, previous iterations did returns a list of all wildcard imports. They were implemented in the scala front-end for java. Perhaps a return to that solution would be feasible.

Describe alternatives you've considered Technically you can guess the imports using the full names of various nodes such as methods, classes, and so on, but since I require the wildcard imports to give optimization suggestions, I can't really guess where the asterisks is being used in the import statement. For example, if I am using a function from jdk.jshell.execution.JdiExecutionControllerProvider, if I don't have access to the wildcard import statements, I won't know if the import statement the user wrote is jdk.jshell.execution.* or jdk.jshell.* thus meaning that I can't really "guess" it using only method' full name.

Additional context Here is a link to and a screenshot of asteriskImportNodes

https://github.com/joernio/joern/blob/a113c4850286ce6820e7914fa8bb1c67b1393231/joern-cli/frontends/javasrc2cpg/src/main/scala/io/joern/javasrc2cpg/astcreation/AstCreator.scala#L226

Image

Arash444 avatar Mar 31 '25 14:03 Arash444

@johannescoetzee a quick check in here as I encountered the same issue. Do you have any updates to share?

pwnslinger avatar May 05 '25 15:05 pwnslinger

Bumping this, I agree with things mentioned in the issue @johannescoetzee

ventusfortis avatar Sep 22 '25 16:09 ventusfortis

I somehow missed this issue, so thanks for the bump. These import nodes should indeed be added to the CPG

johannescoetzee avatar Sep 22 '25 16:09 johannescoetzee

Bumping again 🙏 Can you please look into it

ventusfortis avatar Nov 14 '25 07:11 ventusfortis