whitesource / unified-agent-distribution

51 stars 48 forks source link

Java/Gradle semantic analysis does not fail when gradle error is encountered #52

Open MaciejDobrowolski opened 4 months ago

MaciejDobrowolski commented 4 months ago

When scanner hits a jar file compiled against newer version of Java, it just throws an exception and continues as regular:

[INFO] [2024-02-23 19:30:50,803 +0000] - Trying to resolve GRADLE dependencies
[INFO] [2024-02-23 19:30:53,893 +0000] - topFolder = /workspace/cloned-git-repository
[WARN] [2024-02-23 19:31:08,657 +0000] - Command - executeProcess - error in execute command '/workspace/cloned-git-repository/gradlew --init-script /tmp/blablabla/init.ws.gradle whitesourceDependenciesTask -DWS_INIT_GRADLE_OUTPUT_PATH=/tmp/blablabla/gradle_XNAMTL/20240223193053/gradle_dependencies -Dorg.gradle.parallel= -DWS_INIT_GRADLE_INCLUDE_DEPENDENCIES=true', Exit Status 1
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #1: FAILURE: Build failed with an exception.
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #2: * Where:
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #3: Initialization script '/tmp/blablabla/gradle_XNAMTL/20240223193053/init.ws.gradle'
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #4: * What went wrong:
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #5: Could not compile initialization script '/tmp/blablabla/gradle_XNAMTL/20240223193053/init.ws.gradle'.
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #6: > startup failed:
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #7:   General error during semantic analysis: Unsupported class file major version 61
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #8:   java.lang.IllegalArgumentException: Unsupported class file major version 61
[WARN] [2024-02-23 19:31:08,658 +0000] - Read error line #9:    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
...
------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------- WhiteSource Scan Summary: --------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
======================================================================================================================================================
Scan Origin: Local File System
======================================================================================================================================================
Step                                              Completion Status               Elapsed                  Comments
======================================================================================================================================================
Fetch Configuration                                  COMPLETED                  00:00:00.391               --------
Pre-Step And Resolve Dependencies                    COMPLETED                  00:02:07.832               8 total dependencies (3 unique)
   MAVEN                                             COMPLETED                  00:00:28.334               0 dependencies
   GRADLE                                            **COMPLETED**                  00:01:38.458               0 dependencies
....

Is this a correct behavior? The scan reports 0 gradle dependencies found/scanned and just continues, while it could abort the analysis and report the offending class name

Of course we can see this in logs, but we don't usually look there if the scanner says it's fine