Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SonarQube 10.4 compatibility fixes #873

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading