Пример #1
0
            public static void addVelocityMappings(TreeView tvRawData)
            {
                String  sFunctionSignature = "ModelMap.addAttribute";
                O2Timer tTimer             = new O2Timer("Adding Velocity Mappings : {0} ").start();
                Dictionary <AssessmentAssessmentFileFinding, O2AssessmentData_OunceV6> dMatches =
                    analyzer.getSinksFindingsThatMatchRegEx(tvRawData, sFunctionSignature);

                foreach (AssessmentAssessmentFileFinding fFinding in dMatches.Keys)
                {
                    // resolve addAddtibute name
                    String sSinkContext        = AnalysisUtils.getSinkContext(fFinding, dMatches[fFinding]);
                    var    fsFilteredSignature = new FilteredSignature(sSinkContext);
                    String sParameters         = fsFilteredSignature.sParameters.Replace("\"", "");
                    String sSpringParameter    = sParameters.Substring(0, sParameters.IndexOf(',')).Trim();

                    // create a unique name for it:
                    String sSink = AnalysisUtils.getSink(fFinding, dMatches[fFinding]);
                    // String sSinkWithAttributeName = sSink.Replace("(", "_" + sSpringParameter + "(");
                    String sVelocityMapping = String.Format("{0}            0", sSink);

                    TreeNode tnVelocityNode = tvRawData.Nodes[sSink];
                    if (tnVelocityNode != null)
                    {
                        var otbO2TraceBlockWithVelocityMappings = (O2TraceBlock_OunceV6)tnVelocityNode.Tag;

                        String sUniqueSignature = analyzer.getUniqueSignature(fFinding, TraceType.Known_Sink,
                                                                              dMatches[fFinding], true);
                        var otbO2TraceBlockToAddVelocityMappings = (O2TraceBlock_OunceV6)tvRawData.Nodes[sUniqueSignature].Tag;
                        //   sUniqueSignature = sUniqueSignature.Replace("_" + sSpringParameter + "(", "(");
                        //  O2TraceBlock_OunceV6 otbO2TraceBlockToAddVelocityMappings = (O2TraceBlock_OunceV6)tvRawData.Nodes[sUniqueSignature].Tag;

                        if (otbO2TraceBlockWithVelocityMappings.dSinks.Count > 1)
                        {
                        }

                        foreach (
                            AssessmentAssessmentFileFinding fVelocityFinding in
                            otbO2TraceBlockWithVelocityMappings.dSinks.Keys)
                        {
                            if (false == otbO2TraceBlockToAddVelocityMappings.dGluedSinks.ContainsKey(fVelocityFinding))
                            {
                                otbO2TraceBlockToAddVelocityMappings.dGluedSinks.Add(fVelocityFinding,
                                                                                     otbO2TraceBlockWithVelocityMappings
                                                                                     .dSinks[fVelocityFinding]);
                            }
                            if (false == otbO2TraceBlockToAddVelocityMappings.dSinks.ContainsKey(fVelocityFinding))
                            {
                                otbO2TraceBlockToAddVelocityMappings.dSinks.Add(fVelocityFinding,
                                                                                otbO2TraceBlockWithVelocityMappings.
                                                                                dSinks[fVelocityFinding]);
                            }
                        }
                    }
                }
            }
Пример #2
0
            public static void findSpringAttributes(TreeView tvRawData)
            {
                String  sFunctionSignature = "ModelMap.addAttribute";
                O2Timer tTimer             = new O2Timer("Resolving attribute based function: {0} ").start();

                Dictionary <AssessmentAssessmentFileFinding, O2AssessmentData_OunceV6> dMatches =
                    analyzer.getSinksFindingsThatMatchRegEx(tvRawData, sFunctionSignature);

                foreach (AssessmentAssessmentFileFinding fFinding in dMatches.Keys)
                {
                    // resolve addAddtibute name
                    String sSinkContext        = AnalysisUtils.getSinkContext(fFinding, dMatches[fFinding]);
                    var    fsFilteredSignature = new FilteredSignature(sSinkContext);
                    String sParameters         = fsFilteredSignature.sParameters.Replace("\"", "");
                    String sSpringParameter    = sParameters.Substring(0, sParameters.IndexOf(',')).Trim();

                    // create a unique name for it:
                    String sSink = AnalysisUtils.getSink(fFinding, dMatches[fFinding]);
                    String sSinkWithAttributeName = sSink.Replace("(", "_" + sSpringParameter + "(");
                    // make sure we have not added this already
                    if (sSink.IndexOf(sSpringParameter) == -1)
                    {
                        //     String sSinkWithAttributeName = sSink.Replace("(", "_" + sSpringParameter + "(");
                        //      String sSinkWithAttributeName = sSpringParameter;
                        String sUniqueSignature = analyzer.getUniqueSignature(fFinding, TraceType.Known_Sink,
                                                                              dMatches[fFinding], true);
                        var otbO2TraceBlockOfThisFinding = (O2TraceBlock_OunceV6)tvRawData.Nodes[sUniqueSignature].Tag;

                        CallInvocation ciCallInvocation =
                            AnalysisSearch.findTraceTypeInSmartTrace_Recursive_returnCallInvocation(
                                fFinding.Trace, TraceType.Known_Sink);
                        UInt32 uNewId = OzasmtUtils_OunceV6.addTextToStringIndexes(sSinkWithAttributeName,
                                                                                   dMatches[fFinding].arAssessmentRun);
                        ;
                        ciCallInvocation.sig_id = uNewId;
                        DI.log.debug(" Found spring attribute '{0}' on sinks and modified to {1}", sSpringParameter,
                                     sSinkWithAttributeName);
                        //o2.analysis.Analysis.getSink(fFinding, dMatches[fFinding]));
                        otbO2TraceBlockOfThisFinding.sSignature  = sSinkWithAttributeName;
                        otbO2TraceBlockOfThisFinding.sUniqueName = analyzer.getUniqueSignature(fFinding,
                                                                                               TraceType.
                                                                                               Known_Sink,
                                                                                               dMatches[fFinding], true);

                        List <O2TraceBlock_OunceV6> lotbO2TraceBlockWithVelocityMappings =
                            analyzer.getO2TraceBlocksThatMatchSignature(sSinkWithAttributeName, tvRawData);


/*                        String sVelocityMapping = String.Format("{0}            0", sSinkWithAttributeName);
 *                      TreeNode tnVelocityNode = tvRawData.Nodes[sVelocityMapping];
 *                      if (tnVelocityNode != null)
 */
                        foreach (
                            O2TraceBlock_OunceV6 otbO2TraceBlockWithVelocityMappings in lotbO2TraceBlockWithVelocityMappings)
                        {
                            if (otbO2TraceBlockWithVelocityMappings.sFile.IndexOf(".vm") > -1)
                            {
                                //O2TraceBlock_OunceV6 otbO2TraceBlockWithVelocityMappings = (O2TraceBlock_OunceV6)tnVelocityNode.Tag;
                                foreach (
                                    AssessmentAssessmentFileFinding fVelocityFinding in
                                    otbO2TraceBlockWithVelocityMappings.dSinks.Keys)
                                {
                                    if (false == otbO2TraceBlockOfThisFinding.dGluedSinks.ContainsKey(fVelocityFinding))
                                    {
                                        otbO2TraceBlockOfThisFinding.dGluedSinks.Add(fVelocityFinding,
                                                                                     otbO2TraceBlockWithVelocityMappings
                                                                                     .dSinks[fVelocityFinding]);
                                    }
                                    if (false == otbO2TraceBlockOfThisFinding.dSinks.ContainsKey(fVelocityFinding))
                                    {
                                        otbO2TraceBlockOfThisFinding.dSinks.Add(fVelocityFinding,
                                                                                otbO2TraceBlockWithVelocityMappings.
                                                                                dSinks[fVelocityFinding]);
                                    }
                                }
                            }
                        }
                    }
                }
                tTimer.stop();
            }