Exemplo n.º 1
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);
        }
Exemplo n.º 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);
            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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public resultClass dispatch()
        {
            resultClass token = Configuration.mono_command_args();

            if (token.status != 0)
            {
                return(token);
            }
            secure secure = new secure(token);

            _options.debug = token.debug;
            _options.level = token.verbosity;

            switch (token.api_action)
            {
            case api_action.getToken:
            {
                fetchToken newtoken = new fetchToken();
                newtoken.get_token(secure.decrypt_Credentials());
                break;
            }

            case api_action.storeCredentials:
            {
                storeCredentials cred = new storeCredentials();
                token = cred.save_credentials(token);
                break;
            }

            case api_action.scanResults:
            {
                if (token.report_name.Contains("REST"))
                {
                    using (CxRest_API cxRest_API = new CxRest_API(token))
                    {
                        if (token.report_name == "REST_REPORT_1")
                        {
                            cxRest_API.fetchReportsbyDate();
                        }
                    }
                }
                else
                {
                }
                using (CxSoapSDK cxSoapSDK = new CxSoapSDK(token))
                {
                    if (token.report_name == "REPORT_1")
                    {
                        cxSoapSDK.makeProjectScanCsv_1();
                    }
                    if (token.report_name == "REPORT_2")
                    {
                        cxSoapSDK.makeProjectScanCsv_2();
                    }
                }

                break;
            }

            case api_action.getProjects:
            {
                getProjects getProjects = new getProjects();
                getProjects.get_projects(token);
                break;
            }
            }
            return(token);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
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);
        }