public void guiAddEntry(DataEntry entry) { Dictionary <int, DataEntry> targetHashMap = null; switch (entry.getRiskFactor()) { case RiskFactor.HIGH: targetHashMap = highRisk; break; case RiskFactor.MEDIUM: targetHashMap = mediumRisk; break; case RiskFactor.LOW: targetHashMap = lowRisk; break; case RiskFactor.NONE: targetHashMap = noneRisk; break; case RiskFactor.OPEN: targetHashMap = openPort; break; } // Change risk stat foreach (String ip in entry.getIpList()) { if (ip.Contains(",")) { String[] ipList = ip.Split(','); for (int i = 0; i < ipList.Length; i++) { String tempString = ""; foreach (char c in ipList[i]) { if (c != ' ') { tempString += c; } } ipList[i] = tempString; } foreach (String s in ipList) { riskStats.add(s, entry.getRiskFactor()); } } else { riskStats.add(ip, entry.getRiskFactor()); } } //Add ReportItem entry to hashmap (dictionary) targetHashMap.Add(targetHashMap.Count, entry); }
private bool isDuplicate(Dictionary <int, DataEntry> risk, DataEntry entry) { foreach (KeyValuePair <int, DataEntry> keyValuePair in risk) { DataEntry tempEntry = keyValuePair.Value; if (entry.getRiskFactor() != RiskFactor.OPEN) { if (tempEntry.getIp() == entry.getIp() && tempEntry.getPluginName() == entry.getPluginName() && tempEntry.getDescription() == entry.getDescription() && tempEntry.getReferenceLink() == entry.getReferenceLink()) { return(true); } else if (tempEntry.getPluginName() == entry.getPluginName() && tempEntry.getDescription() == entry.getDescription() && tempEntry.getReferenceLink() == entry.getReferenceLink()) { List <String> ips = entry.getIpList(); foreach (String ip in ips) { tempEntry.addIp(ip); } return(true); } } else { if (tempEntry.getRiskFactor() != RiskFactor.OPEN) { return(false); } else { List <String> ips = tempEntry.getIpList(); foreach (String ip in ips) { if (ip == entry.getIp()) { String tempDescription = tempEntry.getDescription(); String[] tempSplitter = { ", " }; String[] descriptionList = entry.getDescription().Split(tempSplitter, StringSplitOptions.None); foreach (String description in descriptionList) { if (!tempDescription.Contains(description)) { tempDescription += ", " + description; } } tempEntry.setDescription(tempDescription); return(true); } } } } } return(false); }
public void nessusAddEntry(int pluginId, String ip, DataEntry entry) { Dictionary <int, DataEntry> targetHashMap = null; switch (entry.getRiskFactor()) { case RiskFactor.HIGH: targetHashMap = highRisk; break; case RiskFactor.MEDIUM: targetHashMap = mediumRisk; break; case RiskFactor.LOW: targetHashMap = lowRisk; break; case RiskFactor.NONE: targetHashMap = noneRisk; break; case RiskFactor.OPEN: targetHashMap = openPort; break; } // Change risk stat riskStats.add(ip, entry.getRiskFactor()); // Add ReportItem entry to hashmap (Dictionary) if (entry.getRiskFactor() != RiskFactor.OPEN) { if (targetHashMap.ContainsKey((int)pluginId)) { targetHashMap[pluginId].addIp(ip); } else { targetHashMap[pluginId] = entry; } } // Add Open Port entry to hashmap (Dictionary) else { bool isDuplicate = false; foreach (KeyValuePair <int, DataEntry> keyValuePair in targetHashMap) { DataEntry tempEntry = keyValuePair.Value; List <String> ipList = tempEntry.getIpList(); foreach (String s in ipList) { if (s == entry.getIp()) { tempEntry.setDescription(tempEntry.getDescription() + ", " + entry.getDescription()); isDuplicate = true; break; } } if (isDuplicate) { break; } } if (!isDuplicate) { targetHashMap.Add(targetHashMap.Count, entry); } } }