public static API_CatNet save_Report_To(this API_CatNet catNet, string file)
 {
     file.deleteIfExists();
     catNet.Engine.Configuration.ReportFile          = file;
     catNet.Engine.Configuration.ReportXslOutputFile = file + ".html";
     return(catNet);
 }
        public static API_CatNet analyze(this API_CatNet catNet, string file)
        {
            var o2Timer = new O2Timer("Scanned file in :").start();

            catNet.Engine.Analyze(file);
            o2Timer.stop();

            catNet.Engine.AnalysisEngine.ResetState();
            return(catNet);
        }
        public static ascx_FindingsViewer show(this API_CatNet catNet, Control control, SourceCodeEditor codeEditor = null)
        {
            var reportFile = catNet.Engine.Configuration.ReportFile;

            if (reportFile.valid())
            {
                return(control.add_CatNet_FindingsViewer(reportFile, codeEditor));
            }
            return(null);
        }
        public static API_CatNet_GUI scanAssembly(this API_CatNet_GUI catNetGui, string file)
        {
            catNetGui.SolutionLoaded         = "";
            catNetGui.TriggerOnSelectedEvent = false;
            var catNet      = new API_CatNet().loadRules();
            var savedReport = catNet.scan(file).savedReport();

            catNetGui.openReport(savedReport);
            return(catNetGui);
        }
        public static API_CatNet_GUI scanSolution(this API_CatNet_GUI catNetGui, string solutionFile)
        {
            catNetGui.TriggerOnSelectedEvent = true;
            catNetGui.SolutionLoaded         = solutionFile;
            var catNet      = new API_CatNet().loadRules();
            var assemblies  = solutionFile.compileSolution();
            var savedReport = catNet.scan(assemblies).savedReport();

            catNetGui.openReport(savedReport);
            return(catNetGui);
        }
        public static API_CatNet_GUI scanCSharpFile(this API_CatNet_GUI catNetGui, string file)
        {
            catNetGui.SolutionLoaded         = "";
            catNetGui.TriggerOnSelectedEvent = false;
            var catNet   = new API_CatNet().loadRules();
            var assembly = new CompileEngine().compileSourceFile(file);

            if (assembly.notNull())
            {
                catNetGui.openReport(catNet.scan(assembly).savedReport());
            }
            else
            {
                catNetGui.CodeViewer.open(file);
            }
            return(catNetGui);
        }
        public static API_CatNet analyze(this API_CatNet catNet, List <Assembly> assembliesToScan)
        {
            var o2Timer = new O2Timer("Scanned assembly in :").start();

            try
            {
                var analysisEngine = catNet.Engine.AnalysisEngine;

                analysisEngine.BeginAnalysis();

                var cci          = "CatNet_1.1/SourceDir/Microsoft.Cci.dll".assembly();
                var assemblyNode = cci.type("AssemblyNode");
                foreach (var assemblyToScan in assembliesToScan)
                {
                    var module = assemblyNode.invokeStatic("GetAssembly", assemblyToScan, null, true, true, true);

                    if (module.notNull())
                    {
                        analysisEngine.invoke("AnalyzeModule", module);
                    }
                    else
                    {
                        "[API_CatNet][analyze] could not get Module for provided assembly: {0}".error(assemblyToScan);
                    }
                }
                analysisEngine.FinalizeState();
                catNet.Engine.RulesEngine.Process(analysisEngine);
                analysisEngine.EndAnalysis();
                catNet.Engine.SaveReport();
                analysisEngine.ResetState();
                o2Timer.stop();
            }
            catch (Exception ex)
            {
                ex.log("[API_CatNet][analyze] assembly");
            }
            return(catNet);
        }
 public static API_CatNet scan_Assembly(this API_CatNet catNet, Assembly assemblyToScan)
 {
     return(catNet.scan(assemblyToScan));
 }
 public static List <string> rules_Names(this API_CatNet catNet)
 {
     return((from rule in catNet.rules()
             select rule.Info.Name).toList());
 }
예제 #10
0
 public static List <Rules.Rule> rules(this API_CatNet catNet)
 {
     return(catNet.Engine.RulesEngine.Rules.toList());
 }
예제 #11
0
 public static API_CatNet loadRules(this API_CatNet catNet)
 {
     catNet.Engine.RulesEngine.LoadDirectory(catNet.Rules_Folder);
     return(catNet);
 }
예제 #12
0
 public static API_CatNet scan(this API_CatNet catNet, string file)
 {
     return(catNet.analyze(file));
 }
예제 #13
0
 public static API_CatNet scan(this API_CatNet catNet, List <Assembly> assembliesToScan)
 {
     return(catNet.analyze(assembliesToScan));
 }
예제 #14
0
 public static string engineDirectory(this API_CatNet catNet)
 {
     return(catNet.Engine.type().Assembly.Location.directoryName());
 }
예제 #15
0
 public static string output(this API_CatNet catNet)
 {
     return(catNet.EventsLog.OutputLines.str());
 }
예제 #16
0
 public static API_CatNet save_GraphML_To(this API_CatNet catNet, string file)
 {
     catNet.Engine.Configuration.DataFlowGraphFile = file;
     return(catNet);
 }
예제 #17
0
 public static string savedReport(this API_CatNet catNet)
 {
     return(catNet.Engine.Configuration.ReportFile);
 }
예제 #18
0
 public static API_CatNet scan(this API_CatNet catNet, Assembly assemblyToScan)
 {
     return(catNet.scan(new List <Assembly>().add(assemblyToScan)));
 }
예제 #19
0
 public static Rules.Rule rule(this API_CatNet catNet, string ruleName)
 {
     return((from rule in catNet.rules()
             where rule.Info.Name == ruleName
             select rule).first());
 }