public override void readTablesFromWord(string wordFile) { using (DocX document = DocX.Load(wordFile)) { string cvss = ""; if (document.Tables.Count > 0) { foreach (Novacode.Table table in document.Tables) { if (scap.myTable.containsAffectedSoftware(table.Rows[0])) { scap.myTable.setHeaderSupporteTrue(); // We are in a new Table, so we have restart the table variables extractTableContent(table); } else { if (scap.myTable.tableContainsCVEs(table.Rows[0])) { cvss += scap.myTable.getCVS(table); break; } } } } scap.set_Cvss(cvss); } }
public override void readTablesFromWeb(HtmlDocument page) { string cvss = ""; string content; if (page.DocumentNode != null) { if (page.DocumentNode.SelectNodes("//table[@class='dataTable']") != null) { foreach (HtmlNode table in page.DocumentNode.SelectNodes("//table[@class='dataTable']")) { if (table.SelectNodes("thead") != null) { HtmlNode head = table.SelectSingleNode("thead"); if (head.SelectNodes("tr") != null) { HtmlNode headRow = head.SelectSingleNode("tr"); HtmlNodeCollection headCols = headRow.SelectNodes("th"); if ((headCols.Count == 4) || (headCols.Count == 5) && (scap.myTable.isValidHeader(headCols)))//This table have 4 or 5 colums, so it is a valid table { scap.myTable.setHeaderSupporteTrue(); scap.myTable.setSystemOrComponent(headCols[0].InnerText); if (table.SelectNodes("tbody") != null) { foreach (HtmlNode body in table.SelectNodes("tbody")) { if (body.SelectNodes("tr") != null) { HtmlNode bodyRows = body.SelectSingleNode("tr"); if ((bodyRows.SelectNodes("th") != null)) { HtmlNode bodyHead = bodyRows.SelectSingleNode("th"); // we are assuming that there is gonna be only on <th> tag content = bodyHead.InnerText; scap.myTable.setSupportedHeader(content); } else { foreach (HtmlNode row in body.SelectNodes("tr")) { if (row.SelectNodes("td") != null) { HtmlNodeCollection cols = row.SelectNodes("td"); if (cols.Count == 4) // This are the only rows that we are interested in { processRowFourCols(cols); } if (cols.Count == 5) { processRowFiveCols(cols); } } } } } } } } if (table.SelectNodes("caption") != null) { HtmlNode caption = table.SelectSingleNode("caption"); if (scap.myTable.isCVEHeader(caption.InnerText)) { cvss += scap.myTable.getCVS(headCols); break; } } } } } } scap.set_Cvss(cvss); } /*if (document.Tables.Count > 0) * { * foreach (Novacode.Table table in document.Tables) * { * if (myTable.containsAffectedSoftware(table.Rows[0])) * { * extractTableContent(table); * } * else * { * if (myTable.tableContainsCVEs(table.Rows[0])) * { * cvss += myTable.getCVS(table); * break; * } * } * } * } * set_Cvss(cvss); */ }