WebFuzzing / EvoMaster

The first open-source AI-driven tool for automatically generating system-level test cases (also known as fuzzing) for web/enterprise applications. Currently targeting whitebox and blackbox testing of Web APIs, like REST, GraphQL and RPC (e.g., gRPC and Thrift).
GNU Lesser General Public License v3.0
470 stars 79 forks source link

Feat/solver table alias #1028

Closed agusaldasoro closed 1 month ago

agusaldasoro commented 1 month ago

Summary

This PR enhances the SMTConditionVisitor and related classes to support SQL queries involving multiple tables, table aliases, and conditions with operands in different orders. Specifically, it addresses the following features:

  1. Support for Multiple Tables (JOIN):

    • The SMTConditionVisitor now supports SQL conditions involving more than one table. For example, it can handle queries like SELECT * FROM users u JOIN products p WHERE u.age > p.min_age.
  2. Support for Table Aliases:

    • The SMTConditionVisitor and related classes can now handle queries with table aliases. For instance, it supports queries like SELECT * FROM USERS u WHERE u.age > 30.
  3. Support for Conditions with Operands in Different Orders:

    • The SMTConditionVisitor can now process SQL conditions where the column and literal operands are in reverse order. For example, it supports conditions like SELECT * FROM USERS WHERE 7 = age.

Detailed Changes

  1. SMTConditionVisitor:

    • Modified to support multiple tables by including a tableAliases map that associates aliases with their corresponding table names.
    • Enhanced the visit methods to reference columns using the table aliases correctly.
    • Updated the getColumnReference method to use the correct table name based on the alias provided.
  2. SmtLibGenerator:

    • Updated the appendQueryConstraints method to pass table aliases to the SMTConditionVisitor.
    • Adjusted the method to handle the parsing and mapping of table aliases correctly.
  3. Example Adjustments:

    • Adjusted the example conditions and assertions to support the new features.