コード例 #1
0
        public void ReportDoPrevResults()
        {
            IPerspectiveView rep = _reportWin.Window as IPerspectiveView;

            PerspectiveHelper.DoPrevResult();
            if (rep == null || rep.Report == null || rep.Report.Tree.Count == 0)
            {
                TopMostMessageBox.Show("There are no vulnerabilities to show");
            }
        }
コード例 #2
0
        private void cbAssign_SelectionChangeCommitted(object sender, EventArgs e)
        {
            bool needRefresh = false;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                ComboBox               senderComboBox = (ComboBox)sender;
                ComboBoxItem1          cbItem         = (ComboBoxItem1)senderComboBox.SelectedItem;
                string                 item           = cbItem.Value;
                List <ResultStateData> list           = new List <ResultStateData>();
                foreach (DataGridViewRow row in dgvProjects.Rows)
                {
                    if (row.Cells["checkBoxesColumn"].Value != null && (bool)row.Cells["checkBoxesColumn"].Value)
                    {
                        CxWSSingleResultData reportQueryItemPathResult = row.Cells["ResultEntity"].Value as CxWSSingleResultData;
                        long pathId   = reportQueryItemPathResult.PathId;
                        long resultId = Convert.ToInt64(row.Cells["ScanId"].Value);
                        list.Add(new ResultStateData()
                        {
                            data            = item,
                            PathId          = pathId,
                            Remarks         = string.Empty,
                            ResultLabelType = (int)CxViewerAction.Helpers.ResultLabelTypeEnum.Assign,
                            scanId          = resultId
                        });
                    }
                }

                if (list.Count > 0)
                {
                    needRefresh = PerspectiveHelper.UpdateResultState(list.ToArray());
                }

                if (needRefresh)
                {
                    this.Refresh(this, currentNodedata);
                }
            }
            catch (Exception ex)
            {
                Logger.Create().Error(ex.ToString());
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #3
0
        private void DoScan(Entities.Project project)
        {
            try
            {
                if (!LoginHelper.IsScanner)
                {
                    TopMostMessageBox.Show("User is not allowed to scan", "Error");
                    return;
                }

                // verify that was selected correct project
                if (!string.IsNullOrEmpty(project.RootPath))
                {
                    System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state)
                    {
                        try
                        {
                            CxViewerAction.CxVSWebService.CxWSQueryVulnerabilityData[] scanData = null;
                            long scanId = 0;

                            ProjectScanStatuses status = _scanHelper.DoScan(project, IsIncremental, ref scanData, ref scanId);

                            if (status == ProjectScanStatuses.Success)
                            {
                                LoginData login = LoginHelper.LoadSaved();
                                PerspectiveHelper.ShowStored(scanData, login, scanId);
                                CommonActionsInstance.getInstance().ShowReportView();
                            }

                            CommonActionsInstance.getInstance().ClearScanProgressView();
                            CommonActionsInstance.getInstance().CloseScanProgressView();
                        }
                        catch (Exception err)
                        {
                            Logger.Create().Error(err);
                            LoginHelper.DoLogout();
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                TopMostMessageBox.Show(ex.Message, "Error");
                Logger.Create().Error(ex.ToString());
            }
        }
コード例 #4
0
        private void RetrieveResultsFromServer(LoginData.BindProject bindPro, LoginData login)
        {
            CxWSResponseScansDisplayData cxWSResponseScansDisplayData = PerspectiveHelper.GetScansDisplayData(CommonData.ProjectId);

            if (cxWSResponseScansDisplayData == null)
            { //error occured
                return;
            }
            if (cxWSResponseScansDisplayData.ScanList.Length == 0)
            {
                // show error about 0 scan list
                System.Windows.Forms.MessageBox.Show("The chosen project doesn't contain scans", "Error", System.Windows.Forms.MessageBoxButtons.OK);
                return;
            }
            bindPro.ScanReports.Clear();
            foreach (ScanDisplayData item in cxWSResponseScansDisplayData.ScanList)
            {
                // Add relation to scanned project and scan report
                ScanReportInfo scanReportInfo = new ScanReportInfo {
                    Id = item.ScanID
                };
                string minutes = item.QueuedDateTime.Minute.ToString().Length > 1 ? item.QueuedDateTime.Minute.ToString() : "0" + item.QueuedDateTime.Minute;

                scanReportInfo.Name = string.Format("{0}/{1}/{2} {3}:{4}", item.QueuedDateTime.Month,
                                                    item.QueuedDateTime.Day,
                                                    item.QueuedDateTime.Year,
                                                    item.QueuedDateTime.Hour,
                                                    minutes);

                bindPro.AddScanReport(scanReportInfo);
            }
            LoginHelper.Save(login);


            ShowResultLogic showResultLogic = new ShowResultLogic();

            showResultLogic.Act();


            return;
        }
コード例 #5
0
        public ActionStatus Act()
        {
            if (PerspectiveHelper.LoginToServer() == null)
            {
                return(ActionStatus.Failed);
            }
            LoginData login = LoginHelper.LoadSaved();

            Entities.Project selectedProject = CommonActionsInstance.getInstance().GetSelectedProject();
            if (selectedProject == null)
            {
                return(ActionStatus.Failed);
            }
            CommonData.ProjectName     = selectedProject.ProjectName;
            CommonData.ProjectRootPath = selectedProject.RootPath;
            if (login != null && login.BindedProjects != null)
            {
                LoginData.BindProject bindPro = login.BindedProjects.Find(delegate(LoginData.BindProject bp)
                {
                    return(bp.ProjectName == selectedProject.ProjectName && bp.RootPath == selectedProject.RootPath);
                }
                                                                          );

                if (bindPro != null)
                {
                    CommonData.ProjectId       = bindPro.BindedProjectId;
                    CommonData.SelectedScanId  = bindPro.SelectedScanId;
                    CommonData.IsProjectBound  = bindPro.IsBound;
                    CommonData.IsProjectPublic = bindPro.IsPublic;
                }
                else
                {
                    CommonData.IsProjectBound = false;
                }
            }
            CommonActionsInstance.getInstance().BuildFileMapping();
            CommonActionsInstance.getInstance().ExecuteSystemCommand("File.SaveAll", string.Empty);
            DoScan(selectedProject);
            CommonData.IsWorkingOffline = false;
            return(ActionStatus.Success);
        }
コード例 #6
0
        public ActionStatus Act()
        {
            if (PerspectiveHelper.LoginToServer() == null)
            {
                return(ActionStatus.Failed);
            }
            LoginData login = LoginHelper.LoadSaved();

            Entities.Project selectedProject = CommonActionsInstance.getInstance().GetSelectedProject();
            if (selectedProject == null)
            {
                return(ActionStatus.Failed);
            }
            LoginData.BindProject bindPro = null;
            if (login != null && login.BindedProjects != null)
            {
                bindPro = login.BindedProjects.Find(delegate(LoginData.BindProject bp)
                {
                    return(bp.ProjectName == selectedProject.ProjectName && bp.RootPath == selectedProject.RootPath && bp.IsBound == true);
                }
                                                    );

                if (bindPro != null)
                {
                    CommonData.ProjectId       = bindPro.BindedProjectId;
                    CommonData.ProjectName     = selectedProject.ProjectName;
                    CommonData.ProjectRootPath = selectedProject.RootPath;
                }
                else
                {
                    return(ActionStatus.Failed);
                }
            }

            RetrieveResultsFromServer(bindPro, login);

            return(ActionStatus.Success);
        }
コード例 #7
0
        private void EditRemark(int columnIndex, int rowIndex)
        {
            if (CommonData.IsWorkingOffline)
            {
                MessageBox.Show("You are working offline. \rCannot update data", "Error", MessageBoxButtons.OK);
                return;
            }
            int currentRowIndex    = dgvProjects.CurrentCell.RowIndex;
            int currentColumnIndex = dgvProjects.CurrentCell.ColumnIndex;

            CxWSSingleResultData reportQueryItemPathResult = dgvProjects.Rows[rowIndex].Cells["ResultEntity"].Value as CxWSSingleResultData;

            long pathId   = reportQueryItemPathResult.PathId;
            long resultId = Convert.ToInt64(dgvProjects.Rows[rowIndex].Cells["ScanId"].Value);

            CxViewerAction.CxVSWebService.CxWSResultPath resultPath = PerspectiveHelper.GetPathCommentsHistory(resultId, pathId);
            string commentHistory = string.Empty;

            if (resultPath != null && !string.IsNullOrEmpty(resultPath.Comment))
            {
                commentHistory = resultPath.Comment;
            }

            string[]      commentsArr = commentHistory.Split(Convert.ToChar(255));
            StringBuilder sb          = new StringBuilder();

            for (int i = 0; i < commentsArr.Length; i++)
            {
                if (!string.IsNullOrEmpty(commentsArr[i]))
                {
                    sb.Append(commentsArr[i].ToString());
                    if (i != commentsArr.Length)
                    {
                        sb.Append(Environment.NewLine);
                    }
                }
            }

            EditRemarkPopUp remarkPopUp = new EditRemarkPopUp("", sb.ToString());

            DialogResult result = remarkPopUp.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            string remark = remarkPopUp.Remark;

            if (String.IsNullOrEmpty(remark))
            {
                return;
            }
            if (ChangeResultHelper.EditRemark(resultId, pathId, remark) == Entities.Enum.ProjectScanStatuses.Success)
            {
                reportQueryItemPathResult.Comment = remark;
                dgvProjects.Rows[rowIndex].Cells[columnIndex].Value = remark;
                dgvProjects.Rows[rowIndex].Selected = true;
                dgvProjects.CurrentCell             = dgvProjects.Rows[rowIndex].Cells[columnIndex];
            }
        }
コード例 #8
0
        private void SelectNode(TreeNodeData nodeData)
        {
            fillComboBoxes();

            currentNodedata        = nodeData;
            dgvProjects.DataSource = null;
            DataTable dt = new DataTable();

            DataColumn col = new DataColumn(Constants.COL_NAME_NUMBER, typeof(int));

            col.ReadOnly = true;
            dt.Columns.Add(col);
            DataColumn status = new DataColumn(Constants.COL_NAME_STATUS);

            col.ReadOnly = true;
            dt.Columns.Add(status);
            col          = new DataColumn(Constants.COL_NAME_SOURCE_FOLDER);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_SOURCE_FILE_NAME);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_SOURCE_LINE, typeof(int));
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_SOURCE_OBJECT);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_DEST_FOLDER);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_DEST_FILE_NAME);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_DEST_LINE, typeof(int));
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_DEST_OBJECT);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_SHOW_PATH);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_SEVERITY);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_ASSIGN);
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn(Constants.COL_NAME_REMARK);
            col.ReadOnly = false;
            dt.Columns.Add(col);
            col          = new DataColumn("ResultEntity", typeof(CxWSSingleResultData));
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn("ScanId", typeof(int));
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn("PathId", typeof(long));
            col.ReadOnly = true;
            dt.Columns.Add(col);
            col          = new DataColumn("State", typeof(int));
            col.ReadOnly = true;
            dt.Columns.Add(col);

            CxWSSingleResultData[] results = PerspectiveHelper.GetScanResultsForQuery(nodeData.ScanId, nodeData.Id);

            int index = 1;

            foreach (CxWSSingleResultData reportQueryItemResult in results)
            {
                string resultComment = reportQueryItemResult.Comment;
                if (!string.IsNullOrEmpty(resultComment))
                {
                    string[] commentsArr = resultComment.Split(new char[] { Convert.ToChar(255) }, StringSplitOptions.RemoveEmptyEntries);
                    if (commentsArr.Length > 0)
                    {
                        resultComment = commentsArr[commentsArr.Length - 1];
                        int endMetadataIndex = resultComment.LastIndexOf(SavedResultsManager.RESULT_COMMENT_DETAILS_SEPARATOR);
                        if (endMetadataIndex > 0)
                        {
                            resultComment = resultComment.Substring(endMetadataIndex + SavedResultsManager.RESULT_COMMENT_DETAILS_SEPARATOR.Length).Trim();
                        }
                    }
                }
                else
                {
                    resultComment = string.Empty;
                }

                dt.Rows.Add(new object[] {
                    index,
                    SavedResultsManager.ConvertResultStatusToString(reportQueryItemResult.ResultStatus),
                    reportQueryItemResult.SourceFolder,
                    reportQueryItemResult.SourceFile,
                    (int)reportQueryItemResult.SourceLine,
                    reportQueryItemResult.SourceObject,
                    reportQueryItemResult.DestFolder,
                    reportQueryItemResult.DestFile,
                    (int)reportQueryItemResult.DestLine,
                    reportQueryItemResult.DestObject,
                    ConvertResultState(reportQueryItemResult.State),
                    getSeverityDescription(reportQueryItemResult.Severity),
                    reportQueryItemResult.AssignedUser,
                    resultComment,
                    reportQueryItemResult,
                    nodeData.ScanId,
                    reportQueryItemResult.PathId,
                    reportQueryItemResult.State
                });

                index++;
            }
            dgvProjects.DataSource = dt;
            dgvProjects.DataMember = dt.TableName;

            for (int i = 0; i < 11; i++)
            {
                dgvProjects.Columns[i].HeaderCell.Style.Alignment = GetCellAlignment();
                dgvProjects.Columns[i].DefaultCellStyle.Font      = GetColumnFont();
            }

            dgvProjects.Columns["checkBoxesColumn"].Frozen                        = true;
            dgvProjects.Columns["checkBoxesColumn"].AutoSizeMode                  = DataGridViewAutoSizeColumnMode.None;
            dgvProjects.Columns["checkBoxesColumn"].Resizable                     = DataGridViewTriState.False;
            dgvProjects.Columns[Constants.COL_NAME_NUMBER].Width                  = 30;
            dgvProjects.Columns[Constants.COL_NAME_STATUS].AutoSizeMode           = DataGridViewAutoSizeColumnMode.Fill;
            dgvProjects.Columns[Constants.COL_NAME_SOURCE_FOLDER].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dgvProjects.Columns[Constants.COL_NAME_SOURCE_FILE_NAME].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvProjects.Columns[Constants.COL_NAME_SOURCE_LINE].Width             = 60;
            dgvProjects.Columns[Constants.COL_NAME_SOURCE_OBJECT].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dgvProjects.Columns[Constants.COL_NAME_DEST_FOLDER].AutoSizeMode      = DataGridViewAutoSizeColumnMode.Fill;
            dgvProjects.Columns[Constants.COL_NAME_DEST_FILE_NAME].AutoSizeMode   = DataGridViewAutoSizeColumnMode.Fill;
            dgvProjects.Columns[Constants.COL_NAME_DEST_LINE].Width               = 60;
            dgvProjects.Columns[Constants.COL_NAME_DEST_OBJECT].AutoSizeMode      = DataGridViewAutoSizeColumnMode.Fill;
            dgvProjects.Columns[Constants.COL_NAME_SHOW_PATH].Width               = 60;
            dgvProjects.Columns[Constants.COL_NAME_SEVERITY].Width                = 60;
            dgvProjects.Columns[Constants.COL_NAME_ASSIGN].Width                  = 60;
            dgvProjects.Columns[Constants.COL_NAME_REMARK].AutoSizeMode           = DataGridViewAutoSizeColumnMode.Fill;


            dgvProjects.AdvancedCellBorderStyle.All = DataGridViewAdvancedCellBorderStyle.None;

            dgvProjects.Columns["ResultEntity"].Visible = false;
            dgvProjects.Columns["ScanId"].Visible       = false;
            dgvProjects.Columns["PathId"].Visible       = false;
            dgvProjects.Columns["State"].Visible        = false;

            show_chkBox();

            UpdateGridShowPath();
        }