public ReportModel CreateReport(VulnerabilityScanRequest scanRequest)
        {
            var entity = _dataContext.Reports.Add(new ReportModel(scanRequest.Image)).Entity;

            _dataContext.SaveChanges();

            _jobClient
            .Enqueue <IClairScanner>(c => c.CreateReport(entity.Id));

            return(entity);
        }
        public void CreateReport(Guid reportId)
        {
            this.logger.LogInformation($"Starting to process {reportId}");

            var report = context.Reports.Single(x => x.Id == reportId);

            var result = shell.Run(_commandLineResolver.GetKlarCommand(imageName: report.Image));

            try
            {
                var asObject = JObject.Parse(result);

                report.Vulnerabilities = asObject["Vulnerabilities"]
                                         .SelectMany(x => x.Children()) // High, low, unknown ...
                                         .SelectMany(x => x.Children())
                                         .Select(x => x.ToObject <VulnerabilityModel>())
                                         .ToList();

                logger.LogInformation($"Processed {reportId}");

                report.Processed = true;

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                logger.LogError($"{ex} occurred during parsing report '{reportId}', output of klar was {result}");
                throw;
            }
        }