예제 #1
0
        // Build a Parser to retrieve Function Complexities or user defined Types
        public virtual Parser build()
        {
            Parser parser = new Parser();

            // action used for namespaces, classes, and functions
            PushStack          push = new PushStack(repo);
            AddUserDefinedType addUserDefinedType = new AddUserDefinedType(repo);

            // capture namespace info
            DetectNamespace detectNS = new DetectNamespace();

            detectNS.add(push);
            parser.add(detectNS);

            // capture class info
            DetectType detectCl = new DetectType();

            detectCl.add(push);
            detectCl.add(addUserDefinedType);
            parser.add(detectCl);


            // capture function info
            DetectFunction detectFN = new DetectFunction();

            detectFN.add(push);
            parser.add(detectFN);

            // handle entering anonymous scopes, e.g., if, while, etc.
            DetectAnonymousScope anon = new DetectAnonymousScope();

            anon.add(push);
            parser.add(anon);


            // handle leaving scopes
            DetectLeavingScope leave = new DetectLeavingScope();
            PopStack           pop   = new PopStack(repo);

            leave.add(pop);
            parser.add(leave);

            // handle entering braceless Scopes
            DetectBracelessScope braless = new DetectBracelessScope();

            parser.add(braless);

            // parser configured
            return(parser);
        }
        public virtual Parser build()
        {
            Parser   parser = new Parser();
            PopStack pop    = new PopStack(repo, file_);

            AAction.displaySemi  = false;
            AAction.displayStack = false;
            PushStack       push     = new PushStack(repo);
            DetectNamespace detectNS = new DetectNamespace();

            detectNS.add(push);
            parser.add(detectNS);
            DetectType detectTP = new DetectType();

            detectTP.add(push);
            parser.add(detectTP);
            DetectDelegate detectDE = new DetectDelegate();

            detectDE.add(push);
            detectDE.add(pop);
            parser.add(detectDE);
            DetectFunction detectFN = new DetectFunction();

            detectFN.add(push);
            parser.add(detectFN);
            DetectAnonymousScope anon = new DetectAnonymousScope();

            anon.add(push);
            parser.add(anon);
            DetectAlias    detectAL  = new DetectAlias();
            CollectAliases collectAL = new CollectAliases(repo);

            detectAL.add(collectAL);
            parser.add(detectAL);
            DetectLeavingScope leave = new DetectLeavingScope();

            leave.add(pop);
            parser.add(leave);
            DetectUsingNamespace detectUN  = new DetectUsingNamespace();
            CollectNamespace     collectNM = new CollectNamespace(repo, file_);

            detectUN.add(collectNM);
            parser.add(detectUN);
            return(parser);
        }
        public virtual Parser build()
        {
            Parser   parser = new Parser();
            PopStack pop    = new PopStack(repo, file_);

            // decide what to show
            AAction.displaySemi  = false;
            AAction.displayStack = false;  // false is default

            // action used for namespaces, classes, and functions
            PushStack push = new PushStack(repo);

            // capture namespace info
            DetectNamespace detectNS = new DetectNamespace();

            detectNS.add(push);
            parser.add(detectNS);

            //// capture type info
            DetectType detectTP = new DetectType();

            detectTP.add(push);
            parser.add(detectTP);

            DetectDelegate detectDE = new DetectDelegate();

            detectDE.add(push);
            detectDE.add(pop);
            parser.add(detectDE);

            //// capture function info
            DetectFunction detectFN = new DetectFunction();

            detectFN.add(push);
            parser.add(detectFN);

            //// handle entering anonymous scopes, e.g., if, while, etc.
            DetectAnonymousScope anon = new DetectAnonymousScope();

            anon.add(push);
            parser.add(anon);

            DetectAlias    detectAL  = new DetectAlias();
            CollectAliases collectAL = new CollectAliases(repo);

            detectAL.add(collectAL);
            parser.add(detectAL);

            // handle leaving scopes
            DetectLeavingScope leave = new DetectLeavingScope();

            leave.add(pop);
            parser.add(leave);

            DetectUsingNamespace detectUN  = new DetectUsingNamespace();
            CollectNamespace     collectNM = new CollectNamespace(repo, file_);

            detectUN.add(collectNM);
            parser.add(detectUN);

            // parser configured
            return(parser);
        }