From 11de3fc2a1cba7235a3a89ec36c6ed8c2322b292 Mon Sep 17 00:00:00 2001 From: ic0ns Date: Fri, 6 Apr 2018 16:29:27 +0200 Subject: [PATCH] Changed error handling --- .../nds/siwecos/tls/TlsScannerCallback.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/rub/nds/siwecos/tls/TlsScannerCallback.java b/src/main/java/de/rub/nds/siwecos/tls/TlsScannerCallback.java index 8233f66..4210d36 100644 --- a/src/main/java/de/rub/nds/siwecos/tls/TlsScannerCallback.java +++ b/src/main/java/de/rub/nds/siwecos/tls/TlsScannerCallback.java @@ -30,7 +30,6 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; -import java.nio.charset.Charset; import java.text.DateFormat; import java.util.Date; import java.util.LinkedList; @@ -110,9 +109,13 @@ public void answer(ScanResult result) { } public ScanResult reportToScanResult(SiteReport report) { + if (!report.getServerIsAlive()) { + return new ScanResult("TLS", true, getHttpsResponse(report), 0, new LinkedList()); + } + if (!report.getSupportsSslTls()) { + return new ScanResult("TLS", true, getHttpsSupported(report), 0, new LinkedList()); + } List resultList = new LinkedList<>(); - resultList.add(getHttpsResponse(report)); - resultList.add(getHttpsSupported(report)); if (report.getProbeTypeList().contains(ProbeType.CERTIFICATE)) { resultList.add(getCertificateExpired(report)); resultList.add(getCertificateNotValidYet(report)); @@ -205,20 +208,13 @@ public ScanResult reportToScanResult(SiteReport report) { return result; } - private TestResult getHttpsResponse(SiteReport report) { - List messageList = new LinkedList<>(); - messageList.add(new TranslateableMessage("HTTPS_RESPONSE", new ValuePair("HOST", report.getHost()))); - return new TestResult("HTTPS_NO_RESPONSE", report.getServerIsAlive() == null, null, - report.getServerIsAlive() == Boolean.TRUE ? 100 : 0, - report.getServerIsAlive() == Boolean.TRUE ? "hidden" : "warning", messageList); + private TranslateableMessage getHttpsResponse(SiteReport report) { + return new TranslateableMessage("HTTPS_RESPONSE", new ValuePair("HOST", report.getHost())); + } - private TestResult getHttpsSupported(SiteReport report) { - List messageList = new LinkedList<>(); - messageList.add(new TranslateableMessage("HTTPS_SUPPORTED", new ValuePair("HOST", report.getHost()))); - return new TestResult("HTTPS_NOT_SUPPORTED", report.getSupportsSslTls() == null, null, - report.getSupportsSslTls() == Boolean.TRUE ? 100 : 0, - report.getSupportsSslTls() == Boolean.TRUE ? "hidden" : "fatal", messageList); + private TranslateableMessage getHttpsSupported(SiteReport report) { + return new TranslateableMessage("HTTPS_SUPPORTED", new ValuePair("HOST", report.getHost())); } private TestResult getCertificateExpired(SiteReport report) {