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

Revert "August integration branch" #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 3 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>checkmarx.com</groupId>
<artifactId>com.checkmarx.sonar.cxplugin</artifactId>
<packaging>sonar-plugin</packaging>
<version>2023.3.4</version>
<version>2022.3.2</version>
<name>Checkmarx plugin</name>
<description>Checkmarx plugin</description>

Expand Down Expand Up @@ -173,7 +173,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
<version>20210307</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.sun.xml.ws</groupId>-->
Expand Down Expand Up @@ -241,7 +241,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.4.2</version>
<version>2.13.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
Expand Down Expand Up @@ -331,10 +331,6 @@
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand All @@ -348,11 +344,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>1.8.0-beta2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.8.0</version>
</dependency>
</dependencies>

Expand Down
30 changes: 11 additions & 19 deletions src/main/java/com/checkmarx/sonar/sensor/utils/CxConfigHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class CxConfigHelper {
public static final String SONAR_PROJECT_KEY = "sonar.projectKey";
public static final String SONAR_LOGIN_KEY = "sonar.login";
public static final String SONAR_PASSWORD_KEY = "sonar.password";
public static final String SONAR_TOKEN_KEY = "sonar.token";

private static final String VALUE = "value";

Expand Down Expand Up @@ -186,18 +185,17 @@ private String getPropertyValue(String responseJson) {
}
return value;
}

private ProjectDetails getProjectAndTeamDetails(String cxProject, CxFullCredentials cxFullCredentials) throws IOException {
log.info("Team/Project path: " + cxProject);

int lastIndex = Math.max(cxProject.lastIndexOf("\\"), cxProject.lastIndexOf("/"));
String teamName = cxProject.substring(1, lastIndex);
teamName = "/" + teamName;


String teamName = cxProject.substring(cxProject.indexOf("\\") + 1, cxProject.lastIndexOf("\\"));
teamName = "/" + teamName ;

log.info("Team name parsed from the projectName: "+teamName);
ProjectDetails projectDetails = new ProjectDetails();
projectDetails.setTeamName(teamName);
projectDetails.setTeamId(getTeamId(teamName, cxFullCredentials));
projectDetails.setProjectName(cxProject.substring(lastIndex + 1));
projectDetails.setProjectName(cxProject.substring(cxProject.lastIndexOf("\\") + 1));
return projectDetails;
}

Expand Down Expand Up @@ -230,13 +228,7 @@ private String getSonarPropertyHttp(String propertyName, Configuration config) {
String token;
String user;
String pass;
//adding below condition for new versions of sonarqube including 10.1
if (config.get(SONAR_TOKEN_KEY).isPresent()) {
log.info("sonar.token present");
token = config.get(SONAR_TOKEN_KEY).get();
auth = token + ":";
auth = new String(Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)));
}else if (config.get(SONAR_LOGIN_KEY).isPresent() &&
if (config.get(SONAR_LOGIN_KEY).isPresent() &&
!config.get(SONAR_PASSWORD_KEY).isPresent()) {
token = config.get(SONAR_LOGIN_KEY).get();
auth = token + ":";
Expand Down Expand Up @@ -264,7 +256,7 @@ private String getSonarPropertyHttp(String propertyName, Configuration config) {
}
return "";
} catch (IOException e) {
log.warn("Error occured while retrieving property value for property: " + propertyName);
log.warn("Error occured while retrieving property value for property: "+propertyName);
return null;
} finally {
if (response != null) {
Expand Down Expand Up @@ -296,8 +288,8 @@ private static String createStringFromResponse(org.apache.http.HttpResponse resp
while ((line = rd.readLine()) != null) {
result.append(line);
}


return result.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,7 @@ private HttpResponse getResponse(HttpUriRequest request) throws IOException {
private void addAuthHeaders(HttpUriRequest request, CookieStore cookieStore) {
try {
if (sensorContext != null) {
if (sensorContext.config().get(CxConfigHelper.SONAR_TOKEN_KEY).isPresent()) {
logger.info("Sonar server token is provided in sonar.token");
String auth = sensorContext.config().get(CxConfigHelper.SONAR_TOKEN_KEY).get() + ":";
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
String authHeader = "Basic " + new String(encodedAuth);
request.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
}else if (sensorContext.config().get(CxConfigHelper.SONAR_LOGIN_KEY).isPresent() &&
if (sensorContext.config().get(CxConfigHelper.SONAR_LOGIN_KEY).isPresent() &&
!sensorContext.config().get(CxConfigHelper.SONAR_PASSWORD_KEY).isPresent()) {
logger.info("Sonar server token is provided");
String auth = sensorContext.config().get(CxConfigHelper.SONAR_LOGIN_KEY).get() + ":";
Expand Down
15 changes: 1 addition & 14 deletions src/main/resources/static/cx_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ window.registerExtension('checkmarx/cx_report', function (options) {

// let's create a flag telling if the static is still displayed
var isDisplayed = true;
//Setting analysis date to resolve continuous page refresh issue.
//It is observeed that until a sonar analysis is done for a project, all the pages keeps on reloading.
//By setting analysisDate for the project resolves the issue for checkmarx pages without having to run sonar scan on the project.
if(!options.component.analysisDate)
{
options.component.analysisDate = 'tempAnalysisDate';
}
var staticUrl = window.baseUrl +'/static/checkmarx';
var staticUrl = window.baseUrl +'/static/checkmarx';
var spanSpinner;

//-------------------------- sast vars --------------------------------------
Expand Down Expand Up @@ -1538,12 +1531,6 @@ window.registerExtension('checkmarx/cx_report', function (options) {


return function () {
//This is to reset value of analysisDate and reload the component and other pages will keep on refreshing as expected
if(options.component.analysisDate === 'tempAnalysisDate')
{
options.component.analysisDate = undefined;
location.reload();
}

// we unset the `isDisplayed` flag to ignore to Web API calls finished after the static is closed
isDisplayed = false;
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/static/fstdropdown.min.css

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/static/fstdropdown.min.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/resources/static/jquery-3.5.1.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/main/resources/static/jquery-3.7.1.min.js

This file was deleted.

Loading