示例#1
0
        private ExpressionInfo AnalyzeSubnode(XmlNode node)
        {
            switch (node.LocalName)
            {
                case AstConstants.Subnodes.Cond:
                    return Subnode_Cond(node);
                case AstConstants.Subnodes.Else:
                case AstConstants.Subnodes.Var:
                    return Subnode_WithNode(node);
                case AstConstants.Subnodes.ValueVar:
                case AstConstants.Subnodes.KeyVar:
                case AstConstants.Subnodes.Expr:
                case AstConstants.Subnodes.If:
                    return Subnode_WithNodeOrScalar(node);
                case AstConstants.Subnodes.Exprs:
                    return Subnode_Exprs(node);
                case AstConstants.Subnodes.Value:
                    return Subnode_Value(node);
                case AstConstants.Subnodes.Key:
                    return Subnode_Key(node);
                case AstConstants.Subnodes.Loop:
                case AstConstants.Subnodes.Init:
                    return Subnode_Init(node);

                case AstConstants.Subnodes.Left:
                case AstConstants.Subnodes.Right:
                    return Analyze(node.GetSubNodesByPrefix(AstConstants.Node).Single());

                case AstConstants.Subnodes.Adaptions:
                case AstConstants.Subnodes.Args:
                case AstConstants.Subnodes.ByRef:
                case AstConstants.Subnodes.Cases:
                case AstConstants.Subnodes.Catches:
                case AstConstants.Subnodes.Class:
                case AstConstants.Subnodes.Consts:
                case AstConstants.Subnodes.Declares:
                case AstConstants.Subnodes.Default:
                case AstConstants.Subnodes.Dim:
                case AstConstants.Subnodes.Extends:
                case AstConstants.Subnodes.FinallyStmts:
                case AstConstants.Subnodes.Implements:
                case AstConstants.Subnodes.InsteadOf:
                case AstConstants.Subnodes.Items:
                case AstConstants.Subnodes.Method:
                case AstConstants.Subnodes.Name:
                case AstConstants.Subnodes.NewModifier:
                case AstConstants.Subnodes.NewName:
                case AstConstants.Subnodes.Num:
                case AstConstants.Subnodes.Params:
                case AstConstants.Subnodes.Parts:
                case AstConstants.Subnodes.Props:
                case AstConstants.Subnodes.Remaining:
                case AstConstants.Subnodes.ReturnType:
                case AstConstants.Subnodes.Static:
                case AstConstants.Subnodes.Stmts:
                case AstConstants.Subnodes.Trait:
                case AstConstants.Subnodes.Traits:
                case AstConstants.Subnodes.Type:
                case AstConstants.Subnodes.Unpack:
                case AstConstants.Subnodes.Uses:
                case AstConstants.Subnodes.Variadic:
                case AstConstants.Subnodes.Vars:

                    throw new NotImplementedException("Unknown AST subnode. Was " + node.LocalName);
                default:
                    throw new NotImplementedException("Unknown AST subnode. Was " + node.LocalName);
            }
        }
示例#2
0
 private ExpressionInfo Subnode_WithNode(XmlNode node)
 {
     return Analyze(node.GetSubNodesByPrefix(AstConstants.Node).Single());
 }
示例#3
0
        private ExpressionInfo Subnode_WithNodeOrScalar(XmlNode node)
        {
            var subnodes = node.GetSubNodesByPrefix(AstConstants.Node);
            if (subnodes.Any())
            {
                return Analyze(subnodes.Single());
            }

            // Expr can contain a <scalar:null> rather than an expression.
            // in that case, there is no taint.
            return new ExpressionInfo();
        }
示例#4
0
 private ExpressionInfo Subnode_Key(XmlNode node)
 {
     var subNode = node.GetSubNodesByPrefix(AstConstants.Node);
     if (subNode.Any())
     {
         return AnalyzeNode(subNode.Single());
     }
     return new ExpressionInfo();
 }
示例#5
0
        private ExpressionInfo Subnode_Cond(XmlNode node)
        {
            var subNodes = node.GetSubNodesByPrefix(AstConstants.Node);

            return subNodes.Any() ? Analyze(subNodes.Single()) : new ExpressionInfo();
        }
示例#6
0
        private VariableResolveResult GetVariable(XmlNode node)
        {
            switch (node.Name)
            {
                case AstConstants.Node + ":" + AstConstants.Nodes.Expr_Variable:
                    return Node_Expr_Variable(node);
                case AstConstants.Node + ":" + AstConstants.Nodes.Expr_StaticPropertyFetch:
                    return Node_Expr_StaticPropertyFetch(node);
                case AstConstants.Node + ":" + AstConstants.Nodes.Expr_PropertyFetch:
                    return Node_Expr_PropertyFetch(node);
                case AstConstants.Node + ":" + AstConstants.Nodes.Expr_ArrayDimFetch:
                    return Node_Expr_ArrayDimFetch(node);

                // Subnodes
                case AstConstants.Subnode + ":" + AstConstants.Subnodes.Var:
                    return GetVariable(node.GetSubNodesByPrefix(AstConstants.Node).Single());
            }
            return new VariableResolveResult(new Variable("$UNKNOWN$", VariableScope.Unknown), true);
        }
示例#7
0
        private TaintSets Node_Cond(XmlNode node)
        {
            isConditional = true;

            _variables.Add(EdgeType.False, _variables[EdgeType.Normal].AssignmentClone());
            _variables.Add(EdgeType.True, _variables[EdgeType.Normal].AssignmentClone());
            _variables.Remove(EdgeType.Normal);

            var subnodes = node.GetSubNodesByPrefix(AstConstants.Node);
            return subnodes.Any() ? AnalyzeNode(subnodes.Single()) : new TaintSets().ClearTaint();
        }
示例#8
0
 private TaintSets AnalyzeSubnode(XmlNode node)
 {
     switch (node.LocalName)
     {
         case AstConstants.Subnodes.Cond:
             return Node_Cond(node);
         default:
             var subNodes = node.GetSubNodesByPrefix(AstConstants.Node);
             if (subNodes.Any())
             {
                 return AnalyzeNode(subNodes.Single());
             }
             return new TaintSets().ClearTaint();
     }
 }