private List <IO2Finding> mapStrutsFindings(IStrutsMappings strutsMappingsObject, List <IO2Finding> o2Findings, bool createConsolidatedView) { // calculate findings from strutsMappings var strutsFindings = StrutsMappingHelpers.createFindingsFromStrutsMappings(strutsMappingsObject); // creates a dictionary with the O2JoinSinks as the key (containing a list of Findings that match that key (i.e. O2LostSink)) var joinSinksDictionary = OzasmtSearch.getDictionaryWithJoinSinks(strutsFindings); // creates a list of findings with the root node as the key (containing a list of Findings that match that key (i.e. root node)) var rootFunctions = new Dictionary <string, List <IO2Finding> >(); foreach (var o2Finding in o2Findings) { if (o2Finding.o2Traces.Count > 0) { var rootFunction = o2Finding.o2Traces[0].clazz; if (rootFunction.StartsWith("jsp_servlet")) { rootFunction = rootFunction.Replace("jsp_servlet", ""). Replace("_45_", "-"). Replace(".__", "/"). Replace("._", "/") + ".jsp"; } if (rootFunction != "") { if (false == rootFunctions.ContainsKey(rootFunction)) { rootFunctions.Add(rootFunction, new List <IO2Finding>()); } rootFunctions[rootFunction].Add(o2Finding); } } } // now map the JoinSinks with the Root Functions if (createConsolidatedView) { return(StrutsMappingHelpers.joinTracesUsingConsolidatedView(joinSinksDictionary, rootFunctions)); } return(joinTracesUsingExpandedView(o2Findings, joinSinksDictionary, rootFunctions)); /*foreach (var values in rootFunctions.Values) * foreach (var o2Finding in values) * { * var modifiedFinding = (O2Finding)OzasmtCopy.createCopy(o2Finding); * var currentSource = modifiedFinding.getSource(); * currentSource.traceType = TraceType.Type_4; * modifiedFinding.o2Traces[0].traceType = TraceType.Source; * mappedFindings.Add(modifiedFinding); * } */ }
public static List <IO2Finding> mapTextBoxWebControlsAsSinks(List <IO2Finding> findingsToMap) { var signatureToFind = "System.Web.UI.WebControls.TextBox.get_Text():string"; var results = new List <IO2Finding>(); foreach (var o2Finding in findingsToMap) { var o2Match = OzasmtSearch.findO2TraceSignature(o2Finding.o2Traces, signatureToFind); if (o2Match != null) { var variable = o2Match.context.Substring(0, o2Match.context.IndexOf(' ')); variable = variable.Replace("this->", ""); var source = OzasmtUtils.getSource(o2Finding.o2Traces); source.signature += "_" + variable; //var o2NewO2Trace = new O2Trace(variable); //o2NewO2Trace.childTraces.Add(o2Finding.o2Trace); //o2Finding.o2Trace = o2NewO2Trace; results.Add(o2Finding); } } return(results); }
private void handleDragDrop(DragEventArgs e) { var droppedObject = Dnd.tryToGetObjectFromDroppedObject(e); switch (droppedObject.GetType().Name) { case "O2Trace": var droppedTrace = (IO2Trace)droppedObject; var selectedO2Trace = o2Trace; if (selectedO2Trace == droppedTrace) { DI.log.error("on tvSmartTrace_DragDrop: It is not possible to drop a trace on it seft"); } else if (bMoveTraces && (OzasmtSearch.isO2TraceAChildTraceOfO2Trace(selectedO2Trace, droppedTrace))) { // if we draged into a parent, we need to make a copy first, then copy it then delete the original IO2Trace copiedO2Trace = OzasmtCopy.createCopy(droppedTrace); OzasmtGlue.deleteO2Trace(o2Finding.o2Traces, droppedTrace); selectedO2Trace.childTraces.Add(copiedO2Trace); } else if (bMoveTraces && OzasmtSearch.isO2TraceAChildTraceOfO2Trace(droppedTrace, selectedO2Trace)) { DI.log.error( "on tvSmartTrace_DragDrop: Could not move trace since it is not possible to drop a trace into its own child node"); } else { IO2Trace copiedO2Trace = OzasmtCopy.createCopy(droppedTrace); if (bMoveTraces) { OzasmtGlue.deleteO2Trace(o2Finding.o2Traces, droppedTrace); } selectedO2Trace.childTraces.Add(copiedO2Trace); } showO2TraceTree(); break; case "O2Finding": loadO2Finding((O2Finding)droppedObject); break; case "TreeNode": var tagObject = ((TreeNode)droppedObject).Tag; if (tagObject != null) { if (tagObject is O2Finding) { loadO2Finding((O2Finding)tagObject); } } break; } /* var droppedTrace2 = (O2Trace)Dnd.tryToGetObjectFromDroppedObject(e, typeof(O2Trace)); * if (droppedTrace2 != null) * { * * } * else * { * var droppedO2Finding = (O2Finding)Dnd.tryToGetObjectFromDroppedObject(e, typeof(O2Finding)); * if (droppedO2Finding != null) * loadO2Finding(droppedO2Finding); * else * { * droppedO2Finding = (O2Finding)Dnd.tryToGetObjectFromDroppedObject(e, typeof(TreeNode)); * * } * }*/ }