Package hampi.grammars.apps

Examples of hampi.grammars.apps.GrammarStringBounder


    System.out.println(solve);
  }

  public void testGrammarBound8_comment() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 21;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
    h.setSolver(stp());
    Regexp sigmaStar = h.starRegexp(h.orRegexp(h.orRegexp(charRegexp(alpha, h))));
    Expression query = h.concatExpr(h.constExpr("UPDATE"), h.varExpr("v"), h.constExpr("'"));
View Full Code Here


    System.out.println(solve);
  }

  public void testGrammarBound9() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 40;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "SelectStmt", bound, false);
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
    h.setSolver(stp());
    Regexp sigmaStar = h.starRegexp(h.orRegexp(h.orRegexp(charRegexp(alpha, h))));
    Expression query = h.concatExpr(h.constExpr("SELECT * FROM Faq WHERE context = '"), h.varExpr("v"), h.constExpr("'"));
View Full Code Here

   * <br>
   * NOTE: out of memory
   */
  public void testGrammarBound10() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 30;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);

    assertTrue(boundedRegexp.matches("UPDATE m SET n='1' WHERE '1'='1'--', D='1'"));//make sure the intended solution works
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
    h.setSolver(stp());
View Full Code Here

   * <br>
   * NOTE: way out of memory
   */
  public void testGrammarBound11() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 110; //at least
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);

    assertTrue(boundedRegexp
        .matches("UPDATE MembersMain SET Name = '1' WHERE '1'='1'--', Division = '1', RankCorp = '1', Vacation = '1', Comment = '1', LastUpdate = Now(), Deleted = '1' WHERE MemberID = '1'"));//make sure the intended solution works
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
View Full Code Here

   * <br>
   * VAR = 1' OR '1'='1<br>
   */
  public void testGrammarBound12() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 110; //at least
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);

    assertTrue(boundedRegexp
        .matches("SELECT MemberID, Name, Division, DateJoined, RankCorp, Vacation, Comment, Deleted FROM MembersMain WHERE MemberID='1' OR '1'='1'"));//make sure the intended solution works
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
View Full Code Here

   * <br>
   * VAR = 1' OR '1'='1 (length 12 chars)<br>
   */
  public void testGrammarBound12_small() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 25;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "SelectStmt", bound, false);

    assertTrue(boundedRegexp.matches("SELECT M FROM m WHERE d='1' OR '1'='1'"));//make sure the intended solution works
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
    h.setSolver(stp());
View Full Code Here

   * Query = UPDATE MembersMain SET Vacation = 'x' WHERE '1'='1'--' WHERE Name = '1' (length 56 tokens)
   * VAR = x' WHERE '1'='1'-- (length 18 chars)
   */
  public void testGrammarBound13() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 56;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "SelectStmt", bound, false);

    assertTrue(boundedRegexp.matches("SELECT M FROM m WHERE d='1' OR '1'='1'"));//make sure the intended solution works
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
    h.setSolver(stp());
View Full Code Here

TOP

Related Classes of hampi.grammars.apps.GrammarStringBounder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.