public Analyze AnalyzeModel(WebResponseModel webResponse, Analyze analyzeModel) { analyzeModel = JsonConvert.DeserializeObject<Analyze>(webResponse.Payloay, JsonSerializerSettings); analyzeModel.Header = PopulateHeader(analyzeModel.Header, webResponse); analyzeModel.Wrapper = PopulateWrapper(analyzeModel.Wrapper, webResponse); if (analyzeModel.status == "ERROR") { analyzeModel.Errors.Add(new Error() { message = analyzeModel.statusMessage }); } return analyzeModel; }
public Analyze Analyze(string host, Publish publish, StartNew startNew, FromCache fromCache, int? maxHours, All all, IgnoreMismatch ignoreMismatch) { var analyzeModel = new Analyze(); // Checking host is valid before continuing if (!_urlValidation.IsValid(host)) { analyzeModel.HasErrorOccurred = true; analyzeModel.Errors.Add(new Error { message = "Host does not pass preflight validation. No Api call has been made." }); return analyzeModel; } // Building request model var requestModel = _requestModelFactory.NewAnalyzeRequestModel(ApiUrl, "analyze", host, publish.ToString().ToLower(), startNew.ToString().ToLower(), fromCache.ToString().ToLower(), maxHours, all.ToString().ToLower(), ignoreMismatch.ToString().ToLower()); try { var webResponse = _apiProvider.MakeGetRequest(requestModel); analyzeModel = _responsePopulation.AnalyzeModel(webResponse, analyzeModel); } catch (Exception ex) { analyzeModel.HasErrorOccurred = true; analyzeModel.Errors.Add(new Error { message = ex.ToString() }); } // Checking if errors have occoured either from ethier api or wrapper if (analyzeModel.Errors.Count != 0 && !analyzeModel.HasErrorOccurred) { analyzeModel.HasErrorOccurred = true; } return analyzeModel; }
/// <summary> /// Takes the result of the analysis and extracts the information to a new HostEntry. /// If the extraction fails, the same HostEntry as passed will be returned. /// Otherwise the fresh HostEntry gets returned. /// </summary> private HostEntry extractInfoFromAnalysis(Analyze a, HostEntry he) { HostEntry extracted = new HostEntry(he.URL.ToString(), he.Protocol.ToString()); try { extracted.SetIP(a.endpoints[0].ipAddress); extracted.SetRanking(a.endpoints[0].grade); extracted.SetFingerPrintCert(a.endpoints[0].Details.cert.sigAlg); extracted.SetExpirationDate(a.endpoints[0].Details.cert.notAfter); extracted.SetProtocolVersions(a.endpoints[0].Details.protocols); extracted.SetRC4(a.endpoints[0].Details.supportsRc4.ToString()); extracted.SetBeastVulnerarbility(a.endpoints[0].Details.vulnBeast); extracted.SetForwardSecrecy(a.endpoints[0].Details.forwardSecrecy); extracted.SetHeartbleedVulnerability(a.endpoints[0].Details.heartbleed); extracted.SetSignatureAlgorithm(a.endpoints[0].Details.cert.sigAlg); extracted.SetPoodleVulnerability(a.endpoints[0].Details.poodle, a.endpoints[0].Details.poodleTls); extracted.SetExtendedValidation(a.endpoints[0].Details.cert.validationType); extracted.SetOpenSSLCCSVulnerable(a.endpoints[0].Details.openSslCcs); extracted.SetHTTPServerSignature(a.endpoints[0].Details.serverSignature); extracted.SetServerHostName(a.endpoints[0].serverName); extracted.Set3DESPresence(check3DESCipherPresence(a.endpoints[0].Details.suites)); } catch (Exception ex) { Debug.WriteLine(ex); } return extracted; }
public static void Setup(TestContext testContext) { _host = ConfigurationManager.AppSettings.Get("EndpointHost"); _ssllService = new SSLLabsApiService(ConfigurationManager.AppSettings.Get("ApiUrl")); _analyze = _ssllService.AutomaticAnalyze(_host); }
/// <summary> /// This method adds further notes for the 'Recent outcome' list on the UI. /// </summary> private HostEntry addMetaNotes(Analyze a, HostEntry host) { try { host.AddDifference("General message", a.endpoints[0].statusMessage); host.AddDifference("Detailed message", a.endpoints[0].statusDetailsMessage); } catch (Exception) { host.AddDifference("Error", a.Errors[0].message); host.AddDifference("App", "This entry will be treated as unchanged."); } return host; }