Repository navigation
Conversation
|
Can't think of how this could be auto tested |
|
Added some minor comments. 🙇 Thank you. |
and do not have many test cases probably with mc/dc coverage testing, or at least some smoke tests... p.s: thanks for considering other comments To moke directly java API like ProcessHandle not sure how it is possible, maybe need to extract to a separate class and mock that class rather... :/ And in that case, it is just maybe too much hassle for unit tests, it's a decision. |
|
I think the interesting parts to tests would be:
-> Let's not spend time on auto testing this but let's react when/if somebody reports a problem |
| if (javaAgent.contains(":")) { | ||
| String binFolder = javaAgent.split(":")[1]; | ||
| Optional<File> bin = Stream.of("idea", "idea.sh", "idea.bat") | ||
| .map(binName -> new File(binFolder, binName)) |
There was a problem hiding this comment.
PATH_TRAVERSAL_IN: This API (java/io/File.(Ljava/lang/String;Ljava/lang/String;)V) reads a file whose location might be specified by user input
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
🛠 Lift Auto-fixSome of the Lift findings in this PR can be automatically fixed. You can download and apply these changes in your local project directory of your branch to review the suggestions before committing.1 # Download the patch
curl https://lift.sonatype.com/api/patch/github.com/vaadin/flow/15605.diff -o lift-autofixes.diff
# Apply the patch with git
git apply lift-autofixes.diff
# Review the changes
git diffWant it all in a single command? Open a terminal in your project's directory and copy and paste the following command: curl https://lift.sonatype.com/api/patch/github.com/vaadin/flow/15605.diff | git applyOnce you're satisfied commit and push your changes in your project. Footnotes |
|
Now there is at least one test for each |
|
Any more considerations @mcollovati ? |
| + lineNumber); | ||
| } else { | ||
| try { | ||
| run(cmd, "--line", lineNumber + "", absolutePath); |
There was a problem hiding this comment.
This does actually not work on my environment (IDEA on Linux)
It starts a jvm, but not IDEA
/home/marco/local/tools/idea/2021.3/jbr/bin/java --line 12 /home/marco/tmp/my-app-v24/src/main/java/com/example/application/views/helloworld/HelloWorldView.java
Using processInfo.commandLine() may work, but only if the command is short enough not to be truncated by the native call that gets process info
There was a problem hiding this comment.
Coding is hard yo.. Maybe now that it actually uses the binary it detects?
| int agentPos = commandAndArguments.toLowerCase(Locale.ENGLISH) | ||
| .indexOf("-javaagent:"); |
There was a problem hiding this comment.
-javaagent seems to be present only on the command line that runs the application, not in the one that launches the IDE
/home/marco/local/tools/idea/2021.3/jbr/bin/java -classpath /home/marco/local/tools/idea/2021.3/lib/util.jar:/home/marco/local/tools/idea/2021.3/lib/app.jar:/home/marco/local/tools/idea/2021.3/lib/3rd-party-rt.jar:/home/marco/local/tools/idea/2021.3/lib/platform-statistics-devkit.jar:/home/marco/local/tools/idea/2021.3/lib/jps-model.jar:/home/marco/local/tools/idea/2021.3/lib/stats.jar:/home/marco/local/tools/idea/2021.3/lib/protobuf.jar:/home/marco/local/tools/idea/2021.3/lib/external-system-rt.jar:/home/marco/local/tools/idea/2021.3/lib/forms_rt.jar:/home/marco/local/tools/idea/2021.3/lib/intellij-test-discovery.jar:/home/marco/local/tools/idea/2021.3/lib/annotations.jar:/home/marco/local/tools/idea/2021.3/lib/groovy.jar:/home/marco/local/tools/idea/2021.3/lib/3rd-party-native.jar:/home/marco/local/tools/idea/2021.3/lib/annotations-java5.jar:/home/marco/local/tools/idea/2021.3/lib/byte-buddy-agent.jar:/home/marco/local/tools/idea/2021.3/lib/error-prone-annotations.jar:/home/marco/local/tools/idea/2021.3/lib/externalProcess-rt.jar:/home/marco/local/tools/idea/2021.3/lib/idea_rt.jar:/home/marco/local/tools/idea/2021.3/lib/intellij-coverage-agent-1.0.682.jar:/home/marco/local/tools/idea/2021.3/lib/jsch-agent.jar:/home/marco/local/tools/idea/2021.3/lib/jsp-base.jar:/home/marco/local/tools/idea/2021.3/lib/junit.jar:/home/marco/local/tools/idea/2021.3/lib/junit4.jar:/home/marco/local/tools/idea/2021.3/lib/kotlin-script-runtime.jar:/home/marco/local/tools/idea/2021.3/lib/platform-duplicates-analysis.jar:/home/marco/local/tools/idea/2021.3/lib/platform-objectSerializer-annotations.jar:/home/marco/local/tools/idea/2021.3/lib/platform-structuralSearch.jar:/home/marco/local/tools/idea/2021.3/lib/rd.jar:/home/marco/local/tools/idea/2021.3/lib/tools-testsBootstrap.jar:/home/marco/local/tools/idea/2021.3/lib/util_rt.jar:/home/marco/local/tools/idea/2021.3/lib/xml-dom-impl.jar:/home/marco/local/tools/idea/2021.3/lib/xml-dom.jar:/home/marco/local/tools/idea/2021.3/lib/ant/lib/ant.jar -Xms128m -Xmx750m -XX:ReservedCodeCacheSize=512m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -XX:+IgnoreUnrecognizedVMOptions -XX:CompileCommand=exclude,com/intellij/openapi/vfs/impl/FilePartNodeRoot,trieDescend -ea -Dsun.io.useCanonCaches=false -Dsun.java2d.metal=true -Djbr.catch.SIGABRT=true -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off -Dsun.tools.attach.tmp.only=true -Xmx1985m -XX:ErrorFile=/home/marco/java_error_in_idea_%p.log -XX:HeapDumpPath=/home/marco/java_error_in_idea_.hprof -Djb.vmOptionsFile=/home/marco/.config/JetBrains/IdeaIC2022.3/idea64.vmoptions -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.vendor.name=JetBrains -Didea.paths.selector=IdeaIC2022.3 -Djna.boot.library.path=/home/marco/local/tools/idea/2021.3/lib/jna/amd64 -Dpty4j.preferred.native.folder=/home/marco/local/tools/idea/2021.3/lib/pty4j -Djna.nosys=true -Djna.nounpack=true -Didea.platform.prefix=Idea -Dsplash=true --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/jdk.internal.vm=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.fs=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED --add-opens=java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd.peer=ALL
What about checking for -Didea.vendor.name?
There was a problem hiding this comment.
Yes but that should not matter if we can get the idea location from the last part of the javaagent parameter. Does it still not work?
There was a problem hiding this comment.
What about checking for lib/idea_rt.jar and then search the idea script in ../bin?
There was a problem hiding this comment.
Yes but that should not matter if we can get the idea location from the last part of the javaagent parameter. Does it still not work?
On the inspected command line, javaagent is not present at all
There was a problem hiding this comment.
Are you saying there is something wrong with the ideaOnLinuxDetected test then because that one should be based exactly on your environment...
There was a problem hiding this comment.
I would go for idea_rt.jar
For example running on another project with no evident differences in Run configuration I get this for the javaagent param
-javaagent:/home/marco/local/tools/idea/2021.3/plugins/java/lib/rt/debugger-agent.jar=file:/tmp/capture.props
and the detection fails because of the file:/tmp/... part
There was a problem hiding this comment.
Changed once again. Does it work now? :)
There was a problem hiding this comment.
Can confirm it now works on my laptop! 🥳
There was a problem hiding this comment.
OMG. I am sure you will figure out how to break it tomorrow though
There was a problem hiding this comment.
I can perhaps try to install Eclipse... 😆
|
Kudos, SonarCloud Quality Gate passed!
|
| "bin"); | ||
| Optional<File> bin = Stream | ||
| .of("idea", "idea.sh", "idea.bat") | ||
| .map(binName -> new File(binFolder, binName)) |
There was a problem hiding this comment.
PATH_TRAVERSAL_IN: This API (java/io/File.(Ljava/io/File;Ljava/lang/String;)V) reads a file whose location might be specified by user input
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| .replaceFirst(".*[:;]([^:;]*)(idea_rt.jar).*", "$1$2"); | ||
| if (!replaced.equals(commandAndArguments)) { | ||
| System.out.println(replaced); | ||
| File binFolder = new File( |
There was a problem hiding this comment.
PATH_TRAVERSAL_IN: This API (java/io/File.(Ljava/lang/String;)V) reads a file whose location might be specified by user input
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
|
This ticket/PR has been released with Vaadin 24.0.0.alpha9 and is also targeting the upcoming stable 24.0.0 version. |








Supports Eclipse, IntelliJ and VS Code