Exemplo n.º 1
0
        public static List <IO2Finding> loadFindingsFile(string fileToLoad)
        {
            var o2Assessment = new O2Assessment(new O2AssessmentLoad_OunceV6(), fileToLoad);

            log.info("there are {0} findings loaded in this file", o2Assessment.o2Findings.Count);
            return(o2Assessment.o2Findings);
        }
Exemplo n.º 2
0
        public static string sayHelloO2World()
        {
            string message = string.Format("Hello O2 World");

            log.info(message);
            return(message);
        }
        public static void closeAppDomain(AppDomain appDomain, bool deleteFilesInBaseDirectory)
        {
            log.info("Unloading AppDomain:{0}", appDomain.FriendlyName);
            string baseDirectory = appDomain.BaseDirectory;

            AppDomain.Unload(appDomain);
            if (deleteFilesInBaseDirectory)
            {
                log.info("Deleting all files from AppDomain BaseDirectory : {0}", baseDirectory);
                Directory.Delete(baseDirectory, true);
            }
        }
        public string compileFileToExe()
        {
            var assembly = new  CompileEngine().compileSourceFiles(new List <string> {
                scriptToInstrument
            }, "O2_Scanner_DotNet._TestScripts.TestScript_MultipleCalls");

            Assert.That(assembly != null);
            Assert.That(Path.GetExtension(assembly.Location) == ".exe");
            log.debug("File Successfully compiled: {0}", assembly.Location);
            log.info("compileFileToExe executed ok");
            return(assembly.Location);
        }
Exemplo n.º 5
0
        public static void processStrutsFiles(string testStrutsConfigXmlFile, string testValidationXmlFile)
        {
            var strutsConfig = (strutsconfig)Serialize.getDeSerializedObjectFromXmlFile(testStrutsConfigXmlFile, typeof(strutsconfig));
            var validation   = (formvalidation)Serialize.getDeSerializedObjectFromXmlFile(testValidationXmlFile, typeof(formvalidation));

            //listFormBeans(strutsConfig);
            var mappedFormFields = calculateMappedFormFields(strutsConfig, validation);

            showMappedFormFields(mappedFormFields);
            showInGuiMappedFormFields(mappedFormFields);
            log.info("all done....");
        }
 public static void filterFindings_usingForEachLoop()
 {
     string message = string.Format("Hello O2 World");
     var o2Assessment = new O2Assessment(new O2AssessmentLoad_OunceV6(), ozasmtFileToLoad);
     log.info("Assessment file loaded with {0} findings", o2Assessment.o2Findings.Count);
     var results = new List<IO2Finding>();
     foreach (O2Finding o2Finding in o2Assessment.o2Findings)
         if (o2Finding._SinkToSource.IndexOf("Attribute") > -1)
             results.Add(o2Finding);
     log.info("There are {0} findings that match filter", results.Count);
     var newAssessmentFile = new O2Assessment(results);
     var savedFile = newAssessmentFile.save(new O2AssessmentSave_OunceV6());
     log.info("Filtered results saved to: {0}", savedFile);
     ascx_FindingsViewer.openInFloatWindow(results.ToList());
 }
Exemplo n.º 7
0
        // this test expects that there is a current ascx_XRules_Editor loaded in the current GUI
        public void addTextBoxToPanel()
        {
            log.info("in  addTextBoxToPanel");
            var xrulesControl = (ascx_XRules_Editor)O2AscxGUI.getAscx("XRules Editor");

            Assert.That(xrulesControl != null);
            Assert.That(O2Forms_ThreadSafe_ToolStrip.hasToolStripControl(xrulesControl), "xrulesControl control did not contain a ToolStrip control");

            var toolStripControl = O2Forms_ThreadSafe_ToolStrip.getToolStripControl(xrulesControl);

            Assert.That(toolStripControl != null, "toolStripControl was null");

            var newTextBoxName  = "TextBox To Add";
            var newTextBoxValue = "Content of temp textbox";

            Assert.That(false == O2Forms_ThreadSafe_ToolStrip.removeControl(xrulesControl, newTextBoxName), "TextBox To add should NOT BE there at this stage");

            var newTextBoxControl = O2Forms_ThreadSafe_ToolStrip.addTextBox(xrulesControl, newTextBoxName, newTextBoxValue);

            Assert.That(newTextBoxControl != null, "newTextBoxControl was null");

            var itemAdded = O2Forms_ThreadSafe_ToolStrip.getItem(xrulesControl, newTextBoxName);

            Assert.That(itemAdded != null, "itemAdded  == null");
            Assert.That(itemAdded.Text == newTextBoxValue, "itemAdded Text value should be: " + newTextBoxValue);

            Assert.That(O2Forms_ThreadSafe_ToolStrip.removeControl(xrulesControl, newTextBoxName), "TextBox To add should BE there at this stage");
        }
Exemplo n.º 8
0
 public static void help()
 {
     log.info("These are the commands available:");
     foreach (var type in O2CmdApi.typesWithCommands)
     {
         log.info("\n\ton type: {0}\n", type.Name);
         foreach (var methodAvailable in DI.reflection.getMethods(type, BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly))
         {
             // make sure the O2CmdHide attribute is not set
             if (methodAvailable.GetCustomAttributes(typeof(O2CmdHide), false).Length == 0)
             {
                 log.info("\t\t{0}", new FilteredSignature(methodAvailable).sFunctionNameAndParams);
             }
         }
     }
 }
        public void openControl2()
        {
            log.info("in openControl2");
            var o2ObjectModelControl = (ascx_O2ObjectModel)O2AscxGUI.openAscx(typeof(ascx_O2ObjectModel), O2DockState.Float, "O2 Object Model");

            Assert.That(o2ObjectModelControl != null, "o2ObjectModelControl was null");
            //((Form)o2ObjectModelControl.Parent).close();
        }
 public static void openTempGUI()
 {
     log.info("in openTempGUI");
     if (O2AscxGUI.launch("test Breakpoings", 1000, 800))
     {
         O2AscxGUI.openAscx(typeof(ascx_SourceCodeEditor), O2DockState.Document, "sourceCodeEditor");
         O2AscxGUI.waitForAscxGuiClose();
     }
 }
 public static void setAllPhasesAndTasksValue(IAnalysisArtifacts analysisArtifacts, bool value)
 {
     log.info("in setAllPhasesAndTasksValue");
     analysisArtifacts.runAllPhases = true;
     setAllPropertiesValue(analysisArtifacts.phase_1, value);
     setAllPropertiesValue(analysisArtifacts.phase_2, value);
     setAllPropertiesValue(analysisArtifacts.phase_3, value);
     setAllPropertiesValue(analysisArtifacts.phase_4, value);
     setAllPropertiesValue(analysisArtifacts.phase_5, value);
 }
Exemplo n.º 12
0
        /*   public static void loadAssessmentFileAndShowAllFindings()
         * {
         *     var o2Assessment = new O2Assessment(new O2AssessmentLoad_OunceV6(), ozasmtFileToLoad);
         *     ascx_FindingsViewer.openInFloatWindow(o2Assessment.o2Findings);
         * }*/


        public static void joinTraces()
        {
            var sinkFindings   = new List <IO2Finding>();
            var sourceFindings = new List <IO2Finding>();

            findTracesToJoin(sinkFindings, sourceFindings);

            fixSinkVulnNamesBasedOnSinkContextHashMapKey("Findings_With_HashMap_To_Join_", sinkFindings);

            fixSourceVulnNamesBasedOnSinkContextHashMapKey("Findings_With_HashMap_To_Join_", sourceFindings);

            var results = joinTracesWhereSinkMatchesSource(sinkFindings, sourceFindings);

            var newAssessmentFile = new O2Assessment(results);
            var savedFile         = newAssessmentFile.save(new O2AssessmentSave_OunceV6());

            log.info("Filtered results saved to: {0}", savedFile);


            ascx_FindingsViewer.openInFloatWindow(results);
        }
        public static void findTracesToJoin(string sinkMethodToFind, string sourceMethodToFind,
                                            List <IO2Finding> sinkFindings, List <IO2Finding> sourceFindings)
        {
            var o2Assessment = new O2Assessment(new O2AssessmentLoad_OunceV6(), ozasmtFileToLoad);

            foreach (O2Finding o2Finding in o2Assessment.o2Findings)
            {
                if (o2Finding.Sink.IndexOf(sinkMethodToFind) > -1)
                {
                    sinkFindings.Add(o2Finding);
                }
                else if (o2Finding.SourceContext.IndexOf(sourceMethodToFind) > -1)
                {
                    sourceFindings.Add(o2Finding);
                }
            }
            log.info("There are {0} sinkFindings ( sink ~= {1} )", sinkFindings.Count, sinkMethodToFind);
            log.info("There are {0} sourceFindings ( source ~= {1})", sourceFindings.Count, sourceMethodToFind);

            //ascx_FindingsViewer.openInFloatWindow(results.ToList());
        }
        public static void processXHtmlfiles()
        {
            if (rootDirectoryOfFiles == "")
            {
                log.error("you must provide the base directory (rootDirectoryOfFiles) to find {0} files", fileExtension);
            }
            else
            {
                var o2Findings     = new List <IO2Finding>();
                var filesToProcess = Files.getFilesFromDir_returnFullPath(rootDirectoryOfFiles, fileExtension, true
                                                                          /*recursive search */);
                log.info("There are {0} {1} files to process", filesToProcess.Count, fileExtension);
                foreach (var file in filesToProcess)
                {
                    var o2FindingsFromFile = processXHtmlfile(file);
                    o2Findings.AddRange(o2FindingsFromFile);
                }
                log.info("There were {0} findings created", o2Findings.Count);

                // showing findings in Findings Viewer
                showFindingsInFindingsViewer(o2Findings);
                log.info("done...");
            }
        }
Exemplo n.º 15
0
        public static string executeMethod()
        {
            try
            {
                var dependency         = Path.Combine(PublicDI.config.O2TempDir, "_O2_Scanner_DotNet.exe");
                var dependencyAssembly = PublicDI.reflection.getAssembly(dependency);
                PublicDI.log.debug(dependencyAssembly.FullName);
                //return dependencyAssembly.FullName;

                var assemblyToLoad = Path.Combine(PublicDI.config.O2TempDir, @"tmp1AC.tmp.dll");
                //var assemblyToLoad = Path.Combine(PublicDI.config.O2TempDir, @"tmp19C.tmp.dll");

                var assembly = PublicDI.reflection.getAssembly(assemblyToLoad);
                Assert.That(assembly != null, "assembly was null");
                foreach (var method in PublicDI.reflection.getMethods(assembly))
                {
                    log.info(method.Name);
                }
                var methodToInvoke = PublicDI.reflection.getMethod(assemblyToLoad, "runPostSharpOnAssembly");

                Assert.That(methodToInvoke != null, "methodToInvoke was null");

                var liveObject = PublicDI.reflection.createObjectUsingDefaultConstructor(methodToInvoke.ReflectedType);
                Assert.That(liveObject != null, "liveObject was null");
                methodToInvoke.Invoke(liveObject, new object[] {});
                //return PublicDI.reflection.invoke(methodToInvoke,null).ToString();
            }
            catch (Exception ex)
            {
                PublicDI.log.error("in executeMethod: {0}", ex.Message);
                if (ex.InnerException != null)
                {
                    PublicDI.log.error("Inner: {0}", ex.InnerException.Message);
                    if (ex.InnerException.InnerException != null)
                    {
                        PublicDI.log.error("has inner");
                    }
                }
                return("error in execution");
            }
            //var result =
            //return result
            return("ok");
        }
        public string setupGUI()
        {
            var currentAscx = O2DockUtils.getListAvailableAscx();

            foreach (var ascx in currentAscx)
            {
                log.info("[a] {0}", ascx);
            }

            //var o2Debugger = O2AscxGUI.getAscx("O2 Debugger");
            //Assert.That(o2Debugger != null);
            var o2Debugger = O2AscxGUI.openAscx(typeof(ascx_O2MdbgShell), O2DockState.Float, "O2 debugger");

            O2Forms.setAscxPosition(o2Debugger, 100, 10, 100, 10);

            /*          Assert.That(o2Debugger != null, "o2Debugger != null");
             *  var parentForm = O2Forms.findParentThatHostsControl(o2Debugger);
             *          parentForm.Top = 500;
             *          //parentForm.Lef = 10;*/
            return("ok");
        }
 public void onBrowserLocationChanged(IO2Browser _browser, string file)
 {
     log.info("file: {0}", file);
     loadFile(file);
 }
 public ascx_MonoDecompiler()
 {
     log.info("in ascx_MonoDecompiler constructor");
     InitializeComponent();
 }