Skip to content

Commit

Permalink
#870: Update to SonarQube 10.4
Browse files Browse the repository at this point in the history
Updates to the latest Sonarqube minor version, including changes
to the Github decorator to handle changes in the JTW library method
signatures inherited from Sonarqube core, and test only changes to
the Class Loader code built into Sonarqube.
  • Loading branch information
GreyTeardrop authored and mc1arke committed Apr 8, 2024
1 parent 5e5ca50 commit 70d9afb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The Sonarqube base image. 'latest' if building locally, '8.5-community' if targeting a specific version
SONARQUBE_VERSION=10.3-community
SONARQUBE_VERSION=10.4-community

# The name of the Dockerfile to run. 'Dockerfile' is building locally, 'release.Dockerfile' if building the release image
DOCKERFILE=Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repositories {
}
}

def sonarqubeVersion = '10.3.0.82913'
def sonarqubeVersion = '10.4.0.87286'
def sonarqubeLibDir = "${projectDir}/sonarqube-lib"
def sonarLibraries = "${sonarqubeLibDir}/sonarqube-${sonarqubeVersion}/lib"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.github.mc1arke.sonarqube.plugin.almclient.github.v3.model.AppToken;
import com.github.mc1arke.sonarqube.plugin.almclient.github.v3.model.InstallationRepositories;
import com.github.mc1arke.sonarqube.plugin.almclient.github.v3.model.Repository;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.impl.DefaultJwtBuilder;
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
Expand Down Expand Up @@ -78,8 +78,8 @@ public RepositoryAuthenticationToken getInstallationToken(String apiUrl, String

Instant issued = clock.instant().minus(10, ChronoUnit.SECONDS);
Instant expiry = issued.plus(2, ChronoUnit.MINUTES);
String jwtToken = new DefaultJwtBuilder().setIssuedAt(Date.from(issued)).setExpiration(Date.from(expiry))
.claim("iss", appId).signWith(createPrivateKey(apiPrivateKey), SignatureAlgorithm.RS256).compact();
String jwtToken = new DefaultJwtBuilder().issuedAt(Date.from(issued)).expiration(Date.from(expiry))
.claim("iss", appId).signWith(createPrivateKey(apiPrivateKey), Jwts.SIG.RS256).compact();

Optional<RepositoryAuthenticationToken> repositoryAuthenticationToken = findTokenFromAppInstallationList(getV3Url(apiUrl) + "/app/installations", jwtToken, projectPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public void testClassloaderReturnedOnHappyPath() throws ReflectiveOperationExcep
public void testLoadClass() throws ClassNotFoundException, MalformedURLException {
ClassloaderBuilder builder = new ClassloaderBuilder();
builder.newClassloader("_api_", getClass().getClassLoader());
builder.setMask("_api_", new Mask().addInclusion("java/").addInclusion("org/sonar/api/"));
builder.setMask("_api_", Mask.builder().include("java/", "org/sonar/api/").build());

builder.newClassloader("_customPlugin");
builder.setParent("_customPlugin", "_api_", new Mask());
builder.setParent("_customPlugin", "_api_", Mask.ALL);
builder.setLoadingOrder("_customPlugin", ClassloaderBuilder.LoadingOrder.SELF_FIRST);

for (URL pluginUrl : findSonarqubePluginJars()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Michael Clarke
*/
public class ReflectiveElevatedClassLoaderFactoryTest {

private static final String TARGET_PLUGIN_CLASS = "org.sonar.plugins.java.JavaPlugin";
private static final String BUNDLED_PLUGINS_DIRECTORY = "lib/extensions";
private static final String SONARQUBE_LIB_DIRECTORY = "sonarqube-lib/";
Expand All @@ -54,10 +54,10 @@ public ExpectedException expectedException() {
public void testLoadClass() throws ClassNotFoundException, MalformedURLException {
ClassloaderBuilder builder = new ClassloaderBuilder();
builder.newClassloader("_api_", getClass().getClassLoader());
builder.setMask("_api_", new Mask().addInclusion("java/").addInclusion("org/sonar/api/"));
builder.setMask("_api_", Mask.builder().include("java/", "org/sonar/api/").build());

builder.newClassloader("_customPlugin");
builder.setParent("_customPlugin", "_api_", new Mask());
builder.setParent("_customPlugin", "_api_", Mask.ALL);
builder.setLoadingOrder("_customPlugin", ClassloaderBuilder.LoadingOrder.SELF_FIRST);

File[] sonarQubeDistributions = new File(SONARQUBE_LIB_DIRECTORY).listFiles();
Expand All @@ -84,10 +84,10 @@ public void testLoadClass() throws ClassNotFoundException, MalformedURLException
public void testLoadClassInvalidClassRealmKey() throws ClassNotFoundException, MalformedURLException {
ClassloaderBuilder builder = new ClassloaderBuilder();
builder.newClassloader("_xxx_", getClass().getClassLoader());
builder.setMask("_xxx_", new Mask().addInclusion("java/").addInclusion("org/sonar/api/"));
builder.setMask("_xxx_", Mask.builder().include("java/", "org/sonar/api/").build());

builder.newClassloader("_customPlugin");
builder.setParent("_customPlugin", "_xxx_", new Mask());
builder.setParent("_customPlugin", "_xxx_", Mask.ALL);
builder.setLoadingOrder("_customPlugin", ClassloaderBuilder.LoadingOrder.SELF_FIRST);

File[] sonarQubeDistributions = new File(SONARQUBE_LIB_DIRECTORY).listFiles();
Expand Down Expand Up @@ -115,7 +115,7 @@ public void testLoadClassInvalidClassRealmKey() throws ClassNotFoundException, M
public void testLoadClassNoParentRef() throws ClassNotFoundException, MalformedURLException {
ClassloaderBuilder builder = new ClassloaderBuilder();
builder.newClassloader("_xxx_", getClass().getClassLoader());
builder.setMask("_xxx_", new Mask());
builder.setMask("_xxx_", Mask.ALL);

File[] sonarQubeDistributions = new File(SONARQUBE_LIB_DIRECTORY).listFiles();

Expand All @@ -141,7 +141,7 @@ public void testLoadClassNoParentRef() throws ClassNotFoundException, MalformedU
public void testLoadClassInvalidApiClassloader() throws ClassNotFoundException, MalformedURLException {
ClassloaderBuilder builder = new ClassloaderBuilder();
builder.newClassloader("_customPlugin");
builder.setParent("_customPlugin", new URLClassLoader(new URL[0]), new Mask());
builder.setParent("_customPlugin", new URLClassLoader(new URL[0]), Mask.ALL);
builder.setLoadingOrder("_customPlugin", ClassloaderBuilder.LoadingOrder.SELF_FIRST);

File[] sonarQubeDistributions = new File(SONARQUBE_LIB_DIRECTORY).listFiles();
Expand Down

0 comments on commit 70d9afb

Please sign in to comment.