Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cyberark empty cve_id fix #189

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ public CyberArkRootParser() {
* is inside that cell
* @return - text inside cell
*/
private String getCellValue(Element row, String colIdentifier) {
private String getCellValue(Element row, int colIndex) {
// each cell contains a span that references the column it is in
Element cell = row.children().select("td:contains(" + colIdentifier + ")").first();
Element cell = row.children().get(colIndex);
if (cell == null) return "";
String cellText = cell.text();
String[] valueSplit = cellText.split(colIdentifier);
// 1 or less in split means there is no value inside this table cell
if (valueSplit.length > 1)
return valueSplit[1].trim();
return "";
return cell.text();
// String cellText = cell.text();
// String[] valueSplit = cellText.split(colIdentifier);
// // 1 or less in split means there is no value inside this table cell
// if (valueSplit.length > 1)
// return valueSplit[1].trim();
// return "";
}

/**
Expand All @@ -61,17 +62,24 @@ public List<RawVulnerability> parseWebPage(String sSourceURL, String sCVEContent
Element tableBody = table.children().select("tbody").first();
if (tableBody == null) return vulnList;
Elements rows = tableBody.children();

int i = 0;
for (Element row : rows) {
i++;
// get CVE ID from row
String cveId = getCellValue(row, "CVE:");
String cveId = getCellValue(row, 2);

// if the cve id is invalid, don't use
if (getCVEs(cveId).isEmpty()) {
continue;
}

// get date from row
String date = getCellValue(row, "Date:");
String date = getCellValue(row, 8);
// have our description be a combination of
// Vendor, Product, and CWE columns
String vendor = getCellValue(row, "Vendor:");
String product = getCellValue(row, "Product:");
String cwe = getCellValue(row, "Vulnerability Type / CWE:");
String vendor = getCellValue(row, 3);
String product = getCellValue(row, 4);
String cwe = getCellValue(row, 5);
String description = vendor + " " + product + " " + cwe;

vulnList.add(new RawVulnerability(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void testCyberArkRootParser() {
"https://labs.cyberark.com/cyberark-labs-security-advisories/",
html
);
assertEquals(132, list.size());
assertEquals(129, list.size());
RawVulnerability vuln = getVulnerability(list, "CVE-2022-23774");
assertNotNull(vuln);
assertTrue(vuln.getDescription().contains("Docker"));
Expand Down
Loading
Loading