public virtual Parser build()
        {
            Parser parser = new Parser();

            // 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 using info
            DetectUsing detectU = new DetectUsing();

            detectU.add(push);
            parser.add(detectU);

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

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

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

            detectCl.add(push);
            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);

            // show public declarations
            DetectPublicDeclar pubDec = new DetectPublicDeclar();
            SaveDeclar         print  = new SaveDeclar(repo);

            pubDec.add(print);
            parser.add(pubDec);

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

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

            // parser configured
            return(parser);
        }
示例#2
0
        private void AddRules(Parser parser, PushStack push, AddRelationship addRelationship)
        {
            // capture namespace info
            DetectNamespace detectNS = new DetectNamespace();

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

            // capture Aggregation
            DetectAggregation detectAg = new DetectAggregation();

            detectAg.add(addRelationship);
            parser.add(detectAg);

            // capture class info
            DetectInheritance detectIn = new DetectInheritance();

            detectIn.add(push);
            detectIn.add(addRelationship);
            parser.add(detectIn);


            // capture function info and try to detect using relationship
            DetectUsing detectUs = new DetectUsing();

            detectUs.add(push);
            detectUs.add(addRelationship);
            parser.add(detectUs);

            // 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);


            // capture Composition
            DetectComposition detectComp = new DetectComposition();

            detectComp.add(addRelationship);
            parser.add(detectComp);
        }
        public virtual Parser build()
        {
            Parser parser = new Parser();

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

            // action used for inheritance, aggregation, composition and using
            PushStackRelationship push = new PushStackRelationship(repo);

            // capture Inheritance info
            DetectInheritance detectNS = new DetectInheritance();

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

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

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

            // capture Aggr info
            DetectAggregation detectAG = new DetectAggregation();

            detectAG.add(push);
            parser.add(detectAG);

            // capture Composition info
            DetectComposition detectCP = new DetectComposition();

            detectCP.add(push);
            parser.add(detectCP);

            // capture Using info
            DetectUsing detectUs = new DetectUsing();

            detectUs.add(push);
            parser.add(detectUs);

            // parser configured
            return(parser);
        }
示例#4
0
        public virtual Parser build()
        {
            Parser parser = new Parser();

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

            detectNS.add(push);
            parser.add(detectNS);
            DetectUsing detectUS = new DetectUsing();

            detectUS.add(push);
            parser.add(detectUS);
            DetectDelegate detectDel = new DetectDelegate();

            detectDel.add(push);
            parser.add(detectDel);
            DetectClass detectCl = new DetectClass();

            detectCl.add(push);
            parser.add(detectCl);
            DetectFunction detectFN = new DetectFunction();

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

            anon.add(push);
            parser.add(anon);
            DetectPublicDeclar pubDec = new DetectPublicDeclar();
            SaveDeclar         print  = new SaveDeclar(repo);

            pubDec.add(print);
            parser.add(pubDec);
            DetectLeavingScope leave = new DetectLeavingScope();
            PopStack           pop   = new PopStack(repo);

            leave.add(pop);
            parser.add(leave);
            return(parser);
        }
示例#5
0
        public virtual Parser build()
        {
            Parser parser = new Parser();

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

            // action used for using and other namespace uses.
            PushStack push = new PushStack(repo);

            // capture using info
            DetectUsing detectUS = new DetectUsing();

            detectUS.add(push);
            parser.add(detectUS);

            // capture inheritance info
            DetectIN detectIN = new DetectIN();

            detectIN.add(push);
            //Console.WriteLine(detectIN);
            parser.add(detectIN);

/*
 *          // show public declarations
 *          DetectPublicDeclar pubDec = new DetectPublicDeclar();
 *          SaveDeclar print = new SaveDeclar(repo);
 *          pubDec.add(print);
 *          parser.add(pubDec);
 *
 *          // handle leaving scopes
 *          DetectLeavingScope leave = new DetectLeavingScope();
 *          PopStack pop = new PopStack(repo);
 *          leave.add(pop);
 *          parser.add(leave);
 */
            // parser configured
            return(parser);
        }
示例#6
0
        /*creates the parser object and adds all the rules used to find the relationships like
         * inheritance/aggregation/composition/using
         */
        public virtual Parser build()
        {
            Parser parser = new Parser();

            // decide what to show
            AAction.displaySemi  = true;
            AAction.displayStack = false;  // this is default so redundant

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

            // Find inheritance info
            DetectInheritance detectIn = new DetectInheritance();

            detectIn.add(push);
            parser.add(detectIn);

            // Find aggregated info
            DetectAggregation detectAg = new DetectAggregation();

            detectAg.add(push);
            parser.add(detectAg);

            // Find composition info
            DetectComposition detectCs = new DetectComposition();

            detectCs.add(push);
            parser.add(detectCs);

            // Find using info
            DetectUsing detectUs = new DetectUsing();

            detectUs.add(push);
            parser.add(detectUs);

            // parser configured
            return(parser);
        }
示例#7
0
        public virtual Parser build()
        {
            Parser parser = new Parser();

            AAction.displaySemi  = false;         // decide what to show
            AAction.displayStack = false;         // false is default
            PushStack push = new PushStack(repo); // action used for namespaces, classes, and functions

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

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

            DetectDelegate detectDel = new DetectDelegate(); // capture delegates info

            detectDel.add(push);
            parser.add(detectDel);

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

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

            DetectUsing detectUsing = new DetectUsing();   // capture using info

            detectUsing.add(push);
            parser.add(detectUsing);

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

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

            return(parser);  // parser configured
        }
        public virtual Parser build()
        {
            Parser parser = new Parser();

            // decide what to show
            AAction.displaySemi = true;
            AAction.displayStack = false;  // this is default so redundant

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

            // capture inheritance info
            DetectInheritance detectIn = new DetectInheritance();
            detectIn.add(push);
            parser.add(detectIn);

            // capture aggregated info
            DetectAggregation detectAg = new DetectAggregation();
            detectAg.add(push);
            parser.add(detectAg);

            DetectComposition detectCs = new DetectComposition();
            detectCs.add(push);
            parser.add(detectCs);

            DetectUsing detectUs = new DetectUsing();
            detectUs.add(push);
            parser.add(detectUs);

            // parser configured
            return parser;
        }
示例#9
0
        public virtual Parser build()
        {
            Parser parser = new Parser();

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

            // action used for inheritance, aggregation, composition and using
            PushStackRelationship push = new PushStackRelationship(repo);

            // capture Inheritance info
            DetectInheritance detectNS = new DetectInheritance();
            detectNS.add(push);
            parser.add(detectNS);

            // capture class info
            DetectClass detectCl = new DetectClass();
            detectCl.add(push);
            parser.add(detectCl);

            // capture Aggr info
            DetectAggregation detectAG = new DetectAggregation();
            detectAG.add(push);
            parser.add(detectAG);

            // capture Composition info
            DetectComposition detectCP = new DetectComposition();
            detectCP.add(push);
            parser.add(detectCP);

            // capture Using info
            DetectUsing detectUs = new DetectUsing();
            detectUs.add(push);
            parser.add(detectUs);

            // parser configured
            return parser;
        }
    public virtual Parser build_relation()
    {
        Parser parser_rel = new Parser();

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

        //// action used for namespaces, classes, and functions
        PushStack_relation push_rel = new PushStack_relation(repo);

        // capture inheritence info
        DetectInheritance detectIn = new DetectInheritance();
        detectIn.add(push_rel);
        parser_rel.add(detectIn);

        // capture inheritence info
        DetectAggregation detectAg = new DetectAggregation();
        detectAg.add(push_rel);
        parser_rel.add(detectAg);

        // capture using info
        DetectUsing detectUs = new DetectUsing();
        detectUs.add(push_rel);
        parser_rel.add(detectUs);

        // capture using info
        DetectComposition detectCm = new DetectComposition();
        detectCm.add(push_rel);
        parser_rel.add(detectCm);

        // capture inheritence info
        DetectClassRelation detectCl = new DetectClassRelation();
        detectCl.add(push_rel);
        parser_rel.add(detectCl);


        // parser configured
        return parser_rel;

    }