private bool process_CxResponse(XElement result, List <ReportResultAll> response) { try { IEnumerable <XElement> newVulerability = from el in result.Descendants("Query").Descendants("Result") where (string)el.Attribute("Status").Value == "New" select el; foreach (XElement el in newVulerability) { XElement query = el.Parent; XElement root = query.Parent; ReportResultAll isnew = new ReportResultAll() { Query = query.Attribute("name").Value.ToString(), Group = query.Attribute("group").Value.ToString(), projectId = Convert.ToInt64(root.Attribute("ProjectId").Value.ToString()), scanId = Convert.ToInt64(root.Attribute("ScanId").Value.ToString()), status = el.Attribute("Status").Value.ToString(), Severity = el.Attribute("Severity").Value.ToString(), state = Convert.ToInt32(el.Attribute("state").Value.ToString()), teamName = root.Attribute("TeamFullPathOnReportDate").Value.ToString() }; response.Add(isnew); } return(true); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return(false); } }
private bool process_ScanResult(XElement result, Dictionary <long, List <ReportResultAll> > last, long projectId, long scanId) { List <ReportResultAll> reportResults = new List <ReportResultAll>(); try { if (result.Attribute("ScanId").Value == scanId.ToString()) { IEnumerable <XElement> lastScan = from el in result.Descendants("Query") select el; foreach (XElement query in lastScan) { XElement root = query.Parent; IEnumerable <XElement> vulerabilities = from el in query.Descendants("Result") select el; ReportResultAll isnew = new ReportResultAll() { QueryId = Convert.ToInt64(query.Attribute("id").Value.ToString()), Query = query.Attribute("name").Value.ToString(), Group = query.Attribute("group").Value.ToString(), projectName = root.Attribute("ProjectName").Value.ToString(), presetName = root.Attribute("Preset").Value.ToString(), teamName = root.Attribute("Team").Value.ToString(), scanDate = Convert.ToDateTime(root.Attribute("ScanStart").Value.ToString()), projectId = Convert.ToInt64(root.Attribute("ProjectId").Value.ToString()), scanId = Convert.ToInt64(root.Attribute("ScanId").Value.ToString()), Severity = query.Attribute("Severity").Value.ToString(), QueryCount = vulerabilities.Count() }; foreach (XElement vulerability in vulerabilities) { int state = Convert.ToInt32(vulerability.Attribute("state").Value.ToString()); if (state == 1) { isnew.NotExploitableCount++; } } reportResults.Add(isnew); } if (!last.ContainsKey(projectId)) { last.Add(projectId, reportResults); } } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return(false); } return(true); }
private bool process_CxResponse(XElement result, List <ReportResultAll> response) { try { IEnumerable <XElement> newVulerability = from el in result.Descendants("Query").Descendants("Result") where (string)el.Attribute("Status").Value == "New" select el; foreach (XElement el in newVulerability) { XElement query = el.Parent; XElement root = query.Parent; ReportResultAll isnew = new ReportResultAll() { Query = query.Attribute("name").Value.ToString(), Group = query.Attribute("group").Value.ToString(), projectName = root.Attribute("ProjectName").Value.ToString(), presetName = root.Attribute("Preset").Value.ToString(), teamName = root.Attribute("Team").Value.ToString(), scanDate = Convert.ToDateTime(root.Attribute("ScanStart").Value.ToString()), projectId = Convert.ToInt64(root.Attribute("ProjectId").Value.ToString()), scanId = Convert.ToInt64(root.Attribute("ScanId").Value.ToString()), status = el.Attribute("Status").Value.ToString(), Severity = el.Attribute("Severity").Value.ToString(), state = Convert.ToInt32(el.Attribute("state").Value.ToString()) }; response.Add(isnew); } return(true); } catch (Exception ex) { Console.Error.WriteLine("Failure reading XML from scan"); Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); if (token.debug && token.verbosity > 1) { Console.Error.WriteLine("Dumping XML:"); Console.Error.Write(result.ToString()); } return(true); } }
private List <ReportResultAll> process_ScanResult(XElement result, long scanId) { List <ReportResultAll> reportResults = new List <ReportResultAll>(); try { if (result.Attribute("ScanId").Value == scanId.ToString()) { IEnumerable <XElement> lastScan = from el in result.Descendants("Query").Descendants("Result") select el; foreach (XElement el in lastScan) { XElement query = el.Parent; XElement root = query.Parent; ReportResultAll isnew = new ReportResultAll() { Query = query.Attribute("name").Value.ToString(), Group = query.Attribute("group").Value.ToString(), projectName = root.Attribute("ProjectName").Value.ToString(), presetName = root.Attribute("Preset").Value.ToString(), teamName = root.Attribute("Team").Value.ToString(), scanDate = Convert.ToDateTime(root.Attribute("ScanStart").Value.ToString()), projectId = Convert.ToInt64(root.Attribute("ProjectId").Value.ToString()), scanId = Convert.ToInt64(root.Attribute("ScanId").Value.ToString()), status = el.Attribute("Status").Value.ToString(), Severity = el.Attribute("Severity").Value.ToString(), state = Convert.ToInt32(el.Attribute("state").Value.ToString()) }; reportResults.Add(isnew); } } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); } return(reportResults); }