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