private bool getlastReport(XElement result, Dictionary <long, ReportStaging> end, Dictionary <long, List <ReportResultNew> > last) { foreach (long key in end.Keys) { ReportStaging staging = end[key]; if (result.Attribute("ScanId").Value == staging.ScanId.ToString()) { last.Add(staging.ProjectId, process_LastScan(result, staging.ScanId)); } } return(true); }
private bool findFirstorLastScan(long projectId, ScanObject scan, Dictionary <string, Teams> teams, Dictionary <long, ReportStaging> keyValuePairs, bool operation) { getScans scans = new getScans(); string fullName = teams[scan.OwningTeamId].fullName; if (keyValuePairs.ContainsKey(scan.Project.Id)) { bool start = false; ReportStaging reportStaging = keyValuePairs[scan.Project.Id]; long diff = DateTimeOffset.Compare(reportStaging.dateTime, (DateTimeOffset)scan.DateAndTime.StartedOn); if (operation) { start = (diff > 0) ? true : false; } else { start = (diff < 0) ? true : false; } if (start) { ScanStatistics scanStatistics = scans.getScansStatistics(scan.Id, token); ReportStaging staging = new ReportStaging() { ProjectId = scan.Project.Id, ProjectName = scan.Project.Name, TeamName = fullName, dateTime = (DateTimeOffset)scan.DateAndTime.StartedOn, High = scanStatistics.HighSeverity, Medium = scanStatistics.MediumSeverity, Low = scanStatistics.LowSeverity, ScanId = scan.Id }; keyValuePairs[scan.Project.Id] = staging; } } else { ScanStatistics scanStatistics = scans.getScansStatistics(scan.Id, token); keyValuePairs.Add(scan.Project.Id, new ReportStaging() { ProjectId = scan.Project.Id, ProjectName = scan.Project.Name, TeamName = fullName, dateTime = (DateTimeOffset)scan.DateAndTime.StartedOn, High = scanStatistics.HighSeverity, Medium = scanStatistics.MediumSeverity, Low = scanStatistics.LowSeverity, ScanId = scan.Id }); } return(true); }
private List <ReportOutput> totalScansandReports(Dictionary <long, ReportStaging> start, Dictionary <long, ReportStaging> end, List <ReportResultNew> resultNew, Dictionary <long, List <ReportResultNew> > lastScan, Dictionary <long, ScanCount> scanCount) { List <ReportOutput> reports = new List <ReportOutput>(); foreach (long key in start.Keys) { ReportOutput report = new ReportOutput(); ReportStaging first = start[key]; ReportStaging last = end[key]; List <ReportResultNew> lastScanResults = lastScan[key]; foreach (ReportResultNew result in resultNew) { if (result.projectId == first.ProjectId) { if (result.status == "New") { if (result.Severity == "High") { report.NewHigh++; } else if (result.Severity == "Medium") { report.NewMedium++; } else if (result.Severity == "Low") { report.NewLow++; } } } } foreach (ReportResultNew result in lastScanResults) { if (result.state == 0) { report.ToVerify++; } else if (result.state == 1) { report.NotExploitable++; } else if (result.state == 2) { report.Confirmed++; } } report.ProjectName = first.ProjectName; report.StartHigh = first.High; report.StartMedium = first.Medium; report.StartLow = first.Low; report.firstScan = first.dateTime; report.LastHigh = last.High; report.LastMedium = last.Medium; report.LastLow = last.Low; report.lastScan = last.dateTime; report.DiffHigh = first.High - last.High; report.DiffMedium = first.Medium - last.Medium; report.DiffLow = first.Low - last.Low; report.ScanCount = scanCount[key].count; reports.Add(report); } return(reports); }
private bool findFirstandLastScan(long projectId, ScanObject scan, ScanStatistics scanStatistics, Dictionary <long, ReportStaging> keyStartPairs, Dictionary <long, ReportStaging> keyLastPairs) { getScans scans = new getScans(); if (keyStartPairs.ContainsKey(scan.Project.Id)) { ReportStaging reportStaging = keyStartPairs[scan.Project.Id]; long diff = DateTimeOffset.Compare(reportStaging.dateTime, (DateTimeOffset)scan.DateAndTime.StartedOn); if (diff > 0) { ReportStaging staging = new ReportStaging() { ProjectId = scan.Project.Id, ProjectName = scan.Project.Name, dateTime = (DateTimeOffset)scan.DateAndTime.StartedOn, High = scanStatistics.HighSeverity, Medium = scanStatistics.MediumSeverity, Low = scanStatistics.LowSeverity, ScanId = scan.Id }; keyStartPairs[scan.Project.Id] = staging; } } else { keyStartPairs.Add(scan.Project.Id, new ReportStaging() { ProjectId = scan.Project.Id, ProjectName = scan.Project.Name, dateTime = (DateTimeOffset)scan.DateAndTime.StartedOn, High = scanStatistics.HighSeverity, Medium = scanStatistics.MediumSeverity, Low = scanStatistics.LowSeverity, ScanId = scan.Id }); } if (keyLastPairs.ContainsKey(scan.Project.Id)) { ReportStaging reportStaging = keyLastPairs[scan.Project.Id]; long diff = DateTimeOffset.Compare(reportStaging.dateTime, (DateTimeOffset)scan.DateAndTime.StartedOn); if (diff < 0) { ReportStaging staging = new ReportStaging() { ProjectId = scan.Project.Id, ProjectName = scan.Project.Name, dateTime = (DateTimeOffset)scan.DateAndTime.StartedOn, High = scanStatistics.HighSeverity, Medium = scanStatistics.MediumSeverity, Low = scanStatistics.LowSeverity, ScanId = scan.Id }; keyLastPairs[scan.Project.Id] = staging; } } else { keyLastPairs.Add(scan.Project.Id, new ReportStaging() { ProjectId = scan.Project.Id, ProjectName = scan.Project.Name, dateTime = (DateTimeOffset)scan.DateAndTime.StartedOn, High = scanStatistics.HighSeverity, Medium = scanStatistics.MediumSeverity, Low = scanStatistics.LowSeverity, ScanId = scan.Id }); } return(true); }
private List <ReportOutput> totalScansandReports(Dictionary <long, ReportStaging> start, Dictionary <long, ReportStaging> end, List <ReportResultAll> resultNew, Dictionary <long, List <ReportResultAll> > lastScan, Dictionary <long, ScanCount> scanCount) { List <ReportOutput> reports = new List <ReportOutput>(); getScans scans = new getScans(); foreach (long key in start.Keys) { ReportOutput report = new ReportOutput(); ReportStaging first = start[key]; ReportStaging last = end[key]; List <ReportResultAll> lastScanResults = lastScan[key]; foreach (ReportResultAll result in resultNew) { if (result.projectId == first.ProjectId) { if (result.status == "New") { if (result.Severity == "High") { report.NewHigh++; } else if (result.Severity == "Medium") { report.NewMedium++; } else if (result.Severity == "Low") { report.NewLow++; } } } } foreach (ReportResultAll result in lastScanResults) { if (result.state == 0) { report.ToVerify++; } else if (result.state == 1) { report.NotExploitable++; } else if (result.state == 2) { report.Confirmed++; } } //report.TeamName = first.TeamName; string[] split; if (first.TeamName.Contains('\\')) { split = first.TeamName.Split('\\'); } else { split = first.TeamName.Split('/'); } if (split.Length > 1) { report.company = split[split.Length - 2]; report.team = split[split.Length - 1]; } report.ProjectName = first.ProjectName; report.StartHigh = first.High; report.StartMedium = first.Medium; report.StartLow = first.Low; report.firstScan = first.dateTime; report.LastHigh = last.High; report.LastMedium = last.Medium; report.LastLow = last.Low; report.lastScan = last.dateTime; report.DiffHigh = first.High - last.High; report.DiffMedium = first.Medium - last.Medium; report.DiffLow = first.Low - last.Low; report.ScanCount = scanCount[key].count; reports.Add(report); } return(reports); }