Closed Tiaguituh05 closed 2 months ago
Hi,
Thank you so much for the detailed issue report.
Based on the log messages, it appears that your custom plugin may be missing the "Plugin-RequiredForLanguages" entry in the jar manifest.
For Maven-built plugins, the sonar-packaging-maven-plugin version 1.23.0.740 is required with the requiredForLanguages
configuration, as shown in this example:
The equivalent configuration for Gradle can be found here:
Please check if this property is defined on your plugin.
For context, I tested the plsql-custom-rules example locally and here's the output:
INFO Load/download plugins (done) | time=32ms
DEBUG Plugins not loaded because they are optional: [csharp, myrules, flex, go, web, javasymbolicexecution, java, javascript, kotlin, php, ruby, sonarscala, vbnet, plsqlopen]
DEBUG Plugins loaded:
DEBUG * Python Code Quality and Security 4.19.0.15616 (python)
DEBUG * Clean as You Code 2.3.0.1782 (cayc)
DEBUG * XML Code Quality and Security 2.10.0.4108 (xml)
DEBUG * JaCoCo 1.3.0.1538 (jacoco)
DEBUG * IaC Code Quality and Security 1.31.0.10579 (iac)
DEBUG * Text Code Quality and Security 2.12.1.2905 (text)
Initially, SonarScanner did not load the "myrules" or "plsqlopen" plugins. They were loaded after language detection:
DEBUG Detected languages: [plsqlopen]
INFO Load/download plugins
INFO Load/download plugins (done) | time=5ms
DEBUG Optional language-specific plugins not loaded: [csharp, flex, go, web, javasymbolicexecution, java, javascript, kotlin, php, ruby, sonarscala, vbnet]
DEBUG Plugins loaded:
DEBUG * Company PL/SQL Rules 1.0-SNAPSHOT (myrules)
DEBUG * Z PL/SQL Analyzer 3.4.0 (plsqlopen)
Hi Felipe,
Thank you so much for the quick response. I've tried your suggestion and it worked!! It is funny, I've cloned your repo just 2 or 3 days ago, and I didn't see that line on build.gradle.kts. Was that added recently?
May I enjoy asking If I can have multiple custom rules on the same plugin? Or will I have to build a plugin for each?
Would you have some steps to guide me on how to do so on the same?
Thank you once again!
Was that added recently?
No, it was changed months ago. However, I've just realized that all the links in "Create a plugin with custom rules" directed to outdated examples. This may have caused the confusion, sorry!
May I enjoy asking If I can have multiple custom rules on the same plugin?
Yes, you can. Simply create new classes that extend PlSqlCheck and include them in the array of check classes in your "CustomPlSqlRulesDefinition":
Great! Glad I helped find the outdated link :)
Thanks for the quick explanation. I will give it a try!
One last question. This works fine on my local sonarqube on a docker running on v10.6. Will the custom plugin work on a v9.3.0?
No, it won't. The plugin requires SonarQube 9.9 or newer.
Thanks for confirming Felipe. You have been of great help!
Sorry for posting, when I've already placed this as closed, but something crossed my mind. Would it be possible to use zpa 3.5.1 and my custom plugin using zpa-cli, and then send the report to SonarQube v9.3?
Would it be possible to use zpa 3.5.1 and my custom plugin using zpa-cli, and then send the report to SonarQube v9.3?
I'm not sure, but I think it may work. Here are the steps you could follow:
path_to_zpa-cli.../bin/zpa-cli --sources . --output-file zpa-issues.json --output-format sq-generic-issue-import
. The log's first line should indicate that your plugin was loaded, for example: INFO : Plugin 'myrules@1.0-SNAPSHOT' loaded
.-Dsonar.externalIssuesReportPaths=zpa-issues.json
with SonarScanner.Awesome! I will first try to see if we can upgrade sonarqube as it seems by far the best option. If not, I will try this work around. Thanks!
Hi,
I've followed your guide on how to create the plugin with custom rules, to simply create a new rule that detects if any dml statments is missing a ";" at the end. The plugin works file with all the local tests I've made. The issue is when I place the jar file into the sonarqube extension and run the sonnar scanner, no issues are found, and it seems the plugin is not running.
I can see the plugin is installed, I've created a new quality profile, and activated my new rule. I've also made sure the project uses the new quality profile.
When enable debug on the sonar scanner, I can see some interesting things: 1- My plugin is loaded:
2- When sonar scanner pre-analyses the files, it dectect them as plsqlopen:
3- After detecting the language, it just seems to load the base ZPA plugin and not my own. Could the issue be here?
Any input is highly appreciated! Thank you!