().configureEach {
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "io.sentry")
}
- options.errorprone.errorproneArgs.add("-XepExcludedPaths:.*/io/sentry/vendor/.*")
+ // Vendored code is not checked. In io/sentry/vendor/otel/sql only the upstream files and the
+ // generated lexer are excluded, so our own classes there are checked. Error Prone matches with
+ // RE2J, which has no lookahead, hence the explicit list.
+ options.errorprone.errorproneArgs.add(
+ "-XepExcludedPaths:.*/io/sentry/vendor/([^/]+\\.java|gson/.*|otel/sql/(SqlQuery|SqlDialect|StringUtils|AutoSqlSanitizer)\\.java)",
+ )
}
tasks.jar {
diff --git a/sentry/src/main/java/io/sentry/SpanDataConvention.java b/sentry/src/main/java/io/sentry/SpanDataConvention.java
index 93760fb8dc4..043a60d3856 100644
--- a/sentry/src/main/java/io/sentry/SpanDataConvention.java
+++ b/sentry/src/main/java/io/sentry/SpanDataConvention.java
@@ -8,6 +8,11 @@ public interface SpanDataConvention {
// https://develop.sentry.dev/sdk/performance/span-data-conventions/
String DB_SYSTEM_KEY = "db.system";
String DB_NAME_KEY = "db.name";
+ String DB_SYSTEM_NAME_KEY = "db.system.name";
+ String DB_NAMESPACE_KEY = "db.namespace";
+ String DB_QUERY_TEXT_KEY = "db.query.text";
+ String DB_QUERY_SUMMARY_KEY = "db.query.summary";
+ String DB_STORED_PROCEDURE_NAME_KEY = "db.stored_procedure.name";
String HTTP_QUERY_KEY = "http.query";
String HTTP_FRAGMENT_KEY = "http.fragment";
String HTTP_METHOD_KEY = "http.request.method";
diff --git a/sentry/src/main/java/io/sentry/util/sql/SqlQuery.java b/sentry/src/main/java/io/sentry/util/sql/SqlQuery.java
new file mode 100644
index 00000000000..468e8a793ce
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/util/sql/SqlQuery.java
@@ -0,0 +1,46 @@
+package io.sentry.util.sql;
+
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/** Result of {@link SqlQueryAnalyzer#analyze(String, String, int)}. */
+@ApiStatus.Internal
+public final class SqlQuery {
+
+ static final @NotNull SqlQuery EMPTY = new SqlQuery(null, null, null);
+
+ private final @Nullable String queryText;
+ private final @Nullable String querySummary;
+ private final @Nullable String storedProcedureName;
+
+ SqlQuery(
+ final @Nullable String queryText,
+ final @Nullable String querySummary,
+ final @Nullable String storedProcedureName) {
+ this.queryText = queryText;
+ this.querySummary = querySummary;
+ this.storedProcedureName = storedProcedureName;
+ }
+
+ /**
+ * Returns the sanitized statement, or {@code null} if the input was {@code null}, longer than 1
+ * MiB, or analysis failed internally.
+ */
+ public @Nullable String getQueryText() {
+ return queryText;
+ }
+
+ /**
+ * Returns a low-cardinality summary of operations and targets, such as {@code SELECT users}, or
+ * {@code null} if nothing was recognized.
+ */
+ public @Nullable String getQuerySummary() {
+ return querySummary;
+ }
+
+ /** Returns the stored procedure invoked by {@code CALL} or {@code EXECUTE}, or {@code null}. */
+ public @Nullable String getStoredProcedureName() {
+ return storedProcedureName;
+ }
+}
diff --git a/sentry/src/main/java/io/sentry/util/sql/SqlQueryAnalyzer.java b/sentry/src/main/java/io/sentry/util/sql/SqlQueryAnalyzer.java
new file mode 100644
index 00000000000..a40ae71426c
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/util/sql/SqlQueryAnalyzer.java
@@ -0,0 +1,82 @@
+package io.sentry.util.sql;
+
+import io.sentry.vendor.otel.sql.OtelSqlSanitizer;
+import io.sentry.vendor.otel.sql.SqlDialect;
+import io.sentry.vendor.otel.sql.StringUtils;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Sanitizes SQL statements with OpenTelemetry Java's SQL grammar, vendored unchanged in {@code
+ * io.sentry.vendor.otel.sql}, and derives a low-cardinality summary and the stored procedure name.
+ *
+ * Literal values are replaced with {@code ?} as upstream replaces them; comments and the gaps
+ * upstream has are kept as upstream keeps them. This class adds only what does not depend on SQL
+ * syntax: {@code null} and oversized input, the dialect choice, the length limit and failing
+ * closed.
+ */
+@ApiStatus.Internal
+public final class SqlQueryAnalyzer {
+
+ /**
+ * Longest input that is analyzed, in characters. The grammar reads a single huge literal or
+ * comment to its end on the caller's thread, however short the output.
+ */
+ static final int MAX_INPUT_LENGTH = 1024 * 1024;
+
+ private SqlQueryAnalyzer() {}
+
+ /**
+ * Analyzes a SQL statement.
+ *
+ *
Does not throw a {@link RuntimeException} for any input: an internal failure gives a result
+ * without text, summary or stored procedure, and the input is not logged. Input longer than 1 MiB
+ * is not analyzed and gives the same empty result.
+ *
+ * @param sql the statement as passed to the database driver, may be {@code null}
+ * @param dbSystemName the OpenTelemetry {@code db.system.name} of the database, as {@link
+ * SqlSpanData#toDbSystemName(String)} returns it, or {@code null} if unknown. It decides
+ * whether double quotes delimit identifiers or literals.
+ * @param maxQueryTextLength maximum length of {@link SqlQuery#getQueryText()}, must be positive.
+ * Longer text is cut at the last whitespace within the limit.
+ * @return the analysis result, never {@code null}
+ */
+ public static @NotNull SqlQuery analyze(
+ final @Nullable String sql,
+ final @Nullable String dbSystemName,
+ final int maxQueryTextLength) {
+ if (sql == null || sql.length() > MAX_INPUT_LENGTH) {
+ return SqlQuery.EMPTY;
+ }
+ try {
+ final @NotNull io.sentry.vendor.otel.sql.SqlQuery result =
+ OtelSqlSanitizer.sanitize(sql, SqlDialect.forDbSystemName(dbSystemName));
+ return new SqlQuery(
+ cut(result.getQueryText(), maxQueryTextLength),
+ result.getQuerySummary(),
+ result.getStoredProcedureName());
+ } catch (RuntimeException e) {
+ // A bug in the vendored grammar must neither crash the caller nor return unsanitized
+ // text, so any RuntimeException gives an empty result. Errors are not caught. The input is
+ // never logged: it may contain the values this class exists to remove.
+ return SqlQuery.EMPTY;
+ }
+ }
+
+ /**
+ * Cuts sanitized text to {@code maxLength} at the last whitespace within the limit, or at the
+ * limit if there is none, without splitting a surrogate pair. Literals are already replaced, so
+ * any cut point is safe; whitespace only keeps the last token whole.
+ */
+ private static @Nullable String cut(final @Nullable String text, final int maxLength) {
+ if (text == null || text.length() <= maxLength) {
+ return text;
+ }
+ int end = maxLength;
+ while (end > 0 && !Character.isWhitespace(text.charAt(end))) {
+ end--;
+ }
+ return end > 0 ? text.substring(0, end) : StringUtils.truncate(text, maxLength);
+ }
+}
diff --git a/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java b/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java
new file mode 100644
index 00000000000..a7f046768a5
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java
@@ -0,0 +1,109 @@
+package io.sentry.util.sql;
+
+import io.sentry.ILogger;
+import io.sentry.ISpan;
+import io.sentry.SentryLevel;
+import io.sentry.SpanDataConvention;
+import java.util.Locale;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * The sanitized query data a SQL integration puts on its span: the analyzer's text as description
+ * and {@code db.query.text}, plus the summary and stored procedure when present. The raw query is
+ * never kept, returned or logged.
+ */
+@ApiStatus.Internal
+public final class SqlSpanData {
+
+ private final @NotNull SqlQuery query;
+
+ private SqlSpanData(final @NotNull SqlQuery query) {
+ this.query = query;
+ }
+
+ /**
+ * Analyzes {@code sql} once, with the dialect for {@code dbSystem}; never throws a {@link
+ * RuntimeException}.
+ *
+ * @param dbSystem the {@code db.system} value the integration reports, mapped with {@link
+ * #toDbSystemName(String)} for the analyzer
+ */
+ public static @NotNull SqlSpanData analyze(
+ final @Nullable String sql,
+ final @Nullable String dbSystem,
+ final int maxQueryTextLength,
+ final @NotNull ILogger logger) {
+ final @NotNull SqlQuery query =
+ SqlQueryAnalyzer.analyze(sql, toDbSystemName(dbSystem), maxQueryTextLength);
+ // No text for input that was analyzed means an internal failure. Null input and input over
+ // 1 MiB have no text by design and are not logged.
+ if (query.getQueryText() == null
+ && sql != null
+ && sql.length() <= SqlQueryAnalyzer.MAX_INPUT_LENGTH) {
+ logger.log(SentryLevel.DEBUG, "SQL query analysis failed; the span gets no query data.");
+ }
+ return new SqlSpanData(query);
+ }
+
+ /** The span description: the sanitized text, or {@code null} if there is none. */
+ public @Nullable String getDescription() {
+ return query.getQueryText();
+ }
+
+ /**
+ * Maps a {@code db.system} value as reported by the Sentry JDBC and SQLite integrations to the
+ * OpenTelemetry semantic-conventions {@code db.system.name} value, or {@code null} if there is
+ * none. The analyzer chooses its dialect from that value.
+ */
+ public static @Nullable String toDbSystemName(final @Nullable String dbSystem) {
+ if (dbSystem == null) {
+ return null;
+ }
+ final @NotNull String system = dbSystem.toLowerCase(Locale.ROOT);
+ switch (system) {
+ case "postgresql":
+ case "mysql":
+ case "mariadb":
+ case "sqlite":
+ case "hsqldb":
+ case "derby":
+ case "clickhouse":
+ return system;
+ case "in-memory":
+ return "sqlite";
+ case "h2":
+ return "h2database";
+ case "sqlserver":
+ return "microsoft.sql_server";
+ case "oracle":
+ return "oracle.db";
+ case "db2":
+ return "ibm.db2";
+ case "sap":
+ return "sap.hana";
+ case "mongo":
+ return "mongodb";
+ default:
+ return null;
+ }
+ }
+
+ /** Sets the {@code db.query.*} and {@code db.stored_procedure.name} keys that have a value. */
+ public void applyTo(final @NotNull ISpan span) {
+ final @Nullable String text = query.getQueryText();
+ if (text == null) {
+ return;
+ }
+ span.setData(SpanDataConvention.DB_QUERY_TEXT_KEY, text);
+ final @Nullable String summary = query.getQuerySummary();
+ if (summary != null) {
+ span.setData(SpanDataConvention.DB_QUERY_SUMMARY_KEY, summary);
+ }
+ final @Nullable String storedProcedure = query.getStoredProcedureName();
+ if (storedProcedure != null) {
+ span.setData(SpanDataConvention.DB_STORED_PROCEDURE_NAME_KEY, storedProcedure);
+ }
+ }
+}
diff --git a/sentry/src/main/java/io/sentry/vendor/otel/sql/AutoValue_SqlDialect.java b/sentry/src/main/java/io/sentry/vendor/otel/sql/AutoValue_SqlDialect.java
new file mode 100644
index 00000000000..bfbfb78ceef
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/vendor/otel/sql/AutoValue_SqlDialect.java
@@ -0,0 +1,43 @@
+package io.sentry.vendor.otel.sql;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * What AutoValue would generate for the vendored {@link SqlDialect}: field, constructor, getter and
+ * builder. Hand-written so that {@code sentry} needs no annotation processor. A property added or
+ * removed upstream breaks compilation here, so a sync cannot drift silently.
+ */
+final class AutoValue_SqlDialect extends SqlDialect {
+
+ private final boolean doubleQuotesAreIdentifiers;
+
+ private AutoValue_SqlDialect(final boolean doubleQuotesAreIdentifiers) {
+ this.doubleQuotesAreIdentifiers = doubleQuotesAreIdentifiers;
+ }
+
+ @Override
+ boolean doubleQuotesAreIdentifiers() {
+ return doubleQuotesAreIdentifiers;
+ }
+
+ static final class Builder extends SqlDialect.Builder {
+
+ private boolean doubleQuotesAreIdentifiers;
+
+ Builder() {}
+
+ @Override
+ public @NotNull SqlDialect.Builder setDoubleQuotesAreIdentifiers(
+ final boolean doubleQuotesAreIdentifiers) {
+ this.doubleQuotesAreIdentifiers = doubleQuotesAreIdentifiers;
+ return this;
+ }
+
+ // This class stands in for AutoValue's output, so referring to AutoValue_SqlDialect is its job.
+ @SuppressWarnings("AutoValueSubclassLeaked")
+ @Override
+ public @NotNull SqlDialect build() {
+ return new AutoValue_SqlDialect(doubleQuotesAreIdentifiers);
+ }
+ }
+}
diff --git a/sentry/src/main/java/io/sentry/vendor/otel/sql/AutoValue_SqlQuery.java b/sentry/src/main/java/io/sentry/vendor/otel/sql/AutoValue_SqlQuery.java
new file mode 100644
index 00000000000..30747249caf
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/vendor/otel/sql/AutoValue_SqlQuery.java
@@ -0,0 +1,55 @@
+package io.sentry.vendor.otel.sql;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * What AutoValue would generate for the vendored {@link SqlQuery}: fields, constructor and getters.
+ * Hand-written so that {@code sentry} needs no annotation processor. A property added or removed
+ * upstream breaks compilation here, so a sync cannot drift silently.
+ */
+final class AutoValue_SqlQuery extends SqlQuery {
+
+ private final @Nullable String queryText;
+ private final @Nullable String operationName;
+ private final @Nullable String collectionName;
+ private final @Nullable String storedProcedureName;
+ private final @Nullable String querySummary;
+
+ AutoValue_SqlQuery(
+ final @Nullable String queryText,
+ final @Nullable String operationName,
+ final @Nullable String collectionName,
+ final @Nullable String storedProcedureName,
+ final @Nullable String querySummary) {
+ this.queryText = queryText;
+ this.operationName = operationName;
+ this.collectionName = collectionName;
+ this.storedProcedureName = storedProcedureName;
+ this.querySummary = querySummary;
+ }
+
+ @Override
+ public @Nullable String getQueryText() {
+ return queryText;
+ }
+
+ @Override
+ public @Nullable String getOperationName() {
+ return operationName;
+ }
+
+ @Override
+ public @Nullable String getCollectionName() {
+ return collectionName;
+ }
+
+ @Override
+ public @Nullable String getStoredProcedureName() {
+ return storedProcedureName;
+ }
+
+ @Override
+ public @Nullable String getQuerySummary() {
+ return querySummary;
+ }
+}
diff --git a/sentry/src/main/java/io/sentry/vendor/otel/sql/OtelSqlSanitizer.java b/sentry/src/main/java/io/sentry/vendor/otel/sql/OtelSqlSanitizer.java
new file mode 100644
index 00000000000..16a854fc4b0
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/vendor/otel/sql/OtelSqlSanitizer.java
@@ -0,0 +1,23 @@
+package io.sentry.vendor.otel.sql;
+
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Entry point into the vendored OpenTelemetry SQL grammar, whose generated lexer is package-private.
+ * Only {@link io.sentry.util.sql.SqlQueryAnalyzer} calls it.
+ */
+@ApiStatus.Internal
+public final class OtelSqlSanitizer {
+
+ private OtelSqlSanitizer() {}
+
+ /**
+ * Runs the grammar on {@code sql}. Can throw a {@link RuntimeException} on an internal lexer
+ * error; the caller fails closed.
+ */
+ public static @NotNull SqlQuery sanitize(
+ final @NotNull String sql, final @NotNull SqlDialect dialect) {
+ return AutoSqlSanitizer.sanitize(sql, dialect);
+ }
+}
diff --git a/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlDialect.java b/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlDialect.java
new file mode 100644
index 00000000000..10c55424689
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlDialect.java
@@ -0,0 +1,128 @@
+// Adapted from OpenTelemetry Java Instrumentation.
+// Copyright The OpenTelemetry Authors.
+// Licensed under the Apache License, Version 2.0.
+// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/979e8684e783f1a710955341924bdddeff6e83f2/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlDialect.java
+// Changes: package moved to io.sentry.vendor.otel.sql; javax.annotation.Nullable replaced by org.jetbrains.annotations.Nullable; @ApiStatus.Internal added; @AutoValue, @AutoValue.Builder and @CanIgnoreReturnValue removed (AutoValue_SqlDialect is hand-written).
+// Applied by scripts/sync-otel-sql.sh; do not edit this file by hand.
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.sentry.vendor.otel.sql;
+
+import org.jetbrains.annotations.ApiStatus;
+
+import org.jetbrains.annotations.Nullable;
+
+/** Describes SQL dialect options that affect how {@link SqlQueryAnalyzer} processes queries. */
+@ApiStatus.Internal
+public abstract class SqlDialect {
+
+ /**
+ * Dialect for queries whose database is unknown. Double-quoted fragments are treated as string
+ * literals and sanitized (replaced with {@code ?}).
+ */
+ public static final SqlDialect UNKNOWN = builder().build();
+
+ private static final SqlDialect IDENTIFIERS =
+ builder().setDoubleQuotesAreIdentifiers(true).build();
+
+ /**
+ * Dialect where double-quoted fragments are treated as string literals and therefore sanitized
+ * (replaced with {@code ?}).
+ *
+ * @deprecated Use {@link #UNKNOWN} instead. May be removed in the next minor release.
+ */
+ @Deprecated public static final SqlDialect DOUBLE_QUOTES_ARE_STRING_LITERALS = UNKNOWN;
+
+ /**
+ * Dialect where double-quoted fragments are treated as identifiers (e.g. column/table names) and
+ * therefore left intact during sanitization. Use this only for databases where double quotes
+ * always denote identifiers.
+ *
+ * @deprecated Use {@link #forDbSystemName(String)} or {@link #builder()} instead. May be removed
+ * in the next minor release.
+ */
+ @Deprecated public static final SqlDialect DOUBLE_QUOTES_ARE_IDENTIFIERS = IDENTIFIERS;
+
+ /**
+ * Returns the dialect for the given {@code db.system.name} value, or {@link #UNKNOWN} if the
+ * database is {@code null} or not recognized.
+ */
+ public static SqlDialect forDbSystemName(@Nullable String dbSystemName) {
+ if (dbSystemName == null) {
+ return UNKNOWN;
+ }
+ switch (dbSystemName) {
+ // "A string constant in SQL is an arbitrary sequence of characters
+ // bounded by single quotes (')"
+ // https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
+ case "postgresql":
+ // "Text, character, and string literals are always surrounded
+ // by single quotation marks."
+ // https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
+ case "oracle.db":
+ // "A sequence of characters that starts and ends with a string delimiter,
+ // which is an apostrophe (')"
+ // https://www.ibm.com/docs/en/db2/12.1?topic=elements-constants
+ case "ibm.db2":
+ // "Single quotation marks delimit character strings."
+ // "Double quotation marks delimit special identifiers"
+ // https://db.apache.org/derby/docs/10.17/ref/rrefsqlj28468.html
+ case "derby":
+ // "names of objects are enclosed in double-quotes"
+ // (double quotes are exclusively for identifiers; follows SQL standard strictly)
+ // https://hsqldb.org/doc/2.0/guide/sqlgeneral-chapt.html
+ case "hsqldb":
+ // ::= [...]
+ // ::= ...
+ // https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/sql-notation-conventions
+ case "sap.hana":
+ // "String literals must be enclosed in single quotes.
+ // Double quotes are not supported."
+ // https://clickhouse.com/docs/en/sql-reference/syntax#string
+ case "clickhouse":
+ // "A string constant is an arbitrary sequence of characters enclosed by single-quote(')."
+ // https://cassandra.apache.org/doc/stable/cassandra/developing/cql/definitions.html#constants
+ case "cassandra":
+ // "String literals must be surrounded by single quotes."
+ // https://docs.influxdata.com/influxdb/v2/reference/syntax/influxql/spec/#strings
+ case "influxdb":
+ return IDENTIFIERS;
+ default:
+ return UNKNOWN;
+ }
+ }
+
+ /**
+ * Returns a builder for explicit dialect options. By default, double-quoted fragments are treated
+ * as string literals, as with {@link #UNKNOWN}.
+ */
+ public static Builder builder() {
+ return new AutoValue_SqlDialect.Builder().setDoubleQuotesAreIdentifiers(false);
+ }
+
+ SqlDialect() {}
+
+ /**
+ * Returns {@code true} if the dialect uses double quotes for identifiers, {@code false} if double
+ * quotes are used for string literals.
+ */
+ abstract boolean doubleQuotesAreIdentifiers();
+
+ /** Builder for SQL dialect options. */
+ public abstract static class Builder {
+
+ Builder() {}
+
+ /**
+ * Sets whether double-quoted fragments are identifiers and preserved, rather than string
+ * literals that are sanitized. Use {@code true} only when double quotes always denote
+ * identifiers.
+ */
+ public abstract Builder setDoubleQuotesAreIdentifiers(boolean doubleQuotesAreIdentifiers);
+
+ public abstract SqlDialect build();
+ }
+}
diff --git a/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlLexerException.java b/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlLexerException.java
new file mode 100644
index 00000000000..d8eae7298f8
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlLexerException.java
@@ -0,0 +1,17 @@
+package io.sentry.vendor.otel.sql;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Thrown by the generated lexer on an internal JFlex error ({@code %scanerror}) instead of {@link
+ * Error}, so that {@link io.sentry.util.sql.SqlQueryAnalyzer} can fail closed. No input is known to
+ * reach it: the grammar's catch-all rule matches every character.
+ */
+final class SqlLexerException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ SqlLexerException(final @NotNull String message) {
+ super(message);
+ }
+}
diff --git a/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlQuery.java b/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlQuery.java
new file mode 100644
index 00000000000..14c9a0003f8
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/vendor/otel/sql/SqlQuery.java
@@ -0,0 +1,103 @@
+// Adapted from OpenTelemetry Java Instrumentation.
+// Copyright The OpenTelemetry Authors.
+// Licensed under the Apache License, Version 2.0.
+// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/979e8684e783f1a710955341924bdddeff6e83f2/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuery.java
+// Changes: package and StringUtils import moved to io.sentry.vendor.otel.sql; javax.annotation.Nullable replaced by org.jetbrains.annotations.Nullable; @ApiStatus.Internal added; @AutoValue removed (AutoValue_SqlQuery is hand-written).
+// Applied by scripts/sync-otel-sql.sh; do not edit this file by hand.
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.sentry.vendor.otel.sql;
+
+import org.jetbrains.annotations.ApiStatus;
+
+import static io.sentry.vendor.otel.sql.StringUtils.truncate;
+
+import org.jetbrains.annotations.Nullable;
+
+@ApiStatus.Internal
+public abstract class SqlQuery {
+
+ private static final String SQL_CALL = "CALL";
+ private static final int QUERY_SUMMARY_MAX_LENGTH = 255;
+
+ /**
+ * Creates a SQL analysis result with operation, collection, stored procedure, and summary values.
+ *
+ * The query text is used as supplied; the summary is truncated to at most 255 characters.
+ */
+ public static SqlQuery create(
+ @Nullable String queryText,
+ @Nullable String operationName,
+ @Nullable String collectionName,
+ @Nullable String storedProcedureName,
+ @Nullable String querySummary) {
+ String truncatedQuerySummary = truncateQuerySummary(querySummary);
+ return new AutoValue_SqlQuery(
+ queryText, operationName, collectionName, storedProcedureName, truncatedQuerySummary);
+ }
+
+ /** Creates a SQL analysis result with an operation and its table or stored procedure target. */
+ public static SqlQuery create(
+ @Nullable String queryText, @Nullable String operationName, @Nullable String target) {
+ boolean isStoredProcedure = SQL_CALL.equals(operationName) || "EXECUTE".equals(operationName);
+ String collectionName = isStoredProcedure ? null : target;
+ String storedProcedureName = isStoredProcedure ? target : null;
+ return create(queryText, operationName, collectionName, storedProcedureName, null);
+ }
+
+ @Nullable
+ private static String truncateQuerySummary(@Nullable String querySummary) {
+ if (querySummary == null || querySummary.length() <= QUERY_SUMMARY_MAX_LENGTH) {
+ return querySummary;
+ }
+ // Truncate at the last space before the limit to avoid cutting in the middle of an identifier
+ int lastSpace = querySummary.lastIndexOf(' ', QUERY_SUMMARY_MAX_LENGTH);
+ if (lastSpace > 0) {
+ return querySummary.substring(0, lastSpace);
+ }
+ // If no space found, truncate at the limit
+ return truncate(querySummary, QUERY_SUMMARY_MAX_LENGTH);
+ }
+
+ @Nullable
+ public abstract String getQueryText();
+
+ /** Returns the parsed operation name, or null when no operation was analyzed. */
+ @Nullable
+ public abstract String getOperationName();
+
+ /**
+ * Returns the table/collection name, or null for CALL operations.
+ *
+ * @see #getStoredProcedureName()
+ */
+ @Nullable
+ public abstract String getCollectionName();
+
+ /** Returns the stored procedure name for CALL operations, or null for other operations. */
+ @Nullable
+ public abstract String getStoredProcedureName();
+
+ /**
+ * Returns a low cardinality summary of the database query suitable for use as a span name or
+ * metric attribute.
+ *
+ *
The summary contains operations (e.g., SELECT, INSERT) and their targets (e.g., table names)
+ * in the order they appear in the query. For example:
+ *
+ *
+ * - {@code SELECT wuser_table}
+ *
- {@code INSERT shipping_details SELECT orders}
+ *
- {@code SELECT songs artists} (multiple tables)
+ *
+ *
+ * @see Generating
+ * a summary of the query
+ */
+ @Nullable
+ public abstract String getQuerySummary();
+}
diff --git a/sentry/src/main/java/io/sentry/vendor/otel/sql/StringUtils.java b/sentry/src/main/java/io/sentry/vendor/otel/sql/StringUtils.java
new file mode 100644
index 00000000000..8773b508429
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/vendor/otel/sql/StringUtils.java
@@ -0,0 +1,75 @@
+// Adapted from OpenTelemetry Java Instrumentation.
+// Copyright The OpenTelemetry Authors.
+// Licensed under the Apache License, Version 2.0.
+// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/979e8684e783f1a710955341924bdddeff6e83f2/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/StringUtils.java
+// Changes: package moved to io.sentry.vendor.otel.sql; @ApiStatus.Internal added.
+// Applied by scripts/sync-otel-sql.sh; do not edit this file by hand.
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.sentry.vendor.otel.sql;
+
+import org.jetbrains.annotations.ApiStatus;
+
+/**
+ * Internal string utilities.
+ *
+ * This class is internal and is hence not for public use. Its APIs are unstable and can change
+ * at any time.
+ */
+@ApiStatus.Internal
+public final class StringUtils {
+
+ /**
+ * Returns the longest prefix whose {@link String#length()} does not exceed {@code maxLength}. If
+ * truncating at the limit would split a surrogate pair, the pair is omitted.
+ */
+ public static String truncate(String value, int maxLength) {
+ if (value.length() <= maxLength) {
+ return value;
+ }
+ return value.substring(0, truncationLength(value, maxLength));
+ }
+
+ /**
+ * Truncates {@code value} so that its length does not exceed {@code maxLength}. If the limit
+ * would split a surrogate pair, the pair is omitted.
+ */
+ public static void truncate(StringBuilder value, int maxLength) {
+ if (value.length() > maxLength) {
+ value.setLength(truncationLength(value, maxLength));
+ }
+ }
+
+ /**
+ * Truncates {@code value} so that its length does not exceed {@code maxLength}. If the limit
+ * would split a surrogate pair, the pair is omitted.
+ */
+ public static void truncate(StringBuffer value, int maxLength) {
+ if (value.length() > maxLength) {
+ value.setLength(truncationLength(value, maxLength));
+ }
+ }
+
+ /**
+ * Appends the longest prefix of {@code value} whose length does not exceed {@code maxLength}. If
+ * the limit would split a surrogate pair, the pair is omitted.
+ */
+ public static void appendTruncated(StringBuilder target, String value, int maxLength) {
+ int length = value.length() <= maxLength ? value.length() : truncationLength(value, maxLength);
+ target.append(value, 0, length);
+ }
+
+ private static int truncationLength(CharSequence value, int maxLength) {
+ if (maxLength > 0
+ && Character.isHighSurrogate(value.charAt(maxLength - 1))
+ && Character.isLowSurrogate(value.charAt(maxLength))) {
+ return maxLength - 1;
+ }
+ return maxLength;
+ }
+
+ private StringUtils() {}
+}
diff --git a/sentry/src/main/java/io/sentry/vendor/otel/sql/UPSTREAM b/sentry/src/main/java/io/sentry/vendor/otel/sql/UPSTREAM
new file mode 100644
index 00000000000..427d5aa0942
--- /dev/null
+++ b/sentry/src/main/java/io/sentry/vendor/otel/sql/UPSTREAM
@@ -0,0 +1,7 @@
+# Vendored by scripts/sync-otel-sql.sh; do not edit by hand.
+repository=open-telemetry/opentelemetry-java-instrumentation
+commit=979e8684e783f1a710955341924bdddeff6e83f2
+file=instrumentation-api-incubator/src/main/jflex/SqlSanitizer.jflex
+file=instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuery.java
+file=instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlDialect.java
+file=instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/StringUtils.java
diff --git a/sentry/src/main/jflex/SqlSanitizer.jflex b/sentry/src/main/jflex/SqlSanitizer.jflex
new file mode 100644
index 00000000000..e668922795c
--- /dev/null
+++ b/sentry/src/main/jflex/SqlSanitizer.jflex
@@ -0,0 +1,1456 @@
+// Adapted from OpenTelemetry Java Instrumentation.
+// Copyright The OpenTelemetry Authors.
+// Licensed under the Apache License, Version 2.0.
+// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/979e8684e783f1a710955341924bdddeff6e83f2/instrumentation-api-incubator/src/main/jflex/SqlSanitizer.jflex
+// Changes: package and StringUtils import moved to io.sentry.vendor.otel.sql; %scanerror SqlLexerException added.
+// Applied by scripts/sync-otel-sql.sh; do not edit this file by hand.
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.sentry.vendor.otel.sql;
+
+import io.sentry.vendor.otel.sql.StringUtils;
+import java.util.ArrayDeque;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+%%
+
+%final
+%class AutoSqlSanitizer
+%scanerror SqlLexerException
+%apiprivate
+%int
+%buffer 2048
+
+%unicode
+%ignorecase
+
+%state BLOCK_COMMENT DOLLAR_STRING
+
+COMMA = ","
+OPEN_PAREN = "("
+CLOSE_PAREN = ")"
+OPEN_COMMENT = "/*"
+CLOSE_COMMENT = "*/"
+LINE_COMMENT = "--" [^\r\n]*
+UNQUOTED_IDENTIFIER = ([:letter:] | "_") ([:letter:] | [0-9] | "_")*
+IDENTIFIER_PART = {UNQUOTED_IDENTIFIER} | {DOUBLE_QUOTED_STR} | {BACKTICK_QUOTED_STR} | {BRACKET_QUOTED_STR}
+// We are using {UNQUOTED_IDENTIFIER} instead of {IDENTIFIER_PART} here because DOUBLE_QUOTED_STR
+// and BACKTICK_QUOTED_STR are handled separately. Depending on the context they appear in they will
+// either be recorded as the identifier or replaced with ?.
+// The optional "@" {UNQUOTED_IDENTIFIER} suffix supports Oracle database link syntax (table@dblink).
+IDENTIFIER = ({UNQUOTED_IDENTIFIER} | ({IDENTIFIER_PART} ("." {IDENTIFIER_PART})+)) ("@" {UNQUOTED_IDENTIFIER})?
+BASIC_NUM = [.+-]* [0-9] ([0-9] | [eE.+-])*
+HEX_NUM = "0x" ([a-f] | [A-F] | [0-9])+
+QUOTED_STR = "'" ("''" | [^'])* "'"
+DOUBLE_QUOTED_STR = "\"" ("\"\"" | [^\"])* "\""
+DOLLAR_QUOTED_STR = "$$" [^$]* "$$"
+DOLLAR_TAG_START = "$" {UNQUOTED_IDENTIFIER} "$"
+BACKTICK_QUOTED_STR = "`" ("``" | [^`])* "`"
+BRACKET_QUOTED_STR = "[" [^\]]* "]"
+UNTERMINATED_BRACKET_STR = "[" [^\]]*
+POSTGRE_PARAM_MARKER = "$"[0-9]*
+WHITESPACE = [ \t\r\n]+
+
+%{
+ static SqlQuery sanitize(String statement, SqlDialect dialect) {
+ AutoSqlSanitizer sanitizer = new AutoSqlSanitizer(new java.io.StringReader(statement));
+ sanitizer.dialect = dialect;
+ try {
+ while (!sanitizer.yyatEOF()) {
+ int token = sanitizer.yylex();
+ // YYEOF token may be used to stop processing
+ if (token == YYEOF) {
+ break;
+ }
+ }
+ return sanitizer.getResult();
+ } catch (java.io.IOException e) {
+ // should never happen
+ return SqlQuery.create(null, null, null);
+ }
+ }
+
+ // maximum sanitized statement length
+ static final int LIMIT = 32 * 1024;
+
+ // Match on strings like "IN(?, ?, ...)"
+ private static final Pattern IN_STATEMENT_PATTERN = Pattern.compile("(\\sIN\\s*)\\(\\s*\\?\\s*(?:,\\s*\\?\\s*)*+\\)", Pattern.CASE_INSENSITIVE);
+ private static final String IN_STATEMENT_NORMALIZED = "$1(?)";
+
+ private final StringBuilder builder = new StringBuilder();
+ private final StringBuilder querySummaryBuilder = new StringBuilder();
+ private String operationName = null;
+ private String collectionName = null;
+ private String storedProcedureName = null;
+ private String dollarTag = null;
+
+ private void appendCurrentFragment() {
+ builder.append(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
+ }
+
+ private boolean appendCommentLiteral(boolean sanitize) {
+ String text = yytext();
+ if (text.contains("/*") || text.contains("*/")) {
+ // Quotes have no syntactic meaning in a block comment and cannot hide its delimiters.
+ yypushback(yylength() - 1);
+ appendCurrentFragment();
+ } else if (sanitizeAmbiguousRemainder()) {
+ return true;
+ } else if (sanitize) {
+ builder.append('?');
+ } else {
+ appendCurrentFragment();
+ }
+ return false;
+ }
+
+ private boolean sanitizeAmbiguousRemainder() {
+ if (zzBuffer[zzStartRead] == '$') {
+ return false;
+ }
+ char quote = 0;
+ int backslashes = 0;
+ for (int i = zzStartRead; i < zzMarkedPos; i++) {
+ char c = zzBuffer[i];
+ if (quote == 0) {
+ if (c == '\'' || c == '"' || c == '`') {
+ quote = c;
+ } else if (c == '[') {
+ quote = ']';
+ }
+ } else if (c == quote) {
+ if (quote != ']' && backslashes % 2 != 0) {
+ // Backslash escaping depends on connection settings that the dialect does not describe.
+ builder.append('?');
+ return true;
+ }
+ quote = 0;
+ }
+ backslashes = c == '\\' ? backslashes + 1 : 0;
+ }
+ return false;
+ }
+
+ private boolean isOverLimit() {
+ return builder.length() > LIMIT;
+ }
+
+ /** Appends an operation name (SELECT, INSERT, etc.) to the query summary. */
+ private void appendOperationToSummary() {
+ if (querySummaryBuilder.length() > 0) {
+ querySummaryBuilder.append(' ');
+ }
+ // yytext() allocates a String; append directly from JFlex's buffer.
+ querySummaryBuilder.append(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
+ }
+
+ private void appendOperationToSummary(String operationName) {
+ if (querySummaryBuilder.length() > 0) {
+ querySummaryBuilder.append(' ');
+ }
+ querySummaryBuilder.append(operationName);
+ }
+
+ /** Appends a target (table name, procedure name, etc.) to the query summary using current token text. */
+ private void appendTargetToSummary() {
+ if (querySummaryBuilder.length() > 0) {
+ querySummaryBuilder.append(' ');
+ }
+ querySummaryBuilder.append(yytext());
+ }
+
+ private void recordOperationName(String operationName) {
+ if (this.operationName == null) {
+ this.operationName = operationName;
+ }
+ }
+
+ private void recordOperationName() {
+ recordOperationName(yytext());
+ }
+
+ private void refineOperationName(String operationTarget) {
+ if (operationName != null) {
+ operationName = operationName + " " + operationTarget;
+ }
+ }
+
+ private void recordCollectionName() {
+ if (collectionName == null) {
+ collectionName = yytext();
+ }
+ }
+
+ private int parenLevel = 0;
+ private boolean insideComment = false;
+ // using special "none" Operation instead of null to avoid null checking it everywhere
+ private final Operation none = new Operation() {};
+ private Operation operation = none;
+ private SqlDialect dialect;
+
+ // Global set of CTE names defined in the current statement (for filtering CTE references)
+ private final Set cteNames = new HashSet<>();
+
+ // Stack to save outer operations when entering subqueries
+ private final ArrayDeque operationStack = new ArrayDeque<>();
+ // Track the paren levels where we pushed operations (to know when to pop)
+ private final ArrayDeque subqueryStartLevels = new ArrayDeque<>();
+
+ // Pending subquery: when we see ( that might start a subquery, we don't push immediately.
+ // Instead, we wait to see if an operation keyword (SELECT, etc.) appears inside.
+ // If it does, we do the push. If we see an identifier first, it's a parenthesized table name.
+ private boolean pendingSubqueryPush = false;
+
+ private boolean shouldStartNewOperation() {
+ return !insideComment && operation == none;
+ }
+
+ /** Returns true if we should start a main query operation (no operation yet, or With at main query level). */
+ private boolean shouldStartMainOperation() {
+ return !insideComment
+ && (operation == none || (operation instanceof With && ((With) operation).isMainQueryLevel()));
+ }
+
+ private void setOperation(Operation operation) {
+ this.operation = operation;
+ }
+
+ private boolean shouldSanitizeRemainderAfterPassword() {
+ return !insideComment && operation.shouldSanitizeRemainderAfterPassword();
+ }
+
+ private boolean shouldSanitizeRemainderAfterIdentifiedBy() {
+ return !insideComment && operation.shouldSanitizeRemainderAfterIdentifiedBy();
+ }
+
+ /** Push current operation onto stack and reset to none for subquery processing. */
+ private void pushOperation() {
+ operationStack.push(operation);
+ subqueryStartLevels.push(parenLevel);
+ operation = none;
+ }
+
+ /** Called when an operation keyword is seen - confirms pending subquery if any. */
+ private void confirmPendingSubqueryIfNeeded() {
+ if (pendingSubqueryPush) {
+ pushOperation();
+ pendingSubqueryPush = false;
+ }
+ }
+
+ /** Called when an identifier is seen - cancels pending subquery (it's a parenthesized table name). */
+ private void cancelPendingSubqueryIfNeeded() {
+ pendingSubqueryPush = false;
+ }
+
+ /** Pop operation from stack if we're exiting a subquery. */
+ private void popOperationIfNeeded() {
+ // Cancel pending subquery - any ) while pending means exiting the potential subquery
+ pendingSubqueryPush = false;
+ if (!subqueryStartLevels.isEmpty() && parenLevel < subqueryStartLevels.peek()) {
+ subqueryStartLevels.pop();
+ operation = operationStack.pop();
+ // Signal to the restored operation that a subquery was processed
+ operation.handleSubqueryComplete();
+ }
+ }
+
+ private abstract class Operation {
+ void handleFrom() {}
+ void handleInto() {}
+ void handleJoin() {}
+ void handleIdentifier() {}
+ void handleComma() {}
+ void handleNext() {}
+ void handleAs() {}
+ void handleOperationTarget(String target) {}
+ void handleOpenParen() {}
+ void handleCloseParen() {}
+ void handleSelect() {}
+ boolean expectingOperationTarget() {
+ return false;
+ }
+ boolean isCapturingIdentifier() {
+ return false;
+ }
+ boolean shouldSanitizeRemainderAfterPassword() {
+ return false;
+ }
+ boolean shouldSanitizeRemainderAfterIdentifiedBy() {
+ return shouldSanitizeRemainderAfterPassword();
+ }
+ /** Returns true if open paren should start a subquery context. */
+ boolean isEnteringSubquery() {
+ return false;
+ }
+ /** Called after a subquery completes and this operation is restored. */
+ void handleSubqueryComplete() {}
+ }
+
+ private abstract class DdlOperation extends Operation {
+ private String operationTarget = "";
+ private boolean expectingOperationTarget = true;
+ private boolean identifierCaptured = false;
+ private boolean inEmbeddedSelect = false;
+ private boolean expectingTableName = false;
+ private int selectParenLevel = -1;
+
+ boolean expectingOperationTarget() {
+ return expectingOperationTarget;
+ }
+
+ void handleOperationTarget(String target) {
+ operationTarget = target;
+ expectingOperationTarget = false;
+ appendOperationToSummary(operationTarget);
+ refineOperationName(operationTarget);
+ }
+
+ boolean isCapturingIdentifier() {
+ return (!identifierCaptured && !inEmbeddedSelect)
+ || (inEmbeddedSelect && expectingTableName && parenLevel == selectParenLevel);
+ }
+
+ /** Returns true for DDL targets where PASSWORD is treated as an identifier, not a secret clause. */
+ boolean hasSafeDdlTarget() {
+ return operationTarget.equalsIgnoreCase("TABLE")
+ || operationTarget.equalsIgnoreCase("INDEX")
+ || operationTarget.equalsIgnoreCase("PROCEDURE")
+ || operationTarget.equalsIgnoreCase("VIEW");
+ }
+
+ boolean shouldSanitizeRemainderAfterPassword() {
+ return !hasSafeDdlTarget();
+ }
+
+ void handleIdentifier() {
+ if (!identifierCaptured && !inEmbeddedSelect) {
+ appendTargetToSummary();
+ if (operationTarget.equalsIgnoreCase("TABLE")) {
+ recordCollectionName();
+ }
+ identifierCaptured = true;
+ } else if (inEmbeddedSelect && expectingTableName && parenLevel == selectParenLevel) {
+ appendTargetToSummary();
+ recordCollectionName();
+ expectingTableName = false;
+ }
+ }
+
+ void handleSelect() {
+ inEmbeddedSelect = true;
+ selectParenLevel = parenLevel;
+ appendOperationToSummary();
+ }
+
+ void handleFrom() {
+ if (inEmbeddedSelect) {
+ expectingTableName = true;
+ }
+ }
+ }
+
+ private class Select extends Operation {
+ // Max identifiers in a table reference: "table", "table alias", or "table as alias"
+ private static final int TABLE_REF_MAX_IDENTIFIERS = 3;
+
+ // Table capture modes (mutually exclusive)
+ boolean captureTableList = false; // FROM clause: capture tables, comma restarts capture
+ boolean captureSingleTable = false; // JOIN clause: capture one table then stop
+
+ // Counts identifiers since we started expecting a table (after FROM/JOIN/comma)
+ // Used for: (1) capturing first identifier as table name, (2) detecting implicit joins via comma
+ int identifierCount = 0;
+
+ // FROM clause context - tracks paren level where FROM appeared (-1 if not in FROM clause)
+ int fromClauseParenLevel = -1;
+
+ // AS keyword tracking: set when AS seen, cleared after alias identifier or open paren
+ boolean sawAsKeyword = false;
+
+ // Column alias list paren level: >= 0 means inside "AS alias(col1, col2)" syntax
+ int columnAliasListParenLevel = -1;
+
+ void handleFrom() {
+ // Enter table list capture mode for FROM clause
+ captureTableList = true;
+ // Track the paren level where FROM clause started
+ // This allows nested SELECTs to track their own FROM clause level
+ fromClauseParenLevel = parenLevel;
+ identifierCount = 0;
+ sawAsKeyword = false;
+ }
+
+ void handleJoin() {
+ // Enter single table capture mode for JOIN clause
+ captureSingleTable = true;
+ identifierCount = 0;
+ sawAsKeyword = false;
+ }
+
+ void handleApply() {
+ // APPLY is similar to JOIN in SQL Server (CROSS APPLY, OUTER APPLY)
+ captureSingleTable = true;
+ identifierCount = 0;
+ sawAsKeyword = false;
+ }
+
+ void handleAs() {
+ // Mark that we saw AS keyword
+ // Next identifier is an alias, and open paren after alias might be column alias list
+ sawAsKeyword = true;
+ }
+
+ boolean isEnteringSubquery() {
+ // Entering subquery if we're in table capture mode and haven't seen an identifier yet
+ // sawAsKeyword check prevents "AS alias(" from being treated as subquery
+ return !sawAsKeyword && (captureTableList || captureSingleTable) && identifierCount == 0;
+ }
+
+ void handleOpenParen() {
+ // "AS alias(" starts a column alias list for derived tables
+ // e.g., SELECT * FROM (SELECT a, b FROM t) AS sub(col1, col2)
+ if (sawAsKeyword) {
+ columnAliasListParenLevel = parenLevel;
+ sawAsKeyword = false;
+ }
+ // Note: subquery push is handled at the global level before this is called
+ }
+
+ void handleCloseParen() {
+ // Exit column alias list when its paren closes
+ // Note: parenLevel has already been decremented when this is called
+ if (columnAliasListParenLevel >= 0 && parenLevel < columnAliasListParenLevel) {
+ columnAliasListParenLevel = -1;
+ }
+ // Note: subquery state restoration is handled at the global level via operation stack
+ }
+
+ void handleSubqueryComplete() {
+ // A subquery counts as one table reference in the FROM clause
+ captureTableList = false;
+ captureSingleTable = false;
+ if (identifierCount == 0) {
+ identifierCount = 1;
+ }
+ }
+
+ void handleSelect() {
+ // Reset FROM clause tracking for nested SELECT (e.g., after UNION/INTERSECT/EXCEPT)
+ // This prevents column commas from being treated as implicit joins
+ // Called when SELECT keyword is encountered while already in a Select operation
+ fromClauseParenLevel = -1;
+ captureTableList = false;
+ captureSingleTable = false;
+ identifierCount = 0;
+ sawAsKeyword = false;
+ columnAliasListParenLevel = -1;
+ }
+
+ void handleIdentifier() {
+ // Don't capture identifiers if we're inside a column alias list or after AS (alias name)
+ if (columnAliasListParenLevel >= 0 || sawAsKeyword) {
+ return;
+ }
+
+ ++identifierCount;
+
+ // Check if this is a CTE reference (should be filtered from table list)
+ boolean isCteReference = isCteReference(yytext());
+
+ // Handle single table capture (JOIN): capture first identifier then stop
+ if (captureSingleTable && identifierCount == 1) {
+ if (!isCteReference) {
+ appendTargetToSummary();
+ recordCollectionName();
+ }
+ captureSingleTable = false;
+ identifierCount = 0;
+ return;
+ }
+
+ // Handle table list capture (FROM): capture first identifier after FROM or comma
+ if (captureTableList && identifierCount == 1) {
+ if (!isCteReference) {
+ appendTargetToSummary();
+ recordCollectionName();
+ }
+ captureTableList = false;
+ // Don't reset identifierCount - keep counting for implicit join detection
+ }
+ }
+
+ void handleComma() {
+ // Don't process commas if we're inside a column alias list
+ if (columnAliasListParenLevel >= 0) {
+ return;
+ }
+
+ // Reset sawAsKeyword - comma indicates we're not entering a column alias list
+ sawAsKeyword = false;
+
+ // Detect implicit join: comma in FROM clause after seeing 1-3 identifiers (a table reference)
+ // A table reference can be: "table", "table alias", or "table as alias" (max 3 identifiers)
+ // If we see more than 3 identifiers before comma, it's not a table list (e.g., column list)
+ // Only treat comma as table separator if we're at the same paren level as the FROM clause
+ if (fromClauseParenLevel >= 0 && parenLevel == fromClauseParenLevel
+ && identifierCount > 0
+ && identifierCount <= TABLE_REF_MAX_IDENTIFIERS) {
+ // Comma in FROM clause - restart table list capture for next table
+ captureTableList = true;
+ identifierCount = 0;
+ }
+ }
+ }
+
+ private class Insert extends Operation {
+ boolean expectingTableName = false;
+
+ void handleInto() {
+ expectingTableName = true;
+ }
+
+ void handleSelect() {
+ operation = new Select();
+ appendOperationToSummary();
+ }
+
+ void handleIdentifier() {
+ if (expectingTableName) {
+ appendTargetToSummary();
+ recordCollectionName();
+ expectingTableName = false;
+ }
+ }
+ }
+
+ private class Delete extends Operation {
+ boolean expectingTableName = false;
+ boolean identifierCaptured = false;
+
+ void handleFrom() {
+ expectingTableName = true;
+ }
+
+ void handleSelect() {
+ // Once we've captured the DELETE table, any SELECT is a subquery
+ if (identifierCaptured) {
+ operation = new Select();
+ appendOperationToSummary();
+ }
+ }
+
+ void handleIdentifier() {
+ if (expectingTableName) {
+ appendTargetToSummary();
+ recordCollectionName();
+ expectingTableName = false;
+ identifierCaptured = true;
+ }
+ }
+ }
+
+ /** Operation that extracts the first identifier as the target. */
+ private class SimpleOperation extends Operation {
+ boolean identifierCaptured = false;
+
+ void handleIdentifier() {
+ if (!identifierCaptured) {
+ appendTargetToSummary();
+ identifierCaptured = true;
+ }
+ }
+ }
+
+ private class Update extends Operation {
+ boolean identifierCaptured = false;
+
+ void handleSelect() {
+ // Once we've captured the UPDATE table, any SELECT is a subquery
+ if (identifierCaptured) {
+ operation = new Select();
+ appendOperationToSummary();
+ }
+ }
+
+ void handleIdentifier() {
+ if (!identifierCaptured) {
+ appendTargetToSummary();
+ recordCollectionName();
+ identifierCaptured = true;
+ }
+ }
+ }
+
+ private class Merge extends Operation {
+ boolean identifierCaptured = false;
+
+ void handleIdentifier() {
+ if (!identifierCaptured) {
+ appendTargetToSummary();
+ recordCollectionName();
+ identifierCaptured = true;
+ }
+ }
+ }
+
+ private class Call extends Operation {
+ boolean identifierCaptured = false;
+ // Track "NEXT VALUE FOR sequence" pattern - sequence name comes after FOR
+ boolean sawNext = false;
+ boolean sawValue = false;
+ boolean expectingSequenceName = false;
+
+ void handleIdentifier() {
+ if (expectingSequenceName) {
+ // This is the sequence name after "NEXT VALUE FOR"
+ appendTargetToSummary();
+ expectingSequenceName = false;
+ identifierCaptured = true;
+ } else if (!identifierCaptured && !sawNext) {
+ storedProcedureName = yytext();
+ appendTargetToSummary();
+ identifierCaptured = true;
+ } else if (sawNext && !sawValue && yytext().equalsIgnoreCase("value")) {
+ // This is "VALUE" in "NEXT VALUE FOR"
+ sawValue = true;
+ } else if (sawValue && yytext().equalsIgnoreCase("for")) {
+ // This is "FOR" in "NEXT VALUE FOR" - expect sequence name next
+ expectingSequenceName = true;
+ }
+ }
+
+ void handleNext() {
+ sawNext = true;
+ storedProcedureName = null;
+ }
+ }
+
+ /** VALUES operation - no table to capture. */
+ private class Values extends Operation {}
+
+ private class SensitivePhraseOperation extends Operation {
+ boolean shouldSanitizeRemainderAfterPassword() {
+ return true;
+ }
+ }
+
+ /** EXECUTE/EXEC operation for stored procedures. */
+ private class Execute extends SimpleOperation {
+ void handleIdentifier() {
+ if (!identifierCaptured) {
+ appendTargetToSummary();
+ identifierCaptured = true;
+ storedProcedureName = yytext();
+ }
+ }
+ }
+
+ private class Create extends DdlOperation {}
+ private class Drop extends DdlOperation {}
+ private class Alter extends DdlOperation {}
+
+ /** TRUNCATE operation - captures TABLE keyword and table name. */
+ private class Truncate extends Operation {
+ boolean tableCaptured = false;
+ boolean identifierCaptured = false;
+
+ void handleIdentifier() {
+ String text = yytext();
+ // Include TABLE keyword in summary
+ if (text.equalsIgnoreCase("TABLE")) {
+ if (!tableCaptured) {
+ appendTargetToSummary();
+ refineOperationName(text);
+ tableCaptured = true;
+ }
+ return;
+ }
+ if (!identifierCaptured) {
+ appendTargetToSummary();
+ if (tableCaptured) {
+ recordCollectionName();
+ }
+ identifierCaptured = true;
+ }
+ }
+ }
+
+ /** REPLACE operation (MySQL) - like INSERT, captures table name. */
+ private class Replace extends Operation {
+ boolean expectingTableName = false;
+ boolean tableCaptured = false;
+
+ void handleInto() {
+ expectingTableName = true;
+ }
+
+ void handleIdentifier() {
+ if (!tableCaptured) {
+ appendTargetToSummary();
+ recordCollectionName();
+ tableCaptured = true;
+ expectingTableName = false;
+ }
+ }
+ }
+
+ /** LOCK operation - captures TABLE/TABLES keyword and table name. */
+ private class Lock extends Operation {
+ boolean tableCaptured = false;
+ boolean identifierCaptured = false;
+
+ void handleIdentifier() {
+ String text = yytext();
+ // Include TABLE/TABLES keywords in summary
+ if (text.equalsIgnoreCase("TABLE") || text.equalsIgnoreCase("TABLES")) {
+ if (!tableCaptured) {
+ appendTargetToSummary();
+ tableCaptured = true;
+ }
+ return;
+ }
+ if (!identifierCaptured) {
+ appendTargetToSummary();
+ recordCollectionName();
+ identifierCaptured = true;
+ }
+ }
+ }
+
+ /** USE operation - captures database name. */
+ private class Use extends SimpleOperation {}
+
+ /** Transaction control operations (BEGIN, COMMIT, ROLLBACK) - captures TRANSACTION if present. */
+ private class TransactionControl extends Operation {
+ boolean transactionCaptured = false;
+
+ void handleIdentifier() {
+ // Capture TRANSACTION keyword if present (e.g., BEGIN TRANSACTION, COMMIT TRANSACTION)
+ if (!transactionCaptured && yytext().equalsIgnoreCase("TRANSACTION")) {
+ appendTargetToSummary();
+ transactionCaptured = true;
+ }
+ }
+ }
+
+ /** GRANT operation - blocks other keywords from being parsed. */
+ private class Grant extends Operation {
+ boolean shouldSanitizeRemainderAfterIdentifiedBy() {
+ return true;
+ }
+ }
+
+ /** REVOKE operation - blocks other keywords from being parsed. */
+ private class Revoke extends Operation {}
+
+ /** SHOW operation - blocks other keywords from being parsed. */
+ private class Show extends Operation {}
+
+ /**
+ * WITH clause operation - handles CTE (Common Table Expression) definitions.
+ * CTEs have the form: WITH name AS (query), name2 AS (query2), ... main_query
+ */
+ private class With extends Operation {
+ // State: true when expecting a CTE name (after WITH or after comma between CTEs)
+ boolean expectingCteName = true;
+
+ // The paren level when WITH was seen - used to detect main query vs CTE body
+ final int baseParenLevel = parenLevel;
+
+ void handleIdentifier() {
+ if (expectingCteName) {
+ // This is the CTE name - record it in global set for filtering CTE references
+ cteNames.add(yytext().toLowerCase(Locale.ROOT));
+ expectingCteName = false;
+ }
+ }
+
+ boolean isEnteringSubquery() {
+ // After we've captured a CTE name, ( starts the CTE body
+ return !expectingCteName;
+ }
+
+ void handleComma() {
+ // Comma at base level means another CTE definition follows
+ if (isMainQueryLevel()) {
+ expectingCteName = true;
+ }
+ }
+
+ /** Returns true if we're at the main query level (outside any CTE body). */
+ boolean isMainQueryLevel() {
+ return parenLevel == baseParenLevel;
+ }
+ }
+
+ /**
+ * Check if an identifier is a CTE reference (should be filtered from table list).
+ * Uses global cteNames set populated by With operation.
+ */
+ private boolean isCteReference(String identifier) {
+ return cteNames.contains(identifier.toLowerCase(Locale.ROOT));
+ }
+
+ private SqlQuery getResult() {
+ StringUtils.truncate(builder, LIMIT);
+ String fullStatement = builder.toString();
+
+ // Normalize all 'in (?, ?, ...)' statements to in (?) to reduce cardinality
+ String normalizedStatement = IN_STATEMENT_PATTERN.matcher(fullStatement).replaceAll(IN_STATEMENT_NORMALIZED);
+
+ String summary = querySummaryBuilder.length() > 0 ? querySummaryBuilder.toString() : null;
+ // Remove trailing semicolon if present (no statement after last ;)
+ if (summary != null && summary.endsWith(";")) {
+ summary = summary.substring(0, summary.length() - 1);
+ }
+
+ return SqlQuery.create(
+ normalizedStatement,
+ operationName,
+ collectionName,
+ storedProcedureName,
+ summary);
+ }
+
+%}
+
+%%
+
+ {
+
+ "WITH" {
+ if (shouldStartNewOperation()) {
+ setOperation(new With());
+ // Don't append WITH to summary - only the main query operation will be appended
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "RECURSIVE" {
+ // Prevent RECURSIVE keyword from being captured as a CTE name
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "SELECT" {
+ if (!insideComment) {
+ // Confirm pending subquery if we see SELECT inside parens
+ confirmPendingSubqueryIfNeeded();
+ if (shouldStartMainOperation()) {
+ setOperation(new Select());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (operation instanceof Select) {
+ // nested SELECT (subquery) - append SELECT to summary
+ appendOperationToSummary();
+ }
+ operation.handleSelect();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "INSERT" {
+ if (shouldStartMainOperation()) {
+ setOperation(new Insert());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "DELETE" {
+ if (shouldStartMainOperation()) {
+ setOperation(new Delete());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "UPDATE" {
+ if (shouldStartMainOperation()) {
+ setOperation(new Update());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "CALL" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Call());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "MERGE" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Merge());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "CREATE" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Create());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "DROP" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Drop());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "ALTER" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Alter());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "VALUES" {
+ if (!insideComment) {
+ // Confirm pending subquery if we see VALUES inside parens (e.g., CTE body)
+ confirmPendingSubqueryIfNeeded();
+ if (shouldStartNewOperation()) {
+ setOperation(new Values());
+ // Only append VALUES to summary if at top level (not inside a subquery or CTE body)
+ if (operationStack.isEmpty()) {
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ }
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "EXECUTE" | "EXEC" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Execute());
+ recordOperationName();
+ appendOperationToSummary();
+ } else if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "TRUNCATE" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Truncate());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "REPLACE" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Replace());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "LOCK" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Lock());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "USE" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Use());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "BEGIN" {
+ if (shouldStartNewOperation()) {
+ setOperation(new TransactionControl());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "COMMIT" {
+ if (shouldStartNewOperation()) {
+ setOperation(new TransactionControl());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "ROLLBACK" {
+ if (shouldStartNewOperation()) {
+ setOperation(new TransactionControl());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "GRANT" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Grant());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "REVOKE" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Revoke());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "SHOW" {
+ if (shouldStartNewOperation()) {
+ setOperation(new Show());
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "CONNECT" | "VALIDATE" | "CHECK" | "EXPORT" | "IMPORT" | "RECOVER" {
+ if (shouldStartNewOperation()) {
+ setOperation(new SensitivePhraseOperation());
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "EXPLAIN" {
+ // EXPLAIN is a prefix command - append to summary but don't set an operation,
+ // so the inner statement (SELECT, INSERT, etc.) gets processed normally.
+ if (!insideComment && operation == none) {
+ recordOperationName();
+ appendOperationToSummary();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "FROM" {
+ if (!insideComment) {
+ if (operation == none) {
+ // hql/jpql queries may skip SELECT and start with FROM clause
+ // treat such queries as SELECT queries
+ setOperation(new Select());
+ // Derive the synthetic SELECT case from the matched FROM token.
+ String operationName = Character.isUpperCase(zzBuffer[zzStartRead]) ? "SELECT" : "select";
+ recordOperationName(operationName);
+ appendOperationToSummary(operationName);
+ }
+ operation.handleFrom();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "INTO" {
+ if (!insideComment) {
+ operation.handleInto();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "JOIN" {
+ if (!insideComment) {
+ operation.handleJoin();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "APPLY" {
+ if (!insideComment && operation instanceof Select) {
+ ((Select) operation).handleApply();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "LATERAL" {
+ // LATERAL is a keyword used before derived tables - just recognize it, don't capture as identifier
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "NEXT" {
+ if (!insideComment) {
+ operation.handleNext();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "AS" {
+ if (!insideComment) {
+ operation.handleAs();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "ONLY" {
+ // PostgreSQL: FROM/UPDATE/DELETE ONLY - just skip, don't treat as table name
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ ";" {
+ if (!insideComment) {
+ // Statement separator - only append separator if we have content and not already ending with semicolon
+ if (querySummaryBuilder.length() > 0
+ && querySummaryBuilder.charAt(querySummaryBuilder.length() - 1) != ';') {
+ querySummaryBuilder.append(';');
+ }
+ // Reset operation state for next statement
+ operation = none;
+ parenLevel = 0;
+ operationStack.clear();
+ subqueryStartLevels.clear();
+ cteNames.clear();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "UNION" | "INTERSECT" | "EXCEPT" | "MINUS" {
+ // UNION etc. don't reset operation - the next SELECT will be handled
+ // by the existing operation via handleSelect(), or if at top level,
+ // a new Select will be created.
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "IF" | "NOT" | "EXISTS" {
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "TABLE" | "INDEX" | "DATABASE" | "PROCEDURE" | "VIEW" | "USER" {
+ if (!insideComment) {
+ // If we see a reserved word where we expected a subquery, it's a parenthesized name
+ cancelPendingSubqueryIfNeeded();
+ if (operation.expectingOperationTarget()) {
+ operation.handleOperationTarget(yytext());
+ } else {
+ operation.handleIdentifier();
+ }
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ "PASSWORD" {
+ boolean passwordTokenIsIdentifier = false;
+ if (!insideComment) {
+ cancelPendingSubqueryIfNeeded();
+ passwordTokenIsIdentifier = operation.isCapturingIdentifier();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (!passwordTokenIsIdentifier && !insideComment && shouldSanitizeRemainderAfterPassword()) {
+ builder.append(" ?");
+ return YYEOF;
+ }
+ if (isOverLimit()) return YYEOF;
+ }
+ "IDENTIFIED" {WHITESPACE}+ "BY" {
+ appendCurrentFragment();
+ if (!insideComment && shouldSanitizeRemainderAfterIdentifiedBy()) {
+ builder.append(" ?");
+ return YYEOF;
+ }
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {COMMA} {
+ if (!insideComment) {
+ operation.handleComma();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ {IDENTIFIER} {
+ if (sanitizeAmbiguousRemainder()) return YYEOF;
+ if (!insideComment) {
+ // If we see an identifier where we expected a subquery, it's a parenthesized table name
+ cancelPendingSubqueryIfNeeded();
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {OPEN_PAREN} {
+ if (!insideComment) {
+ // Check if we're entering a subquery BEFORE incrementing parenLevel
+ boolean enteringSubquery = operation.isEnteringSubquery();
+ parenLevel += 1;
+ if (enteringSubquery) {
+ // Don't push immediately - mark as pending and wait to see if there's an operation keyword
+ pendingSubqueryPush = true;
+ } else {
+ operation.handleOpenParen();
+ }
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ {CLOSE_PAREN} {
+ if (!insideComment) {
+ parenLevel -= 1;
+ operation.handleCloseParen();
+ // Pop operation from stack if we're exiting a subquery
+ popOperationIfNeeded();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {OPEN_COMMENT} {
+ insideComment = true;
+ yybegin(BLOCK_COMMENT);
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+ {CLOSE_COMMENT} {
+ insideComment = false;
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {LINE_COMMENT} {
+ // Line comment - append as-is, don't process keywords or sanitize literals
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ [.+-]+ {
+ // Leave an embedded -- for the line-comment rule.
+ for (int i = zzStartRead + 1; i < zzMarkedPos; i++) {
+ if (zzBuffer[i - 1] == '-' && zzBuffer[i] == '-') {
+ yypushback(zzMarkedPos - i + 1);
+ break;
+ }
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ // here is where the actual sanitization happens
+ {BASIC_NUM} | {HEX_NUM} | {DOLLAR_QUOTED_STR} {
+ builder.append('?');
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {QUOTED_STR} {
+ if (sanitizeAmbiguousRemainder()) return YYEOF;
+ builder.append('?');
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {DOUBLE_QUOTED_STR} {
+ if (sanitizeAmbiguousRemainder()) return YYEOF;
+ if (!insideComment) {
+ // Always notify the operation about double-quoted tokens regardless of dialect so
+ // that summarization works correctly even when the dialect treats them as string
+ // literals. For example, SELECT * FROM "my_table" should produce the summary
+ // "SELECT my_table" whether or not the dialect sanitizes the token.
+ //
+ // The operation's own state guards (e.g. identifierCaptured, captureTableList)
+ // ensure handleIdentifier() is a no-op when not structurally expected, so there
+ // is no risk of leaking sensitive string content into the summary.
+ operation.handleIdentifier();
+ }
+ if (dialect.doubleQuotesAreIdentifiers()) {
+ appendCurrentFragment();
+ } else {
+ builder.append('?');
+ }
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {BACKTICK_QUOTED_STR} | {BRACKET_QUOTED_STR} | {POSTGRE_PARAM_MARKER} {
+ if (sanitizeAmbiguousRemainder()) return YYEOF;
+ if (!insideComment) {
+ operation.handleIdentifier();
+ }
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {UNTERMINATED_BRACKET_STR} {
+ // Consume an unfinished identifier once instead of retrying from every opening bracket.
+ builder.append('?');
+ return YYEOF;
+ }
+
+ {DOLLAR_TAG_START} {
+ // Start of a tagged dollar-quoted string like $tag$...$tag$
+ dollarTag = yytext();
+ yybegin(DOLLAR_STRING);
+ }
+
+ {WHITESPACE} {
+ builder.append(' ');
+ if (isOverLimit()) return YYEOF;
+ }
+ [^] {
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+}
+
+ {
+ {OPEN_COMMENT} {
+ // Nested comments are dialect-dependent, so neither interpretation is safe to assume.
+ builder.append('?');
+ return YYEOF;
+ }
+
+ {CLOSE_COMMENT} {
+ insideComment = false;
+ yybegin(YYINITIAL);
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {QUOTED_STR} | {DOLLAR_QUOTED_STR} {
+ if (appendCommentLiteral(true)) return YYEOF;
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {DOUBLE_QUOTED_STR} {
+ if (appendCommentLiteral(!dialect.doubleQuotesAreIdentifiers())) return YYEOF;
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {BACKTICK_QUOTED_STR} {
+ if (appendCommentLiteral(false)) return YYEOF;
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {DOLLAR_TAG_START} {
+ dollarTag = yytext();
+ yybegin(DOLLAR_STRING);
+ }
+
+ {UNQUOTED_IDENTIFIER} | {POSTGRE_PARAM_MARKER} {
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {BASIC_NUM} | {HEX_NUM} {
+ builder.append('?');
+ if (isOverLimit()) return YYEOF;
+ }
+
+ [.+-]+ {
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+
+ {WHITESPACE} {
+ builder.append(' ');
+ if (isOverLimit()) return YYEOF;
+ }
+
+ [^] {
+ appendCurrentFragment();
+ if (isOverLimit()) return YYEOF;
+ }
+}
+
+ {
+ {DOLLAR_TAG_START} {
+ // Check if this is the closing tag
+ if (yytext().equals(dollarTag)) {
+ builder.append('?');
+ dollarTag = null;
+ yybegin(insideComment ? BLOCK_COMMENT : YYINITIAL);
+ if (isOverLimit()) return YYEOF;
+ }
+ // else: different tag, continue consuming
+ }
+
+ "$" {
+ // Single dollar sign, not part of a tag - continue consuming
+ }
+
+ {OPEN_COMMENT} {
+ if (insideComment) {
+ builder.append('?');
+ return YYEOF;
+ }
+ }
+
+ {CLOSE_COMMENT} {
+ if (insideComment) {
+ builder.append("?*/");
+ dollarTag = null;
+ insideComment = false;
+ yybegin(YYINITIAL);
+ if (isOverLimit()) return YYEOF;
+ }
+ }
+
+ [^$/*]+ {
+ // Consume non-dollar characters
+ }
+
+ [/*] {}
+
+ <> {
+ // Unterminated dollar-quoted string - output what we have as ?
+ builder.append('?');
+ return YYEOF;
+ }
+}
diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt
new file mode 100644
index 00000000000..55a37351bbc
--- /dev/null
+++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt
@@ -0,0 +1,155 @@
+package io.sentry.util.sql
+
+import com.google.common.truth.Truth.assertWithMessage
+import io.sentry.JsonObjectReader
+import io.sentry.vendor.gson.stream.JsonToken
+import java.io.InputStreamReader
+import java.nio.charset.StandardCharsets
+import kotlin.test.Test
+
+/**
+ * Leaks of the unchanged grammar: a corpus case (`sql/analyzer-cases.json`) leaks when one of its
+ * declared secrets appears whole in the text, summary or stored procedure. Every leaking case must
+ * be listed in `sql/known-leaks.txt`, so a sync that adds a leak fails here. A listed case that no
+ * longer leaks only prints a note: an upstream fix must not fail the build.
+ *
+ * Cases are analyzed without a length limit: a cut can hide a leak that production limits (32 KiB
+ * for JDBC, 8 KiB for Android SQLite) would not. Every case must also give a text: `null` text
+ * means an internal failure, which would hide a leak.
+ */
+class SqlQueryAnalyzerKnownLeakTest {
+
+ @Test
+ fun `only listed cases leak a declared secret`() {
+ val known = readKnownLeaks()
+ val failed = mutableListOf()
+ val leaking = mutableSetOf()
+ for (case in readCases()) {
+ val query = SqlQueryAnalyzer.analyze(case.input, case.dbSystemName, Int.MAX_VALUE)
+ if (query.queryText == null) failed += case.id
+ val values = listOfNotNull(query.queryText, query.querySummary, query.storedProcedureName)
+ if (values.any { value -> case.secrets.any { value.contains(it) } }) leaking += case.id
+ }
+
+ val fixed = known - leaking
+ if (fixed.isNotEmpty()) {
+ println(
+ "${fixed.size} listed case(s) no longer leak; remove them from $KNOWN_LEAKS:\n" +
+ fixed.sorted().joinToString("\n"),
+ )
+ }
+ assertWithMessage("cases without text, so the analyzer failed internally")
+ .that(failed)
+ .isEmpty()
+ assertWithMessage("cases that leak but are not listed in %s", KNOWN_LEAKS)
+ .that((leaking - known).sorted())
+ .isEmpty()
+ }
+
+ private class Case(
+ val id: String,
+ val dbSystemName: String?,
+ val input: String,
+ val secrets: List,
+ )
+
+ private fun readKnownLeaks(): Set =
+ resource(KNOWN_LEAKS)
+ .bufferedReader()
+ .readLines()
+ .map { it.trim() }
+ .filter { it.isNotEmpty() && !it.startsWith("#") }
+ .toSet()
+
+ /**
+ * Rejects anything that would silently weaken a case: unknown or missing keys, unknown dialects.
+ */
+ private fun readCases(): List {
+ val cases = mutableListOf()
+ JsonObjectReader(InputStreamReader(resource(CASES), StandardCharsets.UTF_8)).use { reader ->
+ reader.beginObject()
+ while (reader.hasNext()) {
+ when (val key = reader.nextName()) {
+ // The license header of the adapted upstream cases: JSON has no comments.
+ "attribution" -> check(readStrings(reader, key).isNotEmpty())
+ "cases" -> {
+ reader.beginArray()
+ while (reader.hasNext()) {
+ val case = readCase(reader)
+ check(cases.none { it.id == case.id }) { "$CASES: duplicate id '${case.id}'" }
+ cases += case
+ }
+ reader.endArray()
+ }
+ else -> error("$CASES: unknown top-level key '$key'")
+ }
+ }
+ reader.endObject()
+ }
+ check(cases.isNotEmpty()) { "$CASES has no cases" }
+ return cases
+ }
+
+ private fun readCase(reader: JsonObjectReader): Case {
+ val values = mutableMapOf()
+ reader.beginObject()
+ while (reader.hasNext()) {
+ val key = reader.nextName()
+ check(key !in values) { "$CASES: duplicate key '$key' in case ${values["id"]}" }
+ values[key] =
+ when (key) {
+ "id",
+ "dialect",
+ "input",
+ "source" -> readString(reader, key)
+ "secrets" -> readStrings(reader, key)
+ else -> error("$CASES: unknown key '$key' in case ${values["id"]}")
+ }
+ }
+ reader.endObject()
+ val id = values["id"] as String?
+ check(values.keys == KEYS) { "$CASES: case '$id' misses ${KEYS - values.keys}" }
+ check(SOURCE.matches(values["source"] as String)) { "$CASES: case '$id': bad source" }
+ @Suppress("UNCHECKED_CAST") val secrets = values["secrets"] as List
+ check(secrets.isNotEmpty()) { "$CASES: case '$id' declares no secrets" }
+ return Case(
+ id!!,
+ toDbSystemName(values["dialect"] as String),
+ values["input"] as String,
+ secrets,
+ )
+ }
+
+ /**
+ * The file names dialects by the `db.system` the integrations report; the analyzer takes the
+ * semconv `db.system.name`, as [SqlSpanData] passes it. `CONSERVATIVE` is an unknown database. A
+ * value with no mapping is a typo, not an unknown database.
+ */
+ private fun toDbSystemName(dialect: String): String? {
+ if (dialect == "CONSERVATIVE") return null
+ return checkNotNull(SqlSpanData.toDbSystemName(dialect)) { "unknown dialect '$dialect'" }
+ }
+
+ private fun readString(reader: JsonObjectReader, key: String): String {
+ check(reader.peek() == JsonToken.STRING) { "'$key' must be a string" }
+ return reader.nextString()
+ }
+
+ private fun readStrings(reader: JsonObjectReader, key: String): List {
+ val values = mutableListOf()
+ reader.beginArray()
+ while (reader.hasNext()) values += readString(reader, key)
+ reader.endArray()
+ return values
+ }
+
+ private fun resource(name: String) =
+ checkNotNull(javaClass.classLoader.getResourceAsStream(name)) { "$name not found" }
+
+ private companion object {
+ const val CASES = "sql/analyzer-cases.json"
+ const val KNOWN_LEAKS = "sql/known-leaks.txt"
+ val KEYS = setOf("id", "dialect", "input", "secrets", "source")
+ val SOURCE = Regex("sentry|otel-java:\\w+#.+|otel-dotnet:[^#]+#.+")
+ }
+}
diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt
new file mode 100644
index 00000000000..49c58ded5ab
--- /dev/null
+++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt
@@ -0,0 +1,75 @@
+// The IN-list input is adapted from OpenTelemetry Java Instrumentation
+// (SqlQueryAnalyzerTest#longInStatementDoesntCauseStackOverflow).
+// Copyright The OpenTelemetry Authors.
+// Licensed under the Apache License, Version 2.0.
+// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/2acd9a5f1153e725a3b80e9b90ad55b385576fe8/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQueryAnalyzerTest.java
+package io.sentry.util.sql
+
+import com.google.common.truth.Truth.assertWithMessage
+import java.util.concurrent.Callable
+import java.util.concurrent.ExecutionException
+import java.util.concurrent.Executors
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.TimeoutException
+import kotlin.test.Test
+
+/**
+ * Deep and large input on a smaller stack than upstream's tests run on: [SqlQueryAnalyzer.analyze]
+ * must complete within [TIME_BOUND_MILLIS] on a [STACK_SIZE_BYTES] stack without a
+ * `StackOverflowError` or an internal failure.
+ */
+class SqlQueryAnalyzerPathologicalTest {
+
+ @Test
+ fun `deep and large input completes within the bound on a small stack`() {
+ val executor = Executors.newSingleThreadExecutor { runnable ->
+ Thread(null, runnable, "sql-analyzer-worker", STACK_SIZE_BYTES).apply { isDaemon = true }
+ }
+ try {
+ // Untimed, so class loading and initialization don't count against the first input.
+ executor.submit(Callable { SqlQueryAnalyzer.analyze("SELECT 1", null, Int.MAX_VALUE) }).get()
+
+ for ((name, sql) in INPUTS) {
+ // One db.system.name per dialect option: double quotes as literals, and as identifiers.
+ for (dbSystemName in listOf(null, "postgresql")) {
+ val describe = "$name under $dbSystemName"
+ val future =
+ executor.submit(Callable { SqlQueryAnalyzer.analyze(sql, dbSystemName, Int.MAX_VALUE) })
+ val query =
+ try {
+ future.get(TIME_BOUND_MILLIS, TimeUnit.MILLISECONDS)
+ } catch (e: TimeoutException) {
+ future.cancel(true)
+ throw AssertionError("$describe did not complete within $TIME_BOUND_MILLIS ms")
+ } catch (e: ExecutionException) {
+ throw AssertionError("$describe threw ${e.cause}", e.cause)
+ }
+
+ assertWithMessage("no text, so the analyzer failed internally; %s", describe)
+ .that(query.queryText)
+ .isNotNull()
+ }
+ }
+ } finally {
+ executor.shutdownNow()
+ }
+ }
+
+ private companion object {
+ const val TIME_BOUND_MILLIS = 2_000L
+
+ /** Below the default for Android background threads and HotSpot (both about 1 MiB). */
+ const val STACK_SIZE_BYTES = 512L * 1024
+
+ const val MIB = 1024 * 1024
+
+ val INPUTS =
+ mapOf(
+ "10k nested parens" to "SELECT " + "(".repeat(10_000) + "1" + ")".repeat(10_000),
+ "10001-item IN list" to "select col from table where col in (" + "?,".repeat(10_000) + "?)",
+ // The grammar stops once its output passes 32 KiB, but reads a single token to its end:
+ // the slowest input it gets is one literal just under the 1 MiB skip limit.
+ "1 MiB string literal" to "SELECT '" + "x".repeat(MIB - "SELECT ''".length) + "'",
+ )
+ }
+}
diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt
new file mode 100644
index 00000000000..172eebd8ae0
--- /dev/null
+++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt
@@ -0,0 +1,121 @@
+package io.sentry.util.sql
+
+import com.google.common.truth.Truth.assertThat
+import com.google.common.truth.Truth.assertWithMessage
+import io.sentry.vendor.otel.sql.OtelSqlSanitizer
+import kotlin.test.Test
+import kotlin.test.assertFailsWith
+import org.mockito.Mockito
+import org.mockito.kotlin.any
+
+/**
+ * Tests what [SqlQueryAnalyzer] adds around the vendored grammar. The grammar's output is not
+ * asserted, so syncing upstream never means updating expectations; where a test relies on a fact
+ * about that output, it checks the fact first as a precondition.
+ */
+class SqlQueryAnalyzerTest {
+
+ @Test
+ fun `null input gives no text, summary or stored procedure`() {
+ val query = SqlQueryAnalyzer.analyze(null, "postgresql", LIMIT)
+
+ assertThat(query.fields()).isEqualTo(NO_FIELDS)
+ }
+
+ @Test
+ fun `input over 1 MiB is not analyzed`() {
+ val sql = "SELECT a FROM t WHERE b = '" + "x".repeat(MIB) + "'"
+
+ val query = SqlQueryAnalyzer.analyze(sql, "postgresql", LIMIT)
+
+ assertThat(query.fields()).isEqualTo(NO_FIELDS)
+ }
+
+ @Test
+ fun `input of exactly 1 MiB is analyzed`() {
+ val prefix = "SELECT a FROM t WHERE b = '"
+ val sql = prefix + "x".repeat(MIB - prefix.length - 1) + "'"
+ assertThat(sql.length).isEqualTo(MIB)
+
+ val query = SqlQueryAnalyzer.analyze(sql, "postgresql", LIMIT)
+
+ assertThat(query.queryText).isNotNull()
+ }
+
+ @Test
+ fun `text over the limit is cut at the last whitespace within the limit`() {
+ val sql = "SELECT alpha, beta, gamma FROM delta WHERE id = ?"
+ val full = fullText(sql)
+ val from = full.indexOf(" FROM")
+ assertWithMessage("precondition: the grammar keeps ' FROM' in %s", full).that(from).isAtLeast(0)
+
+ // The limit falls inside FROM, so the space before it is the last whitespace within it.
+ val query = SqlQueryAnalyzer.analyze(sql, null, from + 3)
+
+ assertThat(query.queryText).isEqualTo(full.substring(0, from))
+ }
+
+ @Test
+ fun `text without whitespace within the limit is cut at the limit without splitting a surrogate pair`() {
+ // U+1D49C is a letter outside the BMP: two chars, one identifier character.
+ val letter = "\uD835\uDC9C"
+ val sql = letter.repeat(10)
+ assertWithMessage("precondition: the grammar keeps the identifier")
+ .that(fullText(sql))
+ .isEqualTo(sql)
+
+ // Limit 5 falls between the halves of the third letter, which is dropped whole.
+ val query = SqlQueryAnalyzer.analyze(sql, null, 5)
+
+ assertThat(query.queryText).isEqualTo(letter.repeat(2))
+ }
+
+ @Test
+ fun `double quotes are identifiers only for databases that use them so`() {
+ val sql = "SELECT \"Zq9xK7\" FROM t"
+
+ assertThat(SqlQueryAnalyzer.analyze(sql, "postgresql", LIMIT).queryText).contains("Zq9xK7")
+ assertThat(SqlQueryAnalyzer.analyze(sql, "mysql", LIMIT).queryText).doesNotContain("Zq9xK7")
+ assertThat(SqlQueryAnalyzer.analyze(sql, null, LIMIT).queryText).doesNotContain("Zq9xK7")
+ }
+
+ @Test
+ fun `runtime exception from the grammar gives no text, summary or stored procedure`() {
+ Mockito.mockStatic(OtelSqlSanitizer::class.java).use { sanitizer ->
+ sanitizer
+ .`when` { OtelSqlSanitizer.sanitize(any(), any()) }
+ .thenThrow(IllegalStateException("lexer bug"))
+
+ val query = SqlQueryAnalyzer.analyze("SELECT 'Zq9xK7'", null, LIMIT)
+
+ assertThat(query.fields()).isEqualTo(NO_FIELDS)
+ }
+ }
+
+ @Test
+ fun `error from the grammar propagates`() {
+ Mockito.mockStatic(OtelSqlSanitizer::class.java).use { sanitizer ->
+ sanitizer
+ .`when` { OtelSqlSanitizer.sanitize(any(), any()) }
+ .thenThrow(StackOverflowError())
+
+ assertFailsWith { SqlQueryAnalyzer.analyze("SELECT 1", null, LIMIT) }
+ }
+ }
+
+ private fun SqlQuery.fields(): Map =
+ mapOf(
+ "text" to queryText,
+ "summary" to querySummary,
+ "storedProcedure" to storedProcedureName,
+ )
+
+ private fun fullText(sql: String): String =
+ checkNotNull(SqlQueryAnalyzer.analyze(sql, null, Int.MAX_VALUE).queryText)
+
+ private companion object {
+ const val LIMIT = 32 * 1024
+ const val MIB = 1024 * 1024
+ val NO_FIELDS = mapOf("text" to null, "summary" to null, "storedProcedure" to null)
+ }
+}
diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt
new file mode 100644
index 00000000000..c6a7a62577a
--- /dev/null
+++ b/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt
@@ -0,0 +1,155 @@
+package io.sentry.util.sql
+
+import com.google.common.truth.Truth.assertThat
+import io.sentry.ILogger
+import io.sentry.IScopes
+import io.sentry.NoOpLogger
+import io.sentry.SentryLevel
+import io.sentry.SentryOptions
+import io.sentry.SentryTracer
+import io.sentry.Span
+import io.sentry.TransactionContext
+import io.sentry.vendor.otel.sql.OtelSqlSanitizer
+import kotlin.test.Test
+import org.mockito.Mockito
+import org.mockito.kotlin.any
+import org.mockito.kotlin.argumentCaptor
+import org.mockito.kotlin.eq
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.verify
+import org.mockito.kotlin.verifyNoInteractions
+import org.mockito.kotlin.whenever
+
+/**
+ * What the JDBC and Android SQLite integrations put on a span: the analyzer's text as description
+ * and `db.query.text`, summary and stored procedure only when present. The values themselves are
+ * tested in [SqlQueryAnalyzerTest].
+ */
+class SqlSpanDataTest {
+
+ private val scopes =
+ mock().also {
+ whenever(it.options).thenReturn(SentryOptions().apply { dsn = "https://key@sentry.io/proj" })
+ }
+
+ private fun span(): Span =
+ SentryTracer(TransactionContext("name", "op"), scopes).startChild("db.sql.query") as Span
+
+ @Test
+ fun `span gets the analyzer's fields, and only those that have a value`() {
+ for (sql in
+ listOf(
+ "CALL get_user('a@b.c')",
+ "SELECT * FROM users WHERE email = 'x@y.z'",
+ "frobnicate 'secret'",
+ )) {
+ val expected = SqlQueryAnalyzer.analyze(sql, "postgresql", LIMIT)
+ val data = SqlSpanData.analyze(sql, "postgresql", LIMIT, NoOpLogger.getInstance())
+ val span = span()
+
+ data.applyTo(span)
+
+ assertThat(data.description).isEqualTo(expected.queryText)
+ assertThat(span.data.filterKeys { it.startsWith("db.") })
+ .isEqualTo(
+ mapOf(
+ "db.query.text" to expected.queryText,
+ "db.query.summary" to expected.querySummary,
+ "db.stored_procedure.name" to expected.storedProcedureName,
+ )
+ .filterValues { it != null },
+ )
+ }
+ }
+
+ @Test
+ fun `db system is mapped to the db system name the analyzer gets`() {
+ // Oracle reads double quotes as identifiers only under its semconv name, oracle.db.
+ val sql = "SELECT \"Zq9xK7\" FROM t"
+ val mapped = SqlQueryAnalyzer.analyze(sql, "oracle.db", LIMIT).queryText
+ val unmapped = SqlQueryAnalyzer.analyze(sql, "oracle", LIMIT).queryText
+ assertThat(mapped).isNotEqualTo(unmapped)
+
+ val data = SqlSpanData.analyze(sql, "oracle", LIMIT, NoOpLogger.getInstance())
+
+ assertThat(data.description).isEqualTo(mapped)
+ }
+
+ @Test
+ fun `null query gives no description, no query keys and no failure log`() {
+ val logger = mock()
+ val data = SqlSpanData.analyze(null, "postgresql", LIMIT, logger)
+ val span = span()
+
+ data.applyTo(span)
+
+ assertThat(data.description).isNull()
+ assertThat(span.data.keys.filter { it.startsWith("db.") }).isEmpty()
+ verifyNoInteractions(logger)
+ }
+
+ @Test
+ fun `query over 1 MiB gives no description, no query keys and no failure log`() {
+ val logger = mock()
+ val sql = "SELECT '" + "x".repeat(1024 * 1024) + "'"
+ val data = SqlSpanData.analyze(sql, "postgresql", LIMIT, logger)
+ val span = span()
+
+ data.applyTo(span)
+
+ assertThat(data.description).isNull()
+ assertThat(span.data.keys.filter { it.startsWith("db.") }).isEmpty()
+ verifyNoInteractions(logger)
+ }
+
+ @Test
+ fun `internal failure gives no query keys and logs without the query`() {
+ val logger = mock()
+ Mockito.mockStatic(OtelSqlSanitizer::class.java).use { sanitizer ->
+ sanitizer
+ .`when` { OtelSqlSanitizer.sanitize(any(), any()) }
+ .thenThrow(IllegalStateException("lexer bug"))
+
+ val data = SqlSpanData.analyze("SELECT 'Zq9xK7'", "postgresql", LIMIT, logger)
+ val span = span()
+ data.applyTo(span)
+
+ assertThat(data.description).isNull()
+ assertThat(span.data.keys.filter { it.startsWith("db.") }).isEmpty()
+ }
+ val message = argumentCaptor()
+ verify(logger).log(eq(SentryLevel.DEBUG), message.capture())
+ assertThat(message.firstValue).doesNotContain("Zq9xK7")
+ }
+
+ // Expected values: semantic-conventions model/db/registry.yaml.
+ @Test
+ fun `db system values map to semconv db system names`() {
+ val expected =
+ mapOf(
+ "postgresql" to "postgresql",
+ "mysql" to "mysql",
+ "mariadb" to "mariadb",
+ "sqlite" to "sqlite",
+ "in-memory" to "sqlite",
+ "hsqldb" to "hsqldb",
+ "derby" to "derby",
+ "h2" to "h2database",
+ "sqlserver" to "microsoft.sql_server",
+ "oracle" to "oracle.db",
+ "db2" to "ibm.db2",
+ "clickhouse" to "clickhouse",
+ "sap" to "sap.hana",
+ "mongo" to "mongodb",
+ "tc" to null,
+ "" to null,
+ null to null,
+ )
+
+ assertThat(expected.mapValues { SqlSpanData.toDbSystemName(it.key) }).isEqualTo(expected)
+ }
+
+ private companion object {
+ const val LIMIT = 32 * 1024
+ }
+}
diff --git a/sentry/src/test/resources/sql/analyzer-cases.json b/sentry/src/test/resources/sql/analyzer-cases.json
new file mode 100644
index 00000000000..c34a3e7d438
--- /dev/null
+++ b/sentry/src/test/resources/sql/analyzer-cases.json
@@ -0,0 +1,2538 @@
+{
+ "attribution": [
+ "Cases whose source is otel-java:... are adapted from OpenTelemetry Java Instrumentation; cases whose source is otel-dotnet:... are adapted from OpenTelemetry .NET Contrib.",
+ "Copyright The OpenTelemetry Authors.",
+ "Licensed under the Apache License, Version 2.0.",
+ "https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/2acd9a5f1153e725a3b80e9b90ad55b385576fe8/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db",
+ "https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/4e3aba9ddf89f9accac004f44f32ebde335dd115/test/OpenTelemetry.Contrib.Shared.Tests"
+ ],
+ "cases": [
+ {
+ "id": "literal.string.basic",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM users WHERE email = 'Zq9xK7@example.com'",
+ "secrets": ["Zq9xK7@example.com"],
+ "source": "sentry"
+ },
+ {
+ "id": "procedure.call.basic",
+ "dialect": "postgresql",
+ "input": "CALL get_user(?, 'Zq9xK7tenant')",
+ "secrets": ["Zq9xK7tenant"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.conservative.backslash",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE a = 'a\\' , 'Zq9xK7secret'",
+ "secrets": ["Zq9xK7secret"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.string.doubled_quote",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM users WHERE name = 'O''Zq9xK7a'",
+ "secrets": ["Zq9xK7a"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.string.multiline",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM notes WHERE body = 'line one\nZq9xK7b line two'",
+ "secrets": ["Zq9xK7b"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.string.backslash.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT * FROM files WHERE path = 'C:\\' AND owner = 'Zq9xK7c'",
+ "secrets": ["Zq9xK7c"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.string.backslash.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM files WHERE path = 'C:\\' AND owner = 'Zq9xK7d'",
+ "secrets": ["Zq9xK7d"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.string.backslash.mysql",
+ "dialect": "mysql",
+ "input": "SELECT * FROM users WHERE name = 'it\\'s Zq9xK7e'",
+ "secrets": ["Zq9xK7e"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.string.backslash_same_boundary.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM files WHERE name LIKE '100\\%' AND path = 'C:\\\\' AND note = 'say \\\"hi\\\"' AND quote = 'it\\\\''s' AND owner = 'Zq9xK7la'",
+ "secrets": ["Zq9xK7la"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.string.backslash_same_boundary.mysql",
+ "dialect": "mysql",
+ "input": "SELECT * FROM files WHERE name LIKE '100\\%' AND path = 'C:\\\\' AND note = 'say \\\"hi\\\"' AND quote = 'it\\\\''s' AND owner = 'Zq9xK7lb'",
+ "secrets": ["Zq9xK7lb"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.string.backslash_same_boundary.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM files WHERE name LIKE '100\\%' AND path = 'C:\\\\' AND note = 'say \\\"hi\\\"' AND quote = 'it\\\\''s' AND owner = 'Zq9xK7lc'",
+ "secrets": ["Zq9xK7lc"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.hex",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE a = 0xDEADBEEF AND b = 0Xbeef AND c = X'4A6F' AND d = x'4a'",
+ "secrets": ["DEADBEEF"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.number.word_suffix.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE a = 123_456_789 AND b = 0o1234567 AND c = 0x_DEAD_BEEF AND d = 9_876.5e1_2",
+ "secrets": ["123_456_789", "0o1234567", "0x_DEAD_BEEF", "9_876.5e1_2"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.national.sqlserver",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM [Users] WHERE [Name] = N'Zq9xK7f'",
+ "secrets": ["Zq9xK7f"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.escape_string.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM users WHERE name = E'Zq9xK7g'",
+ "secrets": ["Zq9xK7g"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.escape_string.backslash.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM users WHERE nick = E'it\\'s' AND key = 'Zq9xK7h'",
+ "secrets": ["Zq9xK7h"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.charset_introducer.mysql",
+ "dialect": "mysql",
+ "input": "SELECT * FROM users WHERE name = _utf8mb4'Zq9xK7i'",
+ "secrets": ["Zq9xK7i"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.unicode_escape.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT U&'Zq9xK7j' FROM t",
+ "secrets": ["Zq9xK7j"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE body = $$it's Zq9xK7k$$",
+ "secrets": ["Zq9xK7k"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar.dash_dash_inside.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE body = $$a--x\nZq9xK7wf$$",
+ "secrets": ["Zq9xK7wf"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar_tag.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE body = $fn$ it's $$ Zq9xK7l $fn$ AND id = 1",
+ "secrets": ["Zq9xK7l"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar.mysql",
+ "dialect": "mysql",
+ "input": "SELECT $$a FROM t WHERE b = 'x$$' AND c = 'Zq9xK7m'",
+ "secrets": ["Zq9xK7m"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE body = $$Zq9xK7n$$",
+ "secrets": ["Zq9xK7n"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar_tag.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE body = $t$Zq9xK7h2c$t$",
+ "secrets": ["Zq9xK7h2c"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar.h2",
+ "dialect": "h2",
+ "input": "SELECT * FROM t WHERE body = $$it's Zq9xK7h2a$$",
+ "secrets": ["Zq9xK7h2a"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar_tag.h2",
+ "dialect": "h2",
+ "input": "SELECT * FROM t WHERE a = $t$ AND b = 'p $t$' AND c = 'Zq9xK7h2b'",
+ "secrets": ["Zq9xK7h2b"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar_tag.inside_identifier.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT a$x$ FROM t WHERE p = 'foo$x$Zq9xK7si'",
+ "secrets": ["Zq9xK7si"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar.inside_identifier.h2",
+ "dialect": "h2",
+ "input": "SELECT a$$ FROM t WHERE p = 'x$$Zq9xK7sj'",
+ "secrets": ["Zq9xK7sj"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.dollar_tag.inside_identifier.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a$x$Zq9xK7sk$x$ FROM t",
+ "secrets": ["Zq9xK7sk"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.dollar_in_identifier.oracle",
+ "dialect": "oracle",
+ "input": "SELECT sid FROM V$SESSION WHERE username = 'Zq9xK7sl'",
+ "secrets": ["Zq9xK7sl"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.oracle",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE nick = q'[it's me]' AND key = 'Zq9xK7o'",
+ "secrets": ["Zq9xK7o"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.delimiters.oracle",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE a = Q'{it's Zq9xK7p}' AND b = nq'!Zq9xK7q!'",
+ "secrets": ["Zq9xK7p", "Zq9xK7q"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM users WHERE nick = q'[it's me]' AND key = 'Zq9xK7r'",
+ "secrets": ["Zq9xK7r"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT q'Zq9xK7s' FROM t",
+ "secrets": ["Zq9xK7s"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.paired_inner_quotes.oracle",
+ "dialect": "oracle",
+ "input": "SELECT q'[A'Zq9xK7qa'B]' FROM dual",
+ "secrets": ["Zq9xK7qa"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.other_delimiter.oracle",
+ "dialect": "oracle",
+ "input": "SELECT q'#it's Zq9xK7qc#' FROM dual",
+ "secrets": ["Zq9xK7qc"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.paired_inner_quotes.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT q'[A'Zq9xK7qb'B]' FROM dual",
+ "secrets": ["Zq9xK7qb"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.other_closer_inside.oracle",
+ "dialect": "oracle",
+ "input": "SELECT q'[a)'Zq9xK7ss]' FROM t",
+ "secrets": ["Zq9xK7ss"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.after_number.oracle",
+ "dialect": "oracle",
+ "input": "SELECT 1q'[it's Zq9xK7st]' FROM dual",
+ "secrets": ["Zq9xK7st"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.after_dot.oracle",
+ "dialect": "oracle",
+ "input": "SELECT x.q'!it's Zq9xK7sq!' FROM t",
+ "secrets": ["Zq9xK7sq"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.q_quote.after_dot.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT x.nq'[a'Zq9xK7sr]' FROM t",
+ "secrets": ["Zq9xK7sr"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.keyword_before_quote",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT CASE WHEN a = 1 THEN 'x' ELSE'Zq9xK7t' END FROM t",
+ "secrets": ["Zq9xK7t"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.prefix_after_dot.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT \"a\".N'Zq9xK7sg' FROM t",
+ "secrets": ["Zq9xK7sg"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.in_list.collapse",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE a IN (1, 2, 3) AND b IN ('Zq9xK7u', 'x') AND c IN(?, ?) AND d IN (x, 'y')",
+ "secrets": ["Zq9xK7u"],
+ "source": "sentry"
+ },
+ {
+ "id": "literal.values.multi_row_kept",
+ "dialect": "CONSERVATIVE",
+ "input": "INSERT INTO t (a, b) VALUES (1, 'Zq9xK7w'), (2, 'x')",
+ "secrets": ["Zq9xK7w"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.line",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a -- Zq9xK7aa\nFROM t",
+ "secrets": ["Zq9xK7aa"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.block",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a /* Zq9xK7ab */ FROM t",
+ "secrets": ["Zq9xK7ab"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.block.no_space",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a/*Zq9xK7ac*/FROM t",
+ "secrets": ["Zq9xK7ac"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.leading",
+ "dialect": "CONSERVATIVE",
+ "input": "/* Zq9xK7ad */ SELECT a FROM t",
+ "secrets": ["Zq9xK7ad"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.end_without_newline",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a FROM t -- Zq9xK7ae",
+ "secrets": ["Zq9xK7ae"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.nested.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT a /* outer /* Zq9xK7af */ still Zq9xK7ag */ FROM t",
+ "secrets": ["Zq9xK7af", "Zq9xK7ag"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.nested.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT a /* outer /* Zq9xK7ah */ FROM t",
+ "secrets": ["Zq9xK7ah"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.nested.mysql",
+ "dialect": "mysql",
+ "input": "SELECT a /* outer /* Zq9xK7ai */ FROM t WHERE b = 'Zq9xK7aj'",
+ "secrets": ["Zq9xK7ai", "Zq9xK7aj"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.nested.overlapping",
+ "dialect": "sqlite",
+ "input": "SELECT a /*/*/ Zq9xK7wd */ FROM t",
+ "secrets": ["Zq9xK7wd"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.hash.mysql",
+ "dialect": "mysql",
+ "input": "SELECT a FROM t # Zq9xK7ak\nWHERE b = 1",
+ "secrets": ["Zq9xK7ak"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.hash.mariadb",
+ "dialect": "mariadb",
+ "input": "SELECT a FROM t #Zq9xK7al",
+ "secrets": ["Zq9xK7al"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.hash.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM #orders WHERE id = 'Zq9xK7am'",
+ "secrets": ["Zq9xK7am"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.mysql_executable",
+ "dialect": "mysql",
+ "input": "SELECT /*!50001 SQL_NO_CACHE Zq9xK7an */ a FROM t",
+ "secrets": ["Zq9xK7an"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.optimizer_hint",
+ "dialect": "oracle",
+ "input": "SELECT /*+ INDEX(t idx_Zq9xK7ao) */ a FROM t",
+ "secrets": ["Zq9xK7ao"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.markers_inside_string",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT '-- Zq9xK7ap', '/* x */', '#y' FROM t",
+ "secrets": ["Zq9xK7ap"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.quote_inside",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a /* it's */ FROM t -- don't\nWHERE b = 'Zq9xK7aq'",
+ "secrets": ["Zq9xK7aq"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.before_comment.mysql",
+ "dialect": "mysql",
+ "input": "SELECT a--/* Zq9xK7sf */b FROM t",
+ "secrets": ["Zq9xK7sf"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 1--1 FROM t WHERE a = 'Zq9xK7ar'",
+ "secrets": ["Zq9xK7ar"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.after_number.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT 1--Zq9xK7wa\nFROM t",
+ "secrets": ["Zq9xK7wa"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.after_number.mysql",
+ "dialect": "mysql",
+ "input": "SELECT 2-- Zq9xK7wb\nFROM t",
+ "secrets": ["Zq9xK7wb"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.after_number.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT 3.5e--Zq9xK7wc\nFROM t",
+ "secrets": ["Zq9xK7wc"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.sign_prefix.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT a+--1234 Zq9xK7we\nFROM t",
+ "secrets": ["Zq9xK7we"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.double_slash.h2",
+ "dialect": "h2",
+ "input": "SELECT a // Zq9xK7at\nFROM t",
+ "secrets": ["Zq9xK7at"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.double_slash.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a // Zq9xK7au\nFROM t",
+ "secrets": ["Zq9xK7au"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.bare_cr.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT a FROM t -- note\rWHERE b = Zq9xK7xm",
+ "secrets": ["Zq9xK7xm"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.bare_cr.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT a FROM t -- c\r WHERE b = 'x\n Zq9xK7xn'",
+ "secrets": ["Zq9xK7xn"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.bare_cr_empty.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT a FROM t --\rZq9xK7xo",
+ "secrets": ["Zq9xK7xo"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.crlf.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT a FROM t -- Zq9xK7xp\r\nWHERE b = 1",
+ "secrets": ["Zq9xK7xp"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.dash_dash.cr_at_end.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT a FROM t -- Zq9xK7xq\r",
+ "secrets": ["Zq9xK7xq"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.hash.bare_cr.mysql",
+ "dialect": "mysql",
+ "input": "SELECT a FROM t # note\rWHERE b = Zq9xK7xr",
+ "secrets": ["Zq9xK7xr"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.hash.bare_cr_empty.mysql",
+ "dialect": "mysql",
+ "input": "SELECT a FROM t #\rZq9xK7xs",
+ "secrets": ["Zq9xK7xs"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.hash.crlf.mysql",
+ "dialect": "mysql",
+ "input": "SELECT a FROM t # Zq9xK7xt\r\nWHERE b = 1",
+ "secrets": ["Zq9xK7xt"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.double_slash.bare_cr.h2",
+ "dialect": "h2",
+ "input": "SELECT a FROM t // note\rWHERE b = Zq9xK7xu",
+ "secrets": ["Zq9xK7xu"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.block.after_star.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT */* Zq9xK7sa */ FROM t",
+ "secrets": ["Zq9xK7sa"],
+ "source": "sentry"
+ },
+ {
+ "id": "comment.double_slash.after_star.h2",
+ "dialect": "h2",
+ "input": "SELECT a*// Zq9xK7sb\nFROM t",
+ "secrets": ["Zq9xK7sb"],
+ "source": "sentry"
+ },
+ {
+ "id": "jdbc.call_return",
+ "dialect": "CONSERVATIVE",
+ "input": "{? = call calc_total(?, 'Zq9xK7av')}",
+ "secrets": ["Zq9xK7av"],
+ "source": "sentry"
+ },
+ {
+ "id": "jdbc.temporal",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE created > {ts '2024-01-02 03:04:05'} AND day = {d '2024-01-02'}",
+ "secrets": ["2024-01-02"],
+ "source": "sentry"
+ },
+ {
+ "id": "jdbc.fn",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT {fn UCASE(name)}, {fn CONCAT('Zq9xK7aw', name)} FROM t",
+ "secrets": ["Zq9xK7aw"],
+ "source": "sentry"
+ },
+ {
+ "id": "prepared.mixed_constant",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM orders WHERE user_id = ? AND status = 'Zq9xK7ax' AND total > 100",
+ "secrets": ["Zq9xK7ax"],
+ "source": "sentry"
+ },
+ {
+ "id": "prepared.in_memory",
+ "dialect": "in-memory",
+ "input": "SELECT * FROM [cache] WHERE key = ? AND tag = 'Zq9xK7ay'",
+ "secrets": ["Zq9xK7ay"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.create_user.oracle",
+ "dialect": "oracle",
+ "input": "CREATE USER Zq9xK7bb IDENTIFIED BY Zq9xK7ba",
+ "secrets": ["Zq9xK7ba", "Zq9xK7bb"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.alter_user_replace.oracle",
+ "dialect": "oracle",
+ "input": "ALTER USER Zq9xK7bc IDENTIFIED BY Zq9xK7bd REPLACE Zq9xK7be",
+ "secrets": ["Zq9xK7bc", "Zq9xK7bd", "Zq9xK7be"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.create_user.mysql",
+ "dialect": "mysql",
+ "input": "CREATE USER 'Zq9xK7bf'@'localhost' IDENTIFIED BY 'Zq9xK7bg'",
+ "secrets": ["Zq9xK7bf", "Zq9xK7bg"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.create_user.postgresql",
+ "dialect": "postgresql",
+ "input": "CREATE USER Zq9xK7bh WITH PASSWORD 'Zq9xK7bi'",
+ "secrets": ["Zq9xK7bh", "Zq9xK7bi"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.unquoted_password",
+ "dialect": "CONSERVATIVE",
+ "input": "ALTER USER Zq9xK7bj PASSWORD Zq9xK7bk",
+ "secrets": ["Zq9xK7bj", "Zq9xK7bk"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.create_login.sqlserver",
+ "dialect": "sqlserver",
+ "input": "CREATE LOGIN [CONTOSO\\Zq9xK7bl] FROM WINDOWS",
+ "secrets": ["Zq9xK7bl", "CONTOSO"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.create_login_password.sqlserver",
+ "dialect": "sqlserver",
+ "input": "CREATE LOGIN Zq9xK7bm WITH PASSWORD = 'Zq9xK7bn'",
+ "secrets": ["Zq9xK7bm", "Zq9xK7bn"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.drop_user_if_exists.postgresql",
+ "dialect": "postgresql",
+ "input": "DROP USER IF EXISTS \"Zq9xK7bo\"",
+ "secrets": ["Zq9xK7bo"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.grant_grantees",
+ "dialect": "CONSERVATIVE",
+ "input": "GRANT SELECT, INSERT ON orders TO Zq9xK7bp, Zq9xK7bq",
+ "secrets": ["Zq9xK7bp", "Zq9xK7bq"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.revoke_grantee",
+ "dialect": "CONSERVATIVE",
+ "input": "REVOKE SELECT ON orders FROM Zq9xK7br",
+ "secrets": ["Zq9xK7br"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.grant_identified_by.mysql",
+ "dialect": "mysql",
+ "input": "GRANT ALL PRIVILEGES ON db.* TO 'Zq9xK7bs'@'%' IDENTIFIED BY 'Zq9xK7bt'",
+ "secrets": ["Zq9xK7bs", "Zq9xK7bt"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.create_role",
+ "dialect": "CONSERVATIVE",
+ "input": "CREATE ROLE Zq9xK7by",
+ "secrets": ["Zq9xK7by"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.set_password.mysql",
+ "dialect": "mysql",
+ "input": "SET PASSWORD FOR 'Zq9xK7nh'@'localhost' = 'Zq9xK7ni'",
+ "secrets": ["Zq9xK7nh", "Zq9xK7ni"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.pragma_key.sqlite",
+ "dialect": "sqlite",
+ "input": "PRAGMA key = Zq9xK7xa",
+ "secrets": ["Zq9xK7xa"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.pragma_key_call.sqlite",
+ "dialect": "sqlite",
+ "input": "PRAGMA key(Zq9xK7xb)",
+ "secrets": ["Zq9xK7xb"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.pragma_schema_key.sqlite",
+ "dialect": "sqlite",
+ "input": "PRAGMA main.key = Zq9xK7xc",
+ "secrets": ["Zq9xK7xc"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.attach_key.sqlite",
+ "dialect": "sqlite",
+ "input": "ATTACH DATABASE 'Zq9xK7xd.db' AS other KEY Zq9xK7xe",
+ "secrets": ["Zq9xK7xd", "Zq9xK7xe"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.set_custom.postgresql",
+ "dialect": "postgresql",
+ "input": "SET app.tenant = Zq9xK7xf",
+ "secrets": ["Zq9xK7xf"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.set_local_to.postgresql",
+ "dialect": "postgresql",
+ "input": "SET LOCAL app.tenant TO Zq9xK7xg",
+ "secrets": ["Zq9xK7xg"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.set_session_authorization.postgresql",
+ "dialect": "postgresql",
+ "input": "SET SESSION AUTHORIZATION Zq9xK7xh",
+ "secrets": ["Zq9xK7xh"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.alter_system.postgresql",
+ "dialect": "postgresql",
+ "input": "ALTER SYSTEM SET app.k = Zq9xK7xi",
+ "secrets": ["Zq9xK7xi"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.set_list.mysql",
+ "dialect": "mysql",
+ "input": "SET sql_mode = TRADITIONAL, @a = Zq9xK7xj",
+ "secrets": ["Zq9xK7xj"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.alter_session.oracle",
+ "dialect": "oracle",
+ "input": "ALTER SESSION SET CURRENT_SCHEMA = Zq9xK7xk",
+ "secrets": ["Zq9xK7xk"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.config_value.multi_statement.postgresql",
+ "dialect": "postgresql",
+ "input": "SET app.tenant = Zq9xK7xl; SELECT a FROM t",
+ "secrets": ["Zq9xK7xl"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.reduction_ends_at_statement_end.postgresql",
+ "dialect": "postgresql",
+ "input": "CREATE USER Zq9xK7ne WITH PASSWORD 'x; DROP TABLE Zq9xK7nf'; UPDATE t SET a = 'Zq9xK7ng'",
+ "secrets": ["Zq9xK7ne", "Zq9xK7nf", "Zq9xK7ng"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.unterminated_in_reduced_part.postgresql",
+ "dialect": "postgresql",
+ "input": "CREATE ROLE Zq9xK7nj VALID UNTIL 'Zq9xK7nk",
+ "secrets": ["Zq9xK7nj", "Zq9xK7nk"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.identified_by.database_link.oracle",
+ "dialect": "oracle",
+ "input": "CREATE DATABASE LINK remote CONNECT TO scott IDENTIFIED BY Zq9xK7na USING 'Zq9xK7nb'",
+ "secrets": ["Zq9xK7na", "Zq9xK7nb"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.identified_by_quoted.database_link.oracle",
+ "dialect": "oracle",
+ "input": "CREATE DATABASE LINK remote CONNECT TO scott IDENTIFIED BY \"Zq9xK7nc\" USING 'Zq9xK7nd'",
+ "secrets": ["Zq9xK7nc", "Zq9xK7nd"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.identified_by.set_role.oracle",
+ "dialect": "oracle",
+ "input": "SET ROLE app_role IDENTIFIED BY Zq9xK7pa",
+ "secrets": ["Zq9xK7pa"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.identified_by.comment_between.oracle",
+ "dialect": "oracle",
+ "input": "SET ROLE app_role IDENTIFIED /* role password */ BY Zq9xK7pb",
+ "secrets": ["Zq9xK7pb"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.password_stop.double_quoted.postgresql",
+ "dialect": "postgresql",
+ "input": "CREATE DATABASE db SYSTEM USER PASSWORD \"Zq9xK7nl\"",
+ "secrets": ["Zq9xK7nl"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.password_stop.equals.sqlserver",
+ "dialect": "sqlserver",
+ "input": "CREATE CERTIFICATE billing ENCRYPTION BY PASSWORD = 'Zq9xK7nm' WITH SUBJECT = 'Zq9xK7nn'",
+ "secrets": ["Zq9xK7nm", "Zq9xK7nn"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.connect_not_allowlisted",
+ "dialect": "CONSERVATIVE",
+ "input": "CONNECT Zq9xK7bu PASSWORD Zq9xK7bv",
+ "secrets": ["Zq9xK7bu", "Zq9xK7bv"],
+ "source": "sentry"
+ },
+ {
+ "id": "credentials.password_update",
+ "dialect": "CONSERVATIVE",
+ "input": "UPDATE users SET password = 'Zq9xK7bx' WHERE id = 1",
+ "secrets": ["Zq9xK7bx"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.insert",
+ "dialect": "CONSERVATIVE",
+ "input": "INSERT INTO users (id, name) VALUES (1, 'Zq9xK7ca')",
+ "secrets": ["Zq9xK7ca"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.update",
+ "dialect": "CONSERVATIVE",
+ "input": "UPDATE users SET name = 'Zq9xK7cb' WHERE id = 1",
+ "secrets": ["Zq9xK7cb"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.upsert",
+ "dialect": "CONSERVATIVE",
+ "input": "UPSERT INTO users (id, name) VALUES (1, 'Zq9xK7cc')",
+ "secrets": ["Zq9xK7cc"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.insert_on_conflict.postgresql",
+ "dialect": "postgresql",
+ "input": "INSERT INTO users (id, name) VALUES (1, 'Zq9xK7cd') ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name",
+ "secrets": ["Zq9xK7cd"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.replace.mysql",
+ "dialect": "mysql",
+ "input": "REPLACE INTO users VALUES (1, 'Zq9xK7ce')",
+ "secrets": ["Zq9xK7ce"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.create_table",
+ "dialect": "CONSERVATIVE",
+ "input": "CREATE TABLE orders (id INT PRIMARY KEY, status VARCHAR(20) DEFAULT 'Zq9xK7cf')",
+ "secrets": ["Zq9xK7cf"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.call",
+ "dialect": "CONSERVATIVE",
+ "input": "CALL update_stats(1, 'Zq9xK7cg')",
+ "secrets": ["Zq9xK7cg"],
+ "source": "sentry"
+ },
+ {
+ "id": "shape.execute.lowercase",
+ "dialect": "CONSERVATIVE",
+ "input": "execute sp_refresh 'Zq9xK7ch'",
+ "secrets": ["Zq9xK7ch"],
+ "source": "sentry"
+ },
+ {
+ "id": "allowlist.prepare.postgresql",
+ "dialect": "postgresql",
+ "input": "PREPARE find_user (int) AS SELECT * FROM users WHERE id = $1 AND tenant = 'Zq9xK7ma'",
+ "secrets": ["Zq9xK7ma"],
+ "source": "sentry"
+ },
+ {
+ "id": "allowlist.copy.postgresql",
+ "dialect": "postgresql",
+ "input": "COPY users (id, email) FROM '/srv/import/Zq9xK7mb.csv' WITH (FORMAT csv)",
+ "secrets": ["Zq9xK7mb"],
+ "source": "sentry"
+ },
+ {
+ "id": "allowlist.copy_query.postgresql",
+ "dialect": "postgresql",
+ "input": "COPY (SELECT * FROM users WHERE tenant = 'Zq9xK7mc') TO STDOUT",
+ "secrets": ["Zq9xK7mc"],
+ "source": "sentry"
+ },
+ {
+ "id": "allowlist.kill.mysql",
+ "dialect": "mysql",
+ "input": "KILL QUERY 48213",
+ "secrets": ["48213"],
+ "source": "sentry"
+ },
+ {
+ "id": "allowlist.xa.mysql",
+ "dialect": "mysql",
+ "input": "XA START 'Zq9xK7md'",
+ "secrets": ["Zq9xK7md"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.double_quotes.hsqldb",
+ "dialect": "hsqldb",
+ "input": "SELECT \"Name\" FROM \"PUBLIC\".\"Users\" WHERE \"Id\" = 'Zq9xK7da'",
+ "secrets": ["Zq9xK7da"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.double_quotes.derby",
+ "dialect": "derby",
+ "input": "INSERT INTO \"Users\" (\"Name\") VALUES ('Zq9xK7db')",
+ "secrets": ["Zq9xK7db"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.double_quotes.mysql",
+ "dialect": "mysql",
+ "input": "SELECT * FROM users WHERE name = \"Zq9xK7dc\"",
+ "secrets": ["Zq9xK7dc"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.double_quotes.unknown_target_after_quoted_names.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT * FROM [a\"b], `c\"d`, \"Zq9xK7og\"",
+ "secrets": ["Zq9xK7og"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.double_quotes.backslash.mysql",
+ "dialect": "mysql",
+ "input": "SELECT * FROM t WHERE a = \"x\\\" AND b = 'Zq9xK7dd'",
+ "secrets": ["Zq9xK7dd"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.double_quotes.backslash_same_boundary.mysql",
+ "dialect": "mysql",
+ "input": "SELECT * FROM t WHERE a LIKE \"100\\%\" AND b = \"C:\\\\\" AND c = \"say \\'hi\\'\" AND d = 'Zq9xK7ld'",
+ "secrets": ["Zq9xK7ld"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.quote_inside.sqlserver",
+ "dialect": "sqlserver",
+ "input": "SELECT [O'Brien] FROM [Users] WHERE [Note] = N'Zq9xK7de'",
+ "secrets": ["Zq9xK7de"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.bracket_inside.sqlserver",
+ "dialect": "sqlserver",
+ "input": "SELECT [a[b] FROM t WHERE c = 'Zq9xK7sh'",
+ "secrets": ["Zq9xK7sh"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.escaped_close.sqlserver",
+ "dialect": "sqlserver",
+ "input": "SELECT [a]]'x] FROM t WHERE p = 'Zq9xK7sm'",
+ "secrets": ["Zq9xK7sm"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.escaped_close_dotted.sqlserver",
+ "dialect": "sqlserver",
+ "input": "SELECT [dbo].[a]]'x] FROM t WHERE p = 'Zq9xK7sn'",
+ "secrets": ["Zq9xK7sn"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.escaped_close.sqlite",
+ "dialect": "sqlite",
+ "input": "SELECT [a]]'Zq9xK7so' FROM [t]",
+ "secrets": ["Zq9xK7so"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.escaped_close.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT [a]]'x] FROM t WHERE p = 'Zq9xK7sp'",
+ "secrets": ["Zq9xK7sp"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT tags[1] FROM t WHERE tags[2] = 'Zq9xK7df'",
+ "secrets": ["Zq9xK7df"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.quote_inside.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT [O'Brien] FROM t WHERE a = 'Zq9xK7dk'",
+ "secrets": ["Zq9xK7dk"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.comment_inside.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT [-- ] 'a\nZq9xK7dm' FROM t",
+ "secrets": ["Zq9xK7dm"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.double_slash_inside.h2",
+ "dialect": "h2",
+ "input": "SELECT [// ] 'a\nZq9xK7dn' FROM t",
+ "secrets": ["Zq9xK7dn"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.dotted_quote_inside.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT [a].[O'Brien] FROM t WHERE b = 'Zq9xK7dl'",
+ "secrets": ["Zq9xK7dl"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.unterminated_after_literal.mysql",
+ "dialect": "mysql",
+ "input": "SELECT a[ 'Zq9xK7sc]'",
+ "secrets": ["Zq9xK7sc"],
+ "source": "sentry"
+ },
+ {
+ "id": "dialect.brackets.unterminated_quote_inside.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT [O'Brien FROM t WHERE a = 'Zq9xK7sd'",
+ "secrets": ["Zq9xK7sd"],
+ "source": "sentry"
+ },
+ {
+ "id": "bracket.array_literal.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE tags = ARRAY['Zq9xK7dg', 'x']",
+ "secrets": ["Zq9xK7dg"],
+ "source": "sentry"
+ },
+ {
+ "id": "bracket.subscript_string.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT data['Zq9xK7dh'] FROM t",
+ "secrets": ["Zq9xK7dh"],
+ "source": "sentry"
+ },
+ {
+ "id": "bracket.array_literal.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE tags = ARRAY['Zq9xK7di']",
+ "secrets": ["Zq9xK7di"],
+ "source": "sentry"
+ },
+ {
+ "id": "bracket.subscript_string.conservative",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT data['Zq9xK7dj'] FROM t",
+ "secrets": ["Zq9xK7dj"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.unterminated.single_quote",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM users WHERE name = 'Zq9xK7ea",
+ "secrets": ["Zq9xK7ea"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.unterminated.double_quote.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM \"Zq9xK7eb",
+ "secrets": ["Zq9xK7eb"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.unterminated.backtick.mysql",
+ "dialect": "mysql",
+ "input": "SELECT * FROM `Zq9xK7ec",
+ "secrets": ["Zq9xK7ec"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.unterminated.bracket.sqlserver",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM [Orders WHERE name = 'Zq9xK7ed'",
+ "secrets": ["Zq9xK7ed"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.unterminated.block_comment",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a FROM t /* Zq9xK7ee",
+ "secrets": ["Zq9xK7ee"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.unterminated.dollar_tag.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE a = $x$Zq9xK7ef",
+ "secrets": ["Zq9xK7ef"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.unbalanced.open_paren",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE a IN (1, 'Zq9xK7eg'",
+ "secrets": ["Zq9xK7eg"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.control_char",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a\u0000b FROM t WHERE c = 'Zq9xK7eh'",
+ "secrets": ["Zq9xK7eh"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.control_char_in_literal",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE a = 'x\u0001Zq9xK7ei'",
+ "secrets": ["Zq9xK7ei"],
+ "source": "sentry"
+ },
+ {
+ "id": "malformed.lone_surrogate_in_literal",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE a = '\udc00Zq9xK7ej'",
+ "secrets": ["Zq9xK7ej"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.sentence",
+ "dialect": "CONSERVATIVE",
+ "input": "Please email Zq9xK7ek@example.com about the report",
+ "secrets": ["Zq9xK7ek"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.command",
+ "dialect": "CONSERVATIVE",
+ "input": "AUTH Zq9xK7el",
+ "secrets": ["Zq9xK7el"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.after_semicolon",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t; AUTH Zq9xK7em",
+ "secrets": ["Zq9xK7em"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.after_semicolon.double_quoted_name.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT \"a;b\" FROM t; AUTH Zq9xK7oc",
+ "secrets": ["Zq9xK7oc"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.after_semicolon.bracket_name.sqlserver",
+ "dialect": "sqlserver",
+ "input": "SELECT [a;b] FROM t; AUTH Zq9xK7od",
+ "secrets": ["Zq9xK7od"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.after_semicolon.backtick_name.mysql",
+ "dialect": "mysql",
+ "input": "SELECT `a;b` FROM t; AUTH Zq9xK7oe",
+ "secrets": ["Zq9xK7oe"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.after_semicolon.inside_subscript.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT a[1; AUTH Zq9xK7of]",
+ "secrets": ["Zq9xK7of"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.backslash_outside_literal",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT a \\ Zq9xK7en FROM t",
+ "secrets": ["Zq9xK7en"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.symbol",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 😀, Zq9xK7eo FROM t",
+ "secrets": ["Zq9xK7eo"],
+ "source": "sentry"
+ },
+ {
+ "id": "unrecognized.unicode_identifier_kept",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT ąś FROM źćļ WHERE x = 'ɣZq9xK7ep'",
+ "secrets": ["Zq9xK7ep"],
+ "source": "sentry"
+ },
+ {
+ "id": "size.summary.over_255",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM table_with_a_long_name_00, table_with_a_long_name_01, table_with_a_long_name_02, table_with_a_long_name_03, table_with_a_long_name_04, table_with_a_long_name_05, table_with_a_long_name_06, table_with_a_long_name_07, table_with_a_long_name_08, table_with_a_long_name_09, table_with_a_long_name_10, table_with_a_long_name_11 WHERE x = 'Zq9xK7fb'",
+ "secrets": ["Zq9xK7fb"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.room.master_table_insert",
+ "dialect": "sqlite",
+ "input": "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'Zq9xK7va')",
+ "secrets": ["Zq9xK7va"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.hibernate.sequence",
+ "dialect": "postgresql",
+ "input": "select nextval('Zq9xK7vc')",
+ "secrets": ["Zq9xK7vc"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.hibernate.hql_comment",
+ "dialect": "postgresql",
+ "input": "/* select p from Person p where p.email = 'Zq9xK7vd' */ select p1_0.id from person p1_0 where p1_0.email='Zq9xK7vd'",
+ "secrets": ["Zq9xK7vd"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.postgresql.upsert_jsonb",
+ "dialect": "postgresql",
+ "input": "INSERT INTO user_settings (user_id, setting, value) VALUES (?, 'Zq9xK7ve', ?::jsonb) ON CONFLICT (user_id, setting) DO UPDATE SET value = EXCLUDED.value, updated_at = now() RETURNING id",
+ "secrets": ["Zq9xK7ve"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.postgresql.jsonb_filter",
+ "dialect": "postgresql",
+ "input": "SELECT id, payload->>'Zq9xK7vf' AS status FROM events WHERE payload @> '{\"type\": \"Zq9xK7vg\"}'::jsonb AND created_at > ? ORDER BY created_at DESC LIMIT 50",
+ "secrets": ["Zq9xK7vf", "Zq9xK7vg"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.postgresql.job_claim",
+ "dialect": "postgresql",
+ "input": "UPDATE jobs SET status = 'Zq9xK7vh', locked_at = now() WHERE id = (SELECT id FROM jobs WHERE status = 'Zq9xK7vi' ORDER BY priority DESC FOR UPDATE SKIP LOCKED LIMIT 1) RETURNING id, payload",
+ "secrets": ["Zq9xK7vh", "Zq9xK7vi"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.postgresql.do_block",
+ "dialect": "postgresql",
+ "input": "DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'Zq9xK7vs') THEN CREATE TYPE order_status AS ENUM ('new', 'paid'); END IF; END $$",
+ "secrets": ["Zq9xK7vs"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.postgresql.notify",
+ "dialect": "postgresql",
+ "input": "NOTIFY order_events, 'Zq9xK7vj'",
+ "secrets": ["Zq9xK7vj"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.mysql.double_quoted_string",
+ "dialect": "mysql",
+ "input": "SELECT id FROM users WHERE status = \"Zq9xK7vk\" AND email = ?",
+ "secrets": ["Zq9xK7vk"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.mysql.backslash_escaped_quote",
+ "dialect": "mysql",
+ "input": "SELECT id FROM customers WHERE last_name = 'O\\'Zq9xK7vr' AND active = 1",
+ "secrets": ["Zq9xK7vr"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.mysql.json",
+ "dialect": "mysql",
+ "input": "SELECT JSON_UNQUOTE(JSON_EXTRACT(attrs, '$.Zq9xK7vl')) AS color FROM products WHERE JSON_CONTAINS(tags, '\"Zq9xK7vm\"')",
+ "secrets": ["Zq9xK7vl", "Zq9xK7vm"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.sqlserver.insert_audit",
+ "dialect": "sqlserver",
+ "input": "INSERT INTO [dbo].[AuditLog] ([UserId], [Action], [CreatedAt]) VALUES (?, N'Zq9xK7vn', SYSUTCDATETIME())",
+ "secrets": ["Zq9xK7vn"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.sqlserver.exec_procedure",
+ "dialect": "sqlserver",
+ "input": "EXEC [dbo].[usp_GetOrders] @CustomerId = ?, @Status = N'Zq9xK7vo'",
+ "secrets": ["Zq9xK7vo"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.tooling.liquibase_lock.mysql",
+ "dialect": "mysql",
+ "input": "UPDATE DATABASECHANGELOGLOCK SET `LOCKED` = 1, LOCKEDBY = 'Zq9xK7vp', LOCKGRANTED = NOW() WHERE ID = 1 AND `LOCKED` = 0",
+ "secrets": ["Zq9xK7vp"],
+ "source": "sentry"
+ },
+ {
+ "id": "workload.tooling.quartz_lock.postgresql",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM QRTZ_LOCKS WHERE SCHED_NAME = 'Zq9xK7vq' AND LOCK_NAME = ? FOR UPDATE",
+ "secrets": ["Zq9xK7vq"],
+ "source": "sentry"
+ },
+ {
+ "id": "otel_java.sanitize_sql.001",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD=1234",
+ "secrets": ["1234"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[1]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.002",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD = 1234",
+ "secrets": ["1234"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[2]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.003",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD>=-1234",
+ "secrets": ["1234"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[3]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.004",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD<-1234",
+ "secrets": ["1234"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[4]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.005",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD <.1234",
+ "secrets": ["1234"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[5]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.016",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 0x0af764",
+ "secrets": ["0af764"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[16]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.017",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 0xdeadBEEF",
+ "secrets": ["deadBEEF"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[17]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.024",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 123-45-6789",
+ "secrets": ["6789"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[24]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.027",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD = 'words and spaces'",
+ "secrets": ["words and spaces"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[27]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.028",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD = ' an escaped '' quote mark inside'",
+ "secrets": ["quote mark inside"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[28]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.030",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD = '\"inside doubles\"'",
+ "secrets": ["inside doubles"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[30]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.031",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD = '\"$$$$\"'",
+ "secrets": ["\"$$$$\""],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[31]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.032",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TABLE WHERE FIELD = 'a single \" doublequote inside'",
+ "secrets": ["doublequote inside"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[32]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.034",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM TABLE WHERE FIELD = $$words and spaces$$",
+ "secrets": ["words and spaces"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[34]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.035",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM TABLE WHERE FIELD = $$quotes '\" inside$$",
+ "secrets": ["quotes '\" inside"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[35]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.036",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM TABLE WHERE FIELD = $$\"''\"$$",
+ "secrets": ["\"''\""],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[36]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.040",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * \t\r\nFROM TABLE WHERE FIELD1 = 12344 AND FIELD2 = 5678",
+ "secrets": ["12344", "5678"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[40]"
+ },
+ {
+ "id": "otel_java.sanitize_sql.041",
+ "dialect": "CONSERVATIVE",
+ "input": "from TABLE WHERE FIELD=1234",
+ "secrets": ["1234"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[41]"
+ },
+ {
+ "id": "otel_java.simplify_sql.034",
+ "dialect": "CONSERVATIVE",
+ "input": "select 12345678",
+ "secrets": ["12345678"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[34]"
+ },
+ {
+ "id": "otel_java.simplify_sql.054",
+ "dialect": "CONSERVATIVE",
+ "input": "delete from 12345678",
+ "secrets": ["12345678"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[54]"
+ },
+ {
+ "id": "otel_java.simplify_sql.101",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM TABLE WHERE FIELD = $tag$hello world$tag$",
+ "secrets": ["hello world"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[101]"
+ },
+ {
+ "id": "otel_java.simplify_sql.102",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM TABLE WHERE FIELD = $a$nested $b$value$b$ here$a$",
+ "secrets": ["nested $b$value$b$ here"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[102]"
+ },
+ {
+ "id": "otel_java.simplify_sql.109",
+ "dialect": "CONSERVATIVE",
+ "input": "REPLACE INTO users VALUES (1, 'name')",
+ "secrets": ["name"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[109]"
+ },
+ {
+ "id": "otel_java.simplify_sql.123",
+ "dialect": "CONSERVATIVE",
+ "input": "GRANT SELECT ON users TO some_user",
+ "secrets": ["some_user"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[123]"
+ },
+ {
+ "id": "otel_java.simplify_sql.124",
+ "dialect": "CONSERVATIVE",
+ "input": "GRANT ALL PRIVILEGES ON database.* TO 'user'@'host'",
+ "secrets": ["user", "host"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[124]"
+ },
+ {
+ "id": "otel_java.simplify_sql.125",
+ "dialect": "CONSERVATIVE",
+ "input": "REVOKE SELECT ON users FROM some_user",
+ "secrets": ["some_user"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[125]"
+ },
+ {
+ "id": "otel_java.simplify_sql.126",
+ "dialect": "CONSERVATIVE",
+ "input": "REVOKE ALL PRIVILEGES ON database.* FROM 'user'@'host'",
+ "secrets": ["user", "host"],
+ "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[126]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.001",
+ "dialect": "CONSERVATIVE",
+ "input": "CREATE USER new_user PASSWORD Password1",
+ "secrets": ["new_user", "Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[1]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.002",
+ "dialect": "CONSERVATIVE",
+ "input": "ALTER USER user PASSWORD Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[2]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.003",
+ "dialect": "CONSERVATIVE",
+ "input": "CONNECT user PASSWORD Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[3]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.004",
+ "dialect": "CONSERVATIVE",
+ "input": "VALIDATE USER user PASSWORD Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[4]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.005",
+ "dialect": "CONSERVATIVE",
+ "input": "CHECK USER user PASSWORD \"Password1\"",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[5]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.006",
+ "dialect": "CONSERVATIVE",
+ "input": "CREATE DATABASE db SYSTEM USER PASSWORD Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[6]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.007",
+ "dialect": "CONSERVATIVE",
+ "input": "ALTER SYSTEM SET SECURE STORE BACKUP PASSWORD \"Password1\"",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[7]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.008",
+ "dialect": "CONSERVATIVE",
+ "input": "EXPORT table AS BINARY ENCRYPTION PASSWORD Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[8]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.009",
+ "dialect": "CONSERVATIVE",
+ "input": "IMPORT MY_SCHEMA1.T1 FROM '/backup/export_dir' WITH ENCRYPTION PASSWORD Password1",
+ "secrets": ["Password1", "export_dir"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[9]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.010",
+ "dialect": "CONSERVATIVE",
+ "input": "RECOVER ENCRYPTION ROOT KEYS USING 'backup' PASSWORD Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[10]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.011",
+ "dialect": "CONSERVATIVE",
+ "input": "GRANT SELECT ON users TO admin /* PASSWORD Password1 */",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[11]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.012",
+ "dialect": "CONSERVATIVE",
+ "input": "CREATE USER new_user IDENTIFIED BY Password1",
+ "secrets": ["new_user", "Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[12]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.013",
+ "dialect": "oracle",
+ "input": "ALTER USER user IDENTIFIED BY Password1 REPLACE Password2",
+ "secrets": ["Password1", "Password2"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[13]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.014",
+ "dialect": "CONSERVATIVE",
+ "input": "GRANT ALL PRIVILEGES ON database.* TO user IDENTIFIED BY Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[14]"
+ },
+ {
+ "id": "otel_java.sanitize_sensitive.023",
+ "dialect": "CONSERVATIVE",
+ "input": "UPDATE users SET password = \"Password1\"",
+ "secrets": ["ord1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[23]"
+ },
+ {
+ "id": "otel_java.sanitize_grant_identified_by_after_previous_statement.001",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 1; GRANT ALL PRIVILEGES ON database.* TO user IDENTIFIED BY Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeGrantIdentifiedByAfterPreviousStatement[1]"
+ },
+ {
+ "id": "otel_java.sanitize_ddl_object_named_password.001",
+ "dialect": "CONSERVATIVE",
+ "input": "CREATE USER password PASSWORD Password1",
+ "secrets": ["Password1"],
+ "source": "otel-java:SqlQueryAnalyzerTest#sanitizeDdlObjectNamedPassword[1]"
+ },
+ {
+ "id": "otel_java.subqueries_in_clause_positions.009",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT COALESCE((SELECT name FROM t1 WHERE id = ?), 'default') FROM dual",
+ "secrets": ["default"],
+ "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[9]"
+ },
+ {
+ "id": "otel_java.expressions.004",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT CASE WHEN status = ? THEN 'Active' ELSE 'Inactive' END FROM users",
+ "secrets": ["Active", "Inactive"],
+ "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[4]"
+ },
+ {
+ "id": "otel_java.expressions.005",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT CASE WHEN price > (SELECT AVG(price) FROM products) THEN 'High' ELSE 'Low' END FROM products",
+ "secrets": ["High"],
+ "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[5]"
+ },
+ {
+ "id": "otel_java.lexical_edge_cases.002",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM users WHERE name = $tag$unterminated",
+ "secrets": ["unterminated"],
+ "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lexicalEdgeCases[2]"
+ },
+ {
+ "id": "otel_java.vendor_specific_syntax.008",
+ "dialect": "oracle",
+ "input": "SELECT * FROM sales MODEL DIMENSION BY (product) MEASURES (amount) RULES (amount['Total'] = amount['A'] + amount['B'])",
+ "secrets": ["Total"],
+ "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[8]"
+ },
+ {
+ "id": "otel_dotnet.json.numeric_literal_with_decimal_point",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 12.34, -12.34, +12.34, .01, -.01",
+ "secrets": ["12.34"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#numeric_literal_with_decimal_point"
+ },
+ {
+ "id": "otel_dotnet.json.numeric_literal_exponential",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 12.34e56, -12.34e56, +12.34e56",
+ "secrets": ["12.34e56"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#numeric_literal_exponential"
+ },
+ {
+ "id": "otel_dotnet.json.numeric_literal_negative_exponential",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 12.34e-56, -12.34e-56, +12.34e-56",
+ "secrets": ["12.34e-56"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#numeric_literal_negative_exponential"
+ },
+ {
+ "id": "otel_dotnet.json.hex_literal",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 0xDEADBEEF, 0XdeadBEEF",
+ "secrets": ["DEADBEEF", "deadBEEF"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#hex_literal"
+ },
+ {
+ "id": "otel_dotnet.json.string_literal",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 'hello'",
+ "secrets": ["hello"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#string_literal"
+ },
+ {
+ "id": "otel_dotnet.json.string_literal_escaped_single_quote",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 'My name''s not important'",
+ "secrets": ["not important"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#string_literal_escaped_single_quote"
+ },
+ {
+ "id": "otel_dotnet.json.string_with_embedded_newline",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT 'My name is \n not important'",
+ "secrets": ["not important"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#string_with_embedded_newline"
+ },
+ {
+ "id": "otel_dotnet.json.numbers_in_identifiers",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT c3po, r2d2 FROM covid19 WHERE n1h1=1234",
+ "secrets": ["1234"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#numbers_in_identifiers"
+ },
+ {
+ "id": "otel_dotnet.json.insert_into",
+ "dialect": "CONSERVATIVE",
+ "input": "INSERT INTO X VALUES(1, 23456, 123.456, 99+100)",
+ "secrets": ["23456"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#insert_into"
+ },
+ {
+ "id": "otel_dotnet.json.uuid",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT { guid '01234567-89ab-cdef-0123-456789abcdef' }",
+ "secrets": ["01234567-89ab"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#uuid"
+ },
+ {
+ "id": "otel_dotnet.json.comments",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT column -- end of line comment\nFROM /* block \n comment */ table",
+ "secrets": ["end of line", "block \n comment"],
+ "source": "otel-dotnet:SqlProcessorTestCases.json#comments"
+ },
+ {
+ "id": "otel_dotnet.line_comment_crlf.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM table -- comment\r\nWHERE id = 42",
+ "secrets": ["comment"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_SingleLineCommentWithCarriageReturnLineFeed_PreservesLineBreak"
+ },
+ {
+ "id": "otel_dotnet.unterminated_bracket.01",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM [Orders WHERE CustomerName = 'secret-name' AND Id = 123 AND Token = 0xDEADBEEF",
+ "secrets": ["secret-name", "DEADBEEF"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedEscapedIdentifierInFromClause_SanitizesLiterals"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN ('a)b', 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[1]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.02",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN ('a)b', 'secret-name', 'another)one')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[2]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.03",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN ('O''Brien)', 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[3]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.04",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN ('))', 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[4]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.05",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN (1 /* don't */, 'a)b', 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[5]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.06",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN (1 /* ) */, 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[6]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.07",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN (1, -- don't )\n'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[7]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.08",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', $$b)c$$, $$secret-name$$, 'd')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[8]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.09",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', $tag$b)c$tag$, 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[9]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.10",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', E'b\\')c', 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[10]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.11",
+ "dialect": "oracle",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', q'[it's)]', 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[11]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.12",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', /* /* ) */ ) */ 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[12]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.13",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', [b)c], 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[13]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.14",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', \"b)c\", 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[14]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren.15",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', `b)c`, 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParen_SanitizesAllLiterals[15]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren_backslash.01",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name IN ('carol@example.com', \"Fabrikam (UK)\", \"alice@example.com\", \"x\", \"secret-name\")",
+ "secrets": ["secret-name", "carol@example.com", "alice@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParenWithBackslashDialect_SanitizesAllLiterals[1]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren_backslash.01.control",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name IN ('carol@example.com', 'Fabrikam (UK)', 'alice@example.com', 'x', 'secret-name')",
+ "secrets": ["secret-name", "carol@example.com", "alice@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParenWithBackslashDialect_SanitizesAllLiterals[1]/control"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren_backslash.02",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', \"b\\\")c\", 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParenWithBackslashDialect_SanitizesAllLiterals[2]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren_backslash.02.control",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name IN ('a', 'b\\')c', 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParenWithBackslashDialect_SanitizesAllLiterals[2]/control"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren_backslash.03",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name IN (1, 2 # don't )\n, 'secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralOrCommentContainingCloseParenWithBackslashDialect_SanitizesAllLiterals[3]"
+ },
+ {
+ "id": "otel_dotnet.unterminated_in_clause_identifier.01",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM Users WHERE Id IN (1, [Manager's Approval] = 'secret-name' AND Name = [",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedInClause_QuotedIdentifiersInItAreStillParsedAsIdentifiers[1]"
+ },
+ {
+ "id": "otel_dotnet.unterminated_in_clause_identifier.02",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM Users WHERE Id IN (1, \"Manager's Approval\" = 'secret-name' AND Name = \"",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedInClause_QuotedIdentifiersInItAreStillParsedAsIdentifiers[2]"
+ },
+ {
+ "id": "otel_dotnet.unterminated_in_clause_identifier.03",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Id IN (1, `Manager's Approval` = 'secret-name' AND Name = `",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedInClause_QuotedIdentifiersInItAreStillParsedAsIdentifiers[3]"
+ },
+ {
+ "id": "otel_dotnet.in_clause_close_paren_personal_data.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT Id FROM Users WHERE Email IN ('x)', 'user@example.com')",
+ "secrets": ["user@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_InClauseLiteralContainingCloseParen_DoesNotLeakPersonalData"
+ },
+ {
+ "id": "otel_dotnet.unterminated_in_clause_close_paren.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN ('a)b', 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedInClauseLiteralContainingCloseParen_SanitizesAllLiterals"
+ },
+ {
+ "id": "otel_dotnet.backslash_quote_backslash_dialect.01",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Password = 'a\\'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BackslashEscapedQuoteWithBackslashDialect_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.backslash_quote_in_clause_backslash_dialect.01",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name IN ('a\\'secret-name', 'b')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BackslashEscapedQuoteInInClauseWithBackslashDialect_SanitizesLiterals"
+ },
+ {
+ "id": "otel_dotnet.doubled_quote.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Password = 'a''secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubledQuoteEscape_SanitizesLiteralInEitherDialect[1]"
+ },
+ {
+ "id": "otel_dotnet.doubled_quote.02",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Password = 'a''secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubledQuoteEscape_SanitizesLiteralInEitherDialect[2]"
+ },
+ {
+ "id": "otel_dotnet.backslash_before_doubled_quote.01",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM Users WHERE Password = 'a\\''secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BackslashBeforeDoubledQuoteWithoutBackslashDialect_DoesNotLeak"
+ },
+ {
+ "id": "otel_dotnet.dollar_quoted.01",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE c = $$secret-name$$",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DollarQuotedString_SanitizesLiteral[1]"
+ },
+ {
+ "id": "otel_dotnet.dollar_quoted.02",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE c = $tag$se'cret-'name$tag$",
+ "secrets": ["se'cret-'name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DollarQuotedString_SanitizesLiteral[2]"
+ },
+ {
+ "id": "otel_dotnet.unterminated_dollar.01",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE c = $$secret-name",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedDollarQuotedString_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.double_quoted_backslash_dialect.01",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name = \"secret-value\" AND Id = 1",
+ "secrets": ["secret-value"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubleQuotedStringWithBackslashDialect_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.doubled_double_quote_backslash_dialect.01",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name = \"a\"\"secret-value\"",
+ "secrets": ["secret-value"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubledDoubleQuoteEscapeWithBackslashDialect_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.backslash_double_quote_backslash_dialect.01",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name = \"a\\\"secret-value\"",
+ "secrets": ["secret-value"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BackslashEscapedDoubleQuoteWithBackslashDialect_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.unterminated_double_quote_backslash_dialect.01",
+ "dialect": "mysql",
+ "input": "SELECT * FROM Users WHERE Name = \"secret-value",
+ "secrets": ["secret-value"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedDoubleQuotedStringWithBackslashDialect_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.unterminated_in_clause_literal.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Users WHERE Name IN ('secret-name",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedInClauseStringLiteral_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier.01",
+ "dialect": "sqlserver",
+ "input": "SELECT [a].[Id], [a].[Nom de l'enterprise], [a].[Token] FROM [Accounts] AS [a] WHERE [a].[Token] = N'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_SanitizesLiterals[1]"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier.01.control",
+ "dialect": "sqlserver",
+ "input": "SELECT [a].[Id], [a].[NomEnterprise], [a].[Token] FROM [Accounts] AS [a] WHERE [a].[Token] = N'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_SanitizesLiterals[1]/control"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier.02",
+ "dialect": "postgresql",
+ "input": "SELECT \"a\".\"Id\", \"a\".\"Nom de l'enterprise\", \"a\".\"Token\" FROM \"Accounts\" AS \"a\" WHERE \"a\".\"Token\" = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_SanitizesLiterals[2]"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier.02.control",
+ "dialect": "postgresql",
+ "input": "SELECT \"a\".\"Id\", \"a\".\"NomEnterprise\", \"a\".\"Token\" FROM \"Accounts\" AS \"a\" WHERE \"a\".\"Token\" = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_SanitizesLiterals[2]/control"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier.03",
+ "dialect": "mysql",
+ "input": "SELECT `a`.`Id`, `a`.`Nom de l'enterprise`, `a`.`Token` FROM `Accounts` AS `a` WHERE `a`.`Token` = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_SanitizesLiterals[3]"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier.03.control",
+ "dialect": "mysql",
+ "input": "SELECT `a`.`Id`, `a`.`NomEnterprise`, `a`.`Token` FROM `Accounts` AS `a` WHERE `a`.`Token` = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_SanitizesLiterals[3]/control"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier.04",
+ "dialect": "sqlserver",
+ "input": "SELECT [a].[Nom de l'enterprise] FROM [Accounts] AS [a] WHERE [a].[Token] = N'secret-name' AND [a].[Nom de l'enterprise] = N'Contoso'",
+ "secrets": ["secret-name", "Contoso"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_SanitizesLiterals[4]"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier.04.control",
+ "dialect": "sqlserver",
+ "input": "SELECT [a].[NomEnterprise] FROM [Accounts] AS [a] WHERE [a].[Token] = N'secret-name' AND [a].[NomEnterprise] = N'Contoso'",
+ "secrets": ["secret-name", "Contoso"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_SanitizesLiterals[4]/control"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier_summary.01",
+ "dialect": "sqlserver",
+ "input": "SELECT [a].[Nom de l'enterprise] FROM [Accounts] AS [a] WHERE [a].[Note] = N'Transfer from Contoso4471 approved'",
+ "secrets": ["Contoso4471"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_DoesNotChangeQuerySummary"
+ },
+ {
+ "id": "otel_dotnet.quote_in_quoted_identifier_summary.01.control",
+ "dialect": "sqlserver",
+ "input": "SELECT [a].[NomEnterprise] FROM [Accounts] AS [a] WHERE [a].[Note] = N'Transfer from Contoso4471 approved'",
+ "secrets": ["Contoso4471"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_QuoteInQuotedIdentifier_DoesNotChangeQuerySummary/control"
+ },
+ {
+ "id": "otel_dotnet.array_in_from.01",
+ "dialect": "postgresql",
+ "input": "INSERT INTO audit_recipients (email) SELECT e FROM unnest(ARRAY['alice@example.com', 'bob@example.com', 'carol@example.com']) AS t(e)",
+ "secrets": ["alice@example.com", "bob@example.com", "carol@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_ArrayInFromClause_SanitizesLiteralsInSqlAndSummary[1]"
+ },
+ {
+ "id": "otel_dotnet.array_in_from.02",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM unnest(ARRAY ['alice@example.com', 'bob@example.com'])",
+ "secrets": ["alice@example.com", "bob@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_ArrayInFromClause_SanitizesLiteralsInSqlAndSummary[2]"
+ },
+ {
+ "id": "otel_dotnet.array_in_from.03",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM UNNEST(['alice@example.com', 'bob@example.com'])",
+ "secrets": ["alice@example.com", "bob@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_ArrayInFromClause_SanitizesLiteralsInSqlAndSummary[3]"
+ },
+ {
+ "id": "otel_dotnet.array_in_from.04",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM UNNEST([12345, 67890])",
+ "secrets": ["12345", "67890"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_ArrayInFromClause_SanitizesLiteralsInSqlAndSummary[4]"
+ },
+ {
+ "id": "otel_dotnet.array_in_from.05",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM UNNEST([Email, 'alice@example.com'])",
+ "secrets": ["alice@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_ArrayInFromClause_SanitizesLiteralsInSqlAndSummary[5]"
+ },
+ {
+ "id": "otel_dotnet.array_in_from.06",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM UNNEST(['alice]@example.com', 'bob@example.com'])",
+ "secrets": ["bob@example.com", "alice]@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_ArrayInFromClause_SanitizesLiteralsInSqlAndSummary[6]"
+ },
+ {
+ "id": "otel_dotnet.bracket_identifier_and_array.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT [Manager's Approval] FROM [Requests] WHERE [Tags] = ARRAY['secret-name'] AND [Owner] = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketedIdentifierAndArray_SanitizesOnlyLiterals[1]"
+ },
+ {
+ "id": "otel_dotnet.bracket_identifier_and_array.02",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM Requests WHERE [Owner] >[Manager's Approval] AND [Owner] = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketedIdentifierAndArray_SanitizesOnlyLiterals[2]"
+ },
+ {
+ "id": "otel_dotnet.bracket_identifier_and_array.03",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM [1st Manager's Requests] WHERE [Owner] = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketedIdentifierAndArray_SanitizesOnlyLiterals[3]"
+ },
+ {
+ "id": "otel_dotnet.bracket_after_expression.01",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE Tags = ARRAY[E'it\\'s', 'secret-name']",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketAfterExpressionOrKeyword_IsParsedAccordingToItsContext[1]"
+ },
+ {
+ "id": "otel_dotnet.bracket_after_expression.02",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM t WHERE Tags = ARRAY [E'it\\'s', 'secret-name']",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketAfterExpressionOrKeyword_IsParsedAccordingToItsContext[2]"
+ },
+ {
+ "id": "otel_dotnet.bracket_after_expression.03",
+ "dialect": "postgresql",
+ "input": "SELECT Tags[E'secret-name\\''] FROM t",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketAfterExpressionOrKeyword_IsParsedAccordingToItsContext[3]"
+ },
+ {
+ "id": "otel_dotnet.bracket_after_expression.04",
+ "dialect": "postgresql",
+ "input": "SELECT (Tags)[E'secret-name\\''] FROM t",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketAfterExpressionOrKeyword_IsParsedAccordingToItsContext[4]"
+ },
+ {
+ "id": "otel_dotnet.bracket_after_expression.05",
+ "dialect": "postgresql",
+ "input": "SELECT Tags[1][E'secret-name\\''] FROM t",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketAfterExpressionOrKeyword_IsParsedAccordingToItsContext[5]"
+ },
+ {
+ "id": "otel_dotnet.bracket_after_expression.06",
+ "dialect": "postgresql",
+ "input": "SELECT \"Tags\"[E'secret-name\\''] FROM t",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketAfterExpressionOrKeyword_IsParsedAccordingToItsContext[6]"
+ },
+ {
+ "id": "otel_dotnet.bracket_after_expression.07",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM[O'Brien] WHERE [Owner] = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_BracketAfterExpressionOrKeyword_IsParsedAccordingToItsContext[7]"
+ },
+ {
+ "id": "otel_dotnet.double_quoted_number.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE c = \"12345\"",
+ "secrets": ["12345"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubleQuotedValueStartingWithNumber_IsSanitized[1]"
+ },
+ {
+ "id": "otel_dotnet.double_quoted_number.02",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE c = \"078-05-1120\" AND d = 'secret-name'",
+ "secrets": ["078-05-1120", "secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubleQuotedValueStartingWithNumber_IsSanitized[2]"
+ },
+ {
+ "id": "otel_dotnet.double_quoted_number.03",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM t WHERE c = \" +44 20 7946 0958\"",
+ "secrets": ["7946 0958"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubleQuotedValueStartingWithNumber_IsSanitized[3]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.01",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM users WHERE nickname = E'it\\'s me' AND api_key = 'secret-name'",
+ "secrets": ["secret"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[1]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.02",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM users WHERE nickname = e'it\\\\\\'s me' AND api_key = 'secret-name'",
+ "secrets": ["secret"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[2]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.03",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE nickname = q'[it's me]' AND api_key = 'secret-name'",
+ "secrets": ["secret", "it's me"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[3]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.04",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE nickname = Q'{it's me}' AND api_key = 'secret-name'",
+ "secrets": ["secret", "it's me"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[4]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.05",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE nickname = q'(it's me)' AND api_key = 'secret-name'",
+ "secrets": ["secret", "it's me"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[5]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.06",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE nickname = q'' AND api_key = 'secret-name'",
+ "secrets": ["secret", "it's me"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[6]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.07",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE nickname = q'!it's me!' AND api_key = 'secret-name'",
+ "secrets": ["secret", "it's me"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[7]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.08",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE nickname = nq'[it's me]' AND api_key = 'secret-name'",
+ "secrets": ["secret", "it's me"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[8]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.09",
+ "dialect": "oracle",
+ "input": "SELECT * FROM users WHERE nickname = q'[it's me' AND api_key = 'secret-name'",
+ "secrets": ["secret", "it's me"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[9]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.10",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM users /* disabled: /* old */ don't use */ WHERE api_key = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[10]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.11",
+ "dialect": "postgresql",
+ "input": "SELECT * FROM users /* disabled: /* old */ don't use WHERE api_key = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[11]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment.12",
+ "dialect": "mysql",
+ "input": "SELECT * FROM users # don't cache\nWHERE api_key = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_SanitizesFollowingLiteral[12]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment_where_valid.01",
+ "dialect": "sqlserver",
+ "input": "SELECT * FROM #users WHERE api_key = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_IsOnlyRecognizedWhereValid[1]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment_where_valid.02",
+ "dialect": "mysql",
+ "input": "SELECT * FROM users /* a /* b */ WHERE api_key = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_IsOnlyRecognizedWhereValid[2]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment_where_valid.03",
+ "dialect": "sqlserver",
+ "input": "SELECT CASE WHEN x = 1 THEN 'a' ELSE'b\\' END FROM users WHERE api_key = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_IsOnlyRecognizedWhereValid[3]"
+ },
+ {
+ "id": "otel_dotnet.dialect_literal_or_comment_where_valid.04",
+ "dialect": "sqlserver",
+ "input": "SELECT e, q FROM users WHERE e = 'a\\' AND q = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DialectSpecificLiteralOrComment_IsOnlyRecognizedWhereValid[4]"
+ },
+ {
+ "id": "otel_dotnet.login_or_user_name.01",
+ "dialect": "sqlserver",
+ "input": "CREATE LOGIN [CONTOSO\\alice.smith] FROM WINDOWS",
+ "secrets": ["CONTOSO", "alice.smith"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[1]"
+ },
+ {
+ "id": "otel_dotnet.login_or_user_name.02",
+ "dialect": "sqlserver",
+ "input": "CREATE USER [Alice Smith] WITH PASSWORD = 'Pa55w0rd!'",
+ "secrets": ["Alice Smith", "Pa55w0rd!"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[2]"
+ },
+ {
+ "id": "otel_dotnet.login_or_user_name.03",
+ "dialect": "sqlserver",
+ "input": "CREATE USER [svc-payments] WITH PASSWORD = 'Pa55w0rd!'",
+ "secrets": ["svc-payments", "Pa55w0rd!"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[3]"
+ },
+ {
+ "id": "otel_dotnet.login_or_user_name.04",
+ "dialect": "sqlserver",
+ "input": "CREATE USER [alice@contoso.com] FROM EXTERNAL PROVIDER",
+ "secrets": ["alice@contoso.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[4]"
+ },
+ {
+ "id": "otel_dotnet.login_or_user_name.05",
+ "dialect": "sqlserver",
+ "input": "CREATE USER [alice]]smith] WITHOUT LOGIN",
+ "secrets": ["alice]]smith"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[5]"
+ },
+ {
+ "id": "otel_dotnet.login_or_user_name.06",
+ "dialect": "sqlserver",
+ "input": "DROP USER IF EXISTS [Alice Smith]",
+ "secrets": ["Alice Smith"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[6]"
+ },
+ {
+ "id": "otel_dotnet.login_or_user_name.07",
+ "dialect": "sqlserver",
+ "input": "ALTER LOGIN \"Alice Smith\" DISABLE",
+ "secrets": ["Alice Smith"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[7]"
+ },
+ {
+ "id": "otel_dotnet.login_or_user_name.08",
+ "dialect": "sqlserver",
+ "input": "CREATE LOGIN alice WITH PASSWORD = 'Pa55w0rd!'",
+ "secrets": ["Pa55w0rd!"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[8]"
+ },
+ {
+ "id": "otel_dotnet.login_escaped_brackets_max_length.01",
+ "dialect": "sqlserver",
+ "input": "CREATE USER [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]]] WITHOUT LOGIN",
+ "secrets": ["aaaaaaaaaa]]"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserNameWithEscapedBracketsAtMaximumLength_IsSanitized[1]"
+ },
+ {
+ "id": "otel_dotnet.login_escaped_brackets_max_length.02",
+ "dialect": "sqlserver",
+ "input": "CREATE USER [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] WITHOUT LOGIN",
+ "secrets": ["]]]]]]]]]]]]"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserNameWithEscapedBracketsAtMaximumLength_IsSanitized[2]"
+ },
+ {
+ "id": "otel_dotnet.login_escaped_brackets_max_length.03",
+ "dialect": "sqlserver",
+ "input": "CREATE USER []]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] WITHOUT LOGIN",
+ "secrets": ["]]]]]]]]]]]]"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserNameWithEscapedBracketsAtMaximumLength_IsSanitized[3]"
+ },
+ {
+ "id": "otel_dotnet.string_after_summary_limit.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE Password='secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_StringLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[1]"
+ },
+ {
+ "id": "otel_dotnet.string_after_summary_limit.02",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE Password=N'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_StringLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[2]"
+ },
+ {
+ "id": "otel_dotnet.string_after_summary_limit.03",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE Password = 'secret-name'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_StringLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[3]"
+ },
+ {
+ "id": "otel_dotnet.string_after_summary_limit.04",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE Email IN ('secret-name','other')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_StringLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[4]"
+ },
+ {
+ "id": "otel_dotnet.string_after_summary_limit.05",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE Email LIKE'%secret-name%'",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_StringLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[5]"
+ },
+ {
+ "id": "otel_dotnet.string_after_summary_limit.06",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT INSERT INTO Credentials (User, Password) VALUES ('admin','secret-name')",
+ "secrets": ["secret-name"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_StringLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[6]"
+ },
+ {
+ "id": "otel_dotnet.number_after_summary_limit.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE SocialSecurityNumber=123456789",
+ "secrets": ["123456789"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_NumericOrHexLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[1]"
+ },
+ {
+ "id": "otel_dotnet.number_after_summary_limit.02",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE SocialSecurityNumber = 123456789",
+ "secrets": ["123456789"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_NumericOrHexLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[2]"
+ },
+ {
+ "id": "otel_dotnet.number_after_summary_limit.03",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE ApiToken=0xDEADBEEF",
+ "secrets": ["DEADBEEF"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_NumericOrHexLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[3]"
+ },
+ {
+ "id": "otel_dotnet.number_after_summary_limit.04",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE ApiToken = 0xDEADBEEF",
+ "secrets": ["DEADBEEF"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_NumericOrHexLiteralAfterSummaryLengthLimitReached_SanitizesLiteral[4]"
+ },
+ {
+ "id": "otel_dotnet.many_joins_summary_limit.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT o.OrderId, c.Email FROM Orders AS o INNER JOIN CustomerOrderDetails0 AS d0 ON d0.OrderId = o.OrderId INNER JOIN CustomerOrderDetails1 AS d1 ON d1.OrderId = o.OrderId INNER JOIN CustomerOrderDetails2 AS d2 ON d2.OrderId = o.OrderId INNER JOIN CustomerOrderDetails3 AS d3 ON d3.OrderId = o.OrderId INNER JOIN CustomerOrderDetails4 AS d4 ON d4.OrderId = o.OrderId INNER JOIN CustomerOrderDetails5 AS d5 ON d5.OrderId = o.OrderId INNER JOIN CustomerOrderDetails6 AS d6 ON d6.OrderId = o.OrderId INNER JOIN CustomerOrderDetails7 AS d7 ON d7.OrderId = o.OrderId INNER JOIN CustomerOrderDetails8 AS d8 ON d8.OrderId = o.OrderId INNER JOIN CustomerOrderDetails9 AS d9 ON d9.OrderId = o.OrderId INNER JOIN CustomerOrderDetails10 AS d10 ON d10.OrderId = o.OrderId INNER JOIN CustomerOrderDetails11 AS d11 ON d11.OrderId = o.OrderId WHERE c.Email='user@example.com'",
+ "secrets": ["user@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_ManyJoinsExceedingSummaryLengthLimit_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.many_tables_summary_limit.01",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM CustomerOrderDetails0,CustomerOrderDetails1,CustomerOrderDetails2,CustomerOrderDetails3,CustomerOrderDetails4,CustomerOrderDetails5,CustomerOrderDetails6,CustomerOrderDetails7,CustomerOrderDetails8,CustomerOrderDetails9,CustomerOrderDetails10,CustomerOrderDetails11 WHERE Email='user@example.com'",
+ "secrets": ["user@example.com"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_ManyTablesExceedingSummaryLengthLimit_SanitizesLiteral"
+ },
+ {
+ "id": "otel_dotnet.summary_limit_text_unchanged.01.short",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM Orders WHERE Password='secret-name' AND Id=123 AND Token=0xDEADBEEF",
+ "secrets": ["secret-name", "DEADBEEF"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_SummaryLengthLimitReached_DoesNotChangeSanitizedSql/short"
+ },
+ {
+ "id": "otel_dotnet.summary_limit_text_unchanged.01.long",
+ "dialect": "CONSERVATIVE",
+ "input": "SELECT * FROM TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT WHERE Password='secret-name' AND Id=123 AND Token=0xDEADBEEF",
+ "secrets": ["secret-name", "DEADBEEF"],
+ "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_SummaryLengthLimitReached_DoesNotChangeSanitizedSql/long"
+ }
+ ]
+}
diff --git a/sentry/src/test/resources/sql/known-leaks.txt b/sentry/src/test/resources/sql/known-leaks.txt
new file mode 100644
index 00000000000..a493a2d3d74
--- /dev/null
+++ b/sentry/src/test/resources/sql/known-leaks.txt
@@ -0,0 +1,134 @@
+# Corpus cases (sql/analyzer-cases.json) whose declared secret appears in the output of the
+# unchanged OpenTelemetry grammar: accepted leaks, to be fixed upstream. Checked by
+# SqlQueryAnalyzerKnownLeakTest, which reports cases that no longer leak after a sync.
+bracket.array_literal.conservative
+bracket.array_literal.postgresql
+bracket.subscript_string.conservative
+bracket.subscript_string.postgresql
+comment.block
+comment.block.after_star.postgresql
+comment.block.no_space
+comment.dash_dash.after_number.mysql
+comment.dash_dash.after_number.postgresql
+comment.dash_dash.after_number.sqlite
+comment.dash_dash.bare_cr.sqlite
+comment.dash_dash.bare_cr_empty.sqlite
+comment.dash_dash.before_comment.mysql
+comment.dash_dash.cr_at_end.sqlite
+comment.dash_dash.crlf.sqlite
+comment.dash_dash.sign_prefix.postgresql
+comment.double_slash.after_star.h2
+comment.double_slash.bare_cr.h2
+comment.double_slash.conservative
+comment.double_slash.h2
+comment.end_without_newline
+comment.hash.bare_cr.mysql
+comment.hash.bare_cr_empty.mysql
+comment.hash.crlf.mysql
+comment.hash.mariadb
+comment.hash.mysql
+comment.leading
+comment.line
+comment.mysql_executable
+comment.optimizer_hint
+credentials.alter_user_replace.oracle
+credentials.config_value.alter_session.oracle
+credentials.config_value.alter_system.postgresql
+credentials.config_value.attach_key.sqlite
+credentials.config_value.multi_statement.postgresql
+credentials.config_value.pragma_key.sqlite
+credentials.config_value.pragma_key_call.sqlite
+credentials.config_value.pragma_schema_key.sqlite
+credentials.config_value.set_custom.postgresql
+credentials.config_value.set_list.mysql
+credentials.config_value.set_local_to.postgresql
+credentials.config_value.set_session_authorization.postgresql
+credentials.connect_not_allowlisted
+credentials.create_login.sqlserver
+credentials.create_login_password.sqlserver
+credentials.create_role
+credentials.create_user.oracle
+credentials.create_user.postgresql
+credentials.drop_user_if_exists.postgresql
+credentials.grant_grantees
+credentials.identified_by.comment_between.oracle
+credentials.identified_by.set_role.oracle
+credentials.reduction_ends_at_statement_end.postgresql
+credentials.revoke_grantee
+credentials.unquoted_password
+credentials.unterminated_in_reduced_part.postgresql
+dialect.brackets.escaped_close.conservative
+dialect.brackets.escaped_close.sqlserver
+dialect.brackets.escaped_close_dotted.sqlserver
+dialect.brackets.unterminated_after_literal.mysql
+dialect.double_quotes.unknown_target_after_quoted_names.sqlite
+literal.dollar.inside_identifier.h2
+literal.dollar.mysql
+literal.dollar_tag.h2
+literal.dollar_tag.inside_identifier.postgresql
+literal.q_quote.after_dot.conservative
+literal.q_quote.after_dot.oracle
+literal.q_quote.after_number.oracle
+literal.q_quote.conservative
+literal.q_quote.delimiters.oracle
+literal.q_quote.oracle
+literal.q_quote.other_closer_inside.oracle
+literal.q_quote.other_delimiter.oracle
+literal.q_quote.paired_inner_quotes.conservative
+literal.q_quote.paired_inner_quotes.oracle
+malformed.unterminated.backtick.mysql
+malformed.unterminated.block_comment
+malformed.unterminated.double_quote.postgresql
+malformed.unterminated.single_quote
+otel_dotnet.array_in_from.01
+otel_dotnet.array_in_from.02
+otel_dotnet.array_in_from.03
+otel_dotnet.array_in_from.04
+otel_dotnet.array_in_from.05
+otel_dotnet.array_in_from.06
+otel_dotnet.bracket_after_expression.01
+otel_dotnet.bracket_after_expression.02
+otel_dotnet.bracket_after_expression.03
+otel_dotnet.bracket_after_expression.04
+otel_dotnet.bracket_after_expression.05
+otel_dotnet.bracket_after_expression.06
+otel_dotnet.bracket_identifier_and_array.01
+otel_dotnet.dialect_literal_or_comment.03
+otel_dotnet.dialect_literal_or_comment.04
+otel_dotnet.dialect_literal_or_comment.05
+otel_dotnet.dialect_literal_or_comment.06
+otel_dotnet.dialect_literal_or_comment.07
+otel_dotnet.dialect_literal_or_comment.08
+otel_dotnet.dialect_literal_or_comment.09
+otel_dotnet.dialect_literal_or_comment.12
+otel_dotnet.in_clause_close_paren.11
+otel_dotnet.in_clause_close_paren_backslash.03
+otel_dotnet.json.comments
+otel_dotnet.line_comment_crlf.01
+otel_dotnet.login_escaped_brackets_max_length.01
+otel_dotnet.login_escaped_brackets_max_length.02
+otel_dotnet.login_escaped_brackets_max_length.03
+otel_dotnet.login_or_user_name.01
+otel_dotnet.login_or_user_name.02
+otel_dotnet.login_or_user_name.03
+otel_dotnet.login_or_user_name.04
+otel_dotnet.login_or_user_name.05
+otel_dotnet.login_or_user_name.06
+otel_dotnet.unterminated_dollar.01
+otel_dotnet.unterminated_double_quote_backslash_dialect.01
+otel_dotnet.unterminated_in_clause_literal.01
+otel_java.sanitize_sensitive.001
+otel_java.sanitize_sensitive.011
+otel_java.sanitize_sensitive.012
+otel_java.simplify_sql.123
+otel_java.simplify_sql.125
+otel_java.vendor_specific_syntax.008
+unrecognized.after_semicolon
+unrecognized.after_semicolon.backtick_name.mysql
+unrecognized.after_semicolon.bracket_name.sqlserver
+unrecognized.after_semicolon.double_quoted_name.postgresql
+unrecognized.after_semicolon.inside_subscript.postgresql
+unrecognized.backslash_outside_literal
+unrecognized.command
+unrecognized.sentence
+unrecognized.symbol