Пример #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);
        }
        /// <summary>
        /// This is the isHotfix method.
        /// It is used to determine a given entry is a hotfix finding or not.
        /// </summary>
        /// <param name="entry">The DataEntry</param>
        /// <returns>true if the given entry is a hotfix finding, false otherwise</returns>
        public static bool isHotfix(DataEntry entry)
        {
            String tempPluginName = entry.getPluginName();

            // here only plugin name starts with "MSXX-XXX" (X = 0-9)
            // are considered as hotfix finding
            if (tempPluginName.Length >= 9 &&
                tempPluginName[0] == 'M' &&
                tempPluginName[1] == 'S' &&
                tempPluginName[2] >= '0' && tempPluginName[2] <= '9' &&
                tempPluginName[3] >= '0' && tempPluginName[3] <= '9' &&
                tempPluginName[4] == '-' &&
                tempPluginName[5] >= '0' && tempPluginName[5] <= '9' &&
                tempPluginName[6] >= '0' && tempPluginName[6] <= '9' &&
                tempPluginName[7] >= '0' && tempPluginName[7] <= '9' &&
                (tempPluginName[8] == ' ' || tempPluginName[8] == ':')
                )
            {
                // check the pluginName contains "KBXXXXXX" (X = 0-9) or
                // other possibilities
                if (tempPluginName.Contains('(') && tempPluginName.Contains(')'))
                {
                    String kbString = tempPluginName.Substring(tempPluginName.LastIndexOf('('));

                    if (kbString[kbString.Length - 1] == ')')
                    {
                        String tempString = "";

                        int counter = 0;
                        for (int i = 1; i < kbString.Length - 1; i++)
                        {
                            if (!(kbString[i] >= '0' && kbString[i] <= '9'))
                            {
                                tempString += kbString[i];
                            }
                            else
                            {
                                counter++;
                            }
                        }

                        if (tempString == "KB" || String.IsNullOrEmpty(tempString))
                        {
                            if (tempPluginName[8] == ':')
                            {
                                tempPluginName = tempPluginName.Substring(0, 8) + tempPluginName.Substring(9);
                                entry.setPluginName(tempPluginName);
                            }
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Пример #3
0
 private DataEntry.EntryType getEntryType(Dictionary <int, DataEntry> risk, DataEntry entry)
 {
     foreach (DataEntry tempEntry in risk.Values)
     {
         if (tempEntry.getIp() == entry.getIp() &&
             tempEntry.getPluginName() == entry.getPluginName() &&
             tempEntry.getDescription() == entry.getDescription() &&
             tempEntry.getImpact() == entry.getImpact() &&
             tempEntry.getCve() == entry.getCve() &&
             tempEntry.getBid() == entry.getBid() &&
             tempEntry.getOsvdb() == entry.getOsvdb() &&
             tempEntry.getRiskFactor() == entry.getRiskFactor())
         {
             return(tempEntry.getEntryType());
         }
     }
     return(DataEntry.EntryType.NULL);
 }
        public static bool isHotfix(DataEntry entry)
        {
            String tempPluginName = entry.getPluginName();

            return(false);
        }