コード例 #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 namespace info
            DetectNamespace detectNS = new DetectNamespace();

            detectNS.add(push);
            parser.add(detectNS);
            // capture user defined namespace info
            DetectUserNamespace detectUNS = new DetectUserNamespace();

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

            detectCl.add(push);
            parser.add(detectCl);
            // capture delegate info
            DetectDelegate detectDel = new DetectDelegate();

            detectDel.add(push);
            parser.add(detectDel);
            // handle leaving scopes
            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);
        }
コード例 #4
0
ファイル: RulesAndActions.cs プロジェクト: prmk/CodeAnalyzer
        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);
        }
コード例 #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 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;
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
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 delegate
            DetectDelegate detectDL = new DetectDelegate();

            detectDL.add(push);
            parser.add(detectDL);


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

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

            DetectEnum detectEN = new DetectEnum();

            detectEN.add(push);
            parser.add(detectEN);

            //capture complexity
            DetectComp complex = new DetectComp();

            complex.add(push);
            parser.add(complex);

            // 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);
        }
コード例 #9
0
ファイル: Parser.cs プロジェクト: Logeshkumar/Projects
 public virtual Parser build()
 {
   Parser parser = new Parser();
   Print print = new Print();
   DetectNamespace detectNS = new DetectNamespace();
   detectNS.add(print);
   parser.add(detectNS);
   DetectClass detectCl = new DetectClass();
   detectCl.add(print);
   parser.add(detectCl);
   ///////////////////////////////////////////////////
   // If you wanted to show member functions you 
   // might do that something like this:
   //   DetectFunction detectFN = new DetectFunction(parser.ScopeStack());
   //   PrintFunction printFunction = new PrintFunction();
   //   detectFN.add(printFunction);
   //   parser.add(detectFN);
   return parser;
 }
コード例 #10
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;
        }
コード例 #11
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;
 }
コード例 #12
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);
        }