Exemplo n.º 1
0
        /// <summary>
        /// Generates the warnings output.
        /// </summary>
        /// <typeparam name="T">Type of the warning</typeparam>
        /// <param name="output">The output.</param>
        /// <param name="warnings">The warnings.</param>
        /// <param name="headLine">The head line.</param>
        /// <param name="displayTaintFlows">if set to <c>true</c> the display taint flows.</param>
        public void GenerateWarningsOutput <T>(OutputBase output, IReadOnlyCollection <T> warnings, string headLine, bool displayTaintFlows = false) where T : AnalysisWarning
        {
            output.line();
            output.Headline(headLine);
            if (warnings.Count == 0)
            {
                output.line();
                output.comment("No warnings");
                output.line();
            }
            string fileName = "/";
            bool   dedent   = false;

            foreach (var s in warnings)
            {
                if (fileName != s.FullFileName)
                {
                    if (dedent)
                    {
                        output.Dedent();
                    }
                    output.line();
                    fileName = s.FullFileName;
                    output.head2("File: " + fileName);

                    output.Indent();
                    dedent = true;

                    output.line();
                    output.line();
                }
                output.variableInfoLine(s.ToString());
                output.Indent();
                output.line();
                output.hint("Called from: ");
                output.comment(s.ProgramPoint.OwningPPGraph.Context.ToString());
                if (s is AnalysisTaintWarning && displayTaintFlows)
                {
                    output.line();
                    output.hint("Taint propagation: ");
                    output.Indent();
                    output.line();
                    output.comment(((AnalysisTaintWarning)(object)s).TaintFlow);
                    output.Dedent();
                }
                output.Dedent();

                output.line();
            }

            if (dedent)
            {
                output.Dedent();
            }
            output.line();
        }
Exemplo n.º 2
0
        private void createObjectsRepresentation()
        {
            createObjectMapping();

            foreach (var item in snapshot.Structure.Readonly.ObjectDescriptors)
            {
                ObjectValue       objectValue = item.Key;
                IObjectDescriptor descriptor  = item.Value;

                output.line();
                output.variable(objectValue.ToString());
                output.line();

                output.hint("Object type: ");
                if (descriptor.Type != null)
                {
                    output.info(descriptor.Type.QualifiedName.ToString());
                }
                else
                {
                    output.error("Object has no type");
                }
                output.line();

                output.hint("Parent indexes: ");
                List <MemoryIndex> indexes;
                if (objects.TryGetValue(objectValue, out indexes))
                {
                    foreach (MemoryIndex index in indexes)
                    {
                        output.variable(index.ToString());
                        output.info(", ");
                    }
                }
                else
                {
                    output.error("Object not referenced");
                }

                output.Indent();
                output.line();

                createRepresentation(item.Value);

                output.Dedent();
                output.line();
            }
        }