diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 3af1c5ad8..80975e83a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -2,13 +2,13 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=javax.annotation.ParametersAreNonnullByDefault org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullable.secondary= -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 @@ -57,15 +57,15 @@ org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning @@ -79,7 +79,7 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning diff --git a/grammars/expr_types.g4 b/grammars/expr_types.g4 new file mode 100644 index 000000000..36c30d854 --- /dev/null +++ b/grammars/expr_types.g4 @@ -0,0 +1,109 @@ +// Type annotations for SQL expressions +// This file contains type annotations for the core expression rules in SQL + +// Expression rules with type annotations +expr returns [SQLType type] + : boolPri (IS_SYMBOL notRule? type = (TRUE_SYMBOL | FALSE_SYMBOL | UNKNOWN_SYMBOL))? # exprIs + | NOT_SYMBOL expr # exprNot + | expr op = (AND_SYMBOL | LOGICAL_AND_OPERATOR) expr # exprAnd + | expr XOR_SYMBOL expr # exprXor + | expr op = (OR_SYMBOL | LOGICAL_OR_OPERATOR) expr # exprOr + ; + +boolPri returns [SQLType type] + : predicate # primaryExprPredicate + | boolPri IS_SYMBOL notRule? NULL_SYMBOL # primaryExprIsNull + | boolPri compOp predicate # primaryExprCompare + | boolPri compOp (ALL_SYMBOL | ANY_SYMBOL) subquery # primaryExprAllAny + ; + +predicate returns [SQLType type] + : bitExpr ( + notRule? predicateOperations + | MEMBER_SYMBOL OF_SYMBOL? simpleExprWithParentheses + | SOUNDS_SYMBOL LIKE_SYMBOL bitExpr + )? + ; + +bitExpr returns [SQLType type] + : simpleExpr # bitExprSimple + | bitExpr op = BITWISE_XOR_OPERATOR bitExpr # bitExprXor + | bitExpr op = (MULT_OPERATOR | DIV_OPERATOR | MOD_OPERATOR | DIV_SYMBOL | MOD_SYMBOL) bitExpr # bitExprArithmetic + | bitExpr op = (PLUS_OPERATOR | MINUS_OPERATOR) bitExpr # bitExprAddSub + | bitExpr op = (PLUS_OPERATOR | MINUS_OPERATOR) INTERVAL_SYMBOL expr interval # bitExprInterval + | bitExpr op = (SHIFT_LEFT_OPERATOR | SHIFT_RIGHT_OPERATOR) bitExpr # bitExprShift + | bitExpr op = BITWISE_AND_OPERATOR bitExpr # bitExprAnd + | bitExpr op = BITWISE_OR_OPERATOR bitExpr # bitExprOr + ; + +simpleExpr returns [SQLType type] + : columnRef jsonOperator? # simpleExprColumnRef + | runtimeFunctionCall # simpleExprRuntimeFunction + | functionCall # simpleExprFunction + | simpleExpr COLLATE_SYMBOL textOrIdentifier # simpleExprCollate + | literalOrNull # simpleExprLiteral + | PARAM_MARKER # simpleExprParamMarker + | rvalueSystemOrUserVariable # simpleExpressionRValue + | inExpressionUserVariableAssignment # simpleExprUserVariableAssignment + | sumExpr # simpleExprSum + | groupingOperation # simpleExprGroupingOperation + | windowFunctionCall # simpleExprWindowingFunction + | simpleExpr CONCAT_PIPES_SYMBOL simpleExpr # simpleExprConcat + | op = (PLUS_OPERATOR | MINUS_OPERATOR | BITWISE_NOT_OPERATOR) simpleExpr # simpleExprUnary + | not2Rule simpleExpr # simpleExprNot + | ROW_SYMBOL? OPEN_PAR_SYMBOL exprList CLOSE_PAR_SYMBOL # simpleExprList + | EXISTS_SYMBOL? subquery # simpleExprSubQuery + | OPEN_CURLY_SYMBOL identifier expr CLOSE_CURLY_SYMBOL # simpleExprOdbc + | MATCH_SYMBOL identListArg AGAINST_SYMBOL OPEN_PAR_SYMBOL bitExpr fulltextOptions? CLOSE_PAR_SYMBOL # simpleExprMatch + | BINARY_SYMBOL simpleExpr # simpleExprBinary + | CAST_SYMBOL OPEN_PAR_SYMBOL expr (AT_SYMBOL LOCAL_SYMBOL)? AS_SYMBOL castType arrayCast? CLOSE_PAR_SYMBOL # simpleExprCast + | CAST_SYMBOL OPEN_PAR_SYMBOL expr AT_SYMBOL TIME_SYMBOL ZONE_SYMBOL INTERVAL_SYMBOL? textStringLiteral AS_SYMBOL DATETIME_SYMBOL typeDatetimePrecision CLOSE_PAR_SYMBOL # simpleExprCastTime + | CASE_SYMBOL expr? (whenExpression thenExpression)+ elseExpression? END_SYMBOL # simpleExprCase + | CONVERT_SYMBOL OPEN_PAR_SYMBOL expr COMMA_SYMBOL castType CLOSE_PAR_SYMBOL # simpleExprConvert + | CONVERT_SYMBOL OPEN_PAR_SYMBOL expr USING_SYMBOL charsetName CLOSE_PAR_SYMBOL # simpleExprConvertUsing + | DEFAULT_SYMBOL OPEN_PAR_SYMBOL simpleIdentifier CLOSE_PAR_SYMBOL # simpleExprDefault + | VALUES_SYMBOL OPEN_PAR_SYMBOL simpleIdentifier CLOSE_PAR_SYMBOL # simpleExprValues + | INTERVAL_SYMBOL expr interval PLUS_OPERATOR expr # simpleExprInterval + ; + +// Type annotations for literals +literalOrNull returns [SQLType type] + : NUMERIC_LITERAL # literalNumeric + | STRING_LITERAL # literalString + | NULL_SYMBOL # literalNull + | TRUE_SYMBOL # literalTrue + | FALSE_SYMBOL # literalFalse + ; + +// Type annotations for functions +functionCall returns [SQLType type] + : functionName OPEN_PAR_SYMBOL (functionArgs? | MULT_OPERATOR) CLOSE_PAR_SYMBOL + ; + +// Type annotations for operators +compOp returns [SQLType type] + : EQUAL_OPERATOR # compOpEqual + | NULL_SAFE_EQUAL_OPERATOR # compOpNullSafeEqual + | GREATER_OR_EQUAL_OPERATOR # compOpGreaterEqual + | GREATER_THAN_OPERATOR # compOpGreater + | LESS_OR_EQUAL_OPERATOR # compOpLessEqual + | LESS_THAN_OPERATOR # compOpLess + | NOT_EQUAL_OPERATOR # compOpNotEqual + ; + +// Type annotations for casts +castType returns [SQLType type] + : BINARY_SYMBOL fieldLength? # castTypeBinary + | CHAR_SYMBOL fieldLength? charsetWithOptBinary? # castTypeChar + | nchar fieldLength? # castTypeNChar + | SIGNED_SYMBOL INT_SYMBOL? # castTypeSigned + | UNSIGNED_SYMBOL INT_SYMBOL? # castTypeUnsigned + | DATE_SYMBOL # castTypeDate + | TIME_SYMBOL typeDatetimePrecision? # castTypeTime + | DATETIME_SYMBOL typeDatetimePrecision? # castTypeDateTime + | DECIMAL_SYMBOL floatOptions? # castTypeDecimal + | JSON_SYMBOL # castTypeJson + | realType # castTypeReal + | FLOAT_SYMBOL standardFloatOptions? # castTypeFloat + | spatialType # castTypeSpatial + ; \ No newline at end of file diff --git a/grammars/sql_type_definitions.g4 b/grammars/sql_type_definitions.g4 new file mode 100644 index 000000000..eef3614a5 --- /dev/null +++ b/grammars/sql_type_definitions.g4 @@ -0,0 +1,244 @@ +// SQL Type Definitions +// This file contains the type definitions used in the grammar annotations + +// Base SQL Type interface +interface SQLType { + boolean isNullable(); + int getPrecision(); + int getScale(); + String getCharset(); + String getCollation(); +} + +// Numeric Types +class NumericType implements SQLType { + enum Kind { + TINYINT, + SMALLINT, + MEDIUMINT, + INT, + BIGINT, + FLOAT, + DOUBLE, + DECIMAL + } + + Kind kind; + boolean unsigned; + int precision; + int scale; + boolean nullable; + + @Override + public boolean isNullable() { return nullable; } + + @Override + public int getPrecision() { return precision; } + + @Override + public int getScale() { return scale; } + + @Override + public String getCharset() { return null; } + + @Override + public String getCollation() { return null; } +} + +// String Types +class StringType implements SQLType { + enum Kind { + CHAR, + VARCHAR, + TEXT, + ENUM, + SET + } + + Kind kind; + int length; + String charset; + String collation; + boolean nullable; + + @Override + public boolean isNullable() { return nullable; } + + @Override + public int getPrecision() { return length; } + + @Override + public int getScale() { return 0; } + + @Override + public String getCharset() { return charset; } + + @Override + public String getCollation() { return collation; } +} + +// Date/Time Types +class DateTimeType implements SQLType { + enum Kind { + DATE, + TIME, + DATETIME, + TIMESTAMP, + YEAR + } + + Kind kind; + int precision; + boolean nullable; + + @Override + public boolean isNullable() { return nullable; } + + @Override + public int getPrecision() { return precision; } + + @Override + public int getScale() { return 0; } + + @Override + public String getCharset() { return null; } + + @Override + public String getCollation() { return null; } +} + +// Binary Types +class BinaryType implements SQLType { + enum Kind { + BINARY, + VARBINARY, + BLOB + } + + Kind kind; + int length; + boolean nullable; + + @Override + public boolean isNullable() { return nullable; } + + @Override + public int getPrecision() { return length; } + + @Override + public int getScale() { return 0; } + + @Override + public String getCharset() { return null; } + + @Override + public String getCollation() { return null; } +} + +// JSON Type +class JsonType implements SQLType { + boolean nullable; + + @Override + public boolean isNullable() { return nullable; } + + @Override + public int getPrecision() { return 0; } + + @Override + public int getScale() { return 0; } + + @Override + public String getCharset() { return null; } + + @Override + public String getCollation() { return null; } +} + +// Boolean Type +class BooleanType implements SQLType { + boolean nullable; + + @Override + public boolean isNullable() { return nullable; } + + @Override + public int getPrecision() { return 0; } + + @Override + public int getScale() { return 0; } + + @Override + public String getCharset() { return null; } + + @Override + public String getCollation() { return null; } +} + +// Spatial Types +class SpatialType implements SQLType { + enum Kind { + GEOMETRY, + POINT, + LINESTRING, + POLYGON, + MULTIPOINT, + MULTILINESTRING, + MULTIPOLYGON, + GEOMETRYCOLLECTION + } + + Kind kind; + boolean nullable; + + @Override + public boolean isNullable() { return nullable; } + + @Override + public int getPrecision() { return 0; } + + @Override + public int getScale() { return 0; } + + @Override + public String getCharset() { return null; } + + @Override + public String getCollation() { return null; } +} + +// NULL Type +class NullType implements SQLType { + @Override + public boolean isNullable() { return true; } + + @Override + public int getPrecision() { return 0; } + + @Override + public int getScale() { return 0; } + + @Override + public String getCharset() { return null; } + + @Override + public String getCollation() { return null; } +} + +// Any Type (for expressions that can return any type) +class AnyType implements SQLType { + @Override + public boolean isNullable() { return true; } + + @Override + public int getPrecision() { return 0; } + + @Override + public int getScale() { return 0; } + + @Override + public String getCharset() { return null; } + + @Override + public String getCollation() { return null; } +} \ No newline at end of file diff --git a/grammars/sql_type_inference.g4 b/grammars/sql_type_inference.g4 new file mode 100644 index 000000000..673d04f75 --- /dev/null +++ b/grammars/sql_type_inference.g4 @@ -0,0 +1,124 @@ +// SQL Type Inference Rules +// This file contains rules for inferring types in SQL expressions + +// Type inference for arithmetic operations +rule arithmeticTypeInference { + // Numeric type promotion rules + TINYINT + TINYINT -> SMALLINT + SMALLINT + SMALLINT -> INT + INT + INT -> BIGINT + BIGINT + BIGINT -> DECIMAL(20,0) + FLOAT + FLOAT -> DOUBLE + DOUBLE + DOUBLE -> DOUBLE + DECIMAL(p1,s1) + DECIMAL(p2,s2) -> DECIMAL(max(p1-s1,p2-s2)+max(s1,s2), max(s1,s2)) + + // Same rules apply for subtraction + TINYINT - TINYINT -> SMALLINT + SMALLINT - SMALLINT -> INT + INT - INT -> BIGINT + BIGINT - BIGINT -> DECIMAL(20,0) + FLOAT - FLOAT -> DOUBLE + DOUBLE - DOUBLE -> DOUBLE + DECIMAL(p1,s1) - DECIMAL(p2,s2) -> DECIMAL(max(p1-s1,p2-s2)+max(s1,s2), max(s1,s2)) + + // Multiplication rules + TINYINT * TINYINT -> INT + SMALLINT * SMALLINT -> INT + INT * INT -> BIGINT + BIGINT * BIGINT -> DECIMAL(20,0) + FLOAT * FLOAT -> DOUBLE + DOUBLE * DOUBLE -> DOUBLE + DECIMAL(p1,s1) * DECIMAL(p2,s2) -> DECIMAL(p1+p2, s1+s2) + + // Division rules + TINYINT / TINYINT -> DECIMAL(10,4) + SMALLINT / SMALLINT -> DECIMAL(10,4) + INT / INT -> DECIMAL(10,4) + BIGINT / BIGINT -> DECIMAL(20,4) + FLOAT / FLOAT -> DOUBLE + DOUBLE / DOUBLE -> DOUBLE + DECIMAL(p1,s1) / DECIMAL(p2,s2) -> DECIMAL(p1+s2+4, s1+4) +} + +// Type inference for comparison operations +rule comparisonTypeInference { + // Numeric comparisons + NUMERIC_TYPE = NUMERIC_TYPE -> BOOLEAN + NUMERIC_TYPE < NUMERIC_TYPE -> BOOLEAN + NUMERIC_TYPE > NUMERIC_TYPE -> BOOLEAN + NUMERIC_TYPE <= NUMERIC_TYPE -> BOOLEAN + NUMERIC_TYPE >= NUMERIC_TYPE -> BOOLEAN + NUMERIC_TYPE != NUMERIC_TYPE -> BOOLEAN + + // String comparisons + STRING_TYPE = STRING_TYPE -> BOOLEAN + STRING_TYPE < STRING_TYPE -> BOOLEAN + STRING_TYPE > STRING_TYPE -> BOOLEAN + STRING_TYPE <= STRING_TYPE -> BOOLEAN + STRING_TYPE >= STRING_TYPE -> BOOLEAN + STRING_TYPE != STRING_TYPE -> BOOLEAN + + // Date/Time comparisons + DATETIME_TYPE = DATETIME_TYPE -> BOOLEAN + DATETIME_TYPE < DATETIME_TYPE -> BOOLEAN + DATETIME_TYPE > DATETIME_TYPE -> BOOLEAN + DATETIME_TYPE <= DATETIME_TYPE -> BOOLEAN + DATETIME_TYPE >= DATETIME_TYPE -> BOOLEAN + DATETIME_TYPE != DATETIME_TYPE -> BOOLEAN +} + +// Type inference for logical operations +rule logicalTypeInference { + BOOLEAN_TYPE AND BOOLEAN_TYPE -> BOOLEAN + BOOLEAN_TYPE OR BOOLEAN_TYPE -> BOOLEAN + BOOLEAN_TYPE XOR BOOLEAN_TYPE -> BOOLEAN + NOT BOOLEAN_TYPE -> BOOLEAN +} + +// Type inference for string operations +rule stringTypeInference { + STRING_TYPE || STRING_TYPE -> VARCHAR(max_length) + CONCAT(STRING_TYPE, STRING_TYPE) -> VARCHAR(sum_length) + SUBSTRING(STRING_TYPE, INT, INT) -> VARCHAR + LENGTH(STRING_TYPE) -> INT + UPPER(STRING_TYPE) -> STRING_TYPE + LOWER(STRING_TYPE) -> STRING_TYPE +} + +// Type inference for date/time operations +rule datetimeTypeInference { + DATE + INTERVAL -> DATE + TIME + INTERVAL -> TIME + DATETIME + INTERVAL -> DATETIME + TIMESTAMP + INTERVAL -> TIMESTAMP + DATEDIFF(DATETIME_TYPE, DATETIME_TYPE) -> INT + DATE_FORMAT(DATETIME_TYPE, STRING_TYPE) -> VARCHAR(255) +} + +// Type inference for aggregation functions +rule aggregationTypeInference { + COUNT(*) -> BIGINT + COUNT(ANY_TYPE) -> BIGINT + SUM(NUMERIC_TYPE) -> NUMERIC_TYPE + AVG(NUMERIC_TYPE) -> DECIMAL(20,4) + MIN(ANY_TYPE) -> ANY_TYPE + MAX(ANY_TYPE) -> ANY_TYPE + GROUP_CONCAT(STRING_TYPE) -> VARCHAR(1024) +} + +// Type inference for CASE expressions +rule caseTypeInference { + CASE WHEN BOOLEAN_TYPE THEN ANY_TYPE ELSE ANY_TYPE END -> ANY_TYPE + CASE ANY_TYPE WHEN ANY_TYPE THEN ANY_TYPE ELSE ANY_TYPE END -> ANY_TYPE +} + +// Type inference for CAST operations +rule castTypeInference { + CAST(ANY_TYPE AS NUMERIC_TYPE) -> NUMERIC_TYPE + CAST(ANY_TYPE AS STRING_TYPE) -> STRING_TYPE + CAST(ANY_TYPE AS DATETIME_TYPE) -> DATETIME_TYPE + CAST(ANY_TYPE AS BINARY_TYPE) -> BINARY_TYPE + CAST(ANY_TYPE AS JSON_TYPE) -> JSON_TYPE + CAST(ANY_TYPE AS BOOLEAN_TYPE) -> BOOLEAN_TYPE + CAST(ANY_TYPE AS SPATIAL_TYPE) -> SPATIAL_TYPE +} \ No newline at end of file diff --git a/grammars/sql_types.g4 b/grammars/sql_types.g4 new file mode 100644 index 000000000..45da52aa1 --- /dev/null +++ b/grammars/sql_types.g4 @@ -0,0 +1,72 @@ +// SQL Data Types for type annotations +// These types are used to annotate grammar rules with their expected SQL data types + +// Numeric Types +NUMERIC_TYPE + : TINYINT + | SMALLINT + | MEDIUMINT + | INT + | BIGINT + | FLOAT + | DOUBLE + | DECIMAL + ; + +// String Types +STRING_TYPE + : CHAR + | VARCHAR + | TEXT + | ENUM + | SET + ; + +// Date/Time Types +DATETIME_TYPE + : DATE + | TIME + | DATETIME + | TIMESTAMP + | YEAR + ; + +// Binary Types +BINARY_TYPE + : BINARY + | VARBINARY + | BLOB + ; + +// JSON Type +JSON_TYPE + : JSON + ; + +// Boolean Type +BOOLEAN_TYPE + : BOOLEAN + | BOOL + ; + +// Spatial Types +SPATIAL_TYPE + : GEOMETRY + | POINT + | LINESTRING + | POLYGON + | MULTIPOINT + | MULTILINESTRING + | MULTIPOLYGON + | GEOMETRYCOLLECTION + ; + +// NULL Type +NULL_TYPE + : NULL + ; + +// Any Type (for expressions that can return any type) +ANY_TYPE + : ANY + ; \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh index 0102d3e33..dc2753340 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -2,7 +2,7 @@ cp src/sqlancer/any/Fuzzer.java.template.txt src/sqlancer/any/Fuzzer.java && \ #First build, to get the SGL jar echo "Building Seagull" && \ -mvn clean package -Dskip.main=true -DskipTests && \ +mvn package -Dskip.main=true -DskipTests && \ #Generate fuzzer java code from grammar file and configuration file echo "Starting Seagull" && \ java -jar target/SGL-jar-with-dependencies.jar -c $2 -g $1 && \ @@ -10,7 +10,7 @@ echo "Fuzzer generated" && \ mv Fuzzer.java src/sqlancer/any/Fuzzer.java && \ #Second build with the real Fuzzer code, to get the sqlancer jar echo "Building SQLancer" && \ -mvn clean package -Dskip.SGL=true -DskipTests && \ +mvn package -Dskip.SGL=true -DskipTests && \ cd target && \ echo "Starting SQLancer" && \ java -jar sqlancer-jar-with-dependencies.jar -g | tee log/stdout.log && \ diff --git a/src/SGL/docs/Documentation.md b/src/SGL/docs/Documentation.md index d3031a3d3..e8425589e 100644 --- a/src/SGL/docs/Documentation.md +++ b/src/SGL/docs/Documentation.md @@ -8,7 +8,6 @@ Features described might still be un-implemented or buggy. This work is inspired by [Grammarinator](https://github.com/renatahodovan/grammarinator) for AST generation and [StringTemplate](https://github.com/antlr/stringtemplate4) for fuzzer rendering. - ## Quick Start We have prepared (not yet) annotated LancerSpec and corresponding configuration files for MySQL dialect, SQLite dialect, as well as Postgresql dialect. @@ -18,7 +17,22 @@ You can run the examples or your own files using
./scripts/run.sh [path to grammar file] [path to config file]
 
- +## Extra Information Required (Compared to ANTLR) + +| Feature | Purpose | Example | Required? | +|---------|---------|---------|-----------| +| Type Annotations | Specify SQL data types for expressions and literals | `expr returns [SQLType type]` | Yes | +| Variable System | Maintain context for test case generation | `variable = expr` | Yes | +| Predicates | Enforce semantic constraints | `predicate {condition}` | Optional | +| Weightage | Control probability of rule selection | `weightage 80` | Optional | +| Precedence | Define operator precedence | `precedence 1` | Optional | +| Action Blocks | Execute custom Java code during generation | `action {Java code}` | Optional | +| EBNF Suffixes | Control repetition patterns | `*`, `+`, `?` | Yes | +| Expression Operations | Define arithmetic/logical operations | `expr op = (PLUS | MINUS)` | Yes | +| Type Inference Rules | Specify type promotion and conversion | `NUMERIC_TYPE + NUMERIC_TYPE -> NUMERIC_TYPE` | Yes | +| Error Handling | Define expected errors and recovery | `catch (SQLException e)` | Optional | +| Context Variables | Store and retrieve generation context | `context.get("variable")` | Optional | +| Template Rendering | Generate formatted SQL statements | `template "SELECT $expr$"` | Optional | ## LancerSpec Syntax