예제 #1
0
파일: viewing.cs 프로젝트: pusp/o2platform
 public static TreeNode getRootNodeToView(O2TraceBlock_OunceV6 otbO2TraceBlockOfRootNode, String sMode)
 {
     //var tnTreeNode = new TreeNode(sRootFunction);
     var tnTreeNode = new TreeNode(otbO2TraceBlockOfRootNode.sUniqueName);
     if (sMode == "Sinks")
     {
         Dictionary<AssessmentAssessmentFileFinding, O2AssessmentData_OunceV6> dSinks = otbO2TraceBlockOfRootNode.dSinks;
         foreach (AssessmentAssessmentFileFinding fFinding in dSinks.Keys)
         {
             var fviFindingViewItem = new FindingViewItem(fFinding, fFinding.vuln_name, null, dSinks[fFinding]);
             String sNodeText = analyzer.getUniqueSignature(fFinding, TraceType.Known_Sink,
                                                            dSinks[fFinding], true);
             if (sNodeText != null)
             {
                 TreeNode tnChildNode = O2Forms.newTreeNode(sNodeText, sNodeText, 0, fviFindingViewItem);
                 tnTreeNode.Nodes.Add(tnChildNode);
             }
         }
     }
     return tnTreeNode;
 }
예제 #2
0
            public static void addFindingAsGlueTrace(O2TraceBlock_OunceV6 otbO2TraceBlockOunceV6WithTracesToGlue,
                                                     AssessmentAssessmentFileFinding fFinding,
                                                     O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6, TreeView tvRawData,
                                                     bool bAddGluedTracesAsRealTraces)
            {
                String sUniqueSignature = analyzer.getUniqueSignature(fFinding, TraceType.Known_Sink,
                                                                      oadO2AssessmentDataOunceV6, true);

                var otbO2TraceBlockWithTracesToReceiveTraces = (O2TraceBlock_OunceV6) tvRawData.Nodes[sUniqueSignature].Tag;

                foreach (AssessmentAssessmentFileFinding fFindingToGlue in otbO2TraceBlockOunceV6WithTracesToGlue.dSinks.Keys)
                {
                    if (false == otbO2TraceBlockWithTracesToReceiveTraces.dGluedSinks.ContainsKey(fFindingToGlue))
                        otbO2TraceBlockWithTracesToReceiveTraces.dGluedSinks.Add(fFindingToGlue,
                                                                                 otbO2TraceBlockOunceV6WithTracesToGlue.dSinks[
                                                                                     fFindingToGlue]);
                    if (bAddGluedTracesAsRealTraces) // so that the traces show in the Raw View list
                        if (false == otbO2TraceBlockWithTracesToReceiveTraces.dSinks.ContainsKey(fFindingToGlue))
                            otbO2TraceBlockWithTracesToReceiveTraces.dSinks.Add(fFindingToGlue,
                                                                                otbO2TraceBlockOunceV6WithTracesToGlue.dSinks[
                                                                                    fFindingToGlue]);
                }
            }
예제 #3
0
파일: analyzer.cs 프로젝트: pusp/o2platform
        public static bool addCompatibleTracesToNode_recursive(TreeNode tnTargetNode, FindingViewItem fviFindingViewItem,
                                                               O2TraceBlock_OunceV6 otbO2TraceBlockOunceV6OfToProcess,
                                                               String sMode,
                                                               Dictionary<String, O2TraceBlock_OunceV6> dRawData)
                                                               //TreeView tvRawData)
        {
            //TreeNode tnParentNode = O2Forms.getRootNode(tnTargetNode);
            //int iNumberOfNodes = tnParentNode.GetNodeCount(true);
            var iNumberOfNodes = O2Forms.getRootNode(tnTargetNode).GetNodeCount(true);

            if (O2Forms.getRootNode(tnTargetNode).GetNodeCount(true) > 1500)
            {
                DI.log.info(String.Format("Max number of subnodes reached (250), aborting this root node: {0}",
                                          O2Forms.getRootNode(tnTargetNode).Text));
                return false;
            }
            if (new StackTrace().FrameCount > 50)
            {
                DI.log.info(String.Format("Max StackTrace reached (50), aborting this leaf:{0}", tnTargetNode.Text));
                return false;
            }

            var tnTreeFor_Root = new TreeNode();
            AnalysisUtils.addCallsToNode_Recursive(fviFindingViewItem.fFinding.Trace, tnTreeFor_Root,
                                                   fviFindingViewItem.oadO2AssessmentDataOunceV6,
                                                   Analysis.SmartTraceFilter.MethodName);
            if (sMode == "Sinks")
            {
                // first add the normal sinks
                foreach (AssessmentAssessmentFileFinding fFinding in otbO2TraceBlockOunceV6OfToProcess.dSinks.Keys)
                {
                    var tnTreeFor_ChildTrace = new TreeNode();
                    var fviFindingViewItemForChildTrace = new FindingViewItem(fFinding,
                                                                              fFinding.vuln_name ?? OzasmtUtils_OunceV6.getStringIndexValue(
                                                                                                        UInt32.Parse(
                                                                                                            fFinding.vuln_name_id),
                                                                                                        otbO2TraceBlockOunceV6OfToProcess.
                                                                                                            dSinks[fFinding]), null,
                                                                              otbO2TraceBlockOunceV6OfToProcess.dSinks[fFinding
                                                                                  ]);
                    AnalysisUtils.addCallsToNode_Recursive(fviFindingViewItemForChildTrace.fFinding.Trace,
                                                           tnTreeFor_ChildTrace,
                                                           fviFindingViewItemForChildTrace.oadO2AssessmentDataOunceV6,
                                                           Analysis.SmartTraceFilter.MethodName);

                    TreeNode tnRootNode_Sink = getTreeNodeOfTraceType_recursive(tnTreeFor_Root,
                                                                                TraceType.Known_Sink);
                    TreeNode tnRootNode_Source = getTreeNodeOfTraceType_recursive(tnTreeFor_ChildTrace,
                                                                                  TraceType.Source);


                    if (AreNodesCompatible(tnRootNode_Sink, tnRootNode_Source))
                    {
                        String sNodeText = getUniqueSignature(fFinding, TraceType.Known_Sink,
                                                              otbO2TraceBlockOunceV6OfToProcess.dSinks[fFinding], true);

                        // ensures we don't add the same source more that once per line (needs to be more optimized
                        List<String> ltnAllNodesAddedSofar = O2Forms.getStringListWithAllParentNodesText(tnTargetNode);
                        if (false == ltnAllNodesAddedSofar.Contains(sNodeText))
                        {
                            if (sNodeText != tnTargetNode.Text) // don't add if the child call is the same as the parent
                                tnTargetNode.Nodes.Add(O2Forms.newTreeNode(sNodeText, sNodeText, 0,
                                                                           fviFindingViewItemForChildTrace));
                            if (sNodeText == null)
                            {
                                return false;
                            }
                        }
                    }
                }
                // then add the Glued Sinks

                foreach (AssessmentAssessmentFileFinding fFinding in otbO2TraceBlockOunceV6OfToProcess.dGluedSinks.Keys)
                {
                    var fviFindingViewItemForChildTrace = new FindingViewItem(fFinding,
                                                                              fFinding.vuln_name ?? OzasmtUtils_OunceV6.getStringIndexValue(
                                                                                                        UInt32.Parse(
                                                                                                            fFinding.vuln_name_id),
                                                                                                        otbO2TraceBlockOunceV6OfToProcess.
                                                                                                            dGluedSinks[fFinding]), null,
                                                                              otbO2TraceBlockOunceV6OfToProcess.dGluedSinks[
                                                                                  fFinding]);
                    String sNodeText = getUniqueSignature(fFinding, TraceType.Known_Sink,
                                                          otbO2TraceBlockOunceV6OfToProcess.dGluedSinks[fFinding], true);
                    tnTargetNode.Nodes.Add(O2Forms.newTreeNode(sNodeText, sNodeText, 0, fviFindingViewItemForChildTrace));
                }
            }
            foreach (TreeNode tnChildNode in tnTargetNode.Nodes)
            {
                //   int iNodeCount = tnChildNode.GetNodeCount(true);
                //    DI.log.info(iNodeCount + "   " + tnChildNode.Text);
                //if (tvRawData.Nodes[tnChildNode.Text] != null)
                if (dRawData.ContainsKey(tnChildNode.Text))
                    // (now back to false) was true (check side effects)
                    if (false ==
                        addCompatibleTracesToNode_recursive(tnChildNode, (FindingViewItem) tnChildNode.Tag,
                                            dRawData[tnChildNode.Text],
                                            //                (O2TraceBlock_OunceV6) tvRawData.Nodes[tnChildNode.Text].Tag,
                                                            "Sinks", dRawData))
                                                            //tvRawData))
                        return false;
            }
            return true;
        }
예제 #4
0
파일: viewing.cs 프로젝트: pusp/o2platform
 public static List<String> GetTracesThatAreFromTheSameTraceSequence(O2TraceBlock_OunceV6 otbO2TraceBlockOunceV6Root,
                                                                     O2TraceBlock_OunceV6 otbO2TraceBlockOunceV6Child,
                                                                     String sKeyword)
 {
     var lsTracesFromSameSequence = new List<string>();
     //      TreeNode tnTreeForTrace_Root = new TreeNode();
     //      o2.analysis.Analysis.SmartTraceFilter stfSmartTraceFilter = o2.analysis.Analysis.SmartTraceFilter.MethodName;
     //            o2.analysis.Analysis.addCallsToNode_Recursive(otbO2TraceBlockOunceV6Root, tnTreeForTrace_Root, fviFindingViewItem.oadO2AssessmentDataOunceV6, stfSmartTraceFilter);
     return lsTracesFromSameSequence;
 }