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

fix_bug_866 #27

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
2 changes: 1 addition & 1 deletion 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>2022.3.2</version>
<version>2022.3.3</version>
<name>Checkmarx plugin</name>
<description>Checkmarx plugin</description>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.checkmarx.sonar.sensor.dto;

import com.checkmarx.sonar.cxportalservice.osa.model.OsaScan;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down Expand Up @@ -30,7 +29,6 @@ public class SastReportData {
private String viewerUri;

public SastReportData() {
logger.info("SastReportData empty constructor");
}

public String getScanStart() {
Expand Down
41 changes: 21 additions & 20 deletions src/main/java/com/checkmarx/sonar/sensor/utils/CxConfigHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,17 @@ public CxScanConfig getScanConfig(CxFullCredentials cxFullCredentials, SensorCon
}

private String getPropertyValue(String responseJson) {
CxSensorSettings settings = null;
try {

CxSensorSettings settings = null;
try {
if (StringUtils.isNotEmpty(responseJson)) {
settings = objectMapper.readValue(responseJson, CxSensorSettings.class);
return settings.getFirstSettingValue();
}
}catch(Exception tryNextLogic) {
log.debug("Fail to retrieve property value using Json");
}
settings = objectMapper.readValue(responseJson, CxSensorSettings.class);
return settings.getFirstSettingValue();
}
} catch (Exception tryNextLogic) {
log.debug("Fail to retrieve property value using Json");
}

String value = null;
try {
int valueIdx = responseJson.indexOf(VALUE);
Expand All @@ -185,17 +185,18 @@ private String getPropertyValue(String responseJson) {
}
return value;
}

private ProjectDetails getProjectAndTeamDetails(String cxProject, CxFullCredentials cxFullCredentials) throws IOException {

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

log.info("Team name parsed from the projectName: "+teamName);
log.info("Team/Project path: " + cxProject);

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

ProjectDetails projectDetails = new ProjectDetails();
projectDetails.setTeamName(teamName);
projectDetails.setTeamId(getTeamId(teamName, cxFullCredentials));
projectDetails.setProjectName(cxProject.substring(cxProject.lastIndexOf("\\") + 1));
projectDetails.setProjectName(cxProject.substring(lastIndex + 1));
return projectDetails;
}

Expand Down Expand Up @@ -256,7 +257,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 @@ -288,8 +289,8 @@ private static String createStringFromResponse(org.apache.http.HttpResponse resp
while ((line = rd.readLine()) != null) {
result.append(line);
}


return result.toString();
}

Expand Down