Exemplo n.º 1
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 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);
        }
Exemplo n.º 2
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 namespaces, classes, and functions
            PushStack push = new PushStack(repo);
            // 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 enum info
            DetectEnum detectEn = new DetectEnum();

            detectEn.add(push);
            parser.add(detectEn);
            // capture Delegate info
            DetectDelegate detectDe = new DetectDelegate();

            detectDe.add(push);
            parser.add(detectDe);
            // capture function info
            DetectFunction detectFN = new DetectFunction();

            detectFN.add(push);
            parser.add(detectFN);
            //Detect Complexity
            DetectComplexity detectComp = new DetectComplexity();

            detectComp.add(push);
            parser.add(detectComp);
            // 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);
            // parser configured
            return(parser);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        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_rel push = new PushStack_rel(repo_rel);

            //detect Inheritance elem info
            DetectInheritance detectIn = new DetectInheritance();

            detectIn.add(push);
            parser.add(detectIn);
            // 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 aggregation info
            DetectAggregation detectAg = new DetectAggregation();

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

            DetectComposition detectComp = new DetectComposition();

            detectComp.add(push);
            parser.add(detectComp);

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

            anon.add(push);
            parser.add(anon);
            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);
        }
Exemplo n.º 7
0
        public virtual Parser build()
        {
            Parser parser = new Parser();

            AAction.displaySemi  = true;
            AAction.displayStack = false;  // this is default so redundant
            PushStack       push     = new PushStack(repo);
            DetectNamespace detectNS = new DetectNamespace();

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

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

            detectFN.add(push);
            parser.add(detectFN);
            DetectScope detectScop = new DetectScope();

            detectScop.add(push);
            parser.add(detectScop);
            DetectScopeWithoutBraces detectScopWB = new DetectScopeWithoutBraces();

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

            anon.add(push);
            parser.add(anon);
            DetectLeavingScopeWithoutBraces leaveWB = new DetectLeavingScopeWithoutBraces();
            PopStack popWB = new PopStack(repo);

            leaveWB.add(popWB);
            parser.add(leaveWB);
            DetectLeavingScope leave = new DetectLeavingScope();
            PopStack           pop   = new PopStack(repo);

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

            return(parser);
        }
Exemplo n.º 8
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);
        }
        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);
            writeTypeTable writetable = new writeTypeTable(repo);                            //add write TypeTable Action to the rules
            // capture namespace info
            DetectNamespace detectNS = new DetectNamespace();

            detectNS.add(push);
            //detectNS.add(writetable);                                                        //add write TypeTable Action to the rules
            parser.add(detectNS);
            // capture class info
            DetectClass detectCl = new DetectClass();

            detectCl.add(push);
            detectCl.add(writetable);
            parser.add(detectCl);
            // capture function info
            DetectFunction detectFN = new DetectFunction();

            detectFN.add(push);
            detectFN.add(writetable);                                                       //add write TypeTable Action to the rules
            parser.add(detectFN);
            DetectDelegate detectD = new DetectDelegate();                                  //capture delegate info

            detectD.add(push);
            detectD.add(writetable);
            parser.add(detectD);
            DetectAlias detectAl = new DetectAlias();                                       //capture Alias info

            detectAl.add(push);
            detectD.add(writetable);
            parser.add(detectAl);
            DetectEnum detectEn = new DetectEnum();                                          //capture Enum info

            detectEn.add(push);
            detectEn.add(writetable);
            parser.add(detectEn);
            // 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);
        }
        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);
        }
Exemplo n.º 11
0
        public virtual Parser build()//Virtual function returns reference to parser ss
        {
            Parser parser = new Parser();


            // decide what to show
            AAction.displaySemi  = false;  //Change here to see things running ss
            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);//one rule one action

            // capture delegate info
            DetectDelegate detectDG = new DetectDelegate();

            detectDG.add(push);
            parser.add(detectDG);

            // capture Alias info
            DetectAlias detectAL = new DetectAlias();

            detectAL.add(push);
            parser.add(detectAL);

            // 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);
        }
Exemplo n.º 12
0
        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 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 these scopes -  "if", "for", "foreach", "while", "catch", "try", "switch" among others
            DetectScope detectScop = new DetectScope();

            detectScop.add(push);
            parser.add(detectScop);

            // handle these scopes without braces-  "if", "for", "foreach", "while", "catch", "try", "switch" among others
            DetectScopeWithoutBraces detectScopWB = new DetectScopeWithoutBraces();

            detectScopWB.add(push);
            parser.add(detectScopWB);

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

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

            // handle leaving scopes
            DetectLeavingScopeWithoutBraces leaveWB = new DetectLeavingScopeWithoutBraces();
            PopStack popWB = new PopStack(repo);

            leaveWB.add(popWB);
            parser.add(leaveWB);

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

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

            // parser configured
            return(parser);
        }
        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 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);

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

              // parser configured
              return parser;
        }
Exemplo n.º 14
0
        public virtual Parser build(bool isFirstPass)
        {
            repo.isFirstPass = isFirstPass;

            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 namespace info
            DetectNamespace detectNS = new DetectNamespace();

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

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

            detectCl.add(push);
            AddClass addClass = new AddClass(repo);

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

            // detect class members
            DetectClassMembers detectClassMembers = new DetectClassMembers();
            SaveDeclar         saveDeclar         = new SaveDeclar(repo);

            detectClassMembers.add(saveDeclar);
            parser.add(detectClassMembers);

            // detect function members
            DetectFunctionMembers detectFunctionMembers = new DetectFunctionMembers();

            saveDeclar = new SaveDeclar(repo);
            detectFunctionMembers.add(saveDeclar);
            parser.add(detectFunctionMembers);

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

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

            // parser configured
            return(parser);
        }
Exemplo n.º 15
0
        public virtual Parser build()
        {
            Parser parser = new Parser();

            //UserType userType = new UserType();

            // 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 class info
            DetectClass detectCl = new DetectClass();

            //SaveUserDefinedType save = new SaveUserDefinedType(UserType.getUserDefinedSet());
            detectCl.add(push);
            //detectCl.add(save);
            parser.add(detectCl);

            //// handle inheritance detection
            //DetectInheritance detectInheritance = new DetectInheritance();
            //UpdateCoupling update = new UpdateCoupling(repo);
            //detectInheritance.add(update);
            //parser.add(detectInheritance);

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

            //this rule detects variable declaration and instantiation for coupling
            DetectAssociation detectAssociation = new DetectAssociation();
            UpdateCoupling    update            = new UpdateCoupling(repo);

            detectAssociation.add(update);
            parser.add(detectAssociation);

            // parser configured
            return(parser);
        }
Exemplo n.º 16
0
        public virtual Parser build()
        {
            Parser parser = new Parser();
            AAction.displaySemi = true;
            AAction.displayStack = false;  // this is default so redundant
            PushStack push = new PushStack(repo);
            DetectNamespace detectNS = new DetectNamespace();
            detectNS.add(push);
            parser.add(detectNS);
            DetectClass detectCl = new DetectClass();
            detectCl.add(push);
            parser.add(detectCl);
            DetectFunction detectFN = new DetectFunction();
            detectFN.add(push);
            parser.add(detectFN);
            DetectScope detectScop = new DetectScope();
            detectScop.add(push);
            parser.add(detectScop);
            DetectScopeWithoutBraces detectScopWB = new DetectScopeWithoutBraces();
            detectScopWB.add(push);
            parser.add(detectScopWB);
            DetectAnonymousScope anon = new DetectAnonymousScope();
            anon.add(push);
            parser.add(anon);
            DetectLeavingScopeWithoutBraces leaveWB = new DetectLeavingScopeWithoutBraces();
            PopStack popWB = new PopStack(repo);
            leaveWB.add(popWB);
            parser.add(leaveWB);
            DetectLeavingScope leave = new DetectLeavingScope();
            PopStack pop = new PopStack(repo);
            leave.add(pop);
            parser.add(leave);

            return parser;
        }
Exemplo n.º 17
0
 public virtual Parser build()    {
   Parser parser = new Parser();
   AAction.displaySemi = false;
   AAction.displayStack = false;  // this is default so redundant
   PushStack push = new PushStack(repo);
   // capture namespace info
   DetectNamespace detectNS = new DetectNamespace();
   detectNS.add(push);
   parser.add(detectNS);
   // capture struct info
   DetectStruct detectSt = new DetectStruct();
   detectSt.add(push);
   parser.add(detectSt);
   // capture enum info
   DetectEnum detectEn = new DetectEnum();
   detectEn.add(push);
   parser.add(detectEn);
   // capture delegate info
   DetectDelegate detectDl = new DetectDelegate();
   detectDl.add(push);
   parser.add(detectDl);
   // 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);
   // capture array info
   DetectArray detectArr = new DetectArray();
   detectArr.add(push);
   parser.add(detectArr);
   // handle leaving scopes
   DetectLeavingScope leave = new DetectLeavingScope();
   PopStack pop = new PopStack(repo);
   leave.add(pop);
   parser.add(leave);
   // capture bracelessscope info
   DetectBraceLess detectBL = new DetectBraceLess();
   detectBL.add(push);
   parser.add(detectBL);
   // parser configured
   return parser;
 }