/// <summary> /// Evaluate expression that contains a list of assignment. /// </summary> /// <param name="declaration"></param> /// <param name="state"></param> private VariableState VisitVariableDeclaration(VariableDeclaratorSyntax declaration, ExecutionState state) { VariableState lastState = new VariableState(declaration, VariableTaint.UNKNOWN); foreach (var variable in declaration.Names) { var identifier = variable.Identifier; var initializer = declaration.Initializer; if (initializer is EqualsValueSyntax) { EqualsValueSyntax equalsClause = initializer; VariableState varState = VisitExpression(equalsClause.Value, state); //varState.SetType(lastState.type); state.AddNewValue(ResolveIdentifier(identifier), varState); lastState = varState; } if (declaration.AsClause is AsNewClauseSyntax) { var newClause = (AsNewClauseSyntax)declaration.AsClause; VariableState varState = VisitExpression(newClause.NewExpression, state); state.AddNewValue(ResolveIdentifier(identifier), varState); lastState = varState; } } return(lastState); }
private VariableState VisitVariableDeclaration(VariableDeclaratorSyntax declaration, ExecutionState state) { VariableState lastState = new VariableState(declaration, VariableTaint.UNKNOWN); var identifier = declaration.GetFirstToken(); var initializer = declaration.Initializer; if (initializer is EqualsValueSyntax) { EqualsValueSyntax equalsClause = initializer; VariableState varState = VisitExpression(equalsClause.Value, state); state.AddNewValue(ResolveIdentifier(identifier), varState); lastState = varState; } return(lastState); }
/// <summary> /// Entry point that visit the method statements. /// </summary> /// <param name="node"></param> /// <param name="state"></param> /// <returns></returns> private VariableState VisitMethodDeclaration(MethodDeclarationSyntax node, ExecutionState state) { foreach (ParameterSyntax statement in node.ParameterList.Parameters) { state.AddNewValue(ResolveIdentifier(statement.Identifier), new VariableState(VariableTaint.TAINTED)); } if (node.Body != null) { foreach (StatementSyntax statement in node.Body.Statements) { VisitStatement(statement, state); } } //The state return is irrelevant because it is not use. return(new VariableState(VariableTaint.UNKNOWN)); }
/// <summary> /// Evaluate expression that contains a list of assignment. /// </summary> /// <param name="declaration"></param> /// <param name="state"></param> private VariableState VisitVariableDeclaration(VariableDeclarationSyntax declaration, ExecutionState state) { VariableState lastState = new VariableState(VariableTaint.UNKNOWN); foreach (var variable in declaration.Variables) { var identifier = variable.Identifier; var initializer = variable.Initializer; if (initializer is EqualsValueClauseSyntax) { EqualsValueClauseSyntax equalsClause = initializer; VariableState varState = VisitExpression(equalsClause.Value, state); state.AddNewValue(ResolveIdentifier(identifier), varState); lastState = varState; } } // return(lastState); }
/// <summary> /// Entry point that visit the method statements. /// </summary> /// <param name="node"></param> /// <param name="state"></param> /// <returns></returns> private VariableState VisitMethodDeclaration(MethodBlockSyntax node, ExecutionState state) { foreach (ParameterSyntax parameter in node.SubOrFunctionStatement.ParameterList.Parameters) { state.AddNewValue(ResolveIdentifier(parameter.Identifier.Identifier), new VariableState(parameter, VariableTaint.TAINTED)); } if (node.Statements != null) { foreach (StatementSyntax statement in node.Statements) { VisitNode(statement, state); foreach (var ext in extensions) { ext.VisitStatement(statement, state); } } } //The state return is irrelevant because it is not use. return(new VariableState(node, VariableTaint.UNKNOWN)); }