コード例 #1
0
        private void ShowScanData(ref CxWSQueryVulnerabilityData[] scanData, ref long scanId, CxWebServiceClient client)
        {
            // Get url to scanned project result
            string savedFileName = string.Format("report{0}", Guid.NewGuid());
            long   id            = 0;
            CxWSResponseScanStatus scanStatus = client.ServiceClient.GetStatusOfSingleScan(_scan.LoginResult.SessionId, _scan.RunScanResult.ScanId);
            string ScanTaskId = scanStatus.ScanId.ToString();//after scan is finished the server replaces the scan id with task scan id

            scanData = PerspectiveHelper.GetScanResultsPaths(ScanTaskId, ref scanId);
            id       = scanId;
            LoginData.BindProject bindProject = _scan.LoginResult.AuthenticationData.BindedProjects.Find(project => project.BindedProjectId == CommonData.ProjectId &&
                                                                                                         project.ProjectName == CommonData.ProjectName &&
                                                                                                         project.RootPath == CommonData.ProjectRootPath);

            if (bindProject == null) // scaned for the first time
            {
                bindProject             = new LoginData.BindProject();
                bindProject.ProjectName = CommonData.ProjectName;
                bindProject.RootPath    = CommonData.ProjectRootPath;
                bindProject.IsBound     = true;
                _scan.LoginResult.AuthenticationData.BindedProjects.Add(bindProject);
            }
            if (!CommonData.IsProjectBound) // its new project
            {
                bindProject.BindedProjectId = scanStatus.ProjectId;
                CommonData.ProjectId        = scanStatus.ProjectId;
                CommonData.IsProjectPublic  = scanStatus.IsPublic;
                bindProject.IsPublic        = scanStatus.IsPublic;
                bindProject.IsBound         = true;
            }
            bindProject.SelectedScanId = id;
            bindProject.ScanReports    = new List <ScanReportInfo>();
            LoginHelper.Save(_scan.LoginResult.AuthenticationData);


            BackgroundWorkerHelper bgWork = new BackgroundWorkerHelper(delegate
            {
                CommonData.SelectedScanId = id;
                String path = PerspectiveHelper.GetScanXML(id);
                ScanReportInfo scanReportInfo         = new ScanReportInfo();
                scanReportInfo.Path                   = path;
                scanReportInfo.Id                     = id;
                LoginData.BindProject projectToUpdate = _scan.LoginResult.AuthenticationData.BindedProjects.Find(delegate(LoginData.BindProject bp)
                {
                    return(bp.BindedProjectId == CommonData.ProjectId);
                }
                                                                                                                 );

                projectToUpdate.ScanReports = new List <ScanReportInfo>();
                projectToUpdate.ScanReports.Add(scanReportInfo);

                LoginHelper.Save(_scan.LoginResult.AuthenticationData);
            });

            bgWork.DoWork();
        }
コード例 #2
0
        private StatusScanResult UpdateScanStatus(ref bool bCancel, bool backgroundMode, IScanView view, BackgroundWorkerHelper bg, CxWebServiceClient client, ref bool isIISStoped)
        {
            // Get current scan status
            CxWSResponseScanStatus cxWSResponseScanStatus = null;
            StatusScanResult       statusScan             = null;

            bg.DoWorkFunc = delegate(object obj)
            {
                cxWSResponseScanStatus         = client.ServiceClient.GetStatusOfSingleScan(_scan.LoginResult.SessionId, _scan.RunScanResult.ScanId);
                statusScan                     = new StatusScanResult();
                statusScan.CurrentStage        = cxWSResponseScanStatus.CurrentStage;
                statusScan.CurrentStagePercent = cxWSResponseScanStatus.CurrentStagePercent;
                statusScan.Details             = cxWSResponseScanStatus.StepDetails;
                statusScan.IsSuccesfull        = cxWSResponseScanStatus.IsSuccesfull;
                statusScan.QueuePosition       = cxWSResponseScanStatus.QueuePosition;
                statusScan.RunId               = cxWSResponseScanStatus.RunId;
                statusScan.RunStatus           = cxWSResponseScanStatus.CurrentStatus;
                statusScan.StageMessage        = cxWSResponseScanStatus.StageMessage;
                statusScan.StageName           = cxWSResponseScanStatus.StageName;
                statusScan.StepMessage         = cxWSResponseScanStatus.StepMessage;
                statusScan.TimeFinished        = cxWSResponseScanStatus.TimeFinished != null?cxWSResponseScanStatus.TimeFinished.ToString() : null;

                statusScan.TimeStarted = cxWSResponseScanStatus.TimeScheduled != null?cxWSResponseScanStatus.TimeScheduled.ToString() : null;

                statusScan.TotalPercent = cxWSResponseScanStatus.TotalPercent;
            };
            bCancel = !bg.DoWork(null);

            if (!BackgroundWorkerHelper.IsReloginInvoked)
            {
                isIISStoped = !_scan.LoginResult.AuthenticationData.SaveSastScan;
            }
            else
            {
                BackgroundWorkerHelper.IsReloginInvoked = false;
            }

            if (!bCancel && cxWSResponseScanStatus != null && !isIISStoped)
            {
                ScanProgress progress = new ScanProgress(
                    _scan.UploadSettings.ProjectName,
                    statusScan.RunStatus.ToString(),
                    statusScan.StageName,
                    statusScan.StepMessage,
                    statusScan.CurrentStagePercent,
                    0,
                    100,
                    statusScan.TotalPercent);

                if (!backgroundMode)
                {
                    view.Progress = progress;
                }
                try {
                    CommonActionsInstance.getInstance().ScanProgressView.Progress = progress;
                }
                catch (Exception ex) {
                    Logger.Create().Error(ex.ToString());
                }

                if (statusScan.RunStatus == CurrentStatusEnum.Failed)
                {
                    TopMostMessageBox.Show(statusScan.StageMessage, "Scan Error");
                    bCancel = true;
                }

                if (_scan.ScanView == null || _scan.ScanView.Visibility == false)
                {
                    var scanStatusBar = new ScanStatusBar(true, string.Format("Scaning project {0}: {1} {2}",
                                                                              _scan.UploadSettings.ProjectName,
                                                                              statusScan.StepMessage, statusScan.RunStatus), statusScan.TotalPercent, 100);

                    CommonActionsInstance.getInstance().UpdateScanProgress(scanStatusBar);
                }
            }
            return(statusScan);
        }
コード例 #3
0
    public CxWSResponseScanStatus GetStatusOfSingleScan(string sessionID, string runId)
    {
        CxWSResponseScanStatus result = _web_Service.GetStatusOfSingleScan(sessionID, runId);

        return(result);
    }