Esempio n. 1
0
        public Dashboard Get(string chartSet, int engagementId)
        {
            var dashboard = new Dashboard();

            if (_engagementService.Get(engagementId) == null)
            {
                return(dashboard);
            }

            var engagement = _engagementRepository.Get(engagementId);
            var customer   = _customerRepository.Get(engagement.CustomerId);

            var latestImportId      = _importRepository.GetLatest(engagementId)?.Id;
            var penultimateImportId = _importRepository.GetPenultimate(engagementId)?.Id;

            MapEngagement(engagement, dashboard);
            MapCustomer(customer, dashboard);

            if (chartSet == "dashboard")
            {
                var phaseEntities = _phaseRepository.GetByEngagementId(engagementId).ToList();
                var riskEntities  = _riskRepository.GetByEngagementId(engagementId).ToList();

                MapRiskGauge(engagement, dashboard);
                MapMitigationSummaryVulnsByRisk(riskEntities, dashboard);
                MapMitigationSummaryRisksByPhase(phaseEntities, dashboard);
                MapMitigationSummaryRisksAndVulns(engagementId, riskEntities, phaseEntities, dashboard);
            }

            else if (chartSet == "compliance")
            {
                foreach (var complianceScheme in _complianceSchemeRepository.GetByEngagementId(engagementId))
                {
                    var complianceEntities = _complianceRepository.GetByEngagementId(engagementId, complianceScheme.Id).ToList();

                    MapComplianceByGapReview(complianceEntities, complianceScheme, dashboard);
                    MapComplianceByMaturityLevel(complianceEntities, complianceScheme, dashboard);
                }
            }

            else if (chartSet == "governance")
            {
                var governanceControlEntities = _governanceControlRepository.GetByEngagementId(engagementId).ToList();

                MapGovernanceControlsByRiskLevel(governanceControlEntities, dashboard);
                MapGovernanceControlsByMaturityLevel(governanceControlEntities, dashboard);
            }

            else if (chartSet == "risk")
            {
                var riskEntities = _riskRepository.GetByEngagementId(engagementId).ToList();

                MapRiskByImpact(riskEntities, dashboard);
                MapRiskByLikelihood(riskEntities, dashboard);
                MapRiskByScore(riskEntities, dashboard);
                MapRiskByPhase(riskEntities, dashboard);
                MapTopRiskByScore(riskEntities, dashboard);
            }

            else if (chartSet == "host")
            {
                var hostEntities = _hostRepository.GetByEngagementId(engagementId).ToList();

                MapHostsByOperatingSystem(hostEntities, dashboard);
            }

            else if (chartSet == "vulnerability")
            {
                var vulnerabilityEntities = _vulnerabilityRepository.GetByEngagementId(engagementId).ToList();

                MapVulnerabilitiesBySeverity(vulnerabilityEntities, dashboard);
                MapVulnerabilitiesByCategory(vulnerabilityEntities, dashboard, latestImportId);
                MapVulnerabilities(vulnerabilityEntities, dashboard);
            }

            else if (chartSet == "risk")
            {
                var phaseEntities = _phaseRepository.GetByEngagementId(engagementId).ToList();

                MapRiskScoreByPhase(phaseEntities, dashboard);
            }

            return(dashboard);
        }