public static string createAllMethodsStreams(this O2MappedAstData astData, string targetFolder, ProgressBar TopProgressBar, Func<string,bool> statusMessage) { var iMethods = astData.iMethods(astData.methodDeclarations()); TopProgressBar.maximum(iMethods.size()); int count = 0; int total = iMethods.size(); //this.MethodStreams = new Dictionary<IMethod, string>(); foreach(var iMethod in iMethods) { TopProgressBar.increment(1); astData.createO2MethodStreamFile(iMethod,targetFolder); //MethodStreams.Add(iMethod,AstData.createO2MethodStream(iMethod).csharpCode()); if (statusMessage.notNull()) if (statusMessage("calculating methodStream: {0}/{1}".format(count++, total)).isFalse()) { "Scan Cancel/Stop request received".info(); return targetFolder; } } return targetFolder; }
public static List<IO2Finding> calculate_Url_to_EntryMethod_Mappings(string pathWithSourceFiles, string urlBase, string port, ProgressBar progressBar) { var o2Findings = new List<IO2Finding>(); var filesToAnalyze = pathWithSourceFiles.files("*.cs",true); progressBar.maximum(filesToAnalyze.size()); foreach(var file in filesToAnalyze) { "Processing file:{0}".info(file); var url = urlBase.format(port, file.replace(pathWithSourceFiles,"").replace(".ascx.cs","")); foreach(var type in file.csharpAst().types(true)) foreach(var baseType in type.BaseTypes) if (baseType.str() == "System.Web.UI.UserControl") { var astData = new O2MappedAstData(); astData.loadFile(file); foreach(var iMethod in astData.iMethods()) { var o2Finding = new O2Finding(); o2Finding.vulnName = url; o2Finding.vulnType = "Web EntryPoint"; var source = new O2Trace(url); var sink = new O2Trace(iMethod.fullName()); source.traceType = TraceType.Source; sink.traceType = TraceType.Known_Sink; source.childTraces.Add(sink); o2Finding.o2Traces.Add(source); o2Findings.Add(o2Finding); } } progressBar.increment(1); } return o2Findings; }