use of com.mercedesbenz.sechub.adapter.AdapterException in project sechub by mercedes-benz.
the class NessusAdapterV1 method resolvePolicyUIDByTitle.
String resolvePolicyUIDByTitle(String content, String searchedPolicyTitle, NessusAdapterContext context) throws AdapterException {
try {
ArrayNode templatesArray = context.json().fetch("templates", content).asArray();
for (Iterator<JsonNode> elements = templatesArray.elements(); elements.hasNext(); ) {
JsonNode node = elements.next();
String title = context.json().fetch("title", node).asText();
if (searchedPolicyTitle.equals(title)) {
return context.json().fetch("uuid", node).asText();
}
}
return null;
} catch (Exception e) {
// JSON errors are marked as adapter exceptions and all others too...
throw asAdapterException("Was not able to resolve policy uid", e, context);
}
}
use of com.mercedesbenz.sechub.adapter.AdapterException in project sechub by mercedes-benz.
the class CheckmarxAdapterV1 method execute.
@Override
public String execute(CheckmarxAdapterConfig config, AdapterRuntimeContext runtimeContext) throws AdapterException {
try {
assertNotInterrupted();
CheckmarxContext context = new CheckmarxContext(config, this, runtimeContext);
context.setFullScan(context.isNewProject() || config.isAlwaysFullScanEnabled());
CheckmarxOAuthSupport oauthSupport = new CheckmarxOAuthSupport();
oauthSupport.loginAndGetOAuthToken(context);
assertNotInterrupted();
/* ensure project and get project context */
CheckmarxProjectSupport projectSupport = new CheckmarxProjectSupport();
projectSupport.ensureProjectExists(context);
assertNotInterrupted();
handleUploadSourceCodeAndStartScan(oauthSupport, context);
assertNotInterrupted();
CheckmarxScanReportSupport scanReportSupport = new CheckmarxScanReportSupport();
scanReportSupport.startFetchReport(oauthSupport, context);
return context.getResult();
} catch (Exception e) {
throw asAdapterException("Was not able to perform scan!", e, config);
}
}
use of com.mercedesbenz.sechub.adapter.AdapterException in project sechub by mercedes-benz.
the class AssertProject method hasWhiteListEntries.
public AssertProject hasWhiteListEntries(String... expectedArray) {
String content = fetchProjectDetails();
List<String> found = new ArrayList<>();
ArrayNode whiteListArray;
try {
whiteListArray = JSONAdapterSupport.FOR_UNKNOWN_ADAPTER.fetch("whiteList", content).asArray();
for (JsonNode node : whiteListArray) {
found.add(node.asText());
}
} catch (AdapterException e) {
e.printStackTrace();
fail("adapter json failure:" + e.getMessage());
}
assertArrayEquals(expectedArray, found.toArray(new String[found.size()]));
return this;
}
use of com.mercedesbenz.sechub.adapter.AdapterException in project sechub by mercedes-benz.
the class TrustAllSupport method createTrustAllFactory.
public ClientHttpRequestFactory createTrustAllFactory() {
HttpClientBuilder clientBuilder = HttpClients.custom();
SSLContext sslContext = null;
if (config.isTrustAllCertificatesEnabled()) {
try {
sslContext = createTrustAllSSLContext(adapter);
} catch (AdapterException e) {
throw new IllegalStateException("Should not happen! See trace", e);
}
} else {
sslContext = SSLContexts.createSystemDefault();
}
if (config.isProxyDefined()) {
// proxy with socks not working with standard HTTPHost,
// clientBuilder.setProxy(..)
// So own approach necessary, details see
// https://stackoverflow.com/questions/22937983/how-to-use-socks-5-proxy-with-apache-http-client-4
Registry<ConnectionSocketFactory> reg = RegistryBuilder.<ConnectionSocketFactory>create().register("http", new SocksProxyConnectionSocketFactory()).register("https", new SocksProxySSLConnectionSocketFactory(sslContext)).build();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(reg, new FakeDnsResolver());
clientBuilder.setConnectionManager(cm);
} else {
clientBuilder.setSSLContext(sslContext);
clientBuilder.setSSLHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return /* NOSONAR - we know what we do here! */
true;
}
});
}
CloseableHttpClient httpClient = clientBuilder.build();
HttpComponentsClientHttpRequestFactory requestFactory2 = new HttpComponentsClientHttpRequestFactory();
requestFactory2.setHttpClient(httpClient);
return requestFactory2;
}
Aggregations