//DETAILED VULNERABILITIES private void deleteVuln_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("Please select a row to remove.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { DataGridViewSelectedRowCollection collection = dataGridView1.SelectedRows; foreach (DataGridViewRow gvr in collection) { object obj = gvr.DataBoundItem; if (null != obj) { if (obj is Vulnerability) { Vulnerability v = obj as Vulnerability; if (null != v) { Vulnerabilities.RemoveItem(v); bindGrid(null); } } } } } }
public static void RemoveItem(Vulnerability v) { lock (lockObject) { if (null != v) { ListofVulnerabilities.Remove(v); } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (-1 == e.RowIndex) { return; } DataGridViewRow gvr = dataGridView1.Rows[e.RowIndex]; if (gvr.DataBoundItem is Vulnerability) { Vulnerability v = gvr.DataBoundItem as Vulnerability; if (null != v) { if (EditGuid == v.Identifier) { return; } try { CancelSave.Visible = true; vulnTypeItems.SelectedIndex = vulnTypeItems.Items.IndexOf(v.VulnTypeReported); vulnTitle.Text = v.Title; vulnerabilityInput.Text = v.Details; penTesterDiscover.SelectedIndex = penTesterDiscover.Items.IndexOf(v.Tester); riskLevelInput.SelectedIndex = riskLevelInput.Items.IndexOf(v.Risk); statusInput.SelectedIndex = statusInput.Items.IndexOf(v.Status); cvssDataText.Value = Convert.ToDecimal(v.CVSS); discoveredDate.Value = (DateTime)v.DiscoveredDate; EditGuid = v.Identifier; completeDateInput.Value = null == v.CompletedDate ? DateTime.Now : (DateTime)v.CompletedDate; isForUpdate.Checked = v.isWeeklyReportItem; addIssueButton.Text = "Save"; } catch { } } } }
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(); }