Example #1
0
        private void addIssueButton_Click(object sender, EventArgs e)
        {
            ProjectPOCO project = projectHelper.GetCurrentProject(ddlProjects.Text);

            if (null == project)
            {
                ShowError("No project found.");
                return;
            }
            bool     isUpdate = false;
            ModTypes t        = ModTypes.Add;

            DateTime       outCompleteDate;
            DateTime       outDiscoveredDate;
            Decimal        cvss = 0;
            IVulnerability vuln = new Vulnerability();

            vuln.Identifier = Guid.NewGuid();
            if (sender is Button)
            {
                Button localB = sender as Button;
                if (null != localB)
                {
                    isUpdate = localB.Text == "Save" ? true : false;
                    if (isUpdate)
                    {
                        t = ModTypes.Update;
                        vuln.Identifier = EditGuid;
                    }
                    else
                    {
                        t = ModTypes.Add;
                    }
                }
            }
            if (Decimal.TryParse(cvssDataText.Text, out cvss))
            {
                vuln.CVSS = cvss;
            }
            else
            {
                MessageBox.Show("Value was not a decimal.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (DateTime.TryParse(completeDateInput.Text, out outCompleteDate))
            {
                vuln.CompletedDate = outCompleteDate;
            }
            else
            {
                vuln.CompletedDate = null;
            }

            if (DateTime.TryParse(discoveredDate.Text, out outDiscoveredDate))
            {
                vuln.DiscoveredDate = outDiscoveredDate;
            }
            else
            {
                vuln.DiscoveredDate = null;
            }

            string title     = vulnTitle.Text;
            string status    = statusInput.Text;
            string risklevel = riskLevelInput.Text;
            string details   = vulnerabilityInput.Text;

            if (status != "Not An Issue" || status != "Fixed")
            {
                vuln.CompletedDate = null;
            }
            vuln.Title            = title;
            vuln.VulnTypeReported = vulnTypeItems.SelectedItem.ToString();
            vuln.Status           = status;
            vuln.Risk             = risklevel;
            vuln.Details          = details;
            vuln.Tester           = penTesterDiscover.SelectedItem.ToString();


            vuln.isWeeklyReportItem = isForUpdate.Checked;
            Vulnerabilities.AddObject(vuln);

            projectHelper.ModifyVulnerabilityAnalysis(t, ddlProjects.Text, vuln);
            if (ModTypes.Update == t)
            {
                dataGridView1.CellContentClick += dataGridView1_CellContentClick;
            }
            bindGrid(project);
            ClearVulnForm();
        }