public bool fetchReportsbyDate() { if (token.debug && token.verbosity > 1) { Console.WriteLine("Running: {0}", token.report_name); } Dictionary <long, Dictionary <DateTime, Dictionary <string, ReportResultExtended> > > fix = new Dictionary <long, Dictionary <DateTime, Dictionary <string, ReportResultExtended> > >(); List <ReportTrace> trace = new List <ReportTrace>(); Dictionary <string, ReportResultExtended> resultAll = new Dictionary <string, ReportResultExtended>(); List <ReportResultExtended> report_output = new List <ReportResultExtended>(); // Dictionary<long, ReportStaging> start = new Dictionary<long, ReportStaging>(); // Dictionary<long, ReportStaging> end = new Dictionary<long, ReportStaging>(); Dictionary <long, ScanCount> scanCount = new Dictionary <long, ScanCount>(); getScanResults scanResults = new getScanResults(); getScans scans = new getScans(); getProjects projects = new getProjects(token); //List<ScanObject> scan = scans.getScan(token); Dictionary <string, Teams> teams = projects.CxTeams; List <ScanObject> scan = projects.filter_by_projects(token); Dictionary <long, ScanStatistics> resultStatistics = projects.CxResultStatistics; if (scan.Count == 0) { Console.Error.WriteLine("No scans were found, pleas check argumants and retry."); return(false); } foreach (ScanObject s in scan) { setCount(s.Project.Id, scanCount); ReportResult result = scanResults.SetResultRequest(s.Id, "XML", token); if (result != null) { trace.Add(new ReportTrace(s.Project.Id, s.Project.Name, teams[s.OwningTeamId].fullName, s.DateAndTime.StartedOn, s.Id, result.ReportId, "XML")); if (trace.Count % token.max_threads == 0) { fetchReports(trace, scanResults, fix, resultAll, report_output); trace.Clear(); } } } fetchReports(trace, scanResults, fix, resultAll, report_output); trace.Clear(); addFixed(fix, report_output); if (token.debug) { Console.WriteLine("Processing data, number of rows: {0}", report_output.Count); } if (token.pipe) { foreach (ReportResultExtended csv in report_output) { Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", csv.projectName, csv.teamName, csv.presetName, csv.similarityId, csv.resultId, csv.reportId, csv.Severity, csv.status, csv.state, csv.Query, csv.Group, csv.scanDate); } } else { csvHelper csvHelper = new csvHelper(); csvHelper.writeCVSFile(report_output, token); } return(true); }
public bool fetchReportsbyDate() { if (token.debug && token.verbosity > 1) { Console.WriteLine("Running: {0}", token.report_name); } List <ReportTrace> trace = new List <ReportTrace>(); Dictionary <long, List <ReportResultMaxQueries> > report = new Dictionary <long, List <ReportResultMaxQueries> >(); Dictionary <long, List <ReportResultAll> > last = new Dictionary <long, List <ReportResultAll> >(); Dictionary <long, ScanCount> scanCount = new Dictionary <long, ScanCount>(); getScans scans = new getScans(); getProjects projects = new getProjects(token); //List<ScanObject> scan = scans.getScan(token); Dictionary <string, Teams> teams = projects.CxTeams; List <ScanObject> scan = projects.filter_by_projects(token, true); Dictionary <long, ScanStatistics> resultStatistics = projects.CxResultStatistics; getScanResults scanResults = new getScanResults(); if (scan.Count == 0) { Console.Error.WriteLine("No scans were found, please check arguments and retry."); return(false); } foreach (ScanObject s in scan) { ReportResult result = scanResults.SetResultRequest(s.Id, "XML", token); if (trace.Count % token.max_threads == 0) { waitForResult(trace, scanResults, last); trace.Clear(); } if (result != null) { trace.Add(new ReportTrace(s.Project.Id, s.Project.Name, teams[s.OwningTeamId].fullName, s.DateAndTime.StartedOn, s.Id, result.ReportId, "XML")); } } waitForResult(trace, scanResults, last); trace.Clear(); List <ReportResultMaxQueries> reportOutputs = totalScansandReports(last, scan, resultStatistics); if (token.debug) { Console.WriteLine("Processing data, number of rows: {0}", reportOutputs.Count); } if (token.pipe) { foreach (ReportResultMaxQueries csv in reportOutputs) { Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25}", csv.Project_Name, csv.Team_Name, csv.Preset_Name, csv.Scan_Date, csv.Project_Id, csv.Scan_Id, csv.Languages, csv.Query_1, csv.Group_1, csv.Severity_1, csv.False_Positive_1, csv.Query_2, csv.Group_2, csv.Severity_2, csv.False_Positive_2, csv.Query_3, csv.Group_3, csv.Severity_3, csv.False_Positive_3, csv.Query_4, csv.Group_4, csv.Severity_4, csv.False_Positive_4, csv.Query_5, csv.Group_5, csv.Severity_5, csv.False_Positive_5); } } else { csvHelper csvHelper = new csvHelper(); csvHelper.writeCVSFile(reportOutputs, token); } return(true); }
public bool fetchReportsbyDate() { if (token.debug && token.verbosity > 1) { Console.WriteLine("Running: {0}", token.report_name); } List <ReportTrace> trace = new List <ReportTrace>(); List <ReportResultAll> resultNew = new List <ReportResultAll>(); Dictionary <long, ReportStaging> start = new Dictionary <long, ReportStaging>(); Dictionary <long, ReportStaging> end = new Dictionary <long, ReportStaging>(); Dictionary <long, List <ReportResultAll> > first = new Dictionary <long, List <ReportResultAll> >(); Dictionary <long, List <ReportResultAll> > last = new Dictionary <long, List <ReportResultAll> >(); Dictionary <long, ScanCount> scanCount = new Dictionary <long, ScanCount>(); getScans scans = new getScans(); getProjects projects = new getProjects(token); //List<ScanObject> scan = scans.getScan(token); Dictionary <string, Teams> teams = projects.CxTeams; List <ScanObject> scan = projects.filter_by_projects(token); Dictionary <long, ScanStatistics> resultStatistics = projects.CxResultStatistics; getScanResults scanResults = new getScanResults(); if (scan.Count == 0) { Console.Error.WriteLine("No scans were found, pleas check arguments and retry."); return(false); } foreach (ScanObject s in scan) { setCount(s.Project.Id, scanCount); findFirstandLastScan(s.Project.Id, s, resultStatistics[s.Id], start, end); ReportResult result = scanResults.SetResultRequest(s.Id, "XML", token); // ReportResult result = scanResults.SetResultRequest(s.Id, "XML", token); // if (result != null) // { // trace.Add(new ReportTrace(s.Project.Id, s.Project.Name, scans.getFullName(teams, s.OwningTeamId), s.DateAndTime.StartedOn, s.Id, result.ReportId, "XML")); // } if (trace.Count % token.max_threads == 0) { waitForResult(trace, scanResults, resultNew, start, end, first, last); trace.Clear(); } if (result != null) { trace.Add(new ReportTrace(s.Project.Id, s.Project.Name, teams[s.OwningTeamId].fullName, s.DateAndTime.StartedOn, s.Id, result.ReportId, "XML")); } } waitForResult(trace, scanResults, resultNew, start, end, first, last); trace.Clear(); List <ReportOutputExtended> reportOutputs = totalScansandReports(start, end, resultNew, first, last, scanCount); if (token.debug) { Console.WriteLine("Processing data, number of rows: {0}", reportOutputs.Count); } if (token.pipe) { foreach (ReportOutputExtended csv in reportOutputs) { Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21}", csv.ProjectName, csv.Team, csv.LastHigh, csv.LastMedium, csv.LastLow, csv.StartNotExploitable, csv.StartConfirmed, csv.StartToVerify, csv.LastOthers, csv.NewHigh, csv.NewMedium, csv.NewLow, csv.DiffHigh, csv.DiffMedium, csv.DiffLow, csv.LastNotExploitable, csv.LastConfirmed, csv.LastToVerify, csv.LastOthers, csv.firstScan, csv.lastScan, csv.ScanCount); } } else { csvHelper csvHelper = new csvHelper(); csvHelper.writeCVSFile(reportOutputs, token); } return(true); }
public bool fetchReportsbyDate() { List <ReportTrace> trace = new List <ReportTrace>(); List <ReportResultNew> resultNew = new List <ReportResultNew>(); Dictionary <long, ReportStaging> start = new Dictionary <long, ReportStaging>(); Dictionary <long, ReportStaging> end = new Dictionary <long, ReportStaging>(); Dictionary <long, List <ReportResultNew> > last = new Dictionary <long, List <ReportResultNew> >(); Dictionary <long, ScanCount> scanCount = new Dictionary <long, ScanCount>(); bool waitFlag = false; getScanResults scanResults = new getScanResults(); getScans scans = new getScans(); List <ScanObject> scan = scans.getScan(token); foreach (ScanObject s in scan) { if ((s.DateAndTime != null) && (s.Status.Id == 7) && (s.DateAndTime.StartedOn > token.start_time) && (s.DateAndTime.StartedOn < token.end_time)) { setCount(s.Project.Id, scanCount); findFirstorLastScan(s.Project.Id, s, start, true); findFirstorLastScan(s.Project.Id, s, end, false); ReportResult result = scanResults.SetResultRequest(s.Id, "XML", token); if (result != null) { trace.Add(new ReportTrace(s.Project.Id, s.Id, result.ReportId)); } } } while (!waitFlag) { foreach (ReportTrace rt in trace) { waitFlag = true; if (!rt.isRead) { waitFlag = false; if (scanResults.GetResultStatus(rt.reportId, token)) { var result = scanResults.GetResult(rt.reportId, token); if (result != null) { if (process_CxResponse(result, resultNew)) { rt.isRead = true; getlastReport(result, end, last); } } } } } } List <ReportOutput> reportOutputs = totalScansandReports(start, end, resultNew, last, scanCount); if (token.pipe) { foreach (ReportOutput csv in reportOutputs) { Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15}", csv.ProjectName, csv.LastHigh, csv.LastMedium, csv.LastLow, csv.NewHigh, csv.NewMedium, csv.NewLow, csv.DiffHigh, csv.DiffMedium, csv.DiffLow, csv.NotExploitable, csv.Confirmed, csv.ToVerify, csv.firstScan, csv.lastScan, csv.ScanCount); } } else { csvHelper csvHelper = new csvHelper(); csvHelper.writeCVSFile(reportOutputs, token); } return(true); }
public bool fetchResultsbyDate() { List<ReportTrace> trace = new List<ReportTrace>(); bool waitFlag = false; getScans scans = new getScans(); getProjects projects = new getProjects(token); //List<ScanObject> scan = scans.getScan(token); Dictionary<string, Teams> teams = projects.CxTeams; List<ScanObject> scan = projects.filter_by_projects(token); Dictionary<long, ScanStatistics> resultStatistics = projects.CxResultStatistics; getScanResults scanResults = new getScanResults(); if (scan.Count == 0) { Console.Error.WriteLine("No scans were found, pleas check arguments and retry."); return false; } foreach (ScanObject s in scan) { if (token.save_result.Contains("XML")) { ReportResult result = scanResults.SetResultRequest(s.Id, "XML", token); if (result != null) { trace.Add(new ReportTrace(s.Project.Id, s.Project.Name, teams[s.OwningTeamId].fullName, s.DateAndTime.StartedOn, s.Id, result.ReportId, "XML")); } } if (token.save_result.Contains("PDF")) { ReportResult result = scanResults.SetResultRequest(s.Id, "PDF", token); if (result != null) { trace.Add(new ReportTrace(s.Project.Id, s.Project.Name, teams[s.OwningTeamId].fullName, s.DateAndTime.StartedOn, s.Id, result.ReportId, "PDF")); } } } while (!waitFlag) { if (token.debug && token.verbosity > 0) { Console.WriteLine("Sleeping 1 second(s)"); } Thread.Sleep(1000); waitFlag = true; foreach (ReportTrace rt in trace) { if (!rt.isRead) { waitFlag = false; if (token.debug && token.verbosity > 0) { Console.WriteLine("Testing report.Id {0}", rt.reportId); } if (scanResults.GetResultStatus(rt.reportId, token)) { if (token.debug && token.verbosity > 0) { Console.WriteLine("Found report.Id {0}", rt.reportId); } var result = scanResults.GetGenaricResult(rt.reportId, token); if (result != null) { rt.isRead = true; writeOutputToFile(rt, token); trace.Remove(rt); break; } } } } } return true; }
public bool fetchReportsbyDate() { List <ReportTrace> trace = new List <ReportTrace>(); List <ReportResultAll> resultNew = new List <ReportResultAll>(); Dictionary <long, ReportStaging> start = new Dictionary <long, ReportStaging>(); Dictionary <long, ReportStaging> end = new Dictionary <long, ReportStaging>(); Dictionary <long, List <ReportResultAll> > last = new Dictionary <long, List <ReportResultAll> >(); Dictionary <long, ScanCount> scanCount = new Dictionary <long, ScanCount>(); /* getScanResults scanResults = new getScanResults(); * getScans scans = new getScans(); * List<Teams> teams = scans.getTeams(token); * List<ScanObject> scan = scans.getScan(token);*/ getScans scans = new getScans(); getProjects projects = new getProjects(token); //List<ScanObject> scan = scans.getScan(token); Dictionary <string, Teams> teams = projects.CxTeams; List <ScanObject> scan = projects.filter_by_projects(token); Dictionary <long, ScanStatistics> resultStatistics = projects.CxResultStatistics; getScanResults scanResults = new getScanResults(); if (scan.Count == 0) { Console.Error.WriteLine("No scans were found, pleas check argumants and retry."); return(false); } foreach (ScanObject s in scan) { setCount(s.Project.Id, scanCount); findFirstorLastScan(s.Project.Id, s, teams, start, true); findFirstorLastScan(s.Project.Id, s, teams, end, false); ReportResult result = scanResults.SetResultRequest(s.Id, "XML", token); if (result != null) { trace.Add(new ReportTrace(s.Project.Id, s.Project.Name, teams[s.OwningTeamId].fullName, s.DateAndTime.StartedOn, s.Id, result.ReportId, "XML")); } if (trace.Count % 5 == 0) { waitForResult(trace, scanResults, resultNew, end, last); trace.Clear(); } } waitForResult(trace, scanResults, resultNew, end, last); trace.Clear(); List <ReportOutput> reportOutputs = totalScansandReports(start, end, resultNew, last, scanCount); if (token.pipe) { foreach (ReportOutput csv in reportOutputs) { Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18}", csv.ProjectName, csv.company, csv.team, csv.LastHigh, csv.LastMedium, csv.LastLow, csv.NewHigh, csv.NewMedium, csv.NewLow, csv.DiffHigh, csv.DiffMedium, csv.DiffLow, csv.NotExploitable, csv.Confirmed, csv.ToVerify, csv.firstScan, csv.lastScan, csv.ScanCount); } } else { csvHelper csvHelper = new csvHelper(); csvHelper.writeCVSFile(reportOutputs, token); } return(true); }