Example #1
0
 /// <summary>
 /// Crease new instance of method info
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="className">Class name</param>
 /// <param name="visibility">Visibility</param>
 /// <param name="method">Modeled method analyzer</param>
 /// <param name="args">Method arguments</param>
 /// <param name="isFinal">Final indicator</param>
 /// <param name="isStatic">Static indicator</param>
 /// <param name="isAbstract">Abstract indicator</param>
 public MethodInfo(Name name, QualifiedName className, Visibility visibility, NativeAnalyzerMethod method, List <MethodArgument> args, bool isFinal = false, bool isStatic = false, bool isAbstract = false)
 {
     Name       = name;
     Method     = method;
     IsFinal    = isFinal;
     IsStatic   = isStatic;
     Visibility = visibility;
     Arguments  = new ReadOnlyCollection <MethodArgument>(args);
     IsAbstract = isAbstract;
     ClassName  = className;
 }
Example #2
0
 /// <summary>
 /// Adds concrete functions implemented in this class to the the dictionary of concrete native functions.
 ///
 /// Note that all functions that have concrete implementation have to be also type-modeled.
 /// </summary>
 /// <param name="typeModeledFunctions">The dictionary of type-modeled native functions.</param>
 /// <param name="concreteFunctions">
 /// (output parameter) the dictionary of concrete native functions
 /// to which functions implemented in this class will be added.
 /// </param>
 public static void AddConcreteFunctions(
     Dictionary <QualifiedName, List <NativeFunction> > typeModeledFunctions,
     Dictionary <QualifiedName, NativeAnalyzerMethod> concreteFunctions)
 {
     foreach (var methodName in functions.Keys)
     {
         var qualifiedName = new QualifiedName(new Name(methodName));
         var analyzer      = new ConcreteFunctionAnalyzerHelper(typeModeledFunctions[qualifiedName],
                                                                functions[methodName]);
         var method = new NativeAnalyzerMethod(analyzer.analyze);
         concreteFunctions.Add(qualifiedName, method);
     }
 }
Example #3
0
        /// <summary>
        /// If function is a reporting function, a warning might be created.
        /// </summary>
        /// <param name="p">program point with a function</param>
        /// <param name="taintInfo">TaintInfo that is being sanitized</param>
        private void warningsReportingFunct(NativeAnalyzerPoint p, TaintInfo taintInfo)
        {
            NativeAnalyzerMethod method    = p.Analyzer.Method;
            QualifiedName        functName = getMethodName(p);

            functAnalyzer = NativeFunctionAnalyzer.CreateInstance();

            List <FlagType> flags;

            if (functAnalyzer.ReportingFunctions.TryGetValue(functName, out flags))
            {
                createWarnings(p, taintInfo, flags);
            }
        }
Example #4
0
        /// <summary>
        /// If the function is a sanitizer, the sanitized taint flows are removed
        /// </summary>
        /// <param name="p">program point with a function</param>
        /// <param name="taintInfo">TaintInfo that is being sanitized</param>
        private void sanitize(NativeAnalyzerPoint p, ref TaintInfo taintInfo)
        {
            NativeAnalyzerMethod method    = p.Analyzer.Method;
            QualifiedName        functName = getMethodName(p);

            functAnalyzer = NativeFunctionAnalyzer.CreateInstance();

            List <FlagType> flags;

            if (functAnalyzer.SanitizingFunctions.TryGetValue(functName, out flags))
            {
                taintInfo.setSanitized(flags);
            }
        }
Example #5
0
 private static MethodInfo method(string name, NativeAnalyzerMethod analyzer)
 {
     return(new MethodInfo(new Name(name), new QualifiedName(new Name("NativeType")), Visibility.PUBLIC, analyzer, new List <MethodArgument>()));
 }
Example #6
0
        private static MethodInfo method(string name, NativeAnalyzerMethod analyzer)
        {
            var exceptionIdentifier = new QualifiedName(new Name("Exception"));

            return(new MethodInfo(new Name(name), exceptionIdentifier, Visibility.PUBLIC, analyzer, new List <MethodArgument>()));
        }
Example #7
0
 /// <summary>
 /// Create NativeAnalyzer with specified method
 /// </summary>
 /// <param name="method">Method which is invoked via native analyzer</param>
 /// <param name="invokingElement">Element which caused invoking of this analyzer - is used for sharing position</param>
 public NativeAnalyzer(NativeAnalyzerMethod method, LangElement invokingElement)
     : base(invokingElement.Position)
 {
     InvokingElement = invokingElement;
     Method          = method;
 }