public virtual ActionResult GetScanResults(string apiKey, string id, string version, string sha256Checksum) { if (string.IsNullOrWhiteSpace(apiKey)) return new HttpStatusCodeWithBodyResult(HttpStatusCode.BadRequest, string.Format(CultureInfo.CurrentCulture, Strings.InvalidApiKey, apiKey)); if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(version)) { return new HttpStatusCodeWithBodyResult(HttpStatusCode.NotFound, string.Format(CultureInfo.CurrentCulture, Strings.PackageWithIdAndVersionNotFound, id, version)); } // if (string.IsNullOrWhiteSpace(sha256Checksum)) return new HttpStatusCodeWithBodyResult(HttpStatusCode.BadRequest, "Sha256Checksum is required."); if (settings.ScanResultsKey.to_lower() != apiKey.to_lower()) { return new HttpStatusCodeWithBodyResult(HttpStatusCode.Forbidden, "The specified key does not provide the authority to get scan results for packages"); } var scanResults = new List<PackageScanResult>(); var results = scanSvc.GetResults(id, version, sha256Checksum); foreach (var result in results.OrEmptyListIfNull()) { scanResults.Add(new PackageScanResult { FileName = result.FileName.to_string(), Sha256Checksum = result.Sha256Checksum.to_string(), Positives = result.Positives.to_string(), TotalScans = result.TotalScans.to_string(), ScanDetailsUrl = result.ScanDetailsUrl.to_string(), ScanData = result.ScanData.to_string(), ScanDate = result.ScanDate.GetValueOrDefault().ToString(CultureInfo.InvariantCulture), }); } return new JsonNetResult(scanResults.ToArray()); }