Hello,
The SpotBugs plugin has been modified to remove (among other things) the usage of the deprecated org.sonar.api.profiles.ProfileDefinition
to make it compatible with SonarQube 9.
So for instance:
public class FindbugsSecurityJspProfile extends ProfileDefinition
Was changed to:
public class FindbugsSecurityJspProfile implements BuiltInQualityProfilesDefinition
The changes are here
Now we’ve got an error report from a user upgrading from SonarQube 7.9.5 (SpotBugs plugin 3.11.1) to 8.9.2 (plugin 4.0.4):
2021.09.10 08:31:38 INFO web[][o.s.s.q.RegisterQualityProfiles] Update profile jsp/FindBugs Security JSP
2021.09.10 08:31:38 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
org.sonar.server.exceptions.BadRequestException: java rule findsecbugs:XSS_JSP_PRINT cannot be activated on jsp profile FindBugs Security JSP
at org.sonar.server.exceptions.BadRequestException.create(BadRequestException.java:57)
at org.sonar.server.exceptions.BadRequestException.create(BadRequestException.java:61)
at org.sonar.server.exceptions.BadRequestException.checkRequest(BadRequestException.java:44)
at org.sonar.server.qualityprofile.RuleActivationContext.doSwitch(RuleActivationContext.java:227)
at org.sonar.server.qualityprofile.RuleActivationContext.reset(RuleActivationContext.java:208)
at org.sonar.server.qualityprofile.RuleActivator.activate(RuleActivator.java:76)
at org.sonar.server.qualityprofile.BuiltInQProfileUpdateImpl.update(BuiltInQProfileUpdateImpl.java:73)
at org.sonar.server.qualityprofile.RegisterQualityProfiles.update(RegisterQualityProfiles.java:132)
at org.sonar.server.qualityprofile.RegisterQualityProfiles.lambda$start$1(RegisterQualityProfiles.java:93)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:405)
at org.sonar.server.qualityprofile.RegisterQualityProfiles.start(RegisterQualityProfiles.java:88)
at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:40)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
at org.picocontainer.behaviors.Stored.start(Stored.java:110)
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)
at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:49)
at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:87)
at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:45)
at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:84)
at org.sonar.server.platform.PlatformImpl.executeStartupTasks(PlatformImpl.java:198)
at org.sonar.server.platform.PlatformImpl.access$400(PlatformImpl.java:46)
at org.sonar.server.platform.PlatformImpl$1.lambda$doRun$1(PlatformImpl.java:122)
at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.runIfNotAborted(PlatformImpl.java:370)
at org.sonar.server.platform.PlatformImpl$1.doRun(PlatformImpl.java:122)
at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.run(PlatformImpl.java:354)
at java.base/java.lang.Thread.run(Thread.java:834)
So if I understand correctly, at startup SonarQube reconciles the built-in profiles/rules saved in the database with the profiles/rules exposed by plugin. When processing the FindBugs Security JSP
profile it encounters a Java rule findsecbugs:XSS_JSP_PRINT
and throws an error because a Java rule cannot be part of a JSP profile.
What I don’t understand is findsecbugs:XSS_JSP_PRINT
should be in the findsecbugs-jsp
profile (not findsecbugs
) so how come it’s loading XSS_JSP_PRINT from the database with the wrong profile and language? I tried looking into the SonarQube source code and the incorrect profile and language seem to be loaded by UUID into a RuleDefinitionDto
There is a dash in the findsecbugs-jsp
profile key, could it be the issue?
The new version of the plugin seems to work on a fresh SQ 8.9 or SQ 9 install, the issue seems to be when upgrading.
Could someone please help us understand what is the problem here?
Side question: is there a way to simulate a server upgrade with Orchestrator?