public void GetAnyNewFlawIds(ref MitigationWebhook webhook) { foreach (var app in webhook.Apps) { Console.WriteLine($"{DateTime.Now.ToLongTimeString()} : Checking {app.AppName} for new flaws"); var latestBuild = _veracodeRepository.GetAllBuildsForApp($"{app.AppId}") .OrderBy(x => x.Build_id).FirstOrDefault(); if (latestBuild == null || latestBuild.Build_id == app.LastBuild) { Console.WriteLine($"{DateTime.Now.ToLongTimeString()} : There are no new builds for {app.AppName} so no new flaws...Skipping"); continue; } var currentFlaws = new List <string>(); if (app.FlawString != null) { currentFlaws.AddRange(app.FlawString.Split(",").ToList()); } var newFlaws = _veracodeRepository.GetFlawIds(latestBuild.Build_id) .Where(f => !currentFlaws.Any(f2 => f2 == f)).ToList(); Console.WriteLine($"{DateTime.Now.ToLongTimeString()} : Adding {newFlaws.Count()} new flaws for {app.AppName}"); currentFlaws.AddRange(newFlaws); app.FlawString = String.Join(",", currentFlaws); Console.WriteLine($"{DateTime.Now.ToLongTimeString()} : Updating last build for {app.AppName} to {latestBuild.Build_id}"); app.LastBuild = latestBuild.Build_id; } }
public async Task <Tuple <string, string, int, MitigationWebhook, MitigationAction, App> > FireWebhook(MitigationWebhook webhook, MitigationAction mitigation, App app) { Console.WriteLine($"{DateTime.Now.ToLongTimeString()} : Preparing to fire {webhook.Name}"); var webhookMessage = SlackPayload(mitigation, app); var json = JsonConvert.SerializeObject(webhookMessage); Console.WriteLine($"{DateTime.Now.ToLongTimeString()} : {webhook.Name} Fire!"); var response = await _httpPostService.SendMessage(json, webhook.SendAddress); var content = await response.Content.ReadAsStringAsync(); Console.WriteLine($"{DateTime.Now.ToLongTimeString()} : {webhook.Name} webhook recieved HTTP Status {response.StatusCode}"); return(new Tuple <string, string, int, MitigationWebhook, MitigationAction, App>(json, content, (int)response.StatusCode, webhook, mitigation, app)); }