private void addBreakpointsToAllMethodsInModule(string moduleToProcess, bool verbose) { DI.log.debug("Adding {0} breakpoints", methodsInModule.Count); O2Thread.mtaThread(() => { var numberOfBreakpointsAdded = 0; var breakpointOffset = 0; var timer = new O2Timer("Breakpoint added in").start(); MDbgModule module = DI.o2MDbg.sessionData.getModule(moduleToProcess); if (module != null) foreach (Type typeInModule in module.Importer.DefinedTypes) // no point in adding interfaces or abstract types since they will not be bound (double check on abstract!!) //if (false == typeInModule.IsInterface && false == typeInModule.IsAbstract) // these are not implemented in the original MDbg :( foreach (MethodInfo methodInType in typeInModule.GetMethods()) { DI.o2MDbg.BreakPoints.add(moduleToProcess, typeInModule.FullName, methodInType.Name, breakpointOffset, verbose); if (numberOfBreakpointsAdded++%500 == 0) DI.log.info( " update: {0} breakpoints added so far of a max of {1}", numberOfBreakpointsAdded, methodsInModule.Count); } timer.stop(); DI.log.info("There where {0} breakpoints added of a max of {1}", numberOfBreakpointsAdded, methodsInModule.Count); }); }
public static Object getDeSerializedObjectFromBinaryFile(String fileToProcess, Type tTypeToProcess) { FileStream fsFileStream = null; O2Timer tO2Timer = new O2Timer("Loaded DeSerialized object from " + Path.GetFileName(fileToProcess)).start(); try { var bfBinaryFormatter = new BinaryFormatter(); fsFileStream = new FileStream(fileToProcess, FileMode.Open); Object deserializedObject = bfBinaryFormatter.Deserialize(fsFileStream); if (deserializedObject.GetType().FullName == tTypeToProcess.FullName) { PublicDI.log.info("sucessfully deserialized file {0} into type {1}", fileToProcess, tTypeToProcess.FullName); return(deserializedObject); } PublicDI.log.error("Could not deserialize file {0} into type {1}", fileToProcess, tTypeToProcess.FullName); return(null); } catch (Exception ex) { PublicDI.log.error("In loadSerializedO2CirDataObject: {0}", ex.Message); return(null); } finally { if (fsFileStream != null) { fsFileStream.Close(); } tO2Timer.stop(); } }
public void createUniqueListOfSignatures_forFile(string ozamstFileToTest) { DI.log.debug("\n\ntesting file: {0}", ozamstFileToTest); var timer = new O2Timer("Unique Signatures calculated").start(); var o2Findings = new O2AssessmentLoad_OunceV6().loadFile(ozamstFileToTest).o2Findings; var uniqueSignatures = RulesAndFindingsUtils.getListOfUniqueSignatures(o2Findings); Assert.That(uniqueSignatures.Count > 0, "uniqueSignatures ==0"); DI.log.info("Unique Signatures calculated = {0}", uniqueSignatures.Count); timer.stop(); }
public static IEnumerable<string> getUniqueSortedListOfStrings(IEnumerable<string> stringsToFilter, ref int numberOfUniqueStrings) { var strings = stringsToFilter.ToList(); var timer = new O2Timer("O2Linq calculated list of unique strings from " + strings.Count() + " strings").start(); var uniqueList = (from string signature in strings orderby signature select signature).Distinct().toList(); numberOfUniqueStrings = uniqueList.Count(); timer.stop(); PublicDI.log.info("There are {0} unique signatures", uniqueList.Count()); return uniqueList; }
public static IEnumerable <string> getUniqueSortedListOfStrings(IEnumerable <string> stringsToFilter, ref int numberOfUniqueStrings) { var strings = stringsToFilter.ToList(); var timer = new O2Timer("O2Linq calculated list of unique strings from " + strings.Count() + " strings").start(); var uniqueList = (from string signature in strings orderby signature select signature).Distinct().toList(); numberOfUniqueStrings = uniqueList.Count(); timer.stop(); PublicDI.log.info("There are {0} unique signatures", uniqueList.Count()); return(uniqueList); }
public bool importFile(string fileToLoad, IO2Assessment o2Assessment) { try { if (canLoadFile(fileToLoad)) { //o2Assessment.lastOzasmtImportWasItSucessfull = false; //o2Assessment.lastOzasmtImportFile = fileToLoad; //o2Assessment.lastOzasmtImportFileSize = Files.getFileSize(fileToLoad); //DateTime startImportTime = DateTime.Now; var timer = new O2Timer("Loaded assessment " + fileToLoad + " ").start(); AssessmentRun assessmentRunToImport = OzasmtUtils_OunceV6.LoadAssessmentRun(fileToLoad); timer.stop(); /* assessmentRun.AssessmentConfig = assessmentRunToImport.AssessmentConfig; assessmentRun.AssessmentStats = assessmentRunToImport.AssessmentStats; assessmentRun.Messages = assessmentRunToImport.Messages; assessmentRun.name = assessmentRunToImport.name ?? OzasmtUtils_OunceV6.calculateAssessmentNameFromScans(assessmentRunToImport);*/ o2Assessment.name = assessmentRunToImport.name ?? OzasmtUtils_OunceV6.calculateAssessmentNameFromScans(assessmentRunToImport); // I don't think I need this since the O2Finding objects have the full strings // map top level objects /* assessmentRun.FileIndeces = assessmentRunToImport.FileIndeces; assessmentRun.StringIndeces = assessmentRunToImport.StringIndeces;*/ // import findings if (null != assessmentRunToImport.Assessment.Assessment) foreach (Assessment assessment in assessmentRunToImport.Assessment.Assessment) if (null != assessment.AssessmentFile) foreach (AssessmentAssessmentFile assessmentFile in assessment.AssessmentFile) if (assessmentFile.Finding != null) foreach (AssessmentAssessmentFileFinding finding in assessmentFile.Finding) o2Assessment.o2Findings.Add(OzasmtUtils_OunceV6.getO2Finding(finding, assessmentFile, assessmentRunToImport)); // if we made it this far all went ok; //o2Assessment.lastOzasmtImportTimeSpan = DateTime.Now - startImportTime; //o2Assessment.lastOzasmtImportWasItSucessfull = true; return true; } } catch (Exception ex) { "in importAssessmentRun: {0}".error(ex.Message); } return false; }
public static Dictionary<String, XmlNode> getAllBeans_RecursiveSearch(String sWebRoot) { if (bLoadFromO2VarsIfAvailable && vars.get(sO2VarToHoldBeansDictionary) != null) if (((Dictionary<String, XmlNode>) vars.get(sO2VarToHoldBeansDictionary)).Count > 0) return (Dictionary<String, XmlNode>) vars.get(sO2VarToHoldBeansDictionary); O2Timer tTimer = new O2Timer("Loading all beans from web root").start(); var dBeans = new Dictionary<String, XmlNode>(); var lsXmlFilesInWebRoot = new List<String>(); Files.getListOfAllFilesFromDirectory(lsXmlFilesInWebRoot, sWebRoot, true, "*.xml", false); DI.log.info("{0} xml files found", lsXmlFilesInWebRoot.Count); int iFilesProcessed = 0; foreach (var sXmlFile in lsXmlFilesInWebRoot) { try { if (Path.GetExtension(sXmlFile).ToLower() == ".xml") { DI.log.info("({0}/{1} Processing xml file: {2}", (iFilesProcessed++), lsXmlFilesInWebRoot.Count, sXmlFile); var xdXmlDocument = new XmlDocument(); String sXmlFileContents = Files.getFileContents(sXmlFile); sXmlFileContents = sXmlFileContents.Replace("<!DOCTYPE", "<!--"); sXmlFileContents = sXmlFileContents.Replace(".dtd\">", "-->"); xdXmlDocument.LoadXml(sXmlFileContents); xdXmlDocument.XmlResolver = null; XmlNodeList xnlBeans = xdXmlDocument.GetElementsByTagName("bean"); foreach (XmlNode xnNode in xnlBeans) if (xnNode.Attributes["id"] != null) { // first add by id if (!dBeans.ContainsKey(xnNode.Attributes["id"].Value)) dBeans.Add(xnNode.Attributes["id"].Value, xnNode); } else if (xnNode.Attributes["name"] != null) // then add by name if (!dBeans.ContainsKey(xnNode.Attributes["name"].Value)) dBeans.Add(xnNode.Attributes["name"].Value, xnNode); } } catch (Exception ex) { DI.log.ex(ex, "in getAllBeans_RecursiveSearch (inside foreach (var sXmlFile in lsXmlFilesInWebRoot)"); throw; } } vars.set_(sO2VarToHoldBeansDictionary, dBeans); DI.log.info("{0} beans loaded", dBeans.Count); tTimer.stop(); return dBeans; }
public static void mapInRulePack_FindingsSourcesAndSinks(O2RulePack o2RulePack, Dictionary<string, List<IO2Rule>> indexedO2Rules, List<IO2Finding> o2Findings, string languageDBId) { var timer = new O2Timer("mapInRulePack_FindingsSourcesAndSinks").start(); foreach (O2Finding o2Finding in o2Findings) updateO2RulePackWithFindingsTraceTypes(o2RulePack, indexedO2Rules, o2Finding.o2Traces, languageDBId, O2RuleType.Source); /*updateSourceOrSinkRule(o2RulePack,indexedO2Rules, o2Finding.Source, languageDBId, O2RuleType.Source); updateSourceOrSinkRule(o2RulePack,indexedO2Rules, o2Finding.KnownSink, languageDBId, O2RuleType.Sink); updateSourceOrSinkRule(o2RulePack, indexedO2Rules, o2Finding.LostSink, languageDBId, O2RuleType.LostSink); */ timer.stop(); }
public static IO2Assessment getO2Assessment(string ozasmtFile) { var loadEngine = getLoadEngineForFile(ozasmtFile); if (loadEngine != null) { O2Cmd.log.write("\n[engine {0}]: loading and converting file: {1}", loadEngine.engineName, ozasmtFile); var timer = new O2Timer("File Loaded").start(); var o2Assessment = loadEngine.loadFile(ozasmtFile); timer.stop(); O2Cmd.log.write("[engine {0}]: There are {1} Findings in the loaded file\n", loadEngine.engineName, o2Assessment.o2Findings.Count); return o2Assessment; } return null; }
public void calculateRulePack_forFile(string ozamstFileToTest, O2RulePack o2RulePackToUse) { DI.log.debug("\n\ntesting file: {0}", ozamstFileToTest); var timer = new O2Timer("Calculate Rule Pack ").start(); // load assesment file and get unique signatures var o2Findings = new O2AssessmentLoad_OunceV6().loadFile(ozamstFileToTest).o2Findings; var uniqueSignatures = RulesAndFindingsUtils.getListOfUniqueSignatures(o2Findings); Assert.That(uniqueSignatures.Count > 0, "uniqueSignatures ==0"); // calculate rulepack for this assessment var o2RulePackForOzasmt = RulesAndFindingsUtils.createRulePackWithSignatures(o2RulePackToUse, uniqueSignatures, Path.GetFileName(ozamstFileToTest), true, testLanguageDBId); Assert.That(o2RulePackForOzasmt.O2Rules.Count > 0, "There were no rules in created o2RulePackForOzasmt"); timer.stop(); }
public void executeSearchAndLoadResults(List<Regex> searchRegExes) { this.invokeOnThread(() => lbSearchResultsStats.Text = "Executing search"); // execute search var timer = new O2Timer("Search execution").start(); var tsrSearchResults = executeSearch(searchRegExes); timer.stop(); this.invokeOnThread( () => lbSearchResultsStats.Text = String.Format("{0} and returned {1} matches", timer.TimeSpanString, tsrSearchResults.Count)); // show Results showResults(tsrSearchResults); }
public static string createO2AssessmentWithCallFlowTraces(ICirDataAnalysis cirDataAnalysis) { DI.log.info("Creating O2Assessment With Call Flow Traces"); var timer = new O2Timer("Created list of finding").start(); var cirFunctionsToProcess = cirDataAnalysis.dCirFunction_bySignature.Values; var o2Findings = createO2FindingsFromCirFunctions(cirFunctionsToProcess); timer.stop(); timer = new O2Timer("Saved Assessment").start(); var o2Assessment = new O2Assessment(); o2Assessment.o2Findings = o2Findings; var savedFile = o2Assessment.save(new O2AssessmentSave_OunceV6()); DI.log.info("Saved O2Asssessment file created: {0}", savedFile); timer.stop(); return savedFile; }
public static void backupGac(string zipFileToSaveGacContents) { var pathToGac = Path.Combine(Environment.GetEnvironmentVariable("windir") ?? "", "Assembly");//\\GAC_MSIL"); O2Thread.mtaThread( () => { PublicDI.log.info("Started unzip process of Gac Folder"); var timer = new O2Timer("Gac Backup").start(); //new zipUtils().zipFolder(PublicDI.PathToGac, zipFileToSaveGacContents); new zipUtils().zipFolder(pathToGac, zipFileToSaveGacContents); var logMessage = String.Format("Contents of \n\n\t{0}\n\n saved to \n\n\t{1}\n\n ", pathToGac, zipFileToSaveGacContents); timer.stop(); PublicDI.log.info(logMessage); //PublicDI.log.showMessageBox(logMessage); }); }
private static void fixFunctionsCalledXRefs(ICirData cirData) { if (cirData != null && cirData.dFunctions_bySignature != null) { var timer = new O2Timer("fixFunctionsCalledXRefs").start(); foreach (CirFunction cirFunction in cirData.dFunctions_bySignature.Values) { if (cirFunction.FunctionName == null) { var filteredSignature = new FilteredSignature(cirFunction.FunctionSignature); cirFunction.FunctionName = filteredSignature.sFunctionName; cirFunction.FunctionNameAndParameters = filteredSignature.sFunctionNameAndParams; cirFunction.ClassNameFunctionNameAndParameters = filteredSignature.sFunctionClass + "." + filteredSignature.sFunctionNameAndParams; } } timer.stop(); } }
public string ProcessRequest(string page) { O2Gui.open<System.Windows.Forms.Panel>("Util - LogViewer", 400,140).add_LogViewer(); "Current Directory: {0}".info(Environment.CurrentDirectory); var o2Timer = new O2Timer("ProcessRequest for file: {0}".info(page)).start(); Page = page ?? Page; var stringWriter = new StringWriter(); simpleWorkerRequest = new SimpleWorkerRequest(Page, string.Empty, stringWriter); //openScript(); //"Good Morning".execute_InScriptEditor_InSeparateAppDomain(); "processing request for: {0}".info(Page); HttpRuntime.ProcessRequest(simpleWorkerRequest); var Html = stringWriter.str(); o2Timer.stop(); return Html; }
public static API_Veracode_DetailedXmlFindings show_Flaws_In_SourceCodeViewer(this API_Veracode_DetailedXmlFindings apiVeracode, Control control) { var topPanel = control.clear(); var codeViewer = topPanel.add_GroupBox("Flaw SourceCode reference").add_SourceCodeViewer(); var treeView = codeViewer.parent().insert_Left("Flaws").add_TreeView(); var propertyGrid = treeView.insert_Below(150,"Flaw properties") .add_PropertyGrid().helpVisible(false); var description = codeViewer.insert_Below(150,"Flaw description") .add_TextArea(); treeView.afterSelect<FlawType>( (flaw)=>{ propertyGrid.show(flaw); if (apiVeracode.hasLocalSourceCodeFile(flaw)) { codeViewer.open(apiVeracode.sourceCodeFile(flaw)); codeViewer.editor().gotoLine((int)flaw.line); } else codeViewer.set_Text(".. no source code available..."); description.set_Text(flaw.description.fix_CRLF()); treeView.focus(); }); treeView.beforeExpand<List<FlawType>>( (flaws)=>{ var selectedNode = treeView.selected(); if (selectedNode.nodes().size()== 1) { selectedNode.clear(); selectedNode.add_Nodes(flaws, (flaw)=> flaw.type, (flaw) => apiVeracode.hasLocalSourceCodeFile(flaw) ? Color.DarkGreen : Color.DarkRed ); } }); Action<TreeNode, Dictionary<string, List<FlawType>>> addFlawsToTreeNode = (treeNode, mappedFlaws) =>{ foreach(var item in mappedFlaws) treeNode.add_Node(item.Key,item.Value,item.Value.size()>0); /*.*/ }; Action showData = ()=>{ treeView.clear(); var o2Timer = new O2Timer("Building XRefs for flaws").start(); var mappedFlawsByType = new Dictionary<string, List<FlawType>>(); var mappedFlawsByCategoryName = new Dictionary<string, List<FlawType>>(); var mappedFlawsByFile = new Dictionary<string, List<FlawType>>(); var mappedFlawsBySeverity = new Dictionary<string, List<FlawType>>(); foreach(var flaw in apiVeracode.flaws()) { mappedFlawsByCategoryName.add(flaw.categoryname, flaw); mappedFlawsByType.add(flaw.type, flaw); mappedFlawsByFile.add(flaw.sourceCodeFile(), flaw); mappedFlawsBySeverity.add(flaw.severity.str(), flaw); } o2Timer.stop(); o2Timer = new O2Timer("Populating treeview").start(); addFlawsToTreeNode(treeView.add_Node("by Category Name"), mappedFlawsByCategoryName); addFlawsToTreeNode(treeView.add_Node("by Type"), mappedFlawsByType); addFlawsToTreeNode(treeView.add_Node("by File"), mappedFlawsByFile); addFlawsToTreeNode(treeView.add_Node("by Severity"),mappedFlawsBySeverity); o2Timer.stop(); }; treeView.onDrop( (file)=>{ apiVeracode.load(file); showData(); }); if (apiVeracode.ReportXmlFile.valid()) showData(); else treeView.add_Node("drop a Veracode DetailedFindings Xml (or zip) file to view it"); // "There were {0} Files That Could Not Mapped Locally".error(apiVeracode.FilesThatCouldNotMappedLocally.size()); /*if (treeView.nodes()>0)) { treeView.nodes()[0] .expand().nodes()[2].selected(); } */ return apiVeracode; }
public ascx_WSDL_Creation_and_Execution buildGui() { var topPanel = this.add_Panel(); topPanel.insert_Below(100).add_LogViewer(); //var assemblyInvoke = topPanel.add_Control<O2.External.SharpDevelop.Ascx.ascx_AssemblyInvoke>(); //assemblyInvoke.loadAssembly("OnlineStorage.dll".assembly()); //var methodProperties = topPanel.add_DataGridView(); TestWebServices = topPanel.insert_Above(22).add_ComboBox(); WsdlLocation = topPanel.insert_Above(22) .add_LabelAndTextAndButton("Load Custom WSDL from location (file or url)","","Load",(value) => open(value)) .control<TextBox>(); ExtraWsdlParameres = topPanel.insert_Above(22).add_Label("Extra wsdl.exe parameters").left(WsdlLocation.Left).top(2) .append_TextBox("").align_Right(topPanel); Methods_TreeView = topPanel.insert_Left(300,"Soap Methods").add_TreeView().sort(); ExecutionResult = topPanel.insert_Below(150).add_GroupBox("Web Service Invocation Response Data").add_TextArea(); ExecutionResult_Properties = ExecutionResult.insert_Right().add_PropertyGrid().helpVisible(false); ExecutionResult_TreeView = ExecutionResult_Properties.insert_Below().add_TreeView(); ExecuteSoapRequest_Button = topPanel.insert_Below(40) .add_Button("Execute Soap request") .font_bold() .fill(); var methodProperties = topPanel.add_GroupBox("Request Data").add_Control<ctrl_ObjectViewer>(); //methodProperties.showSerializedString().createObjectWhenNull().simpleView(); methodProperties.createObjectWhenNull().simpleView(); Methods_TreeView.afterSelect<MethodInfo>( (methodInfo) => { CurrentMethod = methodInfo; "Current Method: {0}".info(CurrentMethod.Name); "Current Method: Signature = {0}".info(CurrentMethod.str()); "Current Method: DeclaringType = {0}".info(CurrentMethod.DeclaringType.FullName); SoapParametersObject = methodInfo.create_LiveObject_From_MethodInfo_Parameters("Soap_Invocation_Parameters"); if (SoapParametersObject.notNull()) { methodProperties.visible(true); methodProperties.show(SoapParametersObject); } else methodProperties.visible(false); //new O2FormsReflectionASCX().loadMethodInfoParametersInDataGridView(methodInfo, methodProperties); }); ExecuteSoapRequest_Button.onClick( ()=>{ //var parameters = new O2FormsReflectionASCX().getParameterObjectsFromDataGridColumn(methodProperties, "Value"); var invocationParameters = new List<object>(); foreach(var property in SoapParametersObject.type().properties()) invocationParameters.add(SoapParametersObject.property(property.Name)); ExecutionResult.set_Text("[{0}] Executing method : {1}".line().format(DateTime.Now,CurrentMethod.Name)); var liveObject = CurrentMethod.DeclaringType.ctor(); ExecutionResult.append_Line("Created dynamic proxy object of type: {0}".format(liveObject)); try { var o2Timer = new O2Timer("Method execution time: ").start(); ResultObject = CurrentMethod.Invoke(liveObject, invocationParameters.ToArray()); ExecutionResult.append_Line("Method execution time: {0}".format(o2Timer.stop())); ExecutionResult.append_Line("Method Executed OK, here is the return value:"); ExecutionResult.append_Line(ResultObject.str().lineBeforeAndAfter()); ExecutionResult_Properties.show(ResultObject); ExecutionResult_TreeView.xmlShow(ResultObject.serialize()); } //catch(System.Web.Services.Protocols.SoapException ex) //{ //} catch (Exception ex) { if(ex.InnerException.notNull()) { var detail = (ex.InnerException.property("Detail") as System.Xml.XmlElement); if (detail.notNull()) ExecutionResult.append_Line(detail.OuterXml); ExecutionResult.append_Line(ex.InnerException.Message); ExecutionResult.append_Line(ex.InnerException.StackTrace); } else ex.log(); //show.info(ex); //ex.details(); } //currentMethod.invoke(parameters); ExecutionResult.append_Line("Execution complete"); }); Methods_TreeView.insert_Below(20) .add_CheckBox("Show Full Method Signatures",0,0,(value)=> ShowFullMethodSignatures = value) .autoSize() .parent<Panel>() .add_CheckBox("Cache WSDL Dll",0,200,(value)=> Cache_WSDL_Dll = value) .autoSize() .check(); //.append_Link("Delete cached compiled dll", deleteCachedFile); ExecutionResult.insert_Below(20) .add_Link("View serialized string of response object", 0,0, ()=>{ var serializedResponse = ResultObject.serialize(false); if (serializedResponse.notNull()) "".showInCodeViewer().set_Text(serializedResponse,"a.xml"); }); addScriptingSupport(); add_TestWebServices(); return this; }
public static API_IKVMC_Java_Metadata create_JavaMetadata(this API_IKVMC ikvmc, string fileToProcess) { var o2Timer = new O2Timer("Created JavaData for {0}".format(fileToProcess)).start(); var javaMetaData = new API_IKVMC_Java_Metadata(); javaMetaData.FileProcessed = fileToProcess; var classes = ikvmc.getRawClassesData_FromFile_ClassesOrJar(fileToProcess); foreach(DictionaryEntry item in classes) { var name = item.Key.str(); var bytes = (byte[])item.Value.field("data"); var classFile = ikvmc.createClassFile(bytes,1); // value of 1 gets the local variables var javaClass = new Java_Class { Signature = name, Name = name.contains(".") ? name.split(".").last() : name, SourceFile = classFile.prop("SourceFileAttribute").str(), IsAbstract = classFile.prop("IsAbstract").str().toBool(), IsInterface = classFile.prop("IsInterface").str().toBool(), IsInternal = classFile.prop("IsInternal").str().toBool(), IsPublic = classFile.prop("IsPublic").str().toBool(), SuperClass = classFile.prop("SuperClass").str() }; if (classFile.prop("GenericSignature").notNull()) javaClass.GenericSignature = classFile.prop("GenericSignature").str(); javaClass.ConstantsPool = classFile.getConstantPoolEntries(); javaClass.map_Annotations(classFile) .map_Interfaces(classFile) .map_Fields(classFile) .map_Methods(classFile) .map_EnclosingMethod(classFile); javaClass.map_LineNumbers(ikvmc.createClassFile(bytes,2)); // for this we need to call createClassFile with the value of 2 (to get the source code references) javaMetaData.Classes.Add(javaClass); //break; // } o2Timer.stop(); return javaMetaData; }
public FVDL loadFvdl_Raw(string fvdlFile) { "Loading fvdl file: {0}".info(fvdlFile); try { var chachedFvdl = (FVDL)O2LiveObjects.get(fvdlFile); if (chachedFvdl.notNull()) return chachedFvdl; } catch { } var o2Timer = new O2Timer("loading {0} file".format(fvdlFile.fileName())).start(); var _fvdl = FVDL.Load(fvdlFile); O2LiveObjects.set(fvdlFile,_fvdl); o2Timer.stop(); return _fvdl; }
public static Fortify_Scan mapFvdlData(this Fortify_Scan fortifyScan) { var o2Timer = new O2Timer("Mapped Fvdl Data").start(); fortifyScan.mapScanDetails() .mapContextPool() .mapDescriptions() .mapCalledWithNoDefs() .mapSinks() .mapSources() .mapSnippets() .mapVulnerabilities(); o2Timer.stop(); return fortifyScan; }
public void mapReferencesIncludedInSourceCode(List<string> sourceCodeFiles, List<string> referencedAssemblies) { var o2Timer = new O2Timer("mapReferencesIncludedInSourceCode").start(); addSourceFileOrFolderIncludedInSourceCode(sourceCodeFiles, referencedAssemblies, new List<string>()); addReferencesIncludedInSourceCode(sourceCodeFiles, referencedAssemblies); if (sourceCodeFiles.Count > 1) { PublicDI.log.debug("There are {0} files to compile", sourceCodeFiles.Count); foreach (var file in sourceCodeFiles) PublicDI.log.debug(" {0}", file); } if (referencedAssemblies.Count > 1) { applyCompilationPathMappings(referencedAssemblies); PublicDI.log.debug("There are {0} referencedAssemblies used", referencedAssemblies.Count); if (debugMode) foreach (var referencedAssembly in referencedAssemblies) PublicDI.log.debug(" {0}", referencedAssembly); } o2Timer.stop(); }
public static void remapXrefs(ICirDataAnalysis cirDataAnalysis) { DI.log.debug("Remapping Methods and Classes XReferences"); var timer = new O2Timer("Remapping XRefs took: {0}").start(); remapIsCalledByXrefs(cirDataAnalysis); // make sure everythings is pointing to the correct place calculateXrefs_SuperClases(cirDataAnalysis); // ensure all the methods are mapped to the correct class foreach(var cirClass in cirDataAnalysis.dCirClass_bySignature.Values) foreach(var cirFunction in cirClass.dFunctions.Values) { cirFunction.ParentClass = cirClass; cirFunction.ParentClassFullName = cirClass.FullName; cirFunction.ParentClassName = cirClass.Name; } timer.stop(); }
public void backup(string backupFolder, bool backupPages, bool backupFiles, bool backupCategoryPages, bool backupTemplates, bool backupUsers) { var o2Timer = new O2Timer("Backed up Wiki in").start(); Backup_Directory.open(backupFolder); if (backupPages && CancelBackup.isFalse()) backup_Pages(backupFolder); if (backupFiles && CancelBackup.isFalse()) backup_Files(backupFolder); if (backupCategoryPages && CancelBackup.isFalse()) backup_CategoryPages(backupFolder); if (backupTemplates && CancelBackup.isFalse()) backup_Templates(backupFolder); if (backupUsers && CancelBackup.isFalse()) backup_Users(backupFolder); //backupFolder.createDir(); o2Timer.stop(); }
private void processFiles_(List<String> lsFilesToProcess, TreeView tvTargetTreeView) { O2Timer tO2Timer = new O2Timer("Processing files").start(); fcdCirData.init(); CirLoad.loadCirDumpXmlFiles_andPopulateDictionariesWithXrefs(lsFilesToProcess, fcdCirData, false /*bVerbose*/); showO2CirDataInTreeViewAndListBox(fcdCirData, tvTargetTreeView, lbO2CirData_Functions); tO2Timer.stop(); }
public object GetCurrentCSharpObjectModel() { var timer = new O2Timer("Calculated O2 Object Model for referencedAssesmblies").start(); var signatures = new List<string>(); var referencedAssemblies = new CompileEngine().getListOfReferencedAssembliesToUse(); //compileEngine.lsGACExtraReferencesToAdd(); foreach (var referencedAssesmbly in referencedAssemblies) if (File.Exists(referencedAssesmbly)) signatures.AddRange(PublicDI.reflection.getMethods(referencedAssesmbly) .Select(method => new FilteredSignature(method).sSignature)); timer.stop(); return signatures; }
public static Object getDeSerializedObjectFromBinaryFile(String fileToProcess, Type tTypeToProcess) { FileStream fsFileStream = null; O2Timer tO2Timer = new O2Timer("Loaded DeSerialized object from " + Path.GetFileName(fileToProcess)).start(); try { var bfBinaryFormatter = new BinaryFormatter(); fsFileStream = new FileStream(fileToProcess, FileMode.Open); Object deserializedObject = bfBinaryFormatter.Deserialize(fsFileStream); if (deserializedObject.GetType().FullName == tTypeToProcess.FullName) { PublicDI.log.info("sucessfully deserialized file {0} into type {1}", fileToProcess, tTypeToProcess.FullName); return deserializedObject; } PublicDI.log.error("Could not deserialize file {0} into type {1}", fileToProcess, tTypeToProcess.FullName); return null; } catch (Exception ex) { PublicDI.log.error("In loadSerializedO2CirDataObject: {0}", ex.Message); return null; } finally { if (fsFileStream != null) fsFileStream.Close(); tO2Timer.stop(); } }
public void processFile(String sPathToFileToProcess, TreeView tvTargetTreeView) { O2Timer tO2TimerLoadingCallTracesInTreeView = new O2Timer("Loaded Cir Dump data ").start(); CommonIRDump cidCommonIrDump = CirLoad.loadCirDumpXmlFile_justReturnCommonIRDump(sPathToFileToProcess, true); tvTargetTreeView.Tag = cidCommonIrDump; if (rb_ClearO2CirDataObjectOnLoad.Checked) fcdCirData.init(); // calculate Xref objects fcdCirData.bVerbose = true; CirDataUtils.populateDictionariesWithXrefs(cidCommonIrDump, fcdCirData); showO2CirDataInTreeViewAndListBox(fcdCirData, tvTargetTreeView, lbO2CirData_Functions); tO2TimerLoadingCallTracesInTreeView.stop(); }
public void setCompilerEnvironment() { var o2Timer = new O2Timer("Code Compiled in"); this.csharpCompiler(new CSharp_FastCompiler()); this.csharpCompiler().set_BeforeSnippetAst(() => this.csharpCompiler().invocationParameters(this.InvocationParameters)); this.csharpCompiler().set_OnAstFail(() => { //"AST creation failed".error(); // this.sourceCodeViewer.enabled(false); executeButton.enabled(false); result_RichTextBox.textColor(Color.Red).set_Text("Ast Parsing Errors:\r\n\r\n"); //.append_Text(csharpCompiler.AstErrors); commandsToExecute.updateCodeComplete(this.csharpCompiler()); sourceCodeViewer.setDocumentContents(this.csharpCompiler().sourceCode()); OnAstFail.invoke(); }); this.csharpCompiler().set_OnAstOK(() => { o2Timer.start(); commandsToExecute.editor().refresh(); sourceCodeViewer.enabled(true); commandsToExecute.invokeOnThread(() => commandsToExecute.Refresh()); GeneratedCode = this.csharpCompiler().sourceCode(); commandsToExecute.updateCodeComplete(this.csharpCompiler()); sourceCodeViewer.setDocumentContents(this.csharpCompiler().sourceCode()); OnAstOK.invoke(); }); this.csharpCompiler().set_OnCompileFail(() => { //"AST OK, but compilation failed".error(); executeButton.enabled(false); var codeOffset = this.csharpCompiler().getGeneratedSourceCodeMethodLineOffset(); this.csharpCompiler().compilationErrors().runForEachCompilationError( (row, col) => { sourceCodeViewer.editor().setSelectedText(row, col, true, false); commandsToExecute.editor().setSelectedText( row - codeOffset.Line, col - codeOffset.Column, true, /*showAsError*/ false, /*showAsBookMark*/ false); /*decrementLineAndColumn*/ }); result_RichTextBox.textColor(Color.Red) .set_Text("Compilation Errors:\r\n\r\n") .append_Text(this.csharpCompiler().compilationErrors()); onCompileFail.invoke(); }); this.csharpCompiler().set_OnCompileOK(() => { o2Timer.stop(); "Compilation OK".debug(); commandsToExecute.editor().refresh(); sourceCodeViewer.editor().refresh(); result_RichTextBox.set_Text("Compilation OK:\r\n\r\n") .textColor(Color.Green); executeButton.enabled(true); if (AutoSaveOnCompileSuccess && Code != defaultCode) { AutoSaveDir.createDir(); // make sure it exits var targetFile = AutoSaveDir.pathCombine(Files.getFileSaveDateTime_Now().trim() + ".cs"); targetFile.fileWrite(Code); } onCompileOK.invoke(); // once all is done update the codeComplete information if (commandsToExecute.editor().o2CodeCompletion.notNull()) commandsToExecute.editor().o2CodeCompletion.addReferences(this.csharpCompiler().referencedAssemblies()); //add_ExtraMethodsFile(); // restore previous mappings here //register cacheAssmbly var codeMd5 = previousCompiledCodeText.md5Hash(); CompileEngine.CachedCompiledAssemblies.add(codeMd5, this.csharpCompiler().compiledAssembly().Location); executeButton.enabled(true); if (ExecuteOnCompile) execute(); }); }
public void deleteAddBreakpoints() { //CommandBase.Debugger.Processes.Active.Breakpoints try { // delete active breakpoints var timer = new O2Timer("Deleted active breakpoints in ").start(); var breakpointsToDelete = new List<MDbgBreakpoint>(); foreach(MDbgBreakpoint mdbgBreakpoint in o2MDbg.ActiveProcess.Breakpoints) breakpointsToDelete.Add(mdbgBreakpoint); DI.log.info("There are {0} breakpoints to delete"); foreach(MDbgBreakpoint mdbgBreakpoint in breakpointsToDelete) mdbgBreakpoint.Delete(); // delete archived breakpoints archivedBreakpoints_InSourceCode = new List<string>(); timer.stop(); } catch (Exception ex) { DI.log.ex(ex, "in deleteAddBreakpoints"); } }
public static List<TeamMentor_Article> xmlDB_Load_GuidanceItemsV3(this TM_Xml_Database tmDatabase, Guid libraryId, List<string> guidanceItemsFullPaths) { var o2Timer = new O2Timer("xmlDB_GuidanceItems").start(); var itemsLoaded = 0; //var maxToLoad = 1000; var guidanceItems = new List<TeamMentor_Article>(); foreach(var fullPath in guidanceItemsFullPaths) { var guidanceItemId = fullPath.fileName().remove(".xml"); if (guidanceItemId.isGuid()) { var guidanceItem = tmDatabase.xmlDB_GuidanceItem(guidanceItemId.guid(),fullPath); if (guidanceItem.notNull()) { guidanceItems.add(guidanceItem); guidanceItem.Metadata.Library_Id = libraryId; } //if (maxToload-- < 1) // break; if (itemsLoaded++ % 200 == 0) "loaded {0} items".info(itemsLoaded); } //if (itemsLoaded > maxToLoad) // break; } o2Timer.stop(); return guidanceItems; }
public static void remapIsCalledByXrefs(ICirDataAnalysis cirDataAnalysis) { try { remapSuperClassesXrefs(cirDataAnalysis); var timer = new O2Timer("remapIsCalledByXrefs").start(); // first clear all Xref foreach (var cirFunction in cirDataAnalysis.dCirFunction_bySignature.Values) cirFunction.FunctionIsCalledBy = new List<ICirFunctionCall>(); // make sure all FunctionsCalledUniqueList and FunctionsCalled are syncronized with dCirFunction_bySignature var functionsToMap = cirDataAnalysis.dCirFunction_bySignature.Values.ToList().Count; var functionsProcessed = 0; foreach (var cirFunction in cirDataAnalysis.dCirFunction_bySignature.Values.ToList()) { for (int i = 0; i < cirFunction.FunctionsCalledUniqueList.Count; i++) cirFunction.FunctionsCalledUniqueList[i] = syncFunctions(cirDataAnalysis, cirFunction.FunctionsCalledUniqueList[i]); for (int i = 0; i < cirFunction.FunctionsCalled.Count; i++) cirFunction.FunctionsCalled[i].cirFunction = syncFunctions(cirDataAnalysis, cirFunction.FunctionsCalled[i].cirFunction); if ((functionsProcessed++) % 500 == 0) DI.log.info(" processed {0} / {1}", functionsProcessed, functionsToMap); } // check the FunctionsCalledUniqueList is calledby mappngs foreach (var cirFunction in cirDataAnalysis.dCirFunction_bySignature.Values) foreach (var functionCalled in cirFunction.FunctionsCalled) { var functionCalledXref = getFunctionRef(cirDataAnalysis, functionCalled.cirFunction); /*if (false == cirDataAnalysis.dCirFunction_bySignature.ContainsValue(functionCalled)) DI.log.error("in remapIsCalledByXrefs something is wrong because the called fucntions does not have a cirFunction mapping: {0}", functionCalled.FunctionSignature); else //{*/ bool found = false; foreach (var functionCall in functionCalled.cirFunction.FunctionIsCalledBy) if (functionCall.cirFunction == functionCalledXref) found = true; if (found == false) functionCalled.cirFunction.FunctionIsCalledBy.Add(new CirFunctionCall(cirFunction, functionCalled.fileName, functionCalled.lineNumber)); //if (false == functionCalledXref.FunctionIsCalledBy.Contains(cirFunction)) // functionCalledXref.FunctionIsCalledBy.Add(cirFunction); } // make sure all functions are syncronized with dCirFunction_bySignature foreach (var cirFunction in cirDataAnalysis.dCirFunction_bySignature.Values) for (int i = 0; i < cirFunction.FunctionsCalledUniqueList.Count; i++) cirFunction.FunctionsCalledUniqueList[i] = syncFunctions(cirDataAnalysis, cirFunction.FunctionsCalledUniqueList[i]); // endure all iscalledby are correcly mapped foreach (var cirFunction in cirDataAnalysis.dCirFunction_bySignature.Values) for (int i = 0; i < cirFunction.FunctionIsCalledBy.Count; i++) cirFunction.FunctionIsCalledBy[i].cirFunction = syncFunctions(cirDataAnalysis, cirFunction.FunctionIsCalledBy[i].cirFunction); // make sure there is a reference to this function on the Classes Dictionanry foreach (var cirFunction in cirDataAnalysis.dCirFunction_bySignature.Values) foreach (var functionCalled in cirFunction.FunctionsCalled) if (functionCalled.cirFunction.ParentClass == null) { var functionSignature = new FilteredSignature(functionCalled.cirFunction.FunctionSignature); var parentClassName = functionSignature.sFunctionClass; if (false == cirDataAnalysis.dCirClass_bySignature.ContainsKey(parentClassName)) cirDataAnalysis.dCirClass_bySignature.Add(parentClassName, new CirClass(parentClassName)); var parentCirClass = cirDataAnalysis.dCirClass_bySignature[parentClassName]; var functionAlreadyMappedToClass = false; foreach (var cirFunctionMappedToClass in parentCirClass.dFunctions.Values) if (cirFunctionMappedToClass.FunctionSignature == functionCalled.cirFunction.FunctionSignature) functionAlreadyMappedToClass = true; if (false == functionAlreadyMappedToClass) parentCirClass.dFunctions.Add(functionCalled.cirFunction.FunctionSignature, functionCalled.cirFunction); functionCalled.cirFunction.ParentClass = parentCirClass; functionCalled.cirFunction.ParentClassName = parentCirClass.Name; functionCalled.cirFunction.ParentClassFullName = parentCirClass.FullName; } timer.stop(); } catch (Exception ex) { DI.log.error("in remapIsCalledByXrefs: {0}", ex.Message); } }
public void createHost() { //if (WebServerHost.isNull()) { var o2Timer = new O2Timer("Creating WebServer host").start(); WebServerHost = (WebServerHost)ApplicationHost.CreateApplicationHost(typeof(WebServerHost), "/", WebRootDir); //WebServerHost = ApplicationHost.CreateApplicationHost(typeof(WebServerHost), "/", WebRootDir); o2Timer.stop(); } }