private static bool applyRuleToTrace(IO2Trace o2Trace, ICollection <IO2Trace> o2PartialTraces, IO2Finding parentO2Finding, List <IO2Finding> findingsCreated, IDictionary <string, List <IO2Rule> > indexedRules)
        {
//            if (o2Trace.signature.IndexOf("System.Data.SqlClient.SqlCommand") > -1)
//                DI.log.info(o2Trace.signature);
            var signatureToFind = MakeSignatureCompatibleWithOunceRules(o2Trace.signature);


            //           if (signatureToFind.IndexOf("System.Data.SqlClient") > -1)
            //               DI.log.info(signatureToFind);

            if (indexedRules.ContainsKey(signatureToFind))  // means we have a match
            {
                // rename to shouldAbortRulesCreation
                if (shouldAbortRulesExecution(indexedRules[signatureToFind]))
                {
                    if (o2Trace.traceType == TraceType.Known_Sink || o2Trace.traceType == TraceType.Lost_Sink)
                    {
                        return(false);
                    }
                    return(true);
                }
                // check if we are a sink at the root of the tree with no child nodes (and if so skip trace creation)
                if (parentO2Finding.o2Traces.Count == 0) //; && (o2Trace.traceType == TraceType.Known_Sink || o2Trace.traceType == TraceType.Lost_Sink || o2Trace.traceType == TraceType.Root_Call))
                {
                    return(true);
                }
                // check if there are no sources on the trace
                if (((O2Finding)parentO2Finding).Source == "")
                {
                    return(false);
                }

                var newTrace = OzasmtCopy.createCopy(o2Trace, false);                                                                          //create new trace (which will be modified
                newTrace.traceType = TraceType.Known_Sink;                                                                                     // make the trace  a sink
                o2PartialTraces.Add(newTrace);                                                                                                 // add it to the partial trace

                var newFindingWithSinkTrace = OzasmtCopy.createCopy(parentO2Finding);                                                          // create template finding which will be applied the rules
                findingsCreated.AddRange(FiltersUtils.applySinkRuleToFindingAndTrace(newFindingWithSinkTrace, signatureToFind, indexedRules)); // apply rules and add resulting findings to findingsCreated list
                //remove the new trace since the invokeOnAllPartialTraces loop will add its own copy
                o2PartialTraces.Remove(newTrace);
            }
            return(true); // in this case return true since we want to process ALL traces
        }
        public static List <IO2Finding> applyFilter(ICollection <IO2Finding> targetO2Findings, List <IO2Rule> o2RulesToUse)
        {
            var filterName = "BasicSinksMapping";

            DI.log.info("Applying filter {0} to {1} findings using {2} rules", filterName, targetO2Findings.Count,
                        o2RulesToUse.Count);

            var indexedRules = IndexedO2Rules.indexOnSinks(o2RulesToUse);

            // list to hold mapped findings
            var mappedFidings = new List <IO2Finding>();

            foreach (O2Finding o2Finding in targetO2Findings)
            {
                var sink = o2Finding.Sink;
                foreach (var newFinding in FiltersUtils.applySinkRuleToFindingAndTrace(o2Finding, sink, indexedRules))
                {
                    mappedFidings.Add(newFinding);
                }
            }
            DI.log.info("There were {0} findings mapped", mappedFidings.Count);
            return(mappedFidings);
        }