Exemple #1
0
        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);
                }
            }
        }