Esempio n. 1
0
        public ScanResults Scan(Stream blob, string blobName)
        {
            string url  = "http://" + hostIp + ":" + port + "/scan";
            var    form = CreateMultiPartForm(blob, blobName);

            log.LogInformation($"Posting request to {url}");
            var    response      = client.PostAsync(url, form).Result;
            string stringContent = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

            if (!response.IsSuccessStatusCode)
            {
                log.LogError($"Request Failed, {response.StatusCode}:{stringContent}");
                return(null);
            }
            log.LogInformation($"Request Success Status Code:{response.StatusCode}");
            var responseDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(stringContent);
            var scanResults        = new ScanResults(
                fileName: blobName,
                isThreat: Convert.ToBoolean(responseDictionary["isThreat"]),
                threatType: responseDictionary["ThreatType"]
                );

            return(scanResults);
        }
 public Remediation(ScanResults scanResults, ILogger log)
 {
     this.scanResults = scanResults;
     this.log         = log;
 }