Пример #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Taint != null ? Taint.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (StorageName != null ? StorageName.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #2
0
        public override string ToString()
        {
            var taintBits = Taint & Safe;

            if (taintBits != 0ul && taintBits != Safe)
            {
                return($"{(Taint & ~Safe).ToString()} | {((ulong)taintBits).ToString()}");
            }

            return(Taint.ToString());
        }
Пример #3
0
 public bool equalTo(Taint other)
 {
     return(other.HTML == HTML && other.SQL == SQL && other.FilePath == FilePath);
 }
 public override string ToString()
 {
     return(Taint.ToString());
 }
Пример #5
0
        /// <summary>
        /// Merges multiple taint information into one.
        /// </summary>
        /// <param name="values">info values with taint information</param>
        /// <param name="nullValue">indicator of null flow</param>
        /// <returns>merged taint information</returns>
        private TaintInfo mergeTaint(List <ValueInfo> values, bool nullValue)
        {
            TaintInfo info = new TaintInfo();

            info.point = _currentPoint;
            TaintPriority    priority            = new TaintPriority(true);
            List <TaintInfo> processedTaintInfos = new List <TaintInfo>();

            //if _currentPoint is a ConcatExPoint, its priority is high whenever one of the values has high priority
            if (_currentPoint is ConcatExPoint)
            {
                priority.setAll(false);
            }
            Taint taint          = new Taint(false);
            bool  existsNullFlow = false;
            bool  existsFlow     = false;
            bool  tainted        = false;

            foreach (var pair in values)
            {
                existsFlow |= (pair.values.Count > 0);
                foreach (var infoValue in pair.values)
                {
                    if (infoValue is UndefinedValue)
                    {
                        continue;
                    }
                    if (!(infoValue is InfoValue <TaintInfo>))
                    {
                        continue;
                    }
                    TaintInfo varInfo = (((InfoValue <TaintInfo>)infoValue).Data);
                    if (processedTaintInfos.Contains(varInfo))
                    {
                        continue;
                    }
                    processedTaintInfos.Add(varInfo);
                    existsNullFlow |= varInfo.nullValue;
                    tainted        |= varInfo.tainted;

                    /* If _currentPoint is not ConcatExPoint, the priority is low whenever one of the values
                     * has a low priority.
                     * If _currentPoint is ConcatExPoint, the priority is high whenever one of the values has
                     * a high priority */
                    if (!(_currentPoint is ConcatExPoint))
                    {
                        priority.copyTaint(false, varInfo.priority);
                    }
                    if (_currentPoint is ConcatExPoint)
                    {
                        priority.copyTaint(true, varInfo.priority);
                    }

                    taint.copyTaint(true, varInfo.taint);

                    info.possibleTaintFlows.Add(new TaintFlow(varInfo, pair.variable));
                }
            }

            info.nullValue = existsNullFlow;
            info.tainted   = tainted;

            if (!existsFlow)
            {
                priority.setAll(false);
            }

            if (nullValue && !existsNullFlow)
            {
                if (!existsFlow)
                {
                    priority.setAll(true);
                }
                info.nullValue = true;
                info.tainted   = true;
            }

            info.priority = priority;
            info.taint    = taint;
            return(info);
        }