public override bool test(CSsemi.CSemiExp semi) { int brIndex = semi.Contains("{"); if (brIndex != -1) { return(false); } int hashIndex = semi.Contains("#"); if (hashIndex != -1) { return(false); } int index = semi.FindFirst("("); if (index > 0 && DetectFunction.isSpecialToken(semi[index - 1])) { CSsemi.CSemiExp local = new CSsemi.CSemiExp(); // create local semiExp with tokens for type and name local.displayNewLines = false; local.Add("control").Add("anonymous"); doActions(local); return(true); } return(false); }
public virtual Parser build() { Parser parser = new Parser(); AAction.displaySemi = false; AAction.displayStack = false; DetectProperty detectME = new DetectProperty(); CollectMember collectME = new CollectMember(ref currentNode); detectME.add(collectME); parser.add(detectME); DetectNewOperator detectNO = new DetectNewOperator(); detectNO.add(collectME); parser.add(detectNO); DetectFunction detectFN = new DetectFunction(); CollectReturn collectRT = new CollectReturn(ref currentNode); detectFN.add(collectRT); parser.add(detectFN); DetectInheritance detectIN = new DetectInheritance(); detectIN.add(collectRT); parser.add(detectIN); DetectEnd detectEN = new DetectEnd(); SaveAll sa = new SaveAll(ref currentNode); detectEN.add(sa); parser.add(detectEN); 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); // 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); }
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); }
// 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(); 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); }
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()//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); }
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); }
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; }
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; }
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; }
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); }
// function to analyze using relationship public void UsingAnalyze(CSsemi.CSemiExp local, List<Elem> TABLE, Elem e) { DetectFunction df = new DetectFunction(); if (df.test(local) == true && local.Contains("(") != -1 && local.Contains(")") != -1 && local.Contains("{") != -1) { foreach (Elem ele in TABLE) { if (local.Contains(ele.name) > -1 && ele.UsingFlag == false && (ele.type == "class" || ele.type == "interface" || ele.type == "enum")) { ele.UsingFlag = true; Console.Write("\n using: "); int index = local.Contains(ele.name); Console.Write(" {0}", local[index]); continue; } } } }
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); }