Example #1
0
        public static void createFindingsFromStrutsMappings(IStrutsMappings strutsMappings, ascx_FindingsViewer findingsViewer_ToLoadResults)
        {
            var createdFindings = StrutsMappingHelpers.createFindingsFromStrutsMappings(strutsMappings);

            findingsViewer_ToLoadResults.setTraceTreeViewVisibleStatus(true);
            findingsViewer_ToLoadResults.setFilter2Value("(no filter)");
            findingsViewer_ToLoadResults.loadO2Findings(createdFindings, true);
        }
Example #2
0
        public void calculateFinalResults(
            string taintSources_SourceRegEx, string taintSources_SinkRegEx, string finalSinks_SourceRegEx, string finalSinks_SinkRegEx)
        {
            if (findingsWith_BaseO2Findings == null)
            {
                findingsWith_BaseO2Findings = XUtils_Findings_v0_1.loadFindingsFile(BaseO2Findings);
            }

            // calculate TaintSources
            findingsWith_FindingsFromTaintSources = O2FindingsHelpers.calculateFindings(
                findingsWith_BaseO2Findings,
                taintSources_SourceRegEx,
                taintSources_SinkRegEx,
                XUtils_Findings_v0_1.mapJoinPoints_HashTagsOn_Sinks);

            // calculate FinalSinks
            findingsWith_FindingsToFinalSinks = O2FindingsHelpers.calculateFindings(
                findingsWith_BaseO2Findings,
                FinalSinks_SourceRegEx,
                finalSinks_SinkRegEx,
                XUtils_Findings_v0_1.mapJoinPoints_HashTagsOn_Sources);

            // calculate strutsMapping object and findings
            if (StrutsMappings == null)
            {
                StrutsMappings = (IStrutsMappings)Serialize.getDeSerializedObjectFromBinaryFile(StrutsMappingsFile, typeof(KStrutsMappings));
            }
            findingsWith_StrutsMappings = StrutsMappingHelpers.createFindingsFromStrutsMappings(StrutsMappings);

            calculateResults();

            //            results = xUtils_Findings_v0_1.mapJoinPoints_HashTagsOn_Sinks(results);


            /*runFilterFor_TaintSources(
             *  taintSources_SourceRegEx, taintSources_SinkRegEx, findingsViewer_BaseFindings.currentO2Findings,
             *  xUtils_Findings_v0_1.mapJoinPoints_HashTagsOn_Sinks, filteredFindings_TaintSources);
             * runFilterFor_FinalSinks(
             *  finalSinks_SourceRegEx, finalSinks_SinkRegEx, findingsViewer_BaseFindings.currentO2Findings,
             *  xUtils_Findings_v0_1.mapJoinPoints_HashTagsOn_Sources, filteredFindings_FinalSinks);
             *
             *
             * /*            runFilterFor_TaintSources(
             *  taintSources_SourceRegEx, taintSources_SinkRegEx, findingsViewer_BaseFindings.currentO2Findings,
             *  xUtils_Findings_v0_1.mapJoinPoints_HashTagsOn_Sinks, filteredFindings_TaintSources);
             * runFilterFor_FinalSinks(
             *  finalSinks_SourceRegEx, finalSinks_SinkRegEx, findingsViewer_BaseFindings.currentO2Findings,
             *  xUtils_Findings_v0_1.mapJoinPoints_HashTagsOn_Sources, filteredFindings_FinalSinks);
             */

            /*
             * createFindingsFromStrutsMappings(strutsMappingsControl, findingsViewer_FromStrutsMappings);
             *
             * calculateResults(strutsMappingsControl,filteredFindings_TaintSources, filteredFindings_FinalSinks, findingsViewer_FinalFindings);
             */
        }
Example #3
0
        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);
             *  }
             */
        }
Example #4
0
        private void btCreateFindingsFromStrutsMapings_Click(object sender, EventArgs e)
        {
            var strutsMappingObject = strutsMappings.getStrutsMappingObject();

            if (strutsMappingObject != null)
            {
                var createdFindings = StrutsMappingHelpers.createFindingsFromStrutsMappings(strutsMappingObject);
                findingsViewer_FromStrutsMappings.setTraceTreeViewVisibleStatus(true);
                findingsViewer_FromStrutsMappings.setFilter2Value("(no filter)");
                findingsViewer_FromStrutsMappings.loadO2Findings(createdFindings, true);
            }
        }
Example #5
0
        public void loadO2StrutsMappingFile(string fileToProcess)
        {
            var strutsMappings = StrutsMappingHelpers.loadO2StrutsMappingFile(fileToProcess);

            if (strutsMappings != null)
            {
                DI.log.info("Sucessfuly create struts mapping object from file: {0}", fileToProcess);
                refreshTreeView(strutsMappings);
            }
            else
            {
                DI.log.error("There was a problem serializing Struts Mapping object saved to: {0}", fileToProcess);
            }
        }
Example #6
0
        public void addFileToArtifactsList(string fileToLoad, Dictionary <Type, object> currentArtifacts, bool loadFileAsObject)
        {
            if (loadFileAsObject)
            {
                switch (Path.GetExtension(fileToLoad))
                {
                case ".ozasmt":
                    var o2Assessment = new O2Assessment(new O2AssessmentLoad_OunceV6(), fileToLoad);
                    addToArtifacts_Findings(o2Assessment.o2Findings, currentArtifacts);
                    return;

                case ".O2StrutsMapping":
                    var strutsMappings = StrutsMappingHelpers.loadO2StrutsMappingFile(fileToLoad);
                    addToArtifacts_Object(strutsMappings, currentArtifacts);
                    return;
                }
            }
            addFileToListString_WithLoadedArtifacts(fileToLoad, currentArtifacts);
        }