Example #1
0
        public resultClass makeProjectScanCsv_1()
        {
            _token.status = -1;
            csvHelper cvsHelper = new csvHelper();


            if ((_token.start_time == null))
            {
                Console.Error.WriteLine("Start time must be provided.");
                return(_token);
            }
            if (LogAdminIn())
            {
                CxSDKWebService.CxSDKWebServiceSoapClient cxSDKProxy = new CxSDKWebService.CxSDKWebServiceSoapClient(CxSDKWebService.CxSDKWebServiceSoapClient.EndpointConfiguration.CxSDKWebServiceSoap12);
                Dictionary <long, string> presets = GetPresetConfiguration(cxSDKProxy);
                Dictionary <long, CxSDKWebService.ProjectDisplayData> projects = GetAllProjects(cxSDKProxy);
                List <csvScanOutput_1> csvOutput = new List <csvScanOutput_1>();
                List <CxSDKWebService.ProjectScannedDisplayData> scannedDisplayDatasList = GetProjectScannedList(cxSDKProxy);
                foreach (CxSDKWebService.ProjectScannedDisplayData scans in scannedDisplayDatasList)
                {
                    CxSDKWebService.ProjectDisplayData proj     = projects[scans.ProjectID];
                    CxSDKWebService.CxDateTime         scanDate = proj.LastScanDate;

                    DateTime lastScanDate = DateTime.Parse(String.Format("{0}/{1}/{2} {3}:{4}:{5}", scanDate.Month, scanDate.Day, scanDate.Year, scanDate.Hour, scanDate.Minute, scanDate.Second));
                    if (lastScanDate > _token.start_time)
                    {
                        if ((_token.end_time == null) || (lastScanDate < _token.end_time))
                        {
                            if ((_token.project_name == null) || (scans.ProjectName.Contains(_token.project_name)))
                            {
                                csvScanOutput_1 csv = new csvScanOutput_1()
                                {
                                    Project_Name         = scans.ProjectName,
                                    Owner                = proj.Owner,
                                    Team                 = scans.TeamName,
                                    Preset               = proj.Preset,
                                    Last_Scan            = lastScanDate,
                                    Total_Vulerabilities = scans.TotalVulnerabilities,
                                    High                 = scans.HighVulnerabilities,
                                    Medium               = scans.MediumVulnerabilities,
                                    Low  = scans.LowVulnerabilities,
                                    Info = scans.InfoVulnerabilities
                                };
                                csvOutput.Add(csv);
                                if ((_token.pipe) || (_token.debug))
                                {
                                    Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8}", csv.Project_Name, csv.Owner, csv.Team, csv.Preset, csv.Last_Scan, csv.Total_Vulerabilities, csv.High, csv.Medium, csv.Low, csv.Info);
                                }
                            }
                        }
                    }
                }
                if (!_token.pipe)
                {
                    _token.status = cvsHelper.writeCVSFile(csvOutput, _token);
                }
            }
            return(_token);
        }
Example #2
0
        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);
            //List<Teams> teams = scans.getTeams(token);
            token.max_scans = (token.max_scans == 0) ? 1 : token.max_scans;
            List <ScanObject> scan = projects.filter_by_projects(token);

            if (scan.Count == 0)
            {
                Console.Error.WriteLine("No scans were found, please check argumants and retry.");
                return(false);
            }
            Dictionary <string, Teams>        teams            = projects.CxTeams;
            Dictionary <long, ScanSettings>   settings         = projects.CxSettings;
            Dictionary <long, ScanStatistics> resultStatistics = projects.CxResultStatistics;
            Dictionary <long, Presets>        presets          = projects.CxPresets;
            List <ReportLastScan>             lastScan         = reportLastScan(token, scan, teams, resultStatistics, settings, presets);

            if (token.debug)
            {
                Console.WriteLine("Processing data, number of rows: {0}", lastScan.Count);
            }

            if (token.pipe)
            {
                foreach (ReportLastScan csv in lastScan)
                {
                    Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", csv.ProjectId, csv.ProjectName, csv.Comment, csv.TeamName, csv.isIncremental, csv.Owner, csv.Origin, csv.ScanType, csv.ScanStartDate, csv.ScanFinishDate, csv.High, csv.Medium, csv.Low);
                }
            }
            else
            {
                csvHelper csvHelper = new csvHelper();
                csvHelper.writeCVSFile(lastScan, token);
            }
            return(true);
        }
Example #3
0
        public resultClass makeProjectScanCsv_3()
        {
            _token.status = -1;
            csvHelper cvsHelper = new csvHelper();

            if ((_token.start_time == null))
            {
                Console.Error.WriteLine("Start time must be provided.");
                return(_token);
            }
            if (LogAdminIn())
            {
                List <CxUsers> UserList = new List <CxUsers>();

                CxSDKWebService.CxSDKWebServiceSoapClient cxSDKProxy = new CxSDKWebService.CxSDKWebServiceSoapClient(CxSDKWebService.CxSDKWebServiceSoapClient.EndpointConfiguration.CxSDKWebServiceSoap12);
                CxSDKWebService.GetAllUsersResponse       response   = cxSDKProxy.GetAllUsersAsync(_token.session_id).Result;

                foreach (CxSDKWebService.UserData userData in response.Body.GetAllUsersResult.UserDataList)
                {
                    CxUsers userList = new CxUsers()
                    {
                        FirstName = userData.FirstName,
                        LastName  = userData.LastName,
                        email     = userData.Email,
                        //isAudit = userData.AuditUser,
                        //createDate = userData.DateCreated,
                        lastLogin  = userData.LastLoginDate,
                        exparation = userData.willExpireAfterDays,
                        company    = userData.CompanyName,
                        isActive   = userData.IsActive,
                        jobTitle   = userData.JobTitle
                    };
                    foreach (CxSDKWebService.Group group in userData.GroupList)
                    {
                        string groupName = group.GroupName;
                        userList.teams += String.Format("{0}: {1};", group.Type.ToString(), group.GroupName);
                    }
                    UserList.Add(userList);
                }
                csvHelper csvHelper = new csvHelper();
                csvHelper.writeCVSFile(UserList, _token);
            }
            return(_token);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        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);
        }