use of com.mercedesbenz.sechub.adapter.support.JSONAdapterSupport.Access in project sechub by mercedes-benz.
the class WaitForScanReportSupport method fetchScanDetails.
// https://checkmarx.atlassian.net/wiki/spaces/KC/pages/563806382/Get+Report+Status+by+Id+-+GET+reports+sastScan+id+status+v8.8.0+and+up
// https://checkmarx.atlassian.net/wiki/spaces/KC/pages/814121878/Swagger+Examples+v8.8.0+-+v1
private void fetchScanDetails(CheckmarxAdapterContext context) throws AdapterException {
oauthSupport.refreshBearerTokenWhenNecessary(context);
ReportDetails details = context.getReportDetails();
long reportId = context.getReportId();
try {
LOG.debug("Fetching scan report status for Checkmarx report Id: {}.", reportId);
RestOperations restTemplate = context.getRestOperations();
ResponseEntity<String> queueData = restTemplate.getForEntity(context.getAPIURL("reports/sastScan/" + reportId + "/status"), String.class);
String body = queueData.getBody();
Access status = context.json().fetch("status", body);
String value = status.fetch("value").asText();
details.status = value;
LOG.debug("Report status: {}. Checkmarx report Id: {}.", details.status, reportId);
if (details.status.equalsIgnoreCase("failed")) {
LOG.warn("Scan report status is: failed. Checkmarx report Id: {}.", reportId);
}
} catch (HttpStatusCodeException e) {
if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) {
/* ok just no longer in queue / or never existed */
details.notFound = true;
LOG.info("Unable to find Checkmarx report Id: {}. Possible reasons: no longer in queue or never existed.", reportId);
return;
}
// rethrow
throw e;
}
}
use of com.mercedesbenz.sechub.adapter.support.JSONAdapterSupport.Access in project sechub by mercedes-benz.
the class CheckmarxOAuthSupport method extractFromJson.
CheckmarxOAuthData extractFromJson(JSONAdapterSupport support, String json) throws AdapterException {
CheckmarxOAuthData data = new CheckmarxOAuthData();
Access rootNode = support.fetchRootNode(json);
data.accessToken = rootNode.fetch("access_token").asText();
data.tokenType = rootNode.fetch("token_type").asText();
data.expiresInSeconds = rootNode.fetch("expires_in").asLong();
return data;
}
use of com.mercedesbenz.sechub.adapter.support.JSONAdapterSupport.Access in project sechub by mercedes-benz.
the class CheckmarxProjectSupport method extractFirstProjectFromJsonWithProjectArray.
CheckmarxSessionData extractFirstProjectFromJsonWithProjectArray(JSONAdapterSupport support, String json) throws AdapterException {
CheckmarxSessionData data = new CheckmarxSessionData();
Access rootNode = support.fetchRootNode(json);
Access first = support.fetchArray(0, rootNode.asArray());
data.setProjectId(first.fetch("id").asLong());
data.setProjectName(first.fetch("name").asText());
return data;
}
use of com.mercedesbenz.sechub.adapter.support.JSONAdapterSupport.Access in project sechub by mercedes-benz.
the class CheckmarxProjectSupport method extractEngineConfigurationsFromGet.
protected List<CheckmarxEngineConfiguration> extractEngineConfigurationsFromGet(String json, JSONAdapterSupport support) throws AdapterException {
Access rootNode = support.fetchRootNode(json);
List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>();
for (JsonNode node : rootNode.asArray()) {
CheckmarxEngineConfiguration engineConfiguration = new CheckmarxEngineConfiguration();
engineConfiguration.setId(node.get("id").asLong());
engineConfiguration.setName(node.get("name").asText());
engineConfigurations.add(engineConfiguration);
}
return engineConfigurations;
}
use of com.mercedesbenz.sechub.adapter.support.JSONAdapterSupport.Access in project sechub by mercedes-benz.
the class CheckmarxProjectSupport method extractProjectFromJsonWithProjectCreationData.
CheckmarxSessionData extractProjectFromJsonWithProjectCreationData(String projectName, JSONAdapterSupport support, String json) throws AdapterException {
CheckmarxSessionData data = new CheckmarxSessionData();
Access rootNode = support.fetchRootNode(json);
data.setProjectId(rootNode.fetch("id").asLong());
data.setProjectName(projectName);
return data;
}
Aggregations