From af5f11f240a509d7123f6490fe3698cd146fd8da Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Thu, 26 Nov 2026 17:23:01 +0100 Subject: [PATCH 1/4] feat(sql): Vendor OpenTelemetry's SQL grammar as the SQL query analyzer --- .github/workflows/check-vendored-otel-sql.yml | 29 + THIRD_PARTY_NOTICES.md | 92 + gradle/libs.versions.toml | 2 + scripts/sync-otel-sql.sh | 252 + sentry/api/sentry.api | 57 + sentry/build.gradle.kts | 53 +- .../java/io/sentry/SpanDataConvention.java | 5 + .../java/io/sentry/util/sql/SqlQuery.java | 47 + .../io/sentry/util/sql/SqlQueryAnalyzer.java | 82 + .../java/io/sentry/util/sql/SqlSpanData.java | 103 + .../vendor/otel/sql/AutoValue_SqlDialect.java | 43 + .../vendor/otel/sql/AutoValue_SqlQuery.java | 55 + .../vendor/otel/sql/OtelSqlSanitizer.java | 23 + .../io/sentry/vendor/otel/sql/SqlDialect.java | 128 + .../vendor/otel/sql/SqlLexerException.java | 17 + .../io/sentry/vendor/otel/sql/SqlQuery.java | 103 + .../sentry/vendor/otel/sql/StringUtils.java | 75 + .../java/io/sentry/vendor/otel/sql/UPSTREAM | 7 + sentry/src/main/jflex/SqlSanitizer.jflex | 1456 +++++ .../io/sentry/util/sql/SqlAnalyzerHarness.kt | 239 + .../util/sql/SqlQueryAnalyzerCorpusTest.kt | 44 + .../util/sql/SqlQueryAnalyzerFuzzTest.kt | 254 + .../util/sql/SqlQueryAnalyzerKnownLeakTest.kt | 58 + .../sql/SqlQueryAnalyzerPathologicalTest.kt | 118 + .../sentry/util/sql/SqlQueryAnalyzerTest.kt | 116 + .../io/sentry/util/sql/SqlSpanDataTest.kt | 156 + .../test/resources/sql/analyzer-cases.json | 5720 +++++++++++++++++ sentry/src/test/resources/sql/known-leaks.txt | 136 + 28 files changed, 9469 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-vendored-otel-sql.yml create mode 100755 scripts/sync-otel-sql.sh create mode 100644 sentry/src/main/java/io/sentry/util/sql/SqlQuery.java create mode 100644 sentry/src/main/java/io/sentry/util/sql/SqlQueryAnalyzer.java create mode 100644 sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java create mode 100644 sentry/src/main/java/io/sentry/vendor/otel/sql/AutoValue_SqlDialect.java create mode 100644 sentry/src/main/java/io/sentry/vendor/otel/sql/AutoValue_SqlQuery.java create mode 100644 sentry/src/main/java/io/sentry/vendor/otel/sql/OtelSqlSanitizer.java create mode 100644 sentry/src/main/java/io/sentry/vendor/otel/sql/SqlDialect.java create mode 100644 sentry/src/main/java/io/sentry/vendor/otel/sql/SqlLexerException.java create mode 100644 sentry/src/main/java/io/sentry/vendor/otel/sql/SqlQuery.java create mode 100644 sentry/src/main/java/io/sentry/vendor/otel/sql/StringUtils.java create mode 100644 sentry/src/main/java/io/sentry/vendor/otel/sql/UPSTREAM create mode 100644 sentry/src/main/jflex/SqlSanitizer.jflex create mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlAnalyzerHarness.kt create mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerCorpusTest.kt create mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt create mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt create mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt create mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt create mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt create mode 100644 sentry/src/test/resources/sql/analyzer-cases.json create mode 100644 sentry/src/test/resources/sql/known-leaks.txt diff --git a/.github/workflows/check-vendored-otel-sql.yml b/.github/workflows/check-vendored-otel-sql.yml new file mode 100644 index 00000000000..c9a11de8fd9 --- /dev/null +++ b/.github/workflows/check-vendored-otel-sql.yml @@ -0,0 +1,29 @@ +name: 'Check vendored OpenTelemetry SQL grammar' +on: + pull_request: + paths: + - 'scripts/sync-otel-sql.sh' + - 'sentry/src/main/jflex/**' + - 'sentry/src/main/java/io/sentry/vendor/otel/sql/**' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + + # Re-derives the vendored files from upstream at the recorded commit; fails on any hand edit. + - name: Compare vendored files with upstream + run: ./scripts/sync-otel-sql.sh --check diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 62d80f721b5..448019e0e56 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -447,6 +447,98 @@ limitations under the License. --- +## OpenTelemetry Java Instrumentation — SQL grammar (Apache 2.0) + +**Source:** https://github.com/open-telemetry/opentelemetry-java-instrumentation (Commit: 979e8684e783f1a710955341924bdddeff6e83f2)
+**License:** Apache License 2.0
+**Copyright:** Copyright The OpenTelemetry Authors + +### Scope + +The Sentry Java SDK's SQL query analyzer uses OpenTelemetry Java Instrumentation's SQL grammar and the three classes it depends on, vendored by `scripts/sync-otel-sql.sh` at the commit recorded in `sentry/src/main/java/io/sentry/vendor/otel/sql/UPSTREAM`. The script changes only package, imports and annotations; the grammar rules are unchanged: + +- `sentry/src/main/jflex/SqlSanitizer.jflex` is adapted from `instrumentation-api-incubator/src/main/jflex/SqlSanitizer.jflex`. +- `io.sentry.vendor.otel.sql.AutoSqlSanitizer` is generated from that grammar at build time and is included in the published `sentry` artifact. It contains the JFlex skeleton, which is licensed under CC0-1.0; JFlex itself is a build-time tool and is not distributed. +- `io.sentry.vendor.otel.sql.SqlQuery` and `io.sentry.vendor.otel.sql.SqlDialect` are adapted from `instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuery.java` and `SqlDialect.java`. +- `io.sentry.vendor.otel.sql.StringUtils` is adapted from `instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/StringUtils.java`. + +``` +Copyright The OpenTelemetry Authors +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` + +--- + +## OpenTelemetry Java Instrumentation — SQL analyzer tests (Apache 2.0) + +**Source:** https://github.com/open-telemetry/opentelemetry-java-instrumentation (Commit: 2acd9a5f1153e725a3b80e9b90ad55b385576fe8)
+**License:** Apache License 2.0
+**Copyright:** Copyright The OpenTelemetry Authors + +### Scope + +The Sentry Java SDK's SQL analyzer test suite includes test inputs adapted from the SQL analyzer tests in `instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/`. The adapted inputs reside in `sentry/src/test/resources/sql/analyzer-cases.json` (cases whose `source` starts with `otel-java:`), `sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt` and `sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt`. These are test sources and are not part of the published artifacts. + +``` +Copyright The OpenTelemetry Authors +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` + +--- + +## OpenTelemetry .NET Contrib — SQL processor tests (Apache 2.0) + +**Source:** https://github.com/open-telemetry/opentelemetry-dotnet-contrib (Commit: 4e3aba9ddf89f9accac004f44f32ebde335dd115)
+**License:** Apache License 2.0
+**Copyright:** Copyright The OpenTelemetry Authors + +### Scope + +The Sentry Java SDK's SQL analyzer test suite includes test inputs adapted from `test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTests.cs` and `test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTestCases.json`. The adapted inputs reside in `sentry/src/test/resources/sql/analyzer-cases.json` (cases whose `source` starts with `otel-dotnet:`) and `sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt`. These are test sources and are not part of the published artifacts. + +``` +Copyright The OpenTelemetry Authors +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` + +--- + ## SalomonBrys — ANR-WatchDog (MIT) **Source:** https://github.com/SalomonBrys/ANR-WatchDog (Commit: 1969075f75f5980e9000eaffbaa13b0daf282dcb)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 12b30895d4c..e622dea3596 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -157,6 +157,8 @@ netflix-dgs-subscriptions-websockets-autoconfigure = { module = "com.netflix.gra jackson-bom = { module = "com.fasterxml.jackson:jackson-bom", version.ref = "jackson" } jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" } jetbrains-annotations = { module = "org.jetbrains:annotations", version = "23.0.0" } +# Build-time only: generates the SQL lexer in :sentry (src/main/jflex). Upstream OpenTelemetry uses 1.9.1. +jflex = { module = "de.jflex:jflex", version = "1.9.1" } kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" } kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } diff --git a/scripts/sync-otel-sql.sh b/scripts/sync-otel-sql.sh new file mode 100755 index 00000000000..03b0d9cd71b --- /dev/null +++ b/scripts/sync-otel-sql.sh @@ -0,0 +1,252 @@ +#!/usr/bin/env bash +# Vendors OpenTelemetry Java's SQL grammar and the three classes it uses into sentry core. +# +# sentry/src/main/jflex/SqlSanitizer.jflex grammar; JFlex generates AutoSqlSanitizer +# sentry/src/main/java/io/sentry/vendor/otel/sql/ SqlQuery, SqlDialect, StringUtils +# sentry/src/main/java/io/sentry/vendor/otel/sql/UPSTREAM repository, commit and paths +# +# Usage: +# scripts/sync-otel-sql.sh vendor the files at (commit, tag or branch), print +# upstream's diff since the recorded commit +# scripts/sync-otel-sql.sh --check re-derive the vendored files from the recorded commit and +# compare them byte for byte (needs network) +# +# Every change to an upstream file is applied here, never by hand. A change whose expected text +# is missing upstream fails the run, so an upstream edit that touches a changed line shows up +# here instead of silently. After a sync, run +# ./gradlew :sentry:test --tests 'io.sentry.util.sql.*' +# Exit status: 0 on success, 1 on a failed check or a missing expected text, 2 on usage or +# download errors. +set -euo pipefail + +repository="open-telemetry/opentelemetry-java-instrumentation" +root="$(git rev-parse --show-toplevel)" +vendor_dir="$root/sentry/src/main/java/io/sentry/vendor/otel/sql" +meta="$vendor_dir/UPSTREAM" + +# Upstream path -> vendored path, relative to the repository roots. +paths=( + "instrumentation-api-incubator/src/main/jflex/SqlSanitizer.jflex" + "instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuery.java" + "instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlDialect.java" + "instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/StringUtils.java" +) +targets=( + "sentry/src/main/jflex/SqlSanitizer.jflex" + "sentry/src/main/java/io/sentry/vendor/otel/sql/SqlQuery.java" + "sentry/src/main/java/io/sentry/vendor/otel/sql/SqlDialect.java" + "sentry/src/main/java/io/sentry/vendor/otel/sql/StringUtils.java" +) + +die() { + echo "error: $*" >&2 + exit 2 +} + +# rewrite : applies the substitution to the whole file; fails if it +# matched nothing. +rewrite() { + perl -e ' + my ($file, $expr, $label) = @ARGV; + local $/; + open(my $in, "<", $file) or die "cannot read $file: $!"; + my $s = <$in>; + close($in); + my $n = eval "\$s =~ $expr"; + die "invalid substitution $expr: $@" if $@; + if (!$n) { + print STDERR "expected text not found in $label: $expr\n"; + exit 1; + } + open(my $out, ">", $file) or die "cannot write $file: $!"; + print $out $s; + close($out); + ' "$1" "$2" "${label:-$1}" || exit 1 +} + +# header : prepends the attribution header (AGENTS.md). +# The upstream license comment stays in place below it. +header() { + local file="$1" path="$2" commit="$3" changes="$4" tmp + tmp="$file.header" + { + echo "// Adapted from OpenTelemetry Java Instrumentation." + echo "// Copyright The OpenTelemetry Authors." + echo "// Licensed under the Apache License, Version 2.0." + echo "// https://github.com/$repository/blob/$commit/$path" + echo "// Changes: $changes" + echo "// Applied by scripts/sync-otel-sql.sh; do not edit this file by hand." + cat "$file" + } >"$tmp" + mv "$tmp" "$file" +} + +java_class_changes() { + local file="$1" from_package="$2" + rewrite "$file" "s/^package \\Q$from_package\\E;\\n/package io.sentry.vendor.otel.sql;\\n\\nimport org.jetbrains.annotations.ApiStatus;\\n/m" + rewrite "$file" 's/^(public (?:final |abstract )?class )/\@ApiStatus.Internal\n$1/m' +} + +remove_auto_value() { + local file="$1" + rewrite "$file" 's/^import com\.google\.auto\.value\.AutoValue;\n//m' + rewrite "$file" 's/^\@AutoValue\n//mg' +} + +jetbrains_nullable() { + rewrite "$1" 's/^import javax\.annotation\.Nullable;$/import org.jetbrains.annotations.Nullable;/m' +} + +string_utils_import() { + rewrite "$1" 's/\bio\.opentelemetry\.instrumentation\.api\.internal\.StringUtils\b/io.sentry.vendor.otel.sql.StringUtils/g' +} + +# transform : applies every change for upstream file to . +transform() { + local index="$1" file="$2" commit="$3" semconv="io.opentelemetry.instrumentation.api.incubator.semconv.db" + case "$index" in + 0) + rewrite "$file" "s/^package \\Q$semconv\\E;\$/package io.sentry.vendor.otel.sql;/m" + string_utils_import "$file" + # Without %scanerror, JFlex throws java.lang.Error on an internal scanner error, which the + # SDK must not catch (AGENTS.md); SqlLexerException is a RuntimeException. + rewrite "$file" 's/^(%class AutoSqlSanitizer\n)/$1%scanerror SqlLexerException\n/m' + header "$file" "${paths[0]}" "$commit" \ + "package and StringUtils import moved to io.sentry.vendor.otel.sql; %scanerror SqlLexerException added." + ;; + 1) + java_class_changes "$file" "$semconv" + string_utils_import "$file" + jetbrains_nullable "$file" + remove_auto_value "$file" + header "$file" "${paths[1]}" "$commit" \ + "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)." + ;; + 2) + java_class_changes "$file" "$semconv" + jetbrains_nullable "$file" + remove_auto_value "$file" + rewrite "$file" 's/^[ \t]*\@AutoValue\.Builder\n//mg' + rewrite "$file" 's/^import com\.google\.errorprone\.annotations\.CanIgnoreReturnValue;\n//m' + rewrite "$file" 's/^[ \t]*\@CanIgnoreReturnValue\n//mg' + header "$file" "${paths[2]}" "$commit" \ + "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)." + ;; + 3) + java_class_changes "$file" "io.opentelemetry.instrumentation.api.internal" + header "$file" "${paths[3]}" "$commit" \ + "package moved to io.sentry.vendor.otel.sql; @ApiStatus.Internal added." + ;; + esac +} + +metadata() { + local commit="$1" path + echo "# Vendored by scripts/sync-otel-sql.sh; do not edit by hand." + echo "repository=$repository" + echo "commit=$commit" + for path in "${paths[@]}"; do + echo "file=$path" + done +} + +recorded_commit() { + [[ -f "$meta" ]] || die "$meta not found" + sed -n 's/^commit=//p' "$meta" +} + +resolve() { + local ref="$1" lines name + if [[ "$ref" =~ ^[0-9a-f]{40}$ ]]; then + echo "$ref" + return + fi + lines="$(git ls-remote "https://github.com/$repository.git")" || die "could not list refs" + # A peeled annotated tag (^{}) names the commit; then a lightweight tag; then a branch. + for name in "refs/tags/$ref^{}" "refs/tags/$ref" "refs/heads/$ref"; do + awk -v name="$name" '$2 == name { print $1; found = 1 } END { exit !found }' <<<"$lines" && + return + done + die "$ref is neither a full commit hash, a tag nor a branch" +} + +# fetch : downloads the upstream files at into /. +fetch() { + local commit="$1" dir="$2" i + for i in "${!paths[@]}"; do + curl -fsSL "https://raw.githubusercontent.com/$repository/$commit/${paths[$i]}" -o "$dir/$i" || + die "could not download ${paths[$i]} at $commit" + done +} + +# derive : downloads and transforms the files at ; writes /out/ +# and /out/UPSTREAM. +derive() { + local commit="$1" dir="$2" i + mkdir -p "$dir/new" "$dir/out" + fetch "$commit" "$dir/new" + for i in "${!paths[@]}"; do + cp "$dir/new/$i" "$dir/out/$i" + label="${paths[$i]} at $commit" transform "$i" "$dir/out/$i" "$commit" + done + metadata "$commit" >"$dir/out/UPSTREAM" +} + +check() { + local commit tmp i failed=0 + commit="$(recorded_commit)" + tmp="$(mktemp -d)" + # shellcheck disable=SC2064 + trap "rm -rf '$tmp'" EXIT + derive "$commit" "$tmp" + for i in "${!paths[@]}"; do + if ! diff -u "$tmp/out/$i" "$root/${targets[$i]}" >&2; then + echo "check failed: ${targets[$i]} differs from upstream $commit with the scripted changes" >&2 + failed=1 + fi + done + if ! diff -u "$tmp/out/UPSTREAM" "$meta" >&2; then + echo "check failed: $meta differs from what the script writes" >&2 + failed=1 + fi + if ((failed)); then + echo "Vendored files must only change through scripts/sync-otel-sql.sh." >&2 + return 1 + fi + echo "ok: vendored files match upstream $commit with the scripted changes" +} + +sync() { + local commit old_commit="" tmp i + commit="$(resolve "$1")" + if [[ -f "$meta" ]]; then + old_commit="$(recorded_commit)" + fi + tmp="$(mktemp -d)" + # shellcheck disable=SC2064 + trap "rm -rf '$tmp'" EXIT + derive "$commit" "$tmp" + for i in "${!paths[@]}"; do + mkdir -p "$(dirname "$root/${targets[$i]}")" + cp "$tmp/out/$i" "$root/${targets[$i]}" + done + cp "$tmp/out/UPSTREAM" "$meta" + echo "vendored $repository at $commit" + + if [[ -n "$old_commit" && "$old_commit" != "$commit" ]]; then + mkdir -p "$tmp/old" + fetch "$old_commit" "$tmp/old" + echo "upstream changes $old_commit..$commit (review them; the tests do not assert outputs):" + for i in "${!paths[@]}"; do + diff -u --label "a/${paths[$i]}" --label "b/${paths[$i]}" "$tmp/old/$i" "$tmp/new/$i" || true + done + fi + echo "next: ./gradlew :sentry:test --tests 'io.sentry.util.sql.*'" +} + +case "${1:-}" in + --check) check ;; + "" | -h | --help) sed -n '2,20p' "$0" | sed 's/^# \{0,1\}//' ;; + -*) die "unknown option: $1" ;; + *) sync "$1" ;; +esac diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index ecba7bee503..b76f22c0121 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -4369,8 +4369,13 @@ public abstract interface class io/sentry/SpanDataConvention { public static final field CALL_STACK_KEY Ljava/lang/String; public static final field CONTRIBUTES_TTFD Ljava/lang/String; public static final field CONTRIBUTES_TTID Ljava/lang/String; + public static final field DB_NAMESPACE_KEY Ljava/lang/String; public static final field DB_NAME_KEY Ljava/lang/String; + public static final field DB_QUERY_SUMMARY_KEY Ljava/lang/String; + public static final field DB_QUERY_TEXT_KEY Ljava/lang/String; + public static final field DB_STORED_PROCEDURE_NAME_KEY Ljava/lang/String; public static final field DB_SYSTEM_KEY Ljava/lang/String; + public static final field DB_SYSTEM_NAME_KEY Ljava/lang/String; public static final field FRAMES_DELAY Ljava/lang/String; public static final field FRAMES_FROZEN Ljava/lang/String; public static final field FRAMES_SLOW Ljava/lang/String; @@ -8062,6 +8067,23 @@ public final class io/sentry/util/network/ReplayNetworkRequestOrResponse { public fun toString ()Ljava/lang/String; } +public final class io/sentry/util/sql/SqlQuery { + public fun getQuerySummary ()Ljava/lang/String; + public fun getQueryText ()Ljava/lang/String; + public fun getStoredProcedureName ()Ljava/lang/String; +} + +public final class io/sentry/util/sql/SqlQueryAnalyzer { + public static fun analyze (Ljava/lang/String;Ljava/lang/String;I)Lio/sentry/util/sql/SqlQuery; +} + +public final class io/sentry/util/sql/SqlSpanData { + public static fun analyze (Ljava/lang/String;Ljava/lang/String;ILio/sentry/ILogger;)Lio/sentry/util/sql/SqlSpanData; + public fun applyTo (Lio/sentry/ISpan;)V + public fun getDescription ()Ljava/lang/String; + public static fun toDbSystemName (Ljava/lang/String;)Ljava/lang/String; +} + public abstract interface class io/sentry/util/thread/IThreadChecker { public abstract fun currentThreadSystemId ()J public abstract fun getCurrentThreadName ()Ljava/lang/String; @@ -8193,3 +8215,38 @@ public final class io/sentry/vendor/gson/stream/MalformedJsonException : java/io public fun (Ljava/lang/Throwable;)V } +public final class io/sentry/vendor/otel/sql/OtelSqlSanitizer { + public static fun sanitize (Ljava/lang/String;Lio/sentry/vendor/otel/sql/SqlDialect;)Lio/sentry/vendor/otel/sql/SqlQuery; +} + +public abstract class io/sentry/vendor/otel/sql/SqlDialect { + public static final field DOUBLE_QUOTES_ARE_IDENTIFIERS Lio/sentry/vendor/otel/sql/SqlDialect; + public static final field DOUBLE_QUOTES_ARE_STRING_LITERALS Lio/sentry/vendor/otel/sql/SqlDialect; + public static final field UNKNOWN Lio/sentry/vendor/otel/sql/SqlDialect; + public static fun builder ()Lio/sentry/vendor/otel/sql/SqlDialect$Builder; + public static fun forDbSystemName (Ljava/lang/String;)Lio/sentry/vendor/otel/sql/SqlDialect; +} + +public abstract class io/sentry/vendor/otel/sql/SqlDialect$Builder { + public abstract fun build ()Lio/sentry/vendor/otel/sql/SqlDialect; + public abstract fun setDoubleQuotesAreIdentifiers (Z)Lio/sentry/vendor/otel/sql/SqlDialect$Builder; +} + +public abstract class io/sentry/vendor/otel/sql/SqlQuery { + public fun ()V + public static fun create (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/sentry/vendor/otel/sql/SqlQuery; + public static fun create (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/sentry/vendor/otel/sql/SqlQuery; + public abstract fun getCollectionName ()Ljava/lang/String; + public abstract fun getOperationName ()Ljava/lang/String; + public abstract fun getQuerySummary ()Ljava/lang/String; + public abstract fun getQueryText ()Ljava/lang/String; + public abstract fun getStoredProcedureName ()Ljava/lang/String; +} + +public final class io/sentry/vendor/otel/sql/StringUtils { + public static fun appendTruncated (Ljava/lang/StringBuilder;Ljava/lang/String;I)V + public static fun truncate (Ljava/lang/String;I)Ljava/lang/String; + public static fun truncate (Ljava/lang/StringBuffer;I)V + public static fun truncate (Ljava/lang/StringBuilder;I)V +} + diff --git a/sentry/build.gradle.kts b/sentry/build.gradle.kts index 6b07d9d746d..6967100d7ba 100644 --- a/sentry/build.gradle.kts +++ b/sentry/build.gradle.kts @@ -19,7 +19,11 @@ tasks.named("compileKotlin") { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11 } +// Build-time only: JFlex generates the SQL lexer; the generated code has no runtime dependency. +val jflex: Configuration = configurations.create("jflex") + dependencies { + jflex(libs.jflex) errorprone(libs.errorprone.core) errorprone(libs.nopen.checker) errorprone(libs.nullaway) @@ -66,6 +70,48 @@ tasks { } } +// Generates the SQL lexer from OpenTelemetry's grammar, vendored by scripts/sync-otel-sql.sh. +val jflexSourceFile = layout.projectDirectory.file("src/main/jflex/SqlSanitizer.jflex") +val jflexOutputDir = layout.buildDirectory.dir("generated/sources/jflex") + +val generateJflex = + tasks.register("generateJflex") { + description = "Generates the SQL lexer from src/main/jflex/SqlSanitizer.jflex." + classpath(jflex) + mainClass.set("jflex.Main") + inputs.file(jflexSourceFile) + outputs.dir(jflexOutputDir) + // Locals, not the script's vals: lambdas that reference script vals capture the script object, + // which the configuration cache cannot serialize. + val sourceFile = jflexSourceFile + val outputDir = jflexOutputDir + argumentProviders.add( + CommandLineArgumentProvider { + listOf( + "--quiet", + "--nobak", + "-d", + outputDir.get().dir("io/sentry/vendor/otel/sql").asFile.absolutePath, + sourceFile.asFile.absolutePath, + ) + }, + ) + doFirst { outputDir.get().asFile.deleteRecursively() } + } + +sourceSets { main { java.srcDir(generateJflex) } } + +// The vendored OpenTelemetry files are internal and keep upstream's Javadoc, which links classes +// that are not vendored; the generated lexer has none. +tasks.javadoc { + exclude( + "io/sentry/vendor/otel/sql/SqlQuery.java", + "io/sentry/vendor/otel/sql/SqlDialect.java", + "io/sentry/vendor/otel/sql/StringUtils.java", + "io/sentry/vendor/otel/sql/AutoSqlSanitizer.java", + ) +} + buildConfig { useJavaOutput() packageName("io.sentry") @@ -79,7 +125,12 @@ tasks.withType().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..b0f94840c6b --- /dev/null +++ b/sentry/src/main/java/io/sentry/util/sql/SqlQuery.java @@ -0,0 +1,47 @@ +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 { + + /** No text, summary or stored procedure: {@code null} or skipped input, or an internal error. */ + 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..02dc2fe871f --- /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 (D66). 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) { + // R5: 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 (D5), 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..406dcc7764a --- /dev/null +++ b/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java @@ -0,0 +1,103 @@ +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 (D66) 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; + } + switch (dbSystem.toLowerCase(Locale.ROOT)) { + case "postgresql": + case "mysql": + case "mariadb": + case "sqlite": + case "hsqldb": + case "derby": + return dbSystem.toLowerCase(Locale.ROOT); + case "in-memory": + return "sqlite"; + case "h2": + return "h2database"; + case "sqlserver": + return "microsoft.sql_server"; + case "oracle": + return "oracle.db"; + 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/SqlAnalyzerHarness.kt b/sentry/src/test/java/io/sentry/util/sql/SqlAnalyzerHarness.kt new file mode 100644 index 00000000000..eee595a9916 --- /dev/null +++ b/sentry/src/test/java/io/sentry/util/sql/SqlAnalyzerHarness.kt @@ -0,0 +1,239 @@ +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 java.util.concurrent.Callable +import java.util.concurrent.ExecutionException +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.concurrent.TimeoutException + +/** + * One `db.system.name` per dialect option of the vendored `SqlDialect`: `null` reads double quotes + * as literals, `postgresql` as identifiers. The robustness tests run under both. + */ +internal val DIALECTS: List = listOf(null, "postgresql") + +internal fun SqlQuery.fields(): Map = + linkedMapOf( + "text" to queryText, + "summary" to querySummary, + "storedProcedure" to storedProcedureName, + ) + +/** + * What every robustness input must give: a text. Non-null input up to 1 MiB has `null` text only + * after an internal error (R5), which no input may cause. + */ +internal fun assertHasText(query: SqlQuery, describe: () -> String) { + if (query.queryText == null) { + assertWithMessage("no text, so the analyzer failed internally (R5); %s", describe()) + .that(query.queryText) + .isNotNull() + } +} + +internal fun assertWithinLimit(query: SqlQuery, limit: Int, describe: () -> String) { + assertWithMessage("text longer than the limit; %s", describe()) + .that(query.queryText?.length ?: 0) + .isAtMost(limit) +} + +/** + * No output splits a surrogate pair. A lone surrogate in the input passes through the grammar like + * any other character, so inputs that have one are not checked. + */ +internal fun assertNoLoneSurrogate(input: String, query: SqlQuery, describe: () -> String) { + if (hasLoneSurrogate(input)) return + for ((field, value) in query.fields()) { + if (value != null && hasLoneSurrogate(value)) { + assertWithMessage("lone surrogate in %s; %s", field, describe()) + .that(escape(value)) + .isEqualTo("no lone surrogate") + } + } +} + +private fun hasLoneSurrogate(value: String): Boolean { + var i = 0 + while (i < value.length) { + val c = value[i] + if (c.isHighSurrogate() && i + 1 < value.length && value[i + 1].isLowSurrogate()) i += 2 + else if (c.isSurrogate()) return true else i++ + } + return false +} + +/** Escapes control characters and surrogates so a failing input can be read and copied. */ +internal fun escape(value: String, maxLength: Int = 4096): String { + val out = StringBuilder() + for (c in value.take(maxLength)) { + when { + c == '\\' -> out.append("\\\\") + c == '\n' -> out.append("\\n") + c == '\r' -> out.append("\\r") + c == '\t' -> out.append("\\t") + c < ' ' || c.isSurrogate() || c.code in 0x7f..0x9f -> + out.append("\\u").append(String.format("%04x", c.code)) + else -> out.append(c) + } + } + if (value.length > maxLength) out.append("… (${value.length} chars)") + return out.toString() +} + +/** + * Runs [SqlQueryAnalyzer.analyze] on a daemon thread with a fixed stack, so that a recursion depth + * that would overflow a typical Android or JVM worker thread fails here, and a hang fails after + * `timeoutMillis` instead of stalling the build. + */ +internal class AnalyzerWorker : AutoCloseable { + private val executor: ExecutorService = Executors.newSingleThreadExecutor { runnable -> + Thread(null, runnable, "sql-analyzer-worker", STACK_SIZE_BYTES).apply { isDaemon = true } + } + + fun analyze( + sql: String, + dbSystemName: String?, + maxQueryTextLength: Int, + timeoutMillis: Long, + describe: () -> String, + ): SqlQuery { + val future = + executor.submit(Callable { SqlQueryAnalyzer.analyze(sql, dbSystemName, maxQueryTextLength) }) + try { + return future.get(timeoutMillis, TimeUnit.MILLISECONDS) + } catch (e: TimeoutException) { + future.cancel(true) + throw AssertionError("analyze did not complete within $timeoutMillis ms: ${describe()}") + } catch (e: ExecutionException) { + throw AssertionError("analyze threw ${e.cause}: ${describe()}", e.cause) + } + } + + override fun close() { + executor.shutdownNow() + } + + companion object { + /** Below the default for Android background threads and HotSpot (both about 1 MiB). */ + const val STACK_SIZE_BYTES = 512L * 1024 + } +} + +/** + * A case of `sql/analyzer-cases.json`: an input with the `db.system.name` and limit it is analyzed + * with, and the secrets it declares. The file has no expected outputs (plan 08, Tests). + */ +class SqlCase( + val id: String, + val dbSystemName: String?, + val input: String, + val maxQueryTextLength: Int, + val secrets: List, +) { + override fun toString(): String = id +} + +internal object SqlCorpus { + private const val RESOURCE = "sql/analyzer-cases.json" + private val SOURCE = Regex("sentry|otel-java:\\w+#.+|otel-dotnet:[^#]+#.+") + private val REQUIRED_KEYS = setOf("id", "dialect", "input", "source") + + /** Used when a case sets no limit: larger than any input. */ + private const val UNLIMITED = Int.MAX_VALUE + + val cases: List by lazy { load() } + + /** + * Rejects anything that would silently weaken a case: unknown or missing keys, unknown dialects. + */ + private fun load(): List { + val stream = + checkNotNull(SqlCorpus::class.java.classLoader.getResourceAsStream(RESOURCE)) { + "$RESOURCE not found" + } + val cases = mutableListOf() + JsonObjectReader(InputStreamReader(stream, 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 }) { "$RESOURCE: duplicate id '${case.id}'" } + cases += case + } + reader.endArray() + } + else -> error("$RESOURCE: unknown top-level key '$key'") + } + } + reader.endObject() + } + check(cases.isNotEmpty()) { "$RESOURCE has no cases" } + return cases + } + + private fun readCase(reader: JsonObjectReader): SqlCase { + var id: String? = null + var dbSystemName: String? = null + var input: String? = null + var maxQueryTextLength = UNLIMITED + var secrets = emptyList() + val seen = mutableSetOf() + reader.beginObject() + while (reader.hasNext()) { + val key = reader.nextName() + check(seen.add(key)) { "$RESOURCE: duplicate key '$key' in case '$id'" } + when (key) { + "id" -> id = readString(reader, key) + "dialect" -> dbSystemName = toDbSystemName(readString(reader, key)) + "input" -> input = readString(reader, key) + "maxQueryTextLength" -> { + check(reader.peek() == JsonToken.NUMBER) { "'$key' must be an integer" } + maxQueryTextLength = reader.nextInt() + check(maxQueryTextLength > 0) { "'$key' must be positive" } + } + "secrets" -> secrets = readStrings(reader, key) + "source" -> check(SOURCE.matches(readString(reader, key))) { "case '$id': bad source" } + else -> error("$RESOURCE: unknown key '$key' in case '$id'") + } + } + reader.endObject() + check(seen.containsAll(REQUIRED_KEYS)) { + "$RESOURCE: case '$id' misses ${REQUIRED_KEYS - seen}" + } + return SqlCase(id!!, dbSystemName, input!!, maxQueryTextLength, 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 + } +} diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerCorpusTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerCorpusTest.kt new file mode 100644 index 00000000000..ea5f765429d --- /dev/null +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerCorpusTest.kt @@ -0,0 +1,44 @@ +package io.sentry.util.sql + +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized + +/** + * Owns stability on the corpus inputs (`sql/analyzer-cases.json`), each under its own dialect and + * limit: [SqlQueryAnalyzer.analyze] completes within [TIME_BOUND_MILLIS] on an + * [AnalyzerWorker.STACK_SIZE_BYTES] stack, fails nowhere internally, respects the limit and splits + * no surrogate pair. Outputs are not asserted (plan 08, Tests); leaks are owned by + * [SqlQueryAnalyzerKnownLeakTest]. + */ +@RunWith(Parameterized::class) +class SqlQueryAnalyzerCorpusTest(private val case: SqlCase) { + + @Test + fun `completes within the bound without failing or exceeding the limit`() { + val describe = { "case ${case.id} (${escape(case.input, 200)})" } + val query = + AnalyzerWorker().use { + it.analyze( + case.input, + case.dbSystemName, + case.maxQueryTextLength, + TIME_BOUND_MILLIS, + describe, + ) + } + + assertHasText(query, describe) + assertWithinLimit(query, case.maxQueryTextLength, describe) + assertNoLoneSurrogate(case.input, query, describe) + } + + companion object { + /** Bound recorded in plan 01, step 6. */ + const val TIME_BOUND_MILLIS = 2_000L + + @JvmStatic + @Parameterized.Parameters(name = "{0}") + fun parameters(): List> = SqlCorpus.cases.map { arrayOf(it) } + } +} diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt new file mode 100644 index 00000000000..ebfe76165a6 --- /dev/null +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt @@ -0,0 +1,254 @@ +// Random UTF-16 inputs adapted from OpenTelemetry Java Instrumentation +// (SqlQueryAnalyzerTest#randomBytesDontCauseExceptionsOrTimeouts). +// 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 java.util.Random +import org.junit.Test + +/** + * Owns stability for generated input: [SqlQueryAnalyzer.analyze] must not throw or fail internally, + * must respect `maxQueryTextLength`, split no surrogate pair, and finish each input within + * [TIME_BOUND_MILLIS] (plan 01, step 6). Outputs and leaks are not asserted (plan 08, Tests). + * + * Each test runs a fixed seed and a run seed. The run seed is random unless the + * `sentry.sql.fuzz.seed` system property sets it; every failure message prints the seed and the + * command that reproduces it. + */ +class SqlQueryAnalyzerFuzzTest { + + /** + * Token soup over keywords, operators, markers and every quote and comment construct, closed or + * not. Half the inputs drop separators at random, which exercises boundary lexing (`x-1`, + * `ELSE'x'`, `1--1`). + */ + @Test + fun `token inputs never fail, exceed the limit or the time bound`() { + run(TOKEN_INPUTS) { random -> + TokenInputGenerator(random, glue = random.nextBoolean()).generate() + } + } + + @Test + fun `random UTF-16 inputs never fail, exceed the limit or the time bound`() { + run(UTF16_INPUTS) { random -> + val keyword = if (random.nextInt(4) != 0) pick(random, LEADING_KEYWORDS) + " " else "" + keyword + String(CharArray(UTF16_LENGTH) { random.nextInt(0x10000).toChar() }) + } + } + + private fun run(count: Int, generate: (Random) -> String) { + AnalyzerWorker().use { worker -> + warmUp(worker) + for (seed in seeds()) { + val random = Random(seed) + repeat(count) { index -> + val dbSystemName = pick(random, DIALECTS) + val limit = pickLimit(random) + val input = generate(random) + val describe = { + "seed=$seed index=$index dbSystemName=$dbSystemName maxQueryTextLength=$limit " + + "input=\"${escape(input)}\"\nReproduce: ./gradlew :sentry:test " + + "--tests '${SqlQueryAnalyzerFuzzTest::class.java.name}' -D$SEED_PROPERTY=$seed" + } + val query = worker.analyze(input, dbSystemName, limit, TIME_BOUND_MILLIS, describe) + + assertHasText(query, describe) + assertWithinLimit(query, limit, describe) + assertNoLoneSurrogate(input, query, describe) + } + } + } + } + + /** Untimed runs so class loading and JIT compilation don't count against the first input. */ + private fun warmUp(worker: AnalyzerWorker) { + val random = Random(WARM_UP_SEED) + repeat(WARM_UP_INPUTS) { + val input = TokenInputGenerator(random, glue = false).generate() + worker.analyze(input, null, Int.MAX_VALUE, WARM_UP_TIMEOUT_MILLIS) { + "warm-up input=\"${escape(input)}\"" + } + } + } + + private fun seeds(): List { + val runSeed = + System.getProperty(SEED_PROPERTY)?.takeIf { it.isNotBlank() }?.toLong() ?: Random().nextLong() + return listOf(FIXED_SEED, runSeed) + } + + /** Half the inputs are unlimited; the rest get small limits so the cut is exercised. */ + private fun pickLimit(random: Random): Int = + if (random.nextBoolean()) Int.MAX_VALUE else 1 + random.nextInt(200) + + companion object { + const val SEED_PROPERTY = "sentry.sql.fuzz.seed" + + /** Bound recorded in plan 01, step 6. */ + const val TIME_BOUND_MILLIS = 250L + + private const val FIXED_SEED = 6019L + private const val WARM_UP_SEED = 712L + private const val WARM_UP_INPUTS = 200 + private const val WARM_UP_TIMEOUT_MILLIS = 10_000L + private const val TOKEN_INPUTS = 2_500 + private const val UTF16_INPUTS = 200 + private const val UTF16_LENGTH = 1_000 + } +} + +private fun pick(random: Random, values: List): T = values[random.nextInt(values.size)] + +private val LEADING_KEYWORDS = + listOf("SELECT", "INSERT INTO", "UPDATE", "DELETE FROM", "CALL", "EXEC", "WITH", "CREATE") + +/** Generates token soup; the last construct is left unterminated in a third of the inputs. */ +private class TokenInputGenerator(private val random: Random, private val glue: Boolean) { + private val out = StringBuilder() + + fun generate(): String { + if (random.nextInt(10) != 0) append(pick(random, LEADING_KEYWORDS)) + repeat(random.nextInt(MAX_SEGMENTS)) { + if (random.nextInt(3) == 0) append(construct(terminated = true)) + else append(pick(random, FREE_TOKENS)) + } + if (random.nextInt(3) == 0) append(construct(terminated = false)) + return out.toString() + } + + private fun append(token: String) { + if (out.isNotEmpty() && !(glue && random.nextBoolean())) out.append(pick(random, SEPARATORS)) + out.append(token) + } + + private fun construct(terminated: Boolean): String { + val (open, close) = pick(random, CONSTRUCTS) + val content = List(random.nextInt(6)) { pick(random, CONTENT) }.joinToString("") + return open + content + if (terminated) close else "" + } + + companion object { + private const val MAX_SEGMENTS = 60 + + private val SEPARATORS = listOf(" ", " ", " ", "\n", "\t", " ", "\r\n") + + private val CONSTRUCTS = + listOf( + "'" to "'", + "N'" to "'", + "E'" to "'", + "\"" to "\"", + "`" to "`", + "[" to "]", + "$$" to "$$", + "\$t$" to "\$t$", + "/*" to "*/", + "/*!" to "*/", + "-- " to "\n", + "--" to "\n", + "#" to "\n", + "//" to "\n", + "q'[" to "]'", + "q'{" to "}'", + ) + + private val CONTENT = + listOf( + "a", + "users", + "Zq9xK7", + "straße", + " ", + "1", + "2.5", + ",", + "(", + ")", + ";", + "=", + "'", + "''", + "\"", + "`", + "\\", + "/*", + "*/", + "--", + "#", + "$$", + "[", + "]", + "\n", + "?", + ":p", + "@p", + "$1", + "\uD835\uDC9C", + ) + + private val FREE_TOKENS = + listOf( + "SELECT", + "FROM", + "WHERE", + "INSERT", + "INTO", + "VALUES", + "UPDATE", + "SET", + "DELETE", + "CALL", + "EXEC", + "EXECUTE", + "WITH", + "AS", + "JOIN", + "ON", + "IN", + "AND", + "OR", + "NULL", + "CREATE", + "TABLE", + "USER", + "IDENTIFIED", + "BY", + "UNION", + "users", + "t", + "col_a", + "straße", + "x1", + "1", + "-2.5", + "1e-5", + "0x1F", + "=", + "<>", + "+", + "-", + "*", + "/", + ",", + ".", + ";", + "(", + ")", + "{", + "}", + "?", + "?1", + ":name", + "@p", + "$1", + "\\", + "$", + "*/", + "]", + "||", + ) + } +} 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..dd761d3c74c --- /dev/null +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt @@ -0,0 +1,58 @@ +package io.sentry.util.sql + +import com.google.common.truth.Truth.assertWithMessage +import kotlin.test.Test + +/** + * Owns the accepted leaks of the unchanged grammar (D69): a corpus case leaks when one of its + * declared secrets appears whole in the text, summary or stored procedure of its full input. 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. + * Prefixes are not analyzed: truncated input does not reach the analyzer (patch-inventory section + * 5). + */ +class SqlQueryAnalyzerKnownLeakTest { + + @Test + fun `only listed cases leak a declared secret`() { + val known = knownLeaks() + val leaking = + SqlCorpus.cases + .filter { it.secrets.isNotEmpty() } + .filter { case -> + val query = + SqlQueryAnalyzer.analyze(case.input, case.dbSystemName, case.maxQueryTextLength) + query.fields().values.any { value -> + value != null && case.secrets.any { value.contains(it) } + } + } + .map { it.id } + .toSet() + + val fixed = known - leaking + if (fixed.isNotEmpty()) { + println( + "${fixed.size} listed case(s) no longer leak; remove them from $RESOURCE:\n" + + fixed.sorted().joinToString("\n"), + ) + } + assertWithMessage("cases that leak but are not listed in %s", RESOURCE) + .that((leaking - known).sorted()) + .isEmpty() + } + + private fun knownLeaks(): Set { + val stream = + checkNotNull(javaClass.classLoader.getResourceAsStream(RESOURCE)) { "$RESOURCE not found" } + return stream + .bufferedReader() + .readLines() + .map { it.trim() } + .filter { it.isNotEmpty() && !it.startsWith("#") } + .toSet() + } + + private companion object { + const val RESOURCE = "sql/known-leaks.txt" + } +} 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..53bd953943f --- /dev/null +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt @@ -0,0 +1,118 @@ +// Inputs adapted from OpenTelemetry Java Instrumentation (SqlQueryAnalyzerTest) and +// OpenTelemetry .NET Contrib (SqlProcessorTests). +// 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 +// https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/4e3aba9ddf89f9accac004f44f32ebde335dd115/test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTests.cs +package io.sentry.util.sql + +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized + +/** + * Owns stability for oversized and degenerate input, under both dialects: + * [SqlQueryAnalyzer.analyze] completes within [TIME_BOUND_MILLIS] on an + * [AnalyzerWorker.STACK_SIZE_BYTES] stack, throws nothing (a `StackOverflowError` would surface + * here), fails nowhere internally, respects `maxQueryTextLength` and never splits a surrogate pair. + * Outputs are not asserted (plan 08, Tests). + */ +@RunWith(Parameterized::class) +class SqlQueryAnalyzerPathologicalTest( + @Suppress("unused") private val name: String, + private val input: Input, + private val dbSystemName: String?, +) { + + class Input( + val name: String, + val maxQueryTextLength: Int = Int.MAX_VALUE, + val build: () -> String, + ) + + @Test + fun `completes within the bound without failing, exceeding the limit or splitting surrogates`() { + val sql = input.build() + val describe = { "${input.name} (${sql.length} chars) under $dbSystemName" } + + val query = + AnalyzerWorker().use { + it.analyze(sql, dbSystemName, input.maxQueryTextLength, TIME_BOUND_MILLIS, describe) + } + + assertHasText(query, describe) + assertWithinLimit(query, input.maxQueryTextLength, describe) + assertNoLoneSurrogate(sql, query, describe) + } + + companion object { + /** Bound recorded in plan 01, step 6. */ + const val TIME_BOUND_MILLIS = 2_000L + + private const val KIB = 1024 + private const val D5_JDBC_LIMIT = 32 * KIB + + private val DIGITS = (0 until 10_000).joinToString("") + + private val INPUTS = + listOf( + Input("10k nested parens") { "SELECT " + "(".repeat(10_000) + "1" + ")".repeat(10_000) }, + Input("1 MiB of statements") { + val statement = "SELECT a, b FROM t WHERE c = 'Zq9xK7' AND d IN (1, 2, 3) /* Zq9xK7 */; " + // Just under 1 MiB: longer input is not analyzed at all (D66). + statement.repeat(KIB * KIB / statement.length) + }, + // An even count closes the literal (`''` is an escaped quote); an odd count leaves it + // unterminated. + Input("64 KiB of single quotes, closed") { "SELECT " + "'".repeat(64 * KIB) }, + Input("64 KiB of single quotes, unterminated") { "SELECT " + "'".repeat(64 * KIB + 1) }, + Input("64 KiB of comment openers") { "/*".repeat(32 * KIB) }, + // OTel .NET SqlProcessorTests#…RepeatedUnterminatedEscapedIdentifiersInFromClause… + Input("4096 unterminated brackets") { + "SELECT * FROM " + + "[".repeat(4096) + + " WHERE CustomerName = 'secret-name' AND Id = 123 AND Token = 0xDEADBEEF" + }, + Input("128 KiB of opening brackets, closed") { "SELECT " + "[".repeat(128 * KIB) + "]" }, + Input("128 KiB of opening brackets, unterminated") { "SELECT " + "[".repeat(128 * KIB) }, + Input("128 KiB of hash signs on one line") { "SELECT 1 " + "#".repeat(128 * KIB) }, + Input("128 KiB of double slashes on one line") { "SELECT 1 " + "//".repeat(64 * KIB) }, + Input("128 KiB of --a on one line") { "SELECT 1 " + "--a".repeat(128 * KIB / 3) }, + Input("128 KiB of q'[ on one line") { "SELECT 1 " + "q'[".repeat(128 * KIB / 3) }, + Input("128 KiB of dollar signs") { "SELECT " + "$".repeat(128 * KIB) }, + // OTel Java SqlQueryAnalyzerTest#longInStatementDoesntCauseStackOverflow + Input("10001-item IN list") { + "select col from table where col in (" + "?,".repeat(10_000) + "?)" + }, + // OTel Java SqlQueryAnalyzerTest#veryLongNumbersAreOk + Input("39k-digit number") { "SELECT $DIGITS" }, + // OTel Java SqlQueryAnalyzerTest#veryLongNumbersAtEndOfTableAreOk + Input("39k-character identifier") { "SELECT A$DIGITS" }, + // OTel Java SqlQueryAnalyzerTest#test32kTruncation + Input("10k statements at the 32 KiB limit", maxQueryTextLength = D5_JDBC_LIMIT) { + "SELECT * FROM TABLE WHERE FIELD = 1234 AND ".repeat(10_000) + }, + // OTel Java SqlQueryAnalyzerTest#queryTextTruncationDoesNotSplitSurrogatePair: the limit + // falls between the two halves of U+1D49C, a letter outside the BMP. + Input("surrogate pair at the 32 KiB limit", maxQueryTextLength = D5_JDBC_LIMIT) { + // The high surrogate is the limit's last character. + "SELECT " + "A".repeat(D5_JDBC_LIMIT - "SELECT ".length - 1) + "\uD835\uDC9C FROM t" + }, + // As above, without whitespace, so the wrapper cuts at the limit itself. + Input( + "surrogate pair at the 32 KiB limit, no whitespace", + maxQueryTextLength = D5_JDBC_LIMIT, + ) { + "A".repeat(D5_JDBC_LIMIT - 1) + "\uD835\uDC9C" + }, + ) + + @JvmStatic + @Parameterized.Parameters(name = "{0}") + fun parameters(): List> = INPUTS.flatMap { input -> + DIALECTS.map { dbSystemName -> + arrayOf(input.name + " / " + dbSystemName, input, dbSystemName) + } + } + } +} 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..8392656939d --- /dev/null +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt @@ -0,0 +1,116 @@ +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 + +/** + * Owns what [SqlQueryAnalyzer] adds around the vendored grammar: `null` and oversized input, the + * length limit, the dialect choice and the error path (plan 08, Wrapper). The grammar's own output + * is not asserted: a sync must not mean re-baselining. Where a test needs a fact about that output + * (that a keyword or an identifier is kept), 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" + + // R8: upstream's forDbSystemName, e.g. PostgreSQL yes, MySQL and unknown databases no. + 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 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..3a576f11ffe --- /dev/null +++ b/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt @@ -0,0 +1,156 @@ +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 (plan 07, D52): the analyzer's text + * as description and `db.query.text`, summary and stored procedure only when present. The values + * themselves are the analyzer's; [SqlQueryAnalyzerTest] owns those. + */ +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`() { + // D66: skipping is not an analysis failure. + 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") + } + + /** + * D55: the integrations' `db.system` values mapped to OTel semconv `db.system.name` values + * (`semantic-conventions` `model/db/registry.yaml`). Unknown systems get no value. + */ + @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", + "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..a593b5ac05d --- /dev/null +++ b/sentry/src/test/resources/sql/analyzer-cases.json @@ -0,0 +1,5720 @@ +{ + "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": "size.limit.over", + "dialect": "postgresql", + "input": "SELECT name FROM users WHERE email = 'Zq9xK7@example.com'", + "maxQueryTextLength": 25, + "secrets": ["Zq9xK7@example.com"], + "source": "sentry" + }, + { + "id": "literal.string.doubled_quote", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users WHERE name = 'O''Zq9xK7a'", + "secrets": ["Zq9xK7a"], + "source": "sentry" + }, + { + "id": "literal.string.empty", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users WHERE name = ''", + "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.number.integers", + "dialect": "CONSERVATIVE", + "input": "SELECT 12, -12, +12 FROM t", + "source": "sentry" + }, + { + "id": "literal.number.decimal_exponent", + "dialect": "CONSERVATIVE", + "input": "SELECT 12.34, .5, -0.5, 1e10, 1.5E-3, -2E+9 FROM t", + "source": "sentry" + }, + { + "id": "literal.number.signed_in_expression", + "dialect": "CONSERVATIVE", + "input": "SELECT a FROM t WHERE b = 99+100 AND c=x-1 AND d = x - 1 AND e>=-5", + "source": "sentry" + }, + { + "id": "literal.number.sign_after_operand", + "dialect": "CONSERVATIVE", + "input": "SELECT a-1, a -1, 2-1, 'b'-1, ?-1, :p-1, $1-1, (c)-1, d[1]-1, `e`-1 FROM t", + "source": "sentry" + }, + { + "id": "literal.number.sign_after_keyword.clauses", + "dialect": "CONSERVATIVE", + "input": "SELECT ALL -1 FROM t JOIN u ON -2 < u.a WHERE -3 < a AND -4 < b OR NOT -5 > c GROUP BY a HAVING -6 < COUNT(*) ORDER BY -7 LIMIT -8 OFFSET -9", + "source": "sentry" + }, + { + "id": "literal.number.sign_after_keyword.expressions", + "dialect": "CONSERVATIVE", + "input": "SELECT DISTINCT CASE -1 WHEN -2 THEN -3 ELSE -4 END FROM t WHERE a BETWEEN -5 AND -6 OR b LIKE -7 ESCAPE -8 OR c = INTERVAL -9 DAY", + "source": "sentry" + }, + { + "id": "literal.number.sign_after_keyword.lists", + "dialect": "CONSERVATIVE", + "input": "SELECT TOP -1 a FROM t WHERE b IN -2 OR c > ANY -3 OR d > SOME -4; VALUES -5; UPDATE t SET -6", + "source": "sentry" + }, + { + "id": "literal.number.sign_after_keyword.ddl", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE t (a INT DEFAULT -1); CREATE PROCEDURE p AS RETURN -2; CREATE SEQUENCE s START WITH -3 INCREMENT BY -4 MINVALUE -5", + "source": "sentry" + }, + { + "id": "literal.number.in_identifier", + "dialect": "CONSERVATIVE", + "input": "SELECT c3po, r2d2 FROM covid19 WHERE n1h1 = 1234", + "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.binary", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t WHERE a = B'1011' AND b = 0b1011", + "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.boolean_null_kept", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t WHERE a = TRUE AND b = false AND c IS NULL AND d IS NOT NULL", + "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.empty_lines.mysql", + "dialect": "mysql", + "input": "SELECT a #\nFROM t #", + "source": "sentry" + }, + { + "id": "comment.hash.postgresql", + "dialect": "postgresql", + "input": "SELECT a # b FROM t", + "source": "sentry" + }, + { + "id": "comment.hash.sqlserver_temp_table", + "dialect": "sqlserver", + "input": "SELECT * FROM #orders WHERE id = 1", + "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.mysql", + "dialect": "mysql", + "input": "SELECT 1--1 FROM t", + "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.postgresql", + "dialect": "postgresql", + "input": "SELECT 1--1\nFROM t", + "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.postgresql", + "dialect": "postgresql", + "input": "SELECT 8 // 2 FROM t", + "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": "param.question", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t WHERE a = ? AND b = ?", + "source": "sentry" + }, + { + "id": "param.numbered", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t WHERE a = ?1 AND b = ?2", + "source": "sentry" + }, + { + "id": "param.named_colon", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t WHERE a = :email AND b = :id", + "source": "sentry" + }, + { + "id": "param.named_at.sqlserver", + "dialect": "sqlserver", + "input": "SELECT * FROM t WHERE a = @email AND b = @p1", + "source": "sentry" + }, + { + "id": "param.dollar_positional.postgresql", + "dialect": "postgresql", + "input": "SELECT * FROM t WHERE a = $1 AND b = $2", + "source": "sentry" + }, + { + "id": "param.dollar_named.sqlite", + "dialect": "sqlite", + "input": "SELECT * FROM t WHERE a = $email", + "source": "sentry" + }, + { + "id": "param.dollar_positional.conservative", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t WHERE a = $1", + "source": "sentry" + }, + { + "id": "param.cast_not_marker.postgresql", + "dialect": "postgresql", + "input": "SELECT a::text FROM t WHERE b = '5'::int", + "source": "sentry" + }, + { + "id": "jdbc.call", + "dialect": "CONSERVATIVE", + "input": "{call get_user(?)}", + "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": "room.select", + "dialect": "sqlite", + "input": "SELECT * FROM `users` WHERE `id` = ? LIMIT 1", + "source": "sentry" + }, + { + "id": "room.insert_or_replace", + "dialect": "sqlite", + "input": "INSERT OR REPLACE INTO `users` (`id`,`name`) VALUES (?,?)", + "source": "sentry" + }, + { + "id": "room.update_or_abort", + "dialect": "sqlite", + "input": "UPDATE OR ABORT `users` SET `id` = ?,`name` = ? WHERE `id` = ?", + "source": "sentry" + }, + { + "id": "room.delete", + "dialect": "sqlite", + "input": "DELETE FROM `users` WHERE `id` = ?", + "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.identified_by.comment_before_glued_by.postgresql", + "dialect": "postgresql", + "input": "UPDATE t SET a = 1 IDENTIFIED/**/BYpw", + "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.password_stop.before_punctuation.postgresql", + "dialect": "postgresql", + "input": "CREATE STATISTICS user_stats ON password, email FROM users", + "source": "sentry" + }, + { + "id": "credentials.password_stop.after_object_kind", + "dialect": "CONSERVATIVE", + "input": "CREATE SCHEMA password AUTHORIZATION app_owner", + "source": "sentry" + }, + { + "id": "credentials.password_kept.safe_kinds", + "dialect": "CONSERVATIVE", + "input": "CREATE INDEX idx_pw ON users (password DESC); CREATE VIEW v AS SELECT password FROM users; CREATE PROCEDURE p AS SELECT password FROM users", + "source": "sentry" + }, + { + "id": "credentials.password_kept.modifiers.postgresql", + "dialect": "postgresql", + "input": "CREATE OR REPLACE TEMP VIEW v AS SELECT password FROM users; CREATE UNLOGGED TABLE t (password TEXT); CREATE GLOBAL TEMPORARY TABLE g (password TEXT); CREATE LOCAL TEMPORARY TABLE l (password TEXT); CREATE UNIQUE INDEX i ON users (password DESC); CREATE MATERIALIZED VIEW m AS SELECT password FROM users", + "source": "sentry" + }, + { + "id": "credentials.password_kept.modifiers.sqlserver", + "dialect": "sqlserver", + "input": "CREATE CLUSTERED INDEX i ON users (password DESC); CREATE NONCLUSTERED INDEX j ON users (password ASC)", + "source": "sentry" + }, + { + "id": "credentials.connect_not_allowlisted", + "dialect": "CONSERVATIVE", + "input": "CONNECT Zq9xK7bu PASSWORD Zq9xK7bv", + "secrets": ["Zq9xK7bu", "Zq9xK7bv"], + "source": "sentry" + }, + { + "id": "credentials.password_column", + "dialect": "CONSERVATIVE", + "input": "SELECT password FROM users WHERE id = 1", + "source": "sentry" + }, + { + "id": "credentials.password_column_ddl", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE users (password VARCHAR(255))", + "source": "sentry" + }, + { + "id": "credentials.password_update", + "dialect": "CONSERVATIVE", + "input": "UPDATE users SET password = 'Zq9xK7bx' WHERE id = 1", + "secrets": ["Zq9xK7bx"], + "source": "sentry" + }, + { + "id": "shape.select.lowercase", + "dialect": "CONSERVATIVE", + "input": "select id from users where id = 1", + "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.delete", + "dialect": "CONSERVATIVE", + "input": "DELETE FROM users WHERE id IN (1, 2, 3)", + "source": "sentry" + }, + { + "id": "shape.merge", + "dialect": "CONSERVATIVE", + "input": "MERGE INTO users USING staging ON users.id = staging.id WHEN MATCHED THEN UPDATE SET name = staging.name", + "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.create_table.modifier_word_as_name", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE temp (id INT)", + "source": "sentry" + }, + { + "id": "shape.alter_table", + "dialect": "CONSERVATIVE", + "input": "ALTER TABLE orders ADD COLUMN note TEXT", + "source": "sentry" + }, + { + "id": "shape.drop_table_if_exists", + "dialect": "CONSERVATIVE", + "input": "DROP TABLE IF EXISTS orders", + "source": "sentry" + }, + { + "id": "shape.create_index", + "dialect": "CONSERVATIVE", + "input": "CREATE INDEX idx_orders_status ON orders (status)", + "source": "sentry" + }, + { + "id": "shape.drop_index", + "dialect": "CONSERVATIVE", + "input": "DROP INDEX idx_orders_status", + "source": "sentry" + }, + { + "id": "shape.create_view", + "dialect": "CONSERVATIVE", + "input": "CREATE VIEW open_orders AS SELECT * FROM orders WHERE status = 'open'", + "source": "sentry" + }, + { + "id": "shape.drop_view", + "dialect": "CONSERVATIVE", + "input": "DROP VIEW open_orders", + "source": "sentry" + }, + { + "id": "shape.call", + "dialect": "CONSERVATIVE", + "input": "CALL update_stats(1, 'Zq9xK7cg')", + "secrets": ["Zq9xK7cg"], + "source": "sentry" + }, + { + "id": "shape.exec.sqlserver", + "dialect": "sqlserver", + "input": "EXEC dbo.cleanup @days = 30", + "source": "sentry" + }, + { + "id": "shape.execute.lowercase", + "dialect": "CONSERVATIVE", + "input": "execute sp_refresh 'Zq9xK7ch'", + "secrets": ["Zq9xK7ch"], + "source": "sentry" + }, + { + "id": "shape.with_cte", + "dialect": "CONSERVATIVE", + "input": "WITH recent AS (SELECT * FROM orders WHERE created > '2024-01-01') SELECT * FROM recent JOIN users ON users.id = recent.user_id", + "source": "sentry" + }, + { + "id": "shape.subquery_in", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users WHERE id IN (SELECT user_id FROM orders WHERE total > 100)", + "source": "sentry" + }, + { + "id": "shape.derived_table", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (SELECT * FROM orders) o", + "source": "sentry" + }, + { + "id": "shape.join", + "dialect": "CONSERVATIVE", + "input": "SELECT u.name, o.total FROM users u JOIN orders o ON o.user_id = u.id LEFT JOIN payments p ON p.order_id = o.id", + "source": "sentry" + }, + { + "id": "shape.implicit_join", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users u, orders o WHERE o.user_id = u.id", + "source": "sentry" + }, + { + "id": "shape.union", + "dialect": "CONSERVATIVE", + "input": "SELECT id FROM users UNION ALL SELECT id FROM admins", + "source": "sentry" + }, + { + "id": "shape.parenthesized_union", + "dialect": "CONSERVATIVE", + "input": "(SELECT id FROM users) UNION (SELECT id FROM admins)", + "source": "sentry" + }, + { + "id": "shape.multi_statement", + "dialect": "CONSERVATIVE", + "input": "INSERT INTO a VALUES (1); UPDATE b SET x = 2", + "source": "sentry" + }, + { + "id": "shape.hql.lowercase", + "dialect": "CONSERVATIVE", + "input": "from User u where u.email = :email", + "source": "sentry" + }, + { + "id": "shape.hql.uppercase", + "dialect": "CONSERVATIVE", + "input": "FROM Order WHERE total > 100", + "source": "sentry" + }, + { + "id": "shape.explain", + "dialect": "CONSERVATIVE", + "input": "EXPLAIN SELECT * FROM users WHERE id = 1", + "source": "sentry" + }, + { + "id": "shape.begin_transaction", + "dialect": "CONSERVATIVE", + "input": "BEGIN TRANSACTION", + "source": "sentry" + }, + { + "id": "shape.commit", + "dialect": "CONSERVATIVE", + "input": "COMMIT", + "source": "sentry" + }, + { + "id": "shape.rollback", + "dialect": "CONSERVATIVE", + "input": "ROLLBACK", + "source": "sentry" + }, + { + "id": "shape.savepoint.sqlite", + "dialect": "sqlite", + "input": "SAVEPOINT sp_1", + "source": "sentry" + }, + { + "id": "shape.release_savepoint.sqlite", + "dialect": "sqlite", + "input": "RELEASE SAVEPOINT sp_1", + "source": "sentry" + }, + { + "id": "shape.operation_keyword_as_table.postgresql", + "dialect": "postgresql", + "input": "INSERT INTO checkpoint (id) VALUES (1)", + "source": "sentry" + }, + { + "id": "shape.pragma.sqlite", + "dialect": "sqlite", + "input": "PRAGMA foreign_keys = ON", + "source": "sentry" + }, + { + "id": "shape.pragma_value.sqlite", + "dialect": "sqlite", + "input": "PRAGMA user_version = 3", + "source": "sentry" + }, + { + "id": "shape.pragma_optimize.sqlite", + "dialect": "sqlite", + "input": "PRAGMA optimize", + "source": "sentry" + }, + { + "id": "shape.empty_statements", + "dialect": "CONSERVATIVE", + "input": ";; SELECT * FROM t;;", + "source": "sentry" + }, + { + "id": "shape.semicolon_only", + "dialect": "CONSERVATIVE", + "input": ";", + "source": "sentry" + }, + { + "id": "allowlist.fetch.postgresql", + "dialect": "postgresql", + "input": "FETCH FORWARD 10 FROM order_cursor", + "source": "sentry" + }, + { + "id": "allowlist.close.postgresql", + "dialect": "postgresql", + "input": "CLOSE order_cursor", + "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.deallocate.postgresql", + "dialect": "postgresql", + "input": "DEALLOCATE PREPARE find_user", + "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.refresh.postgresql", + "dialect": "postgresql", + "input": "REFRESH MATERIALIZED VIEW order_totals", + "source": "sentry" + }, + { + "id": "allowlist.refresh_concurrently.postgresql", + "dialect": "postgresql", + "input": "REFRESH MATERIALIZED VIEW CONCURRENTLY order_totals", + "source": "sentry" + }, + { + "id": "allowlist.optimize.mysql", + "dialect": "mysql", + "input": "OPTIMIZE TABLE orders", + "source": "sentry" + }, + { + "id": "allowlist.checkpoint.postgresql", + "dialect": "postgresql", + "input": "CHECKPOINT", + "source": "sentry" + }, + { + "id": "allowlist.kill.mysql", + "dialect": "mysql", + "input": "KILL QUERY 48213", + "secrets": ["48213"], + "source": "sentry" + }, + { + "id": "allowlist.flush.mysql", + "dialect": "mysql", + "input": "FLUSH PRIVILEGES", + "source": "sentry" + }, + { + "id": "allowlist.reset.postgresql", + "dialect": "postgresql", + "input": "RESET search_path", + "source": "sentry" + }, + { + "id": "allowlist.discard.postgresql", + "dialect": "postgresql", + "input": "DISCARD ALL", + "source": "sentry" + }, + { + "id": "allowlist.abort.postgresql", + "dialect": "postgresql", + "input": "ABORT", + "source": "sentry" + }, + { + "id": "allowlist.xa.mysql", + "dialect": "mysql", + "input": "XA START 'Zq9xK7md'", + "secrets": ["Zq9xK7md"], + "source": "sentry" + }, + { + "id": "dialect.double_quotes.postgresql", + "dialect": "postgresql", + "input": "SELECT \"first name\" FROM \"Users\" WHERE \"id\" = 1", + "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", + "dialect": "mysql", + "input": "SELECT * FROM \"Users\"", + "source": "sentry" + }, + { + "id": "dialect.double_quotes.unknown_procedure", + "dialect": "CONSERVATIVE", + "input": "CALL \"get_user\"(?)", + "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.sqlserver", + "dialect": "sqlserver", + "input": "SELECT [first name] FROM [dbo].[Users] WHERE [id] = 1", + "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.sqlite", + "dialect": "sqlite", + "input": "SELECT [name] FROM [users] WHERE [id] = 1", + "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.h2", + "dialect": "h2", + "input": "SELECT [name] FROM t WHERE a = 1", + "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": "dialect.brackets.number.conservative", + "dialect": "CONSERVATIVE", + "input": "SELECT a[1] FROM t", + "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.unbalanced.close_paren", + "dialect": "CONSERVATIVE", + "input": "SELECT a FROM t WHERE (b = 1))", + "source": "sentry" + }, + { + "id": "malformed.empty", + "dialect": "CONSERVATIVE", + "input": "", + "source": "sentry" + }, + { + "id": "malformed.whitespace_only", + "dialect": "CONSERVATIVE", + "input": " \n\t ", + "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", + "dialect": "CONSERVATIVE", + "input": "SELECT a\ud800 FROM t", + "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.keyword_typo", + "dialect": "CONSERVATIVE", + "input": "SELEC * FROM users", + "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.limit.exact", + "dialect": "CONSERVATIVE", + "input": "SELECT a FROM t WHERE b = 'Zq9xK7fa'", + "maxQueryTextLength": 27, + "secrets": ["Zq9xK7fa"], + "source": "sentry" + }, + { + "id": "size.limit.under", + "dialect": "CONSERVATIVE", + "input": "SELECT a FROM t WHERE b = 'Zq9xK7fa'", + "maxQueryTextLength": 28, + "secrets": ["Zq9xK7fa"], + "source": "sentry" + }, + { + "id": "size.limit.one_over", + "dialect": "CONSERVATIVE", + "input": "SELECT a FROM t WHERE b = 'Zq9xK7fa'", + "maxQueryTextLength": 26, + "secrets": ["Zq9xK7fa"], + "source": "sentry" + }, + { + "id": "size.limit.first_token", + "dialect": "CONSERVATIVE", + "input": "SELECT 1", + "maxQueryTextLength": 4, + "source": "sentry" + }, + { + "id": "size.limit.stop_over_limit", + "dialect": "CONSERVATIVE", + "input": "SELECT a FROM t WHERE b IN ('Zq9xK7fb", + "maxQueryTextLength": 28, + "secrets": ["Zq9xK7fb"], + "source": "sentry" + }, + { + "id": "size.limit.dcl_before_credential.postgresql", + "dialect": "postgresql", + "input": "CREATE USER Zq9xK7oa IDENTIFIED BY 'Zq9xK7ob'", + "maxQueryTextLength": 20, + "secrets": ["Zq9xK7oa", "Zq9xK7ob"], + "source": "sentry" + }, + { + "id": "size.limit.before_first_keyword", + "dialect": "CONSERVATIVE", + "input": "{? = call calc_total(?, ?)}", + "maxQueryTextLength": 4, + "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.insert_entity", + "dialect": "sqlite", + "input": "INSERT OR ABORT INTO `song` (`id`,`title`,`artist`) VALUES (nullif(?, 0),?,?)", + "source": "sentry" + }, + { + "id": "workload.room.insert_batch", + "dialect": "sqlite", + "input": "INSERT INTO song(title, artist) VALUES (?, ?), (?, ?), (?, ?)", + "source": "sentry" + }, + { + "id": "workload.room.count", + "dialect": "sqlite", + "input": "SELECT count(*) FROM song", + "source": "sentry" + }, + { + "id": "workload.room.prime_writer", + "dialect": "sqlite", + "input": "DELETE FROM song WHERE id < 0", + "source": "sentry" + }, + { + "id": "workload.room.query_in_list", + "dialect": "sqlite", + "input": "SELECT * FROM song WHERE id IN (?,?,?) ORDER BY title COLLATE NOCASE LIMIT 20", + "source": "sentry" + }, + { + "id": "workload.room.master_table_create", + "dialect": "sqlite", + "input": "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "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.room.modification_log_create", + "dialect": "sqlite", + "input": "CREATE TEMP TABLE room_table_modification_log (table_id INTEGER PRIMARY KEY, invalidated INTEGER NOT NULL DEFAULT 0)", + "source": "sentry" + }, + { + "id": "workload.room.invalidation_trigger", + "dialect": "sqlite", + "input": "CREATE TEMP TRIGGER IF NOT EXISTS `room_table_modification_trigger_song_INSERT` AFTER INSERT ON `song` BEGIN UPDATE room_table_modification_log SET invalidated = 1 WHERE table_id = 0 AND invalidated = 0; END", + "source": "sentry" + }, + { + "id": "workload.room.modification_log_reset", + "dialect": "sqlite", + "input": "UPDATE room_table_modification_log SET invalidated = 0 WHERE invalidated = 1", + "source": "sentry" + }, + { + "id": "workload.room.pragma_temp_store", + "dialect": "sqlite", + "input": "PRAGMA temp_store = MEMORY;", + "source": "sentry" + }, + { + "id": "workload.room.begin_immediate", + "dialect": "sqlite", + "input": "BEGIN IMMEDIATE TRANSACTION", + "source": "sentry" + }, + { + "id": "workload.room.migration_double_quoted", + "dialect": "sqlite", + "input": "CREATE TABLE \"order\" (\"id\" INTEGER PRIMARY KEY, \"user\" TEXT)", + "source": "sentry" + }, + { + "id": "workload.hibernate.find_by_id_join", + "dialect": "postgresql", + "input": "select p1_0.id,p1_0.email,p1_0.first_name,a1_0.id,a1_0.city from person p1_0 left join address a1_0 on a1_0.id=p1_0.address_id where p1_0.id=?", + "source": "sentry" + }, + { + "id": "workload.hibernate.insert", + "dialect": "postgresql", + "input": "insert into person (address_id,email,first_name,version,id) values (?,?,?,?,?)", + "source": "sentry" + }, + { + "id": "workload.hibernate.update_versioned", + "dialect": "postgresql", + "input": "update person set email=?,first_name=?,version=? where id=? and version=?", + "source": "sentry" + }, + { + "id": "workload.hibernate.delete", + "dialect": "postgresql", + "input": "delete from person where id=?", + "source": "sentry" + }, + { + "id": "workload.hibernate.sequence", + "dialect": "postgresql", + "input": "select nextval('Zq9xK7vc')", + "secrets": ["Zq9xK7vc"], + "source": "sentry" + }, + { + "id": "workload.hibernate.page_like", + "dialect": "postgresql", + "input": "select p1_0.id,p1_0.email from person p1_0 where p1_0.email like ? escape '' order by p1_0.id offset ? rows fetch first ? rows only", + "source": "sentry" + }, + { + "id": "workload.hibernate.in_padding", + "dialect": "postgresql", + "input": "select p1_0.id,p1_0.email from person p1_0 where p1_0.id in (?,?,?,?)", + "source": "sentry" + }, + { + "id": "workload.hibernate.count_subquery", + "dialect": "postgresql", + "input": "select count(o1_0.id) from orders o1_0 where o1_0.customer_id in (select c1_0.id from customer c1_0 where c1_0.region=?)", + "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.hibernate.limit.mysql", + "dialect": "mysql", + "input": "select p1_0.id,p1_0.email from person p1_0 order by p1_0.id limit ?,?", + "source": "sentry" + }, + { + "id": "workload.hibernate.quoted_reserved.mysql", + "dialect": "mysql", + "input": "insert into `order` (`customer_id`,`status`,`id`) values (?,?,?)", + "source": "sentry" + }, + { + "id": "workload.hibernate.top.sqlserver", + "dialect": "sqlserver", + "input": "select top(?) p1_0.id,p1_0.email from person p1_0 where p1_0.email=?", + "source": "sentry" + }, + { + "id": "workload.hibernate.lock_hint.sqlserver", + "dialect": "sqlserver", + "input": "select p1_0.id,p1_0.version from person p1_0 with (updlock,holdlock,rowlock) where p1_0.id=?", + "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.cte_window", + "dialect": "postgresql", + "input": "WITH ranked AS (SELECT o.id, o.customer_id, row_number() OVER (PARTITION BY o.customer_id ORDER BY o.created_at DESC) AS rn FROM orders o WHERE o.status = ANY(?)) SELECT id, customer_id FROM ranked WHERE rn = 1", + "source": "sentry" + }, + { + "id": "workload.postgresql.search_page", + "dialect": "postgresql", + "input": "SELECT id, email FROM users WHERE email ILIKE ? AND deleted_at IS NULL ORDER BY email LIMIT 20 OFFSET 40", + "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.advisory_lock", + "dialect": "postgresql", + "input": "SELECT pg_try_advisory_xact_lock(?)", + "source": "sentry" + }, + { + "id": "workload.postgresql.create_table", + "dialect": "postgresql", + "input": "CREATE TABLE IF NOT EXISTS orders (id BIGSERIAL PRIMARY KEY, customer_id BIGINT NOT NULL REFERENCES customers (id), total NUMERIC(12, 2) NOT NULL DEFAULT 0, created_at TIMESTAMPTZ NOT NULL DEFAULT now())", + "source": "sentry" + }, + { + "id": "workload.postgresql.create_index", + "dialect": "postgresql", + "input": "CREATE INDEX IF NOT EXISTS idx_orders_customer ON orders (customer_id, created_at DESC)", + "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.quoted_identifiers", + "dialect": "postgresql", + "input": "SELECT \"u\".\"id\", \"u\".\"displayName\" FROM \"public\".\"User\" AS \"u\" WHERE \"u\".\"email\" = ?", + "source": "sentry" + }, + { + "id": "workload.postgresql.listen", + "dialect": "postgresql", + "input": "LISTEN order_events", + "source": "sentry" + }, + { + "id": "workload.postgresql.unlisten", + "dialect": "postgresql", + "input": "UNLISTEN order_events", + "source": "sentry" + }, + { + "id": "workload.postgresql.notify", + "dialect": "postgresql", + "input": "NOTIFY order_events, 'Zq9xK7vj'", + "secrets": ["Zq9xK7vj"], + "source": "sentry" + }, + { + "id": "workload.mysql.upsert_counter", + "dialect": "mysql", + "input": "INSERT INTO page_views (page_id, day, views) VALUES (?, CURDATE(), 1) ON DUPLICATE KEY UPDATE views = views + 1", + "source": "sentry" + }, + { + "id": "workload.mysql.backticks", + "dialect": "mysql", + "input": "SELECT `id`, `name`, `price` FROM `products` WHERE `category_id` = ? AND `price` BETWEEN 10 AND 20 ORDER BY `name` LIMIT 10", + "source": "sentry" + }, + { + "id": "workload.mysql.interval", + "dialect": "mysql", + "input": "SELECT COUNT(*) FROM orders WHERE created_at >= NOW() - INTERVAL 1 DAY", + "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.stock_decrement", + "dialect": "mysql", + "input": "UPDATE inventory SET stock = stock - ? WHERE sku = ? AND stock >= ?", + "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.mysql.multi_table_delete", + "dialect": "mysql", + "input": "DELETE o FROM orders o JOIN customers c ON c.id = o.customer_id WHERE c.deleted_at IS NOT NULL", + "source": "sentry" + }, + { + "id": "workload.mysql.insert_ignore", + "dialect": "mysql", + "input": "INSERT IGNORE INTO tags (name) VALUES (?)", + "source": "sentry" + }, + { + "id": "workload.mysql.start_transaction", + "dialect": "mysql", + "input": "START TRANSACTION", + "source": "sentry" + }, + { + "id": "workload.mysql.set_names", + "dialect": "mysql", + "input": "SET NAMES utf8mb4", + "source": "sentry" + }, + { + "id": "workload.mysql.call_procedure", + "dialect": "mysql", + "input": "CALL refresh_daily_stats(?, ?)", + "source": "sentry" + }, + { + "id": "workload.sqlc.get_author", + "dialect": "postgresql", + "input": "-- name: GetAuthor :one\nSELECT id, name, bio FROM authors\nWHERE id = ? LIMIT 1", + "source": "sentry" + }, + { + "id": "workload.sqlc.list_authors", + "dialect": "postgresql", + "input": "-- name: ListAuthors :many\nSELECT id, name, bio FROM authors\nORDER BY name", + "source": "sentry" + }, + { + "id": "workload.sqlc.create_author", + "dialect": "postgresql", + "input": "-- name: CreateAuthor :one\nINSERT INTO authors (\n name, bio\n) VALUES (\n ?, ?\n)\nRETURNING id, name, bio", + "source": "sentry" + }, + { + "id": "workload.sqlc.delete_author", + "dialect": "postgresql", + "input": "-- name: DeleteAuthor :exec\nDELETE FROM authors\nWHERE id = ?", + "source": "sentry" + }, + { + "id": "workload.sqlc.update_bios", + "dialect": "postgresql", + "input": "-- name: UpdateAuthorBios :execrows\nUPDATE authors SET bio = ?\nWHERE bio IS NOT NULL", + "source": "sentry" + }, + { + "id": "workload.sqlc.books_by_titles", + "dialect": "postgresql", + "input": "-- name: ListBooksByTitles :many\nSELECT book_id, title FROM books\nWHERE title = ANY(?::varchar[])", + "source": "sentry" + }, + { + "id": "workload.sqlc.count_join", + "dialect": "postgresql", + "input": "-- name: CountAuthorsByCountry :one\nSELECT count(*) FROM authors a\nJOIN countries c ON c.id = a.country_id\nWHERE c.code = ?", + "source": "sentry" + }, + { + "id": "workload.sqlc.get_user.mysql", + "dialect": "mysql", + "input": "-- name: GetUserByEmail :one\nSELECT id, email FROM users\nWHERE email = ? LIMIT 1", + "source": "sentry" + }, + { + "id": "workload.sqlserver.top_nolock", + "dialect": "sqlserver", + "input": "SELECT TOP (10) [o].[Id], [o].[Total] FROM [dbo].[Orders] AS [o] WITH (NOLOCK) WHERE [o].[CustomerId] = ? ORDER BY [o].[CreatedAt] DESC", + "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.update_counter", + "dialect": "sqlserver", + "input": "UPDATE [dbo].[Users] SET [LastLoginAt] = GETDATE(), [LoginCount] = [LoginCount] + 1 WHERE [Id] = ?", + "source": "sentry" + }, + { + "id": "workload.sqlserver.merge_values", + "dialect": "sqlserver", + "input": "MERGE INTO [dbo].[Inventory] AS [t] USING (VALUES (?, ?)) AS [s] ([Sku], [Qty]) ON [t].[Sku] = [s].[Sku] WHEN MATCHED THEN UPDATE SET [t].[Qty] = [s].[Qty] WHEN NOT MATCHED THEN INSERT ([Sku], [Qty]) VALUES ([s].[Sku], [s].[Qty]);", + "source": "sentry" + }, + { + "id": "workload.sqlserver.exec_procedure", + "dialect": "sqlserver", + "input": "EXEC [dbo].[usp_GetOrders] @CustomerId = ?, @Status = N'Zq9xK7vo'", + "secrets": ["Zq9xK7vo"], + "source": "sentry" + }, + { + "id": "workload.sqlserver.temp_table_insert", + "dialect": "sqlserver", + "input": "INSERT INTO #recent ([Id]) SELECT [Id] FROM [dbo].[Orders] WHERE [CreatedAt] > DATEADD(day, -7, GETDATE())", + "source": "sentry" + }, + { + "id": "workload.sqlserver.brackets_with_spaces", + "dialect": "sqlserver", + "input": "SELECT [Order Id], [Customer's Name] FROM [Sales].[Order Details] WHERE [Unit Price] > ?", + "source": "sentry" + }, + { + "id": "workload.sqlserver.set_nocount", + "dialect": "sqlserver", + "input": "SET NOCOUNT ON; SELECT [Id], [Payload] FROM [dbo].[Jobs] WHERE [State] = ?", + "source": "sentry" + }, + { + "id": "workload.tooling.flyway_history.postgresql", + "dialect": "postgresql", + "input": "SELECT \"installed_rank\",\"version\",\"description\",\"type\",\"script\",\"checksum\",\"installed_on\",\"installed_by\",\"execution_time\",\"success\" FROM \"public\".\"flyway_schema_history\" WHERE \"installed_rank\" > ? ORDER BY \"installed_rank\"", + "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": "workload.tooling.shedlock.postgresql", + "dialect": "postgresql", + "input": "INSERT INTO shedlock (name, lock_until, locked_at, locked_by) VALUES(?, ?, ?, ?) ON CONFLICT (name) DO UPDATE SET lock_until = ?, locked_at = ?, locked_by = ? WHERE shedlock.lock_until <= ?", + "source": "sentry" + }, + { + "id": "workload.tooling.hikari_test_query.mysql", + "dialect": "mysql", + "input": "SELECT 1", + "source": "sentry" + }, + { + "id": "workload.tooling.hikari_init_sql.postgresql", + "dialect": "postgresql", + "input": "SET search_path TO app, public", + "source": "sentry" + }, + { + "id": "workload.tooling.spring_sample_insert.hsqldb", + "dialect": "hsqldb", + "input": "insert into person (firstName, lastName) values (?, ?)", + "source": "sentry" + }, + { + "id": "workload.tooling.spring_sample_schema.hsqldb", + "dialect": "hsqldb", + "input": "CREATE TABLE person (\n id INTEGER IDENTITY PRIMARY KEY,\n firstName VARCHAR(50) NOT NULL,\n lastName VARCHAR(50) NOT NULL\n)", + "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.006", + "dialect": "CONSERVATIVE", + "input": "SELECT 1.2", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[6]" + }, + { + "id": "otel_java.sanitize_sql.007", + "dialect": "CONSERVATIVE", + "input": "SELECT -1.2", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[7]" + }, + { + "id": "otel_java.sanitize_sql.008", + "dialect": "CONSERVATIVE", + "input": "SELECT -1.2e-9", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[8]" + }, + { + "id": "otel_java.sanitize_sql.009", + "dialect": "CONSERVATIVE", + "input": "SELECT 2E+9", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[9]" + }, + { + "id": "otel_java.sanitize_sql.010", + "dialect": "CONSERVATIVE", + "input": "SELECT +0.2", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[10]" + }, + { + "id": "otel_java.sanitize_sql.011", + "dialect": "CONSERVATIVE", + "input": "SELECT .2", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[11]" + }, + { + "id": "otel_java.sanitize_sql.012", + "dialect": "CONSERVATIVE", + "input": "7", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[12]" + }, + { + "id": "otel_java.sanitize_sql.013", + "dialect": "CONSERVATIVE", + "input": ".7", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[13]" + }, + { + "id": "otel_java.sanitize_sql.014", + "dialect": "CONSERVATIVE", + "input": "-7", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[14]" + }, + { + "id": "otel_java.sanitize_sql.015", + "dialect": "CONSERVATIVE", + "input": "+7", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[15]" + }, + { + "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.018", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM \"TABLE\"", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[18]" + }, + { + "id": "otel_java.sanitize_sql.019", + "dialect": "CONSERVATIVE", + "input": "SELECT A + B", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[19]" + }, + { + "id": "otel_java.sanitize_sql.020", + "dialect": "CONSERVATIVE", + "input": "SELECT -- comment", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[20]" + }, + { + "id": "otel_java.sanitize_sql.021", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLE123", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[21]" + }, + { + "id": "otel_java.sanitize_sql.022", + "dialect": "CONSERVATIVE", + "input": "SELECT FIELD2 FROM TABLE_123 WHERE X<>7", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[22]" + }, + { + "id": "otel_java.sanitize_sql.023", + "dialect": "CONSERVATIVE", + "input": "SELECT DEADBEEF", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[23]" + }, + { + "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.025", + "dialect": "CONSERVATIVE", + "input": "SELECT 1/2/34", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[25]" + }, + { + "id": "otel_java.sanitize_sql.026", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLE WHERE FIELD = ''", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[26]" + }, + { + "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.029", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLE WHERE FIELD = '\\\\'", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[29]" + }, + { + "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.033", + "dialect": "postgresql", + "input": "SELECT * FROM TABLE WHERE FIELD = $$$$", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[33]" + }, + { + "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.037", + "dialect": "postgresql", + "input": "SELECT * FROM TABLE WHERE FIELD = $$\\\\$$", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[37]" + }, + { + "id": "otel_java.sanitize_sql.038", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLE WHERE FIELD = $1", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[38]" + }, + { + "id": "otel_java.sanitize_sql.039", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLEओ7 WHERE FIELD = 'ɣ'", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[39]" + }, + { + "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.001", + "dialect": "CONSERVATIVE", + "input": "SELECT x, y, z FROM schema.table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[1]" + }, + { + "id": "otel_java.simplify_sql.002", + "dialect": "CONSERVATIVE", + "input": "SELECT x, y, z FROM `schema table`", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[2]" + }, + { + "id": "otel_java.simplify_sql.003", + "dialect": "CONSERVATIVE", + "input": "SELECT x, y, z FROM `schema`.`table`", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[3]" + }, + { + "id": "otel_java.simplify_sql.004", + "dialect": "CONSERVATIVE", + "input": "SELECT x, y, z FROM \"schema table\"", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[4]" + }, + { + "id": "otel_java.simplify_sql.005", + "dialect": "CONSERVATIVE", + "input": "SELECT x, y, z FROM \"schema\".\"table\"", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[5]" + }, + { + "id": "otel_java.simplify_sql.006", + "dialect": "CONSERVATIVE", + "input": "WITH subquery as (select a from b) SELECT x, y, z FROM table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[6]" + }, + { + "id": "otel_java.simplify_sql.007", + "dialect": "CONSERVATIVE", + "input": "SELECT x, y, (select a from b) as z FROM table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[7]" + }, + { + "id": "otel_java.simplify_sql.008", + "dialect": "CONSERVATIVE", + "input": "select delete, insert into, merge, update from table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[8]" + }, + { + "id": "otel_java.simplify_sql.009", + "dialect": "CONSERVATIVE", + "input": "select col /* from table2 */ from table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[9]" + }, + { + "id": "otel_java.simplify_sql.010", + "dialect": "CONSERVATIVE", + "input": "select col from table join anotherTable", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[10]" + }, + { + "id": "otel_java.simplify_sql.011", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id JOIN t3 ON t2.x = t3.x", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[11]" + }, + { + "id": "otel_java.simplify_sql.012", + "dialect": "CONSERVATIVE", + "input": "select col from (select * from anotherTable)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[12]" + }, + { + "id": "otel_java.simplify_sql.013", + "dialect": "CONSERVATIVE", + "input": "select col from (select * from anotherTable) alias", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[13]" + }, + { + "id": "otel_java.simplify_sql.014", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (SELECT * FROM t1) sub, t3", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[14]" + }, + { + "id": "otel_java.simplify_sql.015", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (SELECT * FROM t1) s1, (SELECT * FROM t2) s2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[15]" + }, + { + "id": "otel_java.simplify_sql.016", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (SELECT * FROM t1) sub, t2 JOIN t3 ON t2.id = t3.id", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[16]" + }, + { + "id": "otel_java.simplify_sql.017", + "dialect": "CONSERVATIVE", + "input": "select col from table1 union select col from table2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[17]" + }, + { + "id": "otel_java.simplify_sql.018", + "dialect": "CONSERVATIVE", + "input": "SELECT id, name FROM employees UNION ALL SELECT id, name FROM contractors UNION SELECT id, name FROM vendors", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[18]" + }, + { + "id": "otel_java.simplify_sql.019", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (t UNION SELECT * FROM t2), t3", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[19]" + }, + { + "id": "otel_java.simplify_sql.020", + "dialect": "CONSERVATIVE", + "input": "select id, (select max(foo) from (select foo from foos union all select foo from bars)) as foo from main_table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[20]" + }, + { + "id": "otel_java.simplify_sql.021", + "dialect": "CONSERVATIVE", + "input": "select col from table where col in (select * from anotherTable)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[21]" + }, + { + "id": "otel_java.simplify_sql.022", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (SELECT * FROM inner1 JOIN inner2 ON inner1.id = inner2.id) AS sub", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[22]" + }, + { + "id": "otel_java.simplify_sql.023", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (VALUES (1,2), (3,4)) AS t(a, b)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[23]" + }, + { + "id": "otel_java.simplify_sql.024", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 CROSS APPLY t2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[24]" + }, + { + "id": "otel_java.simplify_sql.025", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 OUTER APPLY (SELECT * FROM t2 WHERE t2.id = t1.id)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[25]" + }, + { + "id": "otel_java.simplify_sql.026", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1, LATERAL (SELECT * FROM t2 WHERE t2.id = t1.id)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[26]" + }, + { + "id": "otel_java.simplify_sql.027", + "dialect": "CONSERVATIVE", + "input": "select col from table1, table2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[27]" + }, + { + "id": "otel_java.simplify_sql.028", + "dialect": "CONSERVATIVE", + "input": "select col from table1 t1, table2 t2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[28]" + }, + { + "id": "otel_java.simplify_sql.029", + "dialect": "CONSERVATIVE", + "input": "select col from table1 as t1, table2 as t2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[29]" + }, + { + "id": "otel_java.simplify_sql.030", + "dialect": "CONSERVATIVE", + "input": "select col from table where col in (1, 2, 3)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[30]" + }, + { + "id": "otel_java.simplify_sql.031", + "dialect": "CONSERVATIVE", + "input": "select 'a' IN(x, 'b') from table where col in (1) and z IN( '3', '4' )", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[31]" + }, + { + "id": "otel_java.simplify_sql.032", + "dialect": "CONSERVATIVE", + "input": "select col from table order by col, col2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[32]" + }, + { + "id": "otel_java.simplify_sql.033", + "dialect": "CONSERVATIVE", + "input": "select ąś∂ń© from źćļńĶ order by col, col2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[33]" + }, + { + "id": "otel_java.simplify_sql.034", + "dialect": "CONSERVATIVE", + "input": "select 12345678", + "secrets": ["12345678"], + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[34]" + }, + { + "id": "otel_java.simplify_sql.035", + "dialect": "CONSERVATIVE", + "input": "/* update comment */ select * from table1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[35]" + }, + { + "id": "otel_java.simplify_sql.036", + "dialect": "CONSERVATIVE", + "input": "select /*((*/abc from table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[36]" + }, + { + "id": "otel_java.simplify_sql.037", + "dialect": "CONSERVATIVE", + "input": "SeLeCT * FrOm TAblE", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[37]" + }, + { + "id": "otel_java.simplify_sql.038", + "dialect": "CONSERVATIVE", + "input": "select next value in hibernate_sequence", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[38]" + }, + { + "id": "otel_java.simplify_sql.039", + "dialect": "CONSERVATIVE", + "input": "EXPLAIN SELECT * FROM users", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[39]" + }, + { + "id": "otel_java.simplify_sql.040", + "dialect": "CONSERVATIVE", + "input": "from schema.table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[40]" + }, + { + "id": "otel_java.simplify_sql.041", + "dialect": "CONSERVATIVE", + "input": "FROM schema.table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[41]" + }, + { + "id": "otel_java.simplify_sql.042", + "dialect": "CONSERVATIVE", + "input": "/* update comment */ from table1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[42]" + }, + { + "id": "otel_java.simplify_sql.043", + "dialect": "CONSERVATIVE", + "input": " insert into table where lalala", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[43]" + }, + { + "id": "otel_java.simplify_sql.044", + "dialect": "CONSERVATIVE", + "input": "insert into metrics.users (id) values (1)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[44]" + }, + { + "id": "otel_java.simplify_sql.045", + "dialect": "CONSERVATIVE", + "input": "insert insert into table where lalala", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[45]" + }, + { + "id": "otel_java.simplify_sql.046", + "dialect": "CONSERVATIVE", + "input": "insert into db.table where lalala", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[46]" + }, + { + "id": "otel_java.simplify_sql.047", + "dialect": "CONSERVATIVE", + "input": "insert into `db table` where lalala", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[47]" + }, + { + "id": "otel_java.simplify_sql.048", + "dialect": "CONSERVATIVE", + "input": "insert into \"db table\" where lalala", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[48]" + }, + { + "id": "otel_java.simplify_sql.049", + "dialect": "CONSERVATIVE", + "input": "insert without i-n-t-o", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[49]" + }, + { + "id": "otel_java.simplify_sql.050", + "dialect": "CONSERVATIVE", + "input": "delete from table where something something", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[50]" + }, + { + "id": "otel_java.simplify_sql.051", + "dialect": "CONSERVATIVE", + "input": "delete from `my table` where something something", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[51]" + }, + { + "id": "otel_java.simplify_sql.052", + "dialect": "CONSERVATIVE", + "input": "delete from \"my table\" where something something", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[52]" + }, + { + "id": "otel_java.simplify_sql.053", + "dialect": "CONSERVATIVE", + "input": "delete from foo where x IN (1,2,3)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[53]" + }, + { + "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.055", + "dialect": "CONSERVATIVE", + "input": "delete (((", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[55]" + }, + { + "id": "otel_java.simplify_sql.056", + "dialect": "CONSERVATIVE", + "input": "update table set answer=42", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[56]" + }, + { + "id": "otel_java.simplify_sql.057", + "dialect": "CONSERVATIVE", + "input": "update `my table` set answer=42", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[57]" + }, + { + "id": "otel_java.simplify_sql.058", + "dialect": "CONSERVATIVE", + "input": "update `my table` set answer=42 where x IN('a', 'b') AND y In ('a', 'b')", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[58]" + }, + { + "id": "otel_java.simplify_sql.059", + "dialect": "CONSERVATIVE", + "input": "update \"my table\" set answer=42", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[59]" + }, + { + "id": "otel_java.simplify_sql.060", + "dialect": "CONSERVATIVE", + "input": "update /*table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[60]" + }, + { + "id": "otel_java.simplify_sql.061", + "dialect": "CONSERVATIVE", + "input": "call test_proc()", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[61]" + }, + { + "id": "otel_java.simplify_sql.062", + "dialect": "CONSERVATIVE", + "input": "call test_proc", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[62]" + }, + { + "id": "otel_java.simplify_sql.063", + "dialect": "CONSERVATIVE", + "input": "call next value for hibernate_sequence", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[63]" + }, + { + "id": "otel_java.simplify_sql.064", + "dialect": "CONSERVATIVE", + "input": "call db.test_proc", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[64]" + }, + { + "id": "otel_java.simplify_sql.065", + "dialect": "CONSERVATIVE", + "input": "merge into table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[65]" + }, + { + "id": "otel_java.simplify_sql.066", + "dialect": "CONSERVATIVE", + "input": "merge into `my table`", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[66]" + }, + { + "id": "otel_java.simplify_sql.067", + "dialect": "CONSERVATIVE", + "input": "merge into \"my table\"", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[67]" + }, + { + "id": "otel_java.simplify_sql.068", + "dialect": "CONSERVATIVE", + "input": "merge table (into is optional in some dbs)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[68]" + }, + { + "id": "otel_java.simplify_sql.069", + "dialect": "CONSERVATIVE", + "input": "merge (into )))", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[69]" + }, + { + "id": "otel_java.simplify_sql.070", + "dialect": "CONSERVATIVE", + "input": "and now for something completely different", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[70]" + }, + { + "id": "otel_java.simplify_sql.073", + "dialect": "CONSERVATIVE", + "input": "INSERT INTO t1 SELECT * FROM t2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[73]" + }, + { + "id": "otel_java.simplify_sql.074", + "dialect": "CONSERVATIVE", + "input": "DELETE FROM t1 WHERE x IN (SELECT y FROM t2)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[74]" + }, + { + "id": "otel_java.simplify_sql.075", + "dialect": "CONSERVATIVE", + "input": "UPDATE t1 SET x = (SELECT y FROM t2)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[75]" + }, + { + "id": "otel_java.simplify_sql.076", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1; SELECT * FROM t2", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[76]" + }, + { + "id": "otel_java.simplify_sql.077", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1; INSERT INTO t2 VALUES (1)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[77]" + }, + { + "id": "otel_java.simplify_sql.078", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t;", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[78]" + }, + { + "id": "otel_java.simplify_sql.079", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t;;", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[79]" + }, + { + "id": "otel_java.simplify_sql.080", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM ONLY parent", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[80]" + }, + { + "id": "otel_java.simplify_sql.081", + "dialect": "CONSERVATIVE", + "input": "DELETE FROM ONLY parent WHERE id = 1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[81]" + }, + { + "id": "otel_java.simplify_sql.082", + "dialect": "CONSERVATIVE", + "input": "UPDATE ONLY parent SET x = 1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[82]" + }, + { + "id": "otel_java.simplify_sql.083", + "dialect": "CONSERVATIVE", + "input": "VALUES (1)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[83]" + }, + { + "id": "otel_java.simplify_sql.084", + "dialect": "CONSERVATIVE", + "input": "VALUES (1, 'a'), (2, 'b')", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[84]" + }, + { + "id": "otel_java.simplify_sql.085", + "dialect": "CONSERVATIVE", + "input": "EXEC my_procedure", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[85]" + }, + { + "id": "otel_java.simplify_sql.086", + "dialect": "CONSERVATIVE", + "input": "EXECUTE db.my_procedure @param=1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[86]" + }, + { + "id": "otel_java.simplify_sql.087", + "dialect": "sqlserver", + "input": "SELECT * FROM [my table]", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[87]" + }, + { + "id": "otel_java.simplify_sql.088", + "dialect": "sqlserver", + "input": "SELECT * FROM [schema].[table]", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[88]" + }, + { + "id": "otel_java.simplify_sql.089", + "dialect": "sqlserver", + "input": "SELECT [column] FROM [table] WHERE [field] = 1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[89]" + }, + { + "id": "otel_java.simplify_sql.090", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM `my``table`", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[90]" + }, + { + "id": "otel_java.simplify_sql.091", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM `table` WHERE `col``name` = 1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[91]" + }, + { + "id": "otel_java.simplify_sql.093", + "dialect": "CONSERVATIVE", + "input": ";;", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[93]" + }, + { + "id": "otel_java.simplify_sql.094", + "dialect": "CONSERVATIVE", + "input": " ; ", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[94]" + }, + { + "id": "otel_java.simplify_sql.095", + "dialect": "CONSERVATIVE", + "input": "/* comment only */", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[95]" + }, + { + "id": "otel_java.simplify_sql.096", + "dialect": "CONSERVATIVE", + "input": " ", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[96]" + }, + { + "id": "otel_java.simplify_sql.098", + "dialect": "CONSERVATIVE", + "input": "-- This query will DELETE old records\nSELECT * FROM users WHERE active = 1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[98]" + }, + { + "id": "otel_java.simplify_sql.099", + "dialect": "postgresql", + "input": "--This query will DELETE old records\nSELECT * FROM users WHERE active = 1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[99]" + }, + { + "id": "otel_java.simplify_sql.100", + "dialect": "postgresql", + "input": "SELECT --83", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[100]" + }, + { + "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.103", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM a, (SELECT * FROM b), c", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[103]" + }, + { + "id": "otel_java.simplify_sql.104", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (SELECT * FROM inner1), (SELECT * FROM inner2), outer_table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[104]" + }, + { + "id": "otel_java.simplify_sql.105", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (TABLE)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[105]" + }, + { + "id": "otel_java.simplify_sql.106", + "dialect": "CONSERVATIVE", + "input": "TRUNCATE TABLE users", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[106]" + }, + { + "id": "otel_java.simplify_sql.107", + "dialect": "CONSERVATIVE", + "input": "TRUNCATE users", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[107]" + }, + { + "id": "otel_java.simplify_sql.108", + "dialect": "CONSERVATIVE", + "input": "TRUNCATE TABLE schema.table", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[108]" + }, + { + "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.110", + "dialect": "CONSERVATIVE", + "input": "REPLACE users SET name = 'foo'", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[110]" + }, + { + "id": "otel_java.simplify_sql.111", + "dialect": "CONSERVATIVE", + "input": "REPLACE INTO db.table (col) VALUES (1)", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[111]" + }, + { + "id": "otel_java.simplify_sql.112", + "dialect": "CONSERVATIVE", + "input": "BEGIN", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[112]" + }, + { + "id": "otel_java.simplify_sql.115", + "dialect": "CONSERVATIVE", + "input": "COMMIT TRANSACTION", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[115]" + }, + { + "id": "otel_java.simplify_sql.117", + "dialect": "CONSERVATIVE", + "input": "ROLLBACK TRANSACTION", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[117]" + }, + { + "id": "otel_java.simplify_sql.118", + "dialect": "CONSERVATIVE", + "input": "LOCK TABLE users", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[118]" + }, + { + "id": "otel_java.simplify_sql.119", + "dialect": "CONSERVATIVE", + "input": "LOCK TABLE users IN EXCLUSIVE MODE", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[119]" + }, + { + "id": "otel_java.simplify_sql.120", + "dialect": "CONSERVATIVE", + "input": "LOCK TABLES users WRITE, orders READ", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[120]" + }, + { + "id": "otel_java.simplify_sql.121", + "dialect": "CONSERVATIVE", + "input": "USE mydb", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[121]" + }, + { + "id": "otel_java.simplify_sql.122", + "dialect": "CONSERVATIVE", + "input": "USE `my database`", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[122]" + }, + { + "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.simplify_sql.127", + "dialect": "CONSERVATIVE", + "input": "SHOW TABLES", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[127]" + }, + { + "id": "otel_java.simplify_sql.128", + "dialect": "CONSERVATIVE", + "input": "SHOW CREATE TABLE users", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[128]" + }, + { + "id": "otel_java.simplify_sql.129", + "dialect": "CONSERVATIVE", + "input": "SHOW DATABASES", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[129]" + }, + { + "id": "otel_java.simplify_sql.130", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM insert WHERE x = 1", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[130]" + }, + { + "id": "otel_java.simplify_sql.131", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM update", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[131]" + }, + { + "id": "otel_java.simplify_sql.132", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM delete", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[132]" + }, + { + "id": "otel_java.simplify_sql.133", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM call", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[133]" + }, + { + "id": "otel_java.simplify_sql.134", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM merge", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[134]" + }, + { + "id": "otel_java.simplify_sql.135", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM create", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[135]" + }, + { + "id": "otel_java.simplify_sql.136", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM drop", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[136]" + }, + { + "id": "otel_java.simplify_sql.137", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM alter", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[137]" + }, + { + "id": "otel_java.simplify_sql.138", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM exec", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[138]" + }, + { + "id": "otel_java.simplify_sql.139", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM execute", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[139]" + }, + { + "id": "otel_java.simplify_sql.140", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users@remote_db", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[140]" + }, + { + "id": "otel_java.simplify_sql.141", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM schema.users@remote_db", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[141]" + }, + { + "id": "otel_java.simplify_sql.142", + "dialect": "CONSERVATIVE", + "input": "SELECT insert, update FROM mytable", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[142]" + }, + { + "id": "otel_java.simplify_sql.143", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM mytable insert", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[143]" + }, + { + "id": "otel_java.simplify_sql.144", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM mytable AS update", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[144]" + }, + { + "id": "otel_java.simplify_sql.145", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM user", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[145]" + }, + { + "id": "otel_java.simplify_sql.146", + "dialect": "CONSERVATIVE", + "input": "WITH cte AS (SELECT a FROM b) SELECT * FROM cte", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[146]" + }, + { + "id": "otel_java.simplify_sql.147", + "dialect": "CONSERVATIVE", + "input": "WITH cte AS (VALUES (1, 'a'), (2, 'b')) SELECT * FROM cte", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[147]" + }, + { + "id": "otel_java.simplify_sql.148", + "dialect": "CONSERVATIVE", + "input": "WITH a AS (SELECT * FROM t1), b AS (SELECT * FROM t2) SELECT * FROM a JOIN b ON a.id = b.id", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[148]" + }, + { + "id": "otel_java.simplify_sql.149", + "dialect": "CONSERVATIVE", + "input": "WITH RECURSIVE cte AS (SELECT id FROM t WHERE parent IS NULL UNION ALL SELECT t.id FROM t JOIN cte ON t.parent = cte.id) SELECT * FROM cte", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[149]" + }, + { + "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.015", + "dialect": "CONSERVATIVE", + "input": "GRANT SELECT ON users TO admin; SELECT password FROM users", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[15]" + }, + { + "id": "otel_java.sanitize_sensitive.016", + "dialect": "CONSERVATIVE", + "input": "SELECT connect FROM TABLE", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[16]" + }, + { + "id": "otel_java.sanitize_sensitive.017", + "dialect": "CONSERVATIVE", + "input": "SELECT grant, password FROM users", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[17]" + }, + { + "id": "otel_java.sanitize_sensitive.018", + "dialect": "CONSERVATIVE", + "input": "SELECT password FROM users", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[18]" + }, + { + "id": "otel_java.sanitize_sensitive.019", + "dialect": "CONSERVATIVE", + "input": "SELECT identified_by FROM users", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[19]" + }, + { + "id": "otel_java.sanitize_sensitive.020", + "dialect": "CONSERVATIVE", + "input": "TRUNCATE TABLE password", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[20]" + }, + { + "id": "otel_java.sanitize_sensitive.021", + "dialect": "CONSERVATIVE", + "input": "REPLACE password VALUES (1)", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[21]" + }, + { + "id": "otel_java.sanitize_sensitive.022", + "dialect": "CONSERVATIVE", + "input": "VALUES (password)", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[22]" + }, + { + "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_object_named_password.001", + "dialect": "CONSERVATIVE", + "input": "GRANT SELECT ON password TO admin", + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeGrantObjectNamedPassword[1]" + }, + { + "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.query_summary_is_truncated.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM very_long_table_name_0, very_long_table_name_1, very_long_table_name_2, very_long_table_name_3, very_long_table_name_4, very_long_table_name_5, very_long_table_name_6, very_long_table_name_7, very_long_table_name_8, very_long_table_name_9, very_long_table_name_10, very_long_table_name_11, very_long_table_name_12, very_long_table_name_13, very_long_table_name_14, very_long_table_name_15, very_long_table_name_16, very_long_table_name_17, very_long_table_name_18, very_long_table_name_19, very_long_table_name_20, very_long_table_name_21, very_long_table_name_22, very_long_table_name_23, very_long_table_name_24, very_long_table_name_25, very_long_table_name_26, very_long_table_name_27, very_long_table_name_28, very_long_table_name_29, very_long_table_name_30, very_long_table_name_31, very_long_table_name_32, very_long_table_name_33, very_long_table_name_34, very_long_table_name_35, very_long_table_name_36, very_long_table_name_37, very_long_table_name_38, very_long_table_name_39, very_long_table_name_40, very_long_table_name_41, very_long_table_name_42, very_long_table_name_43, very_long_table_name_44, very_long_table_name_45, very_long_table_name_46, very_long_table_name_47, very_long_table_name_48, very_long_table_name_49", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryIsTruncated[1]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.001", + "dialect": "CONSERVATIVE", + "input": "select * from users", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[1]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.002", + "dialect": "CONSERVATIVE", + "input": "SeLeCT * FrOm users", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[2]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.003", + "dialect": "CONSERVATIVE", + "input": "insert into users values (1)", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[3]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.004", + "dialect": "CONSERVATIVE", + "input": "delete from users where id = 1", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[4]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.005", + "dialect": "CONSERVATIVE", + "input": "update users set id = 1", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[5]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.006", + "dialect": "CONSERVATIVE", + "input": "call do_work()", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[6]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.007", + "dialect": "CONSERVATIVE", + "input": "merge into users", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[7]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.008", + "dialect": "CONSERVATIVE", + "input": "create table users (id int)", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[8]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.009", + "dialect": "CONSERVATIVE", + "input": "drop table users", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[9]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.010", + "dialect": "CONSERVATIVE", + "input": "alter table users add column id int", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[10]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.011", + "dialect": "CONSERVATIVE", + "input": "values (1)", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[11]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.012", + "dialect": "CONSERVATIVE", + "input": "exec do_work", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[12]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.013", + "dialect": "CONSERVATIVE", + "input": "execute db.do_work @param=1", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[13]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.014", + "dialect": "CONSERVATIVE", + "input": "truncate table users", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[14]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.015", + "dialect": "CONSERVATIVE", + "input": "replace into users values (1)", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[15]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.016", + "dialect": "CONSERVATIVE", + "input": "lock table users", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[16]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.017", + "dialect": "CONSERVATIVE", + "input": "use mydb", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[17]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.018", + "dialect": "CONSERVATIVE", + "input": "begin transaction", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[18]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.019", + "dialect": "CONSERVATIVE", + "input": "commit transaction", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[19]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.020", + "dialect": "CONSERVATIVE", + "input": "rollback transaction", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[20]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.021", + "dialect": "CONSERVATIVE", + "input": "grant select on users to admin", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[21]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.022", + "dialect": "CONSERVATIVE", + "input": "revoke select on users from admin", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[22]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.023", + "dialect": "CONSERVATIVE", + "input": "show create table users", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[23]" + }, + { + "id": "otel_java.query_summary_preserves_operation_case.024", + "dialect": "CONSERVATIVE", + "input": "explain select * from users", + "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[24]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.001", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE `table`", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[1]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.002", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE ks.users ( id UUID PRIMARY KEY, name text )", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[2]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.003", + "dialect": "CONSERVATIVE", + "input": "create table ks.users ( id UUID PRIMARY KEY, name text )", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[3]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.004", + "dialect": "CONSERVATIVE", + "input": "CREATE KEYSPACE sync_test", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[4]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.005", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE IF NOT EXISTS table", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[5]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.006", + "dialect": "CONSERVATIVE", + "input": "DROP TABLE `if`", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[6]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.007", + "dialect": "CONSERVATIVE", + "input": "ALTER TABLE table ADD CONSTRAINT c FOREIGN KEY (foreign_id) REFERENCES ref (id)", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[7]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.008", + "dialect": "CONSERVATIVE", + "input": "CREATE INDEX types_name ON types (name)", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[8]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.009", + "dialect": "CONSERVATIVE", + "input": "DROP INDEX types_name ON types (name)", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[9]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.010", + "dialect": "CONSERVATIVE", + "input": "CREATE VIEW tmp AS SELECT type FROM table WHERE id = ?", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[10]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.011", + "dialect": "CONSERVATIVE", + "input": "CREATE PROCEDURE p AS SELECT * FROM table GO", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[11]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.012", + "dialect": "CONSERVATIVE", + "input": "ALTER TABLE t2 DROP COLUMN c, DROP COLUMN d", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[12]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.013", + "dialect": "CONSERVATIVE", + "input": "ALTER TABLE users ADD COLUMN email VARCHAR(255), DROP COLUMN legacy_id, MODIFY COLUMN status INT", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[13]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.015", + "dialect": "CONSERVATIVE", + "input": "create table users (password VARCHAR(255))", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[15]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.016", + "dialect": "CONSERVATIVE", + "input": "ALTER TABLE users ADD COLUMN password VARCHAR(255)", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[16]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.017", + "dialect": "CONSERVATIVE", + "input": "alter table users ADD COLUMN password VARCHAR(255)", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[17]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.018", + "dialect": "CONSERVATIVE", + "input": "ALTER TABLE user ADD COLUMN name VARCHAR(255)", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[18]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.019", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE password (id INT)", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[19]" + }, + { + "id": "otel_java.check_ddl_operation_statements_are_ok.020", + "dialect": "CONSERVATIVE", + "input": "DROP TABLE password", + "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[20]" + }, + { + "id": "otel_java.simplify_sql_double_quotes_as_identifiers.001", + "dialect": "postgresql", + "input": "SELECT * FROM \"TABLE\"", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[1]" + }, + { + "id": "otel_java.simplify_sql_double_quotes_as_identifiers.002", + "dialect": "postgresql", + "input": "SELECT x, y, z FROM \"schema table\"", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[2]" + }, + { + "id": "otel_java.simplify_sql_double_quotes_as_identifiers.003", + "dialect": "postgresql", + "input": "insert into \"db table\" where lalala", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[3]" + }, + { + "id": "otel_java.simplify_sql_double_quotes_as_identifiers.004", + "dialect": "postgresql", + "input": "delete from \"my table\" where something something", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[4]" + }, + { + "id": "otel_java.simplify_sql_double_quotes_as_identifiers.005", + "dialect": "postgresql", + "input": "update \"my table\" set answer=42", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[5]" + }, + { + "id": "otel_java.simplify_sql_double_quotes_as_identifiers.006", + "dialect": "postgresql", + "input": "merge into \"my table\"", + "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[6]" + }, + { + "id": "otel_java.database_specific_dml.001", + "dialect": "CONSERVATIVE", + "input": "UPDATE t1 JOIN t2 ON t1.id = t2.t1_id SET t1.col = t2.col WHERE t2.status = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#databaseSpecificDml[1]" + }, + { + "id": "otel_java.database_specific_dml.002", + "dialect": "CONSERVATIVE", + "input": "DELETE t1 FROM t1 JOIN t2 ON t1.id = t2.t1_id WHERE t2.status = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#databaseSpecificDml[2]" + }, + { + "id": "otel_java.database_specific_dml.003", + "dialect": "CONSERVATIVE", + "input": "UPDATE t1 SET col = t2.col FROM t2 WHERE t1.id = t2.t1_id AND t2.status = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#databaseSpecificDml[3]" + }, + { + "id": "otel_java.database_specific_dml.004", + "dialect": "CONSERVATIVE", + "input": "DELETE FROM t1 USING t2 WHERE t1.id = t2.t1_id AND t2.status = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#databaseSpecificDml[4]" + }, + { + "id": "otel_java.insert_variations.001", + "dialect": "CONSERVATIVE", + "input": "INSERT INTO t1 a SELECT * FROM t2 WHERE t2.id = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#insertVariations[1]" + }, + { + "id": "otel_java.insert_variations.002", + "dialect": "CONSERVATIVE", + "input": "INSERT INTO archive (id, data) SELECT o.id, c.data FROM orders o JOIN customers c ON o.cid = c.id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#insertVariations[2]" + }, + { + "id": "otel_java.insert_variations.003", + "dialect": "CONSERVATIVE", + "input": "INSERT INTO orders (product_id) SELECT id FROM products WHERE active = ? RETURNING *", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#insertVariations[3]" + }, + { + "id": "otel_java.update_delete_with_subqueries.001", + "dialect": "CONSERVATIVE", + "input": "UPDATE products SET price = price * 1.1 WHERE category_id IN (SELECT id FROM categories WHERE margin_low = ?)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[1]" + }, + { + "id": "otel_java.update_delete_with_subqueries.002", + "dialect": "CONSERVATIVE", + "input": "UPDATE employees SET salary = (SELECT AVG(salary) FROM employees WHERE department_id = ?) WHERE department_id = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[2]" + }, + { + "id": "otel_java.update_delete_with_subqueries.003", + "dialect": "CONSERVATIVE", + "input": "UPDATE products SET price = (SELECT avg_price FROM stats) WHERE category_id IN (SELECT id FROM categories WHERE active = ?)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[3]" + }, + { + "id": "otel_java.update_delete_with_subqueries.004", + "dialect": "CONSERVATIVE", + "input": "UPDATE t1 SET a = (SELECT MAX(x) FROM t2), b = (SELECT MIN(y) FROM t3), c = (SELECT AVG(z) FROM t4)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[4]" + }, + { + "id": "otel_java.update_delete_with_subqueries.005", + "dialect": "CONSERVATIVE", + "input": "DELETE FROM orders WHERE customer_id NOT IN (SELECT id FROM customers) AND product_id NOT IN (SELECT id FROM products)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[5]" + }, + { + "id": "otel_java.joins.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM colors CROSS JOIN sizes", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[1]" + }, + { + "id": "otel_java.joins.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 CROSS JOIN t2 CROSS JOIN t3", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[2]" + }, + { + "id": "otel_java.joins.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM products CROSS JOIN (SELECT * FROM categories WHERE active = ?) AS c", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[3]" + }, + { + "id": "otel_java.joins.004", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM employees NATURAL JOIN departments", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[4]" + }, + { + "id": "otel_java.joins.005", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 NATURAL LEFT JOIN t2 NATURAL RIGHT JOIN t3", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[5]" + }, + { + "id": "otel_java.joins.006", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders o INNER JOIN customers c ON o.customer_id = c.id LEFT JOIN shipping s ON o.id = s.order_id RIGHT JOIN invoices i ON o.id = i.order_id FULL OUTER JOIN payments p ON o.id = p.order_id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[6]" + }, + { + "id": "otel_java.joins.007", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 JOIN t2 USING (id) LEFT JOIN t3 USING (id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[7]" + }, + { + "id": "otel_java.joins.008", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users WHERE deleted_at IS NULL AND email IS NOT NULL", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[8]" + }, + { + "id": "otel_java.lateral_joins.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 CROSS JOIN LATERAL (SELECT * FROM t2 WHERE t2.id = t1.id) AS sub", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lateralJoins[1]" + }, + { + "id": "otel_java.lateral_joins.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 LEFT JOIN LATERAL (SELECT * FROM t2 WHERE t2.fk = t1.id LIMIT 1) sub ON true", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lateralJoins[2]" + }, + { + "id": "otel_java.lateral_joins.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1, LATERAL (SELECT * FROM t2 WHERE t2.id = t1.id) a, LATERAL (SELECT * FROM t3 WHERE t3.id = a.id) b", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lateralJoins[3]" + }, + { + "id": "otel_java.table_functions.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM get_user_orders(?) WHERE status = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[1]" + }, + { + "id": "otel_java.table_functions.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM dbo.fn_split(?, ',')", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[2]" + }, + { + "id": "otel_java.table_functions.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM UNNEST(ARRAY[1,2,3]) AS t", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[3]" + }, + { + "id": "otel_java.table_functions.004", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM GENERATE_SERIES(1, 10) AS gs", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[4]" + }, + { + "id": "otel_java.table_functions.005", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM fn1(fn2(fn3(?)))", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[5]" + }, + { + "id": "otel_java.table_functions.006", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 CROSS JOIN UNNEST(t1.arr) AS e", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[6]" + }, + { + "id": "otel_java.scalar_subqueries.001", + "dialect": "CONSERVATIVE", + "input": "SELECT e.name, (SELECT AVG(salary) FROM employees WHERE department_id = e.department_id) as avg_dept_salary FROM employees e", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#scalarSubqueries[1]" + }, + { + "id": "otel_java.scalar_subqueries.002", + "dialect": "CONSERVATIVE", + "input": "SELECT p.name, (SELECT MAX(price) FROM products), (SELECT MIN(price) FROM products) FROM products p", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#scalarSubqueries[2]" + }, + { + "id": "otel_java.exists_and_not_exists.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM customers WHERE EXISTS (SELECT 1 FROM orders WHERE customer_id = customers.id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#existsAndNotExists[1]" + }, + { + "id": "otel_java.exists_and_not_exists.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM products WHERE NOT EXISTS (SELECT 1 FROM order_items WHERE product_id = products.id AND quantity > 0)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#existsAndNotExists[2]" + }, + { + "id": "otel_java.exists_and_not_exists.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users u WHERE EXISTS (SELECT 1 FROM sessions WHERE user_id = u.id) AND NOT EXISTS (SELECT 1 FROM banned_users WHERE user_id = u.id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#existsAndNotExists[3]" + }, + { + "id": "otel_java.all_any_some_operators.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM products WHERE price > ALL (SELECT price FROM discounted_products)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#allAnySomeOperators[1]" + }, + { + "id": "otel_java.all_any_some_operators.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM employees WHERE salary >= ANY (SELECT salary FROM managers)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#allAnySomeOperators[2]" + }, + { + "id": "otel_java.all_any_some_operators.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders WHERE amount < SOME (SELECT amount FROM large_orders)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#allAnySomeOperators[3]" + }, + { + "id": "otel_java.in_subqueries.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders WHERE (customer_id, product_id) IN (SELECT customer_id, product_id FROM wishlists)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#inSubqueries[1]" + }, + { + "id": "otel_java.in_subqueries.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users WHERE id NOT IN (SELECT user_id FROM banned_users)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#inSubqueries[2]" + }, + { + "id": "otel_java.derived_tables.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (SELECT id, name FROM users) AS u (user_id, user_name)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#derivedTables[1]" + }, + { + "id": "otel_java.deeply_nested_subqueries.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM users WHERE active = ?) AS l1) AS l2) AS l3", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#deeplyNestedSubqueries[1]" + }, + { + "id": "otel_java.deeply_nested_subqueries.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders WHERE customer_id IN (SELECT id FROM customers WHERE region_id IN (SELECT id FROM regions WHERE country_id IN (SELECT id FROM countries WHERE code = ?)))", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#deeplyNestedSubqueries[2]" + }, + { + "id": "otel_java.subqueries_in_join_conditions.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders o JOIN customers c ON o.customer_id = c.id AND o.amount > (SELECT AVG(amount) FROM orders WHERE customer_id = c.id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[1]" + }, + { + "id": "otel_java.subqueries_in_join_conditions.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM employees e LEFT JOIN departments d ON e.dept_id = d.id AND EXISTS (SELECT 1 FROM projects WHERE dept_id = d.id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[2]" + }, + { + "id": "otel_java.subqueries_in_join_conditions.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders o JOIN order_items i ON o.id = i.order_id AND i.price > (SELECT AVG(price) FROM order_items WHERE order_id = o.id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[3]" + }, + { + "id": "otel_java.subqueries_in_join_conditions.004", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1 JOIN t2 ON t1.a IN (SELECT x FROM t3) AND t2.b IN (SELECT y FROM t4)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[4]" + }, + { + "id": "otel_java.subqueries_in_join_conditions.005", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM customers c JOIN orders o ON c.id = o.cust_id AND EXISTS (SELECT 1 FROM vip WHERE vip.cust_id = c.id AND vip.order_id = o.id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[5]" + }, + { + "id": "otel_java.subqueries_in_clause_positions.001", + "dialect": "CONSERVATIVE", + "input": "SELECT department_id, COUNT(*) FROM employees GROUP BY department_id HAVING COUNT(*) > (SELECT AVG(cnt) FROM (SELECT COUNT(*) as cnt FROM employees GROUP BY department_id) AS dept_counts)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[1]" + }, + { + "id": "otel_java.subqueries_in_clause_positions.002", + "dialect": "CONSERVATIVE", + "input": "SELECT category, SUM(price) FROM products GROUP BY category HAVING SUM(price) > (SELECT AVG(total) FROM category_totals)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[2]" + }, + { + "id": "otel_java.subqueries_in_clause_positions.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM products ORDER BY (SELECT AVG(rating) FROM reviews WHERE product_id = products.id) DESC", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[3]" + }, + { + "id": "otel_java.subqueries_in_clause_positions.004", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM employees ORDER BY (SELECT COUNT(*) FROM projects WHERE manager_id = employees.id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[4]" + }, + { + "id": "otel_java.subqueries_in_clause_positions.005", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM products WHERE price BETWEEN (SELECT MIN(price) FROM products) AND (SELECT MAX(price) FROM products)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[5]" + }, + { + "id": "otel_java.subqueries_in_clause_positions.006", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users LIMIT (SELECT setting FROM config WHERE key = ?)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[6]" + }, + { + "id": "otel_java.subqueries_in_clause_positions.007", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users OFFSET (SELECT page_size FROM config) ROWS", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[7]" + }, + { + "id": "otel_java.subqueries_in_clause_positions.008", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM GENERATE_SERIES(1, (SELECT MAX(id) FROM users))", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[8]" + }, + { + "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.subqueries_in_clause_positions.010", + "dialect": "CONSERVATIVE", + "input": "SELECT COALESCE((SELECT a FROM t1), (SELECT b FROM t2), (SELECT c FROM t3)) FROM dual", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[10]" + }, + { + "id": "otel_java.ctes.001", + "dialect": "CONSERVATIVE", + "input": "WITH cte1 AS (SELECT * FROM t1), cte2 AS (SELECT * FROM cte1 JOIN t2 ON cte1.id = t2.id) SELECT * FROM cte2", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[1]" + }, + { + "id": "otel_java.ctes.002", + "dialect": "CONSERVATIVE", + "input": "WITH a AS (SELECT 1), b AS (SELECT 2), c AS (SELECT 3) SELECT * FROM a, b, c", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[2]" + }, + { + "id": "otel_java.ctes.003", + "dialect": "CONSERVATIVE", + "input": "WITH new_data AS (SELECT * FROM staging WHERE processed = ?) INSERT INTO archive SELECT * FROM new_data", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[3]" + }, + { + "id": "otel_java.ctes.004", + "dialect": "CONSERVATIVE", + "input": "WITH updates AS (SELECT id, new_value FROM temp) UPDATE target SET value = (SELECT new_value FROM updates WHERE updates.id = target.id) WHERE EXISTS (SELECT 1 FROM updates WHERE updates.id = target.id)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[4]" + }, + { + "id": "otel_java.ctes.005", + "dialect": "CONSERVATIVE", + "input": "WITH to_delete AS (SELECT id FROM old_records WHERE date < ?) DELETE FROM records WHERE id IN (SELECT id FROM to_delete)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[5]" + }, + { + "id": "otel_java.ctes.006", + "dialect": "CONSERVATIVE", + "input": "WITH a AS (SELECT 1 as x), b AS (SELECT x FROM a), c AS (SELECT x FROM b) SELECT * FROM c", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[6]" + }, + { + "id": "otel_java.ctes.007", + "dialect": "CONSERVATIVE", + "input": "WITH users AS (SELECT * FROM active_users) SELECT * FROM users", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[7]" + }, + { + "id": "otel_java.set_operations.001", + "dialect": "CONSERVATIVE", + "input": "SELECT user_id FROM premium_users INTERSECT SELECT user_id FROM active_users", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[1]" + }, + { + "id": "otel_java.set_operations.002", + "dialect": "CONSERVATIVE", + "input": "SELECT email FROM all_users EXCEPT SELECT email FROM unsubscribed", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[2]" + }, + { + "id": "otel_java.set_operations.003", + "dialect": "CONSERVATIVE", + "input": "(SELECT id FROM users) UNION (SELECT id FROM customers)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[3]" + }, + { + "id": "otel_java.set_operations.004", + "dialect": "CONSERVATIVE", + "input": "(SELECT * FROM t1 UNION SELECT * FROM t2) INTERSECT (SELECT * FROM t3 UNION SELECT * FROM t4)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[4]" + }, + { + "id": "otel_java.set_operations.005", + "dialect": "CONSERVATIVE", + "input": "SELECT id FROM t1 MINUS SELECT id FROM t2", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[5]" + }, + { + "id": "otel_java.window_functions.001", + "dialect": "CONSERVATIVE", + "input": "SELECT name, department, salary, AVG(salary) OVER (PARTITION BY department) as avg_dept_salary FROM employees", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[1]" + }, + { + "id": "otel_java.window_functions.002", + "dialect": "CONSERVATIVE", + "input": "SELECT id, SUM(val) OVER w FROM data WINDOW w AS (PARTITION BY cat)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[2]" + }, + { + "id": "otel_java.window_functions.003", + "dialect": "CONSERVATIVE", + "input": "SELECT SUM(val) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM data", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[3]" + }, + { + "id": "otel_java.window_functions.004", + "dialect": "CONSERVATIVE", + "input": "SELECT ROW_NUMBER() OVER (ORDER BY a), RANK() OVER (PARTITION BY b ORDER BY c) FROM tbl", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[4]" + }, + { + "id": "otel_java.window_functions.005", + "dialect": "CONSERVATIVE", + "input": "SELECT SUM(amount) OVER (PARTITION BY (SELECT type FROM types WHERE types.id = sales.type_id)) FROM sales", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[5]" + }, + { + "id": "otel_java.expressions.001", + "dialect": "CONSERVATIVE", + "input": "SELECT CAST(price AS DECIMAL(10,2)) FROM products", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[1]" + }, + { + "id": "otel_java.expressions.002", + "dialect": "CONSERVATIVE", + "input": "SELECT CAST((SELECT MAX(amount) FROM orders) AS INTEGER) FROM dual", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[2]" + }, + { + "id": "otel_java.expressions.003", + "dialect": "CONSERVATIVE", + "input": "SELECT name, CAST(created_at AS DATE) FROM users WHERE CAST(status AS INTEGER) = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[3]" + }, + { + "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.expressions.006", + "dialect": "CONSERVATIVE", + "input": "SELECT CASE type WHEN 'A' THEN (SELECT COUNT(*) FROM type_a) WHEN 'B' THEN (SELECT COUNT(*) FROM type_b) ELSE 0 END FROM items", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[6]" + }, + { + "id": "otel_java.expressions.007", + "dialect": "CONSERVATIVE", + "input": "SELECT CASE (SELECT type FROM config) WHEN 'A' THEN (SELECT v FROM a) WHEN 'B' THEN (SELECT v FROM b) END FROM dual", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[7]" + }, + { + "id": "otel_java.expressions.008", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders WHERE (customer_id, product_id) = (?, ?)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[8]" + }, + { + "id": "otel_java.expressions.009", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users WHERE (first_name, last_name) IN (SELECT first_name, last_name FROM vip_users)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[9]" + }, + { + "id": "otel_java.clauses.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users ORDER BY created_at OFFSET 10 ROWS FETCH FIRST 20 ROWS ONLY", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[1]" + }, + { + "id": "otel_java.clauses.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM products ORDER BY price FETCH NEXT 10 ROWS ONLY", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[2]" + }, + { + "id": "otel_java.clauses.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders OFFSET 5 ROWS FETCH NEXT 1 ROW ONLY", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[3]" + }, + { + "id": "otel_java.clauses.004", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users LIMIT 10 OFFSET 5", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[4]" + }, + { + "id": "otel_java.clauses.005", + "dialect": "CONSERVATIVE", + "input": "SELECT dept, SUM(salary) FROM employees GROUP BY ROLLUP(dept)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[5]" + }, + { + "id": "otel_java.clauses.006", + "dialect": "CONSERVATIVE", + "input": "SELECT dept, year, SUM(salary) FROM employees GROUP BY CUBE(dept, year)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[6]" + }, + { + "id": "otel_java.clauses.007", + "dialect": "CONSERVATIVE", + "input": "SELECT dept, year, SUM(salary) FROM employees GROUP BY GROUPING SETS ((dept), (year))", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[7]" + }, + { + "id": "otel_java.clauses.008", + "dialect": "CONSERVATIVE", + "input": "SELECT * INTO temp_table FROM users WHERE active = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[8]" + }, + { + "id": "otel_java.clauses.009", + "dialect": "CONSERVATIVE", + "input": "SELECT u.name, COUNT(o.id) INTO summary_table FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.name", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[9]" + }, + { + "id": "otel_java.clauses.010", + "dialect": "CONSERVATIVE", + "input": "INSERT INTO users (name) VALUES (?) RETURNING id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[10]" + }, + { + "id": "otel_java.clauses.011", + "dialect": "CONSERVATIVE", + "input": "DELETE FROM users WHERE id = ? RETURNING *", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[11]" + }, + { + "id": "otel_java.clauses.012", + "dialect": "CONSERVATIVE", + "input": "UPDATE users SET name = ? WHERE id = ? RETURNING *", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[12]" + }, + { + "id": "otel_java.clauses.013", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users FOR UPDATE OF users.name NOWAIT", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[13]" + }, + { + "id": "otel_java.clauses.014", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users FOR SHARE", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[14]" + }, + { + "id": "otel_java.clauses.015", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users FOR UPDATE SKIP LOCKED", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[15]" + }, + { + "id": "otel_java.clauses.016", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users FETCH FIRST 10 PERCENT ROWS ONLY", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[16]" + }, + { + "id": "otel_java.clauses.017", + "dialect": "CONSERVATIVE", + "input": "SELECT TOP 10 PERCENT * FROM users", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[17]" + }, + { + "id": "otel_java.clauses.018", + "dialect": "CONSERVATIVE", + "input": "SELECT DISTINCT ON (department) * FROM employees", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[18]" + }, + { + "id": "otel_java.values_clauses.001", + "dialect": "CONSERVATIVE", + "input": "INSERT INTO t1 (col) VALUES ((SELECT MAX(col) FROM t2))", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#valuesClauses[1]" + }, + { + "id": "otel_java.values_clauses.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (VALUES (1), (2)) AS t(id) JOIN users u ON t.id = u.id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#valuesClauses[2]" + }, + { + "id": "otel_java.values_clauses.003", + "dialect": "CONSERVATIVE", + "input": "SELECT id FROM users UNION VALUES (1), (2)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#valuesClauses[3]" + }, + { + "id": "otel_java.identifiers_and_table_references.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM \"SELECT\" WHERE \"FROM\" = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[1]" + }, + { + "id": "otel_java.identifiers_and_table_references.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM `SELECT` WHERE `FROM` = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[2]" + }, + { + "id": "otel_java.identifiers_and_table_references.003", + "dialect": "sqlserver", + "input": "SELECT * FROM [SELECT] WHERE [FROM] = ?", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[3]" + }, + { + "id": "otel_java.identifiers_and_table_references.004", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM \"table.name\"", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[4]" + }, + { + "id": "otel_java.identifiers_and_table_references.005", + "dialect": "sqlite", + "input": "SELECT * FROM \"schema\".`table` JOIN [other] ON \"schema\".`table`.id = [other].id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[5]" + }, + { + "id": "otel_java.identifiers_and_table_references.006", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM db.schema.table", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[6]" + }, + { + "id": "otel_java.identifiers_and_table_references.007", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM schema1.t1 JOIN t2 ON schema1.t1.id = t2.id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[7]" + }, + { + "id": "otel_java.identifiers_and_table_references.008", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM (t1), (t2)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[8]" + }, + { + "id": "otel_java.identifiers_and_table_references.009", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.t1_id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[9]" + }, + { + "id": "otel_java.identifiers_and_table_references.010", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM t1, t2 JOIN t3 ON t2.id = t3.t2_id, t4", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[10]" + }, + { + "id": "otel_java.identifiers_and_table_references.011", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users orders JOIN orders o ON orders.id = o.user_id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[11]" + }, + { + "id": "otel_java.alias_edge_cases.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users join", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#aliasEdgeCases[1]" + }, + { + "id": "otel_java.alias_edge_cases.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM orders users JOIN users u ON orders.user_id = u.id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#aliasEdgeCases[2]" + }, + { + "id": "otel_java.alias_edge_cases.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users AS this_is_a_very_long_alias_name_that_exceeds_normal_length", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#aliasEdgeCases[3]" + }, + { + "id": "otel_java.lexical_edge_cases.001", + "dialect": "postgresql", + "input": "SELECT /* outer /* inner */ still comment */ * FROM users", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lexicalEdgeCases[1]" + }, + { + "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.statements_and_semicolons.001", + "dialect": "CONSERVATIVE", + "input": "; SELECT * FROM users", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#statementsAndSemicolons[1]" + }, + { + "id": "otel_java.statements_and_semicolons.002", + "dialect": "CONSERVATIVE", + "input": ";; SELECT * FROM t1", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#statementsAndSemicolons[2]" + }, + { + "id": "otel_java.statements_and_semicolons.003", + "dialect": "CONSERVATIVE", + "input": "; ; SELECT * FROM t1; ; SELECT * FROM t2; ;", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#statementsAndSemicolons[3]" + }, + { + "id": "otel_java.vendor_specific_syntax.001", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM sales PIVOT (SUM(amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'))", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[1]" + }, + { + "id": "otel_java.vendor_specific_syntax.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM wide_table UNPIVOT (value FOR col_name IN (col1, col2, col3))", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[2]" + }, + { + "id": "otel_java.vendor_specific_syntax.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM large_table TABLESAMPLE SYSTEM (10)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[3]" + }, + { + "id": "otel_java.vendor_specific_syntax.004", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM large_table TABLESAMPLE BERNOULLI (1) REPEATABLE (42)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[4]" + }, + { + "id": "otel_java.vendor_specific_syntax.005", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users FOR XML PATH", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[5]" + }, + { + "id": "otel_java.vendor_specific_syntax.006", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM users FOR JSON AUTO", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[6]" + }, + { + "id": "otel_java.vendor_specific_syntax.007", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM ticker MATCH_RECOGNIZE (ORDER BY tstamp MEASURES A.tstamp AS start_t PATTERN (A B* C) DEFINE A AS A.price > 10)", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[7]" + }, + { + "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_java.vendor_specific_syntax.009", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM employees START WITH manager_id IS NULL CONNECT BY PRIOR employee_id = manager_id", + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[9]" + }, + { + "id": "otel_dotnet.json.numeric_literal_integers", + "dialect": "CONSERVATIVE", + "input": "SELECT 12, -12, +12", + "source": "otel-dotnet:SqlProcessorTestCases.json#numeric_literal_integers" + }, + { + "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.arithmetic_on_numeric_literals", + "dialect": "CONSERVATIVE", + "input": "SELECT 99+100", + "source": "otel-dotnet:SqlProcessorTestCases.json#arithmetic_on_numeric_literals" + }, + { + "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.periods_in_identifiers", + "dialect": "CONSERVATIVE", + "input": "SELECT a FROM dbo.Table JOIN dbo.AnotherTable", + "source": "otel-dotnet:SqlProcessorTestCases.json#periods_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.in_clause", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM table WHERE value IN (123, 456, 'abc')", + "source": "otel-dotnet:SqlProcessorTestCases.json#in_clause" + }, + { + "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.json.insert_into_select", + "dialect": "CONSERVATIVE", + "input": "INSERT INTO shipping_details\n(order_id,\naddress)\nSELECT order_id,\naddress\nFROM orders\nWHERE order_id = 1", + "source": "otel-dotnet:SqlProcessorTestCases.json#insert_into_select" + }, + { + "id": "otel_dotnet.json.select_nested_query", + "dialect": "CONSERVATIVE", + "input": "SELECT order_date\nFROM (SELECT *\nFROM orders o\nJOIN customers c\nON o.customer_id = c.customer_id)", + "source": "otel-dotnet:SqlProcessorTestCases.json#select_nested_query" + }, + { + "id": "otel_dotnet.json.select_nested_query_case_preserved", + "dialect": "CONSERVATIVE", + "input": "SELEcT order_date\nFROM (sELECT *\nFROM orders o\nJOIN customers c\nON o.customer_id = c.customer_id)", + "source": "otel-dotnet:SqlProcessorTestCases.json#select_nested_query_case_preserved" + }, + { + "id": "otel_dotnet.json.case_preserved", + "dialect": "CONSERVATIVE", + "input": "SELEcT order_date\nFROM ORders", + "source": "otel-dotnet:SqlProcessorTestCases.json#case_preserved" + }, + { + "id": "otel_dotnet.json.cross_join", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM Orders o CROSS JOIN OrderDetails od", + "source": "otel-dotnet:SqlProcessorTestCases.json#cross_join" + }, + { + "id": "otel_dotnet.json.cross_join_comma_separated_syntax", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM Orders o, OrderDetails od", + "source": "otel-dotnet:SqlProcessorTestCases.json#cross_join_comma_separated_syntax" + }, + { + "id": "otel_dotnet.json.create_table", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE MyTable (\n ID NOT NULL IDENTITY(1,1) PRIMARY KEY\n)", + "source": "otel-dotnet:SqlProcessorTestCases.json#create_table" + }, + { + "id": "otel_dotnet.json.alter_table", + "dialect": "CONSERVATIVE", + "input": "ALTER TABLE MyTable ADD Name varchar(255)", + "source": "otel-dotnet:SqlProcessorTestCases.json#alter_table" + }, + { + "id": "otel_dotnet.json.drop_table", + "dialect": "CONSERVATIVE", + "input": "DROP TABLE MyTable", + "source": "otel-dotnet:SqlProcessorTestCases.json#drop_table" + }, + { + "id": "otel_dotnet.create_table_trailing_identifier.01", + "dialect": "CONSERVATIVE", + "input": "CREATE TABLE XXX", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_CreateTableWithTrailingIdentifier_DoesNotThrow" + }, + { + "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.lone_dollar.01", + "dialect": "CONSERVATIVE", + "input": "SELECT $IDENTITY FROM t", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoneDollarSign_IsNotTreatedAsDollarQuote[1]" + }, + { + "id": "otel_dotnet.lone_dollar.02", + "dialect": "CONSERVATIVE", + "input": "SELECT a WHERE b = $1", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoneDollarSign_IsNotTreatedAsDollarQuote[2]" + }, + { + "id": "otel_dotnet.dollar_tag_digit.01", + "dialect": "postgresql", + "input": "SELECT a WHERE b = $1$not-a-secret$1$", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DollarQuoteTagStartingWithDigit_IsNotTreatedAsDollarQuote" + }, + { + "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_identifier.01", + "dialect": "postgresql", + "input": "SELECT * FROM t WHERE c = \"identifier_or_mysql_string\"", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubleQuotedString_IsPreservedAsIdentifier" + }, + { + "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_or_user_name.09", + "dialect": "sqlserver", + "input": "CREATE USER \"\" X", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[9]" + }, + { + "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.keyword_first_character.01", + "dialect": "CONSERVATIVE", + "input": "SELECT a Xrom b", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_WordWhichOnlyDiffersFromKeywordByFirstCharacter_IsNotKeyword[1]" + }, + { + "id": "otel_dotnet.keyword_first_character.02", + "dialect": "CONSERVATIVE", + "input": "SELECT Prom FROM Events", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_WordWhichOnlyDiffersFromKeywordByFirstCharacter_IsNotKeyword[2]" + }, + { + "id": "otel_dotnet.keyword_first_character.03", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM Orders Xoin Customers", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_WordWhichOnlyDiffersFromKeywordByFirstCharacter_IsNotKeyword[3]" + }, + { + "id": "otel_dotnet.keyword_first_character.04", + "dialect": "CONSERVATIVE", + "input": "Xelect * FROM Orders", + "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_WordWhichOnlyDiffersFromKeywordByFirstCharacter_IsNotKeyword[4]" + }, + { + "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..505e95d725a --- /dev/null +++ b/sentry/src/test/resources/sql/known-leaks.txt @@ -0,0 +1,136 @@ +# Corpus cases (sql/analyzer-cases.json) whose declared secret appears in the output of the +# unchanged OpenTelemetry grammar for the full input: accepted leaks (D69, plan 08). Owned by +# SqlQueryAnalyzerKnownLeakTest. Fixes go upstream (patch-inventory.md section 5); a case that +# no longer leaks after a sync is reported by the test and removed here. +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 +size.limit.dcl_before_credential.postgresql +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 From 6d384958d22c7dc5c3ae0fe103733ecb444adcd3 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Fri, 27 Nov 2026 06:22:13 +0100 Subject: [PATCH 2/4] test(sql): Keep only the SQL analyzer tests upstream does not cover --- THIRD_PARTY_NOTICES.md | 4 +- .../io/sentry/util/sql/SqlAnalyzerHarness.kt | 239 -- .../util/sql/SqlQueryAnalyzerCorpusTest.kt | 44 - .../util/sql/SqlQueryAnalyzerFuzzTest.kt | 254 -- .../util/sql/SqlQueryAnalyzerKnownLeakTest.kt | 153 +- .../sql/SqlQueryAnalyzerPathologicalTest.kt | 151 +- .../sentry/util/sql/SqlQueryAnalyzerTest.kt | 7 + .../test/resources/sql/analyzer-cases.json | 3750 ++--------------- sentry/src/test/resources/sql/known-leaks.txt | 1 - 9 files changed, 475 insertions(+), 4128 deletions(-) delete mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlAnalyzerHarness.kt delete mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerCorpusTest.kt delete mode 100644 sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 448019e0e56..ea575e6969d 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -489,7 +489,7 @@ limitations under the License. ### Scope -The Sentry Java SDK's SQL analyzer test suite includes test inputs adapted from the SQL analyzer tests in `instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/`. The adapted inputs reside in `sentry/src/test/resources/sql/analyzer-cases.json` (cases whose `source` starts with `otel-java:`), `sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt` and `sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt`. These are test sources and are not part of the published artifacts. +The Sentry Java SDK's SQL analyzer test suite includes test inputs adapted from the SQL analyzer tests in `instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/`. The adapted inputs reside in `sentry/src/test/resources/sql/analyzer-cases.json` (cases whose `source` starts with `otel-java:`) and `sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt`. These are test sources and are not part of the published artifacts. ``` Copyright The OpenTelemetry Authors @@ -518,7 +518,7 @@ limitations under the License. ### Scope -The Sentry Java SDK's SQL analyzer test suite includes test inputs adapted from `test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTests.cs` and `test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTestCases.json`. The adapted inputs reside in `sentry/src/test/resources/sql/analyzer-cases.json` (cases whose `source` starts with `otel-dotnet:`) and `sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt`. These are test sources and are not part of the published artifacts. +The Sentry Java SDK's SQL analyzer test suite includes test inputs adapted from `test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTests.cs` and `test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTestCases.json`. The adapted inputs reside in `sentry/src/test/resources/sql/analyzer-cases.json` (cases whose `source` starts with `otel-dotnet:`). These are test sources and are not part of the published artifacts. ``` Copyright The OpenTelemetry Authors diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlAnalyzerHarness.kt b/sentry/src/test/java/io/sentry/util/sql/SqlAnalyzerHarness.kt deleted file mode 100644 index eee595a9916..00000000000 --- a/sentry/src/test/java/io/sentry/util/sql/SqlAnalyzerHarness.kt +++ /dev/null @@ -1,239 +0,0 @@ -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 java.util.concurrent.Callable -import java.util.concurrent.ExecutionException -import java.util.concurrent.ExecutorService -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import java.util.concurrent.TimeoutException - -/** - * One `db.system.name` per dialect option of the vendored `SqlDialect`: `null` reads double quotes - * as literals, `postgresql` as identifiers. The robustness tests run under both. - */ -internal val DIALECTS: List = listOf(null, "postgresql") - -internal fun SqlQuery.fields(): Map = - linkedMapOf( - "text" to queryText, - "summary" to querySummary, - "storedProcedure" to storedProcedureName, - ) - -/** - * What every robustness input must give: a text. Non-null input up to 1 MiB has `null` text only - * after an internal error (R5), which no input may cause. - */ -internal fun assertHasText(query: SqlQuery, describe: () -> String) { - if (query.queryText == null) { - assertWithMessage("no text, so the analyzer failed internally (R5); %s", describe()) - .that(query.queryText) - .isNotNull() - } -} - -internal fun assertWithinLimit(query: SqlQuery, limit: Int, describe: () -> String) { - assertWithMessage("text longer than the limit; %s", describe()) - .that(query.queryText?.length ?: 0) - .isAtMost(limit) -} - -/** - * No output splits a surrogate pair. A lone surrogate in the input passes through the grammar like - * any other character, so inputs that have one are not checked. - */ -internal fun assertNoLoneSurrogate(input: String, query: SqlQuery, describe: () -> String) { - if (hasLoneSurrogate(input)) return - for ((field, value) in query.fields()) { - if (value != null && hasLoneSurrogate(value)) { - assertWithMessage("lone surrogate in %s; %s", field, describe()) - .that(escape(value)) - .isEqualTo("no lone surrogate") - } - } -} - -private fun hasLoneSurrogate(value: String): Boolean { - var i = 0 - while (i < value.length) { - val c = value[i] - if (c.isHighSurrogate() && i + 1 < value.length && value[i + 1].isLowSurrogate()) i += 2 - else if (c.isSurrogate()) return true else i++ - } - return false -} - -/** Escapes control characters and surrogates so a failing input can be read and copied. */ -internal fun escape(value: String, maxLength: Int = 4096): String { - val out = StringBuilder() - for (c in value.take(maxLength)) { - when { - c == '\\' -> out.append("\\\\") - c == '\n' -> out.append("\\n") - c == '\r' -> out.append("\\r") - c == '\t' -> out.append("\\t") - c < ' ' || c.isSurrogate() || c.code in 0x7f..0x9f -> - out.append("\\u").append(String.format("%04x", c.code)) - else -> out.append(c) - } - } - if (value.length > maxLength) out.append("… (${value.length} chars)") - return out.toString() -} - -/** - * Runs [SqlQueryAnalyzer.analyze] on a daemon thread with a fixed stack, so that a recursion depth - * that would overflow a typical Android or JVM worker thread fails here, and a hang fails after - * `timeoutMillis` instead of stalling the build. - */ -internal class AnalyzerWorker : AutoCloseable { - private val executor: ExecutorService = Executors.newSingleThreadExecutor { runnable -> - Thread(null, runnable, "sql-analyzer-worker", STACK_SIZE_BYTES).apply { isDaemon = true } - } - - fun analyze( - sql: String, - dbSystemName: String?, - maxQueryTextLength: Int, - timeoutMillis: Long, - describe: () -> String, - ): SqlQuery { - val future = - executor.submit(Callable { SqlQueryAnalyzer.analyze(sql, dbSystemName, maxQueryTextLength) }) - try { - return future.get(timeoutMillis, TimeUnit.MILLISECONDS) - } catch (e: TimeoutException) { - future.cancel(true) - throw AssertionError("analyze did not complete within $timeoutMillis ms: ${describe()}") - } catch (e: ExecutionException) { - throw AssertionError("analyze threw ${e.cause}: ${describe()}", e.cause) - } - } - - override fun close() { - executor.shutdownNow() - } - - companion object { - /** Below the default for Android background threads and HotSpot (both about 1 MiB). */ - const val STACK_SIZE_BYTES = 512L * 1024 - } -} - -/** - * A case of `sql/analyzer-cases.json`: an input with the `db.system.name` and limit it is analyzed - * with, and the secrets it declares. The file has no expected outputs (plan 08, Tests). - */ -class SqlCase( - val id: String, - val dbSystemName: String?, - val input: String, - val maxQueryTextLength: Int, - val secrets: List, -) { - override fun toString(): String = id -} - -internal object SqlCorpus { - private const val RESOURCE = "sql/analyzer-cases.json" - private val SOURCE = Regex("sentry|otel-java:\\w+#.+|otel-dotnet:[^#]+#.+") - private val REQUIRED_KEYS = setOf("id", "dialect", "input", "source") - - /** Used when a case sets no limit: larger than any input. */ - private const val UNLIMITED = Int.MAX_VALUE - - val cases: List by lazy { load() } - - /** - * Rejects anything that would silently weaken a case: unknown or missing keys, unknown dialects. - */ - private fun load(): List { - val stream = - checkNotNull(SqlCorpus::class.java.classLoader.getResourceAsStream(RESOURCE)) { - "$RESOURCE not found" - } - val cases = mutableListOf() - JsonObjectReader(InputStreamReader(stream, 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 }) { "$RESOURCE: duplicate id '${case.id}'" } - cases += case - } - reader.endArray() - } - else -> error("$RESOURCE: unknown top-level key '$key'") - } - } - reader.endObject() - } - check(cases.isNotEmpty()) { "$RESOURCE has no cases" } - return cases - } - - private fun readCase(reader: JsonObjectReader): SqlCase { - var id: String? = null - var dbSystemName: String? = null - var input: String? = null - var maxQueryTextLength = UNLIMITED - var secrets = emptyList() - val seen = mutableSetOf() - reader.beginObject() - while (reader.hasNext()) { - val key = reader.nextName() - check(seen.add(key)) { "$RESOURCE: duplicate key '$key' in case '$id'" } - when (key) { - "id" -> id = readString(reader, key) - "dialect" -> dbSystemName = toDbSystemName(readString(reader, key)) - "input" -> input = readString(reader, key) - "maxQueryTextLength" -> { - check(reader.peek() == JsonToken.NUMBER) { "'$key' must be an integer" } - maxQueryTextLength = reader.nextInt() - check(maxQueryTextLength > 0) { "'$key' must be positive" } - } - "secrets" -> secrets = readStrings(reader, key) - "source" -> check(SOURCE.matches(readString(reader, key))) { "case '$id': bad source" } - else -> error("$RESOURCE: unknown key '$key' in case '$id'") - } - } - reader.endObject() - check(seen.containsAll(REQUIRED_KEYS)) { - "$RESOURCE: case '$id' misses ${REQUIRED_KEYS - seen}" - } - return SqlCase(id!!, dbSystemName, input!!, maxQueryTextLength, 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 - } -} diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerCorpusTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerCorpusTest.kt deleted file mode 100644 index ea5f765429d..00000000000 --- a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerCorpusTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -package io.sentry.util.sql - -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.Parameterized - -/** - * Owns stability on the corpus inputs (`sql/analyzer-cases.json`), each under its own dialect and - * limit: [SqlQueryAnalyzer.analyze] completes within [TIME_BOUND_MILLIS] on an - * [AnalyzerWorker.STACK_SIZE_BYTES] stack, fails nowhere internally, respects the limit and splits - * no surrogate pair. Outputs are not asserted (plan 08, Tests); leaks are owned by - * [SqlQueryAnalyzerKnownLeakTest]. - */ -@RunWith(Parameterized::class) -class SqlQueryAnalyzerCorpusTest(private val case: SqlCase) { - - @Test - fun `completes within the bound without failing or exceeding the limit`() { - val describe = { "case ${case.id} (${escape(case.input, 200)})" } - val query = - AnalyzerWorker().use { - it.analyze( - case.input, - case.dbSystemName, - case.maxQueryTextLength, - TIME_BOUND_MILLIS, - describe, - ) - } - - assertHasText(query, describe) - assertWithinLimit(query, case.maxQueryTextLength, describe) - assertNoLoneSurrogate(case.input, query, describe) - } - - companion object { - /** Bound recorded in plan 01, step 6. */ - const val TIME_BOUND_MILLIS = 2_000L - - @JvmStatic - @Parameterized.Parameters(name = "{0}") - fun parameters(): List> = SqlCorpus.cases.map { arrayOf(it) } - } -} diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt deleted file mode 100644 index ebfe76165a6..00000000000 --- a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerFuzzTest.kt +++ /dev/null @@ -1,254 +0,0 @@ -// Random UTF-16 inputs adapted from OpenTelemetry Java Instrumentation -// (SqlQueryAnalyzerTest#randomBytesDontCauseExceptionsOrTimeouts). -// 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 java.util.Random -import org.junit.Test - -/** - * Owns stability for generated input: [SqlQueryAnalyzer.analyze] must not throw or fail internally, - * must respect `maxQueryTextLength`, split no surrogate pair, and finish each input within - * [TIME_BOUND_MILLIS] (plan 01, step 6). Outputs and leaks are not asserted (plan 08, Tests). - * - * Each test runs a fixed seed and a run seed. The run seed is random unless the - * `sentry.sql.fuzz.seed` system property sets it; every failure message prints the seed and the - * command that reproduces it. - */ -class SqlQueryAnalyzerFuzzTest { - - /** - * Token soup over keywords, operators, markers and every quote and comment construct, closed or - * not. Half the inputs drop separators at random, which exercises boundary lexing (`x-1`, - * `ELSE'x'`, `1--1`). - */ - @Test - fun `token inputs never fail, exceed the limit or the time bound`() { - run(TOKEN_INPUTS) { random -> - TokenInputGenerator(random, glue = random.nextBoolean()).generate() - } - } - - @Test - fun `random UTF-16 inputs never fail, exceed the limit or the time bound`() { - run(UTF16_INPUTS) { random -> - val keyword = if (random.nextInt(4) != 0) pick(random, LEADING_KEYWORDS) + " " else "" - keyword + String(CharArray(UTF16_LENGTH) { random.nextInt(0x10000).toChar() }) - } - } - - private fun run(count: Int, generate: (Random) -> String) { - AnalyzerWorker().use { worker -> - warmUp(worker) - for (seed in seeds()) { - val random = Random(seed) - repeat(count) { index -> - val dbSystemName = pick(random, DIALECTS) - val limit = pickLimit(random) - val input = generate(random) - val describe = { - "seed=$seed index=$index dbSystemName=$dbSystemName maxQueryTextLength=$limit " + - "input=\"${escape(input)}\"\nReproduce: ./gradlew :sentry:test " + - "--tests '${SqlQueryAnalyzerFuzzTest::class.java.name}' -D$SEED_PROPERTY=$seed" - } - val query = worker.analyze(input, dbSystemName, limit, TIME_BOUND_MILLIS, describe) - - assertHasText(query, describe) - assertWithinLimit(query, limit, describe) - assertNoLoneSurrogate(input, query, describe) - } - } - } - } - - /** Untimed runs so class loading and JIT compilation don't count against the first input. */ - private fun warmUp(worker: AnalyzerWorker) { - val random = Random(WARM_UP_SEED) - repeat(WARM_UP_INPUTS) { - val input = TokenInputGenerator(random, glue = false).generate() - worker.analyze(input, null, Int.MAX_VALUE, WARM_UP_TIMEOUT_MILLIS) { - "warm-up input=\"${escape(input)}\"" - } - } - } - - private fun seeds(): List { - val runSeed = - System.getProperty(SEED_PROPERTY)?.takeIf { it.isNotBlank() }?.toLong() ?: Random().nextLong() - return listOf(FIXED_SEED, runSeed) - } - - /** Half the inputs are unlimited; the rest get small limits so the cut is exercised. */ - private fun pickLimit(random: Random): Int = - if (random.nextBoolean()) Int.MAX_VALUE else 1 + random.nextInt(200) - - companion object { - const val SEED_PROPERTY = "sentry.sql.fuzz.seed" - - /** Bound recorded in plan 01, step 6. */ - const val TIME_BOUND_MILLIS = 250L - - private const val FIXED_SEED = 6019L - private const val WARM_UP_SEED = 712L - private const val WARM_UP_INPUTS = 200 - private const val WARM_UP_TIMEOUT_MILLIS = 10_000L - private const val TOKEN_INPUTS = 2_500 - private const val UTF16_INPUTS = 200 - private const val UTF16_LENGTH = 1_000 - } -} - -private fun pick(random: Random, values: List): T = values[random.nextInt(values.size)] - -private val LEADING_KEYWORDS = - listOf("SELECT", "INSERT INTO", "UPDATE", "DELETE FROM", "CALL", "EXEC", "WITH", "CREATE") - -/** Generates token soup; the last construct is left unterminated in a third of the inputs. */ -private class TokenInputGenerator(private val random: Random, private val glue: Boolean) { - private val out = StringBuilder() - - fun generate(): String { - if (random.nextInt(10) != 0) append(pick(random, LEADING_KEYWORDS)) - repeat(random.nextInt(MAX_SEGMENTS)) { - if (random.nextInt(3) == 0) append(construct(terminated = true)) - else append(pick(random, FREE_TOKENS)) - } - if (random.nextInt(3) == 0) append(construct(terminated = false)) - return out.toString() - } - - private fun append(token: String) { - if (out.isNotEmpty() && !(glue && random.nextBoolean())) out.append(pick(random, SEPARATORS)) - out.append(token) - } - - private fun construct(terminated: Boolean): String { - val (open, close) = pick(random, CONSTRUCTS) - val content = List(random.nextInt(6)) { pick(random, CONTENT) }.joinToString("") - return open + content + if (terminated) close else "" - } - - companion object { - private const val MAX_SEGMENTS = 60 - - private val SEPARATORS = listOf(" ", " ", " ", "\n", "\t", " ", "\r\n") - - private val CONSTRUCTS = - listOf( - "'" to "'", - "N'" to "'", - "E'" to "'", - "\"" to "\"", - "`" to "`", - "[" to "]", - "$$" to "$$", - "\$t$" to "\$t$", - "/*" to "*/", - "/*!" to "*/", - "-- " to "\n", - "--" to "\n", - "#" to "\n", - "//" to "\n", - "q'[" to "]'", - "q'{" to "}'", - ) - - private val CONTENT = - listOf( - "a", - "users", - "Zq9xK7", - "straße", - " ", - "1", - "2.5", - ",", - "(", - ")", - ";", - "=", - "'", - "''", - "\"", - "`", - "\\", - "/*", - "*/", - "--", - "#", - "$$", - "[", - "]", - "\n", - "?", - ":p", - "@p", - "$1", - "\uD835\uDC9C", - ) - - private val FREE_TOKENS = - listOf( - "SELECT", - "FROM", - "WHERE", - "INSERT", - "INTO", - "VALUES", - "UPDATE", - "SET", - "DELETE", - "CALL", - "EXEC", - "EXECUTE", - "WITH", - "AS", - "JOIN", - "ON", - "IN", - "AND", - "OR", - "NULL", - "CREATE", - "TABLE", - "USER", - "IDENTIFIED", - "BY", - "UNION", - "users", - "t", - "col_a", - "straße", - "x1", - "1", - "-2.5", - "1e-5", - "0x1F", - "=", - "<>", - "+", - "-", - "*", - "/", - ",", - ".", - ";", - "(", - ")", - "{", - "}", - "?", - "?1", - ":name", - "@p", - "$1", - "\\", - "$", - "*/", - "]", - "||", - ) - } -} diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt index dd761d3c74c..e11f9582a7b 100644 --- a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt @@ -1,58 +1,159 @@ 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 /** - * Owns the accepted leaks of the unchanged grammar (D69): a corpus case leaks when one of its - * declared secrets appears whole in the text, summary or stored procedure of its full input. 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. - * Prefixes are not analyzed: truncated input does not reach the analyzer (patch-inventory section - * 5). + * Owns the accepted leaks of the unchanged grammar (D69): a corpus case (`sql/analyzer-cases.json`) + * leaks when one of its declared secrets appears whole in the text, summary or stored procedure of + * its full input. 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. Prefixes are not analyzed: truncated input does not reach the analyzer + * (patch-inventory section 5). + * + * 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. The cut is owned by [SqlQueryAnalyzerTest]. + * + * Every case must also give a text: `null` text for analyzed input means an internal failure (R5), + * which would hide a leak. Other robustness of the grammar is upstream's to test (plan 08, Tests). */ class SqlQueryAnalyzerKnownLeakTest { @Test fun `only listed cases leak a declared secret`() { - val known = knownLeaks() - val leaking = - SqlCorpus.cases - .filter { it.secrets.isNotEmpty() } - .filter { case -> - val query = - SqlQueryAnalyzer.analyze(case.input, case.dbSystemName, case.maxQueryTextLength) - query.fields().values.any { value -> - value != null && case.secrets.any { value.contains(it) } - } - } - .map { it.id } - .toSet() + 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 $RESOURCE:\n" + + "${fixed.size} listed case(s) no longer leak; remove them from $KNOWN_LEAKS:\n" + fixed.sorted().joinToString("\n"), ) } - assertWithMessage("cases that leak but are not listed in %s", RESOURCE) + assertWithMessage("cases without text, so the analyzer failed internally (R5)") + .that(failed) + .isEmpty() + assertWithMessage("cases that leak but are not listed in %s", KNOWN_LEAKS) .that((leaking - known).sorted()) .isEmpty() } - private fun knownLeaks(): Set { - val stream = - checkNotNull(javaClass.classLoader.getResourceAsStream(RESOURCE)) { "$RESOURCE not found" } - return stream + 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 RESOURCE = "sql/known-leaks.txt" + 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 index 53bd953943f..fa48e53ce84 100644 --- a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt @@ -1,118 +1,77 @@ -// Inputs adapted from OpenTelemetry Java Instrumentation (SqlQueryAnalyzerTest) and -// OpenTelemetry .NET Contrib (SqlProcessorTests). +// 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 -// https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/4e3aba9ddf89f9accac004f44f32ebde335dd115/test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTests.cs package io.sentry.util.sql -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.Parameterized +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 /** - * Owns stability for oversized and degenerate input, under both dialects: - * [SqlQueryAnalyzer.analyze] completes within [TIME_BOUND_MILLIS] on an - * [AnalyzerWorker.STACK_SIZE_BYTES] stack, throws nothing (a `StackOverflowError` would surface - * here), fails nowhere internally, respects `maxQueryTextLength` and never splits a surrogate pair. - * Outputs are not asserted (plan 08, Tests). + * Owns what upstream's tests don't cover: deep and large input on a smaller stack than upstream + * runs on. [SqlQueryAnalyzer.analyze] must complete within [TIME_BOUND_MILLIS] on a + * [STACK_SIZE_BYTES] stack, about half of an Android background thread's, without a + * `StackOverflowError` or an internal failure. Outputs are not asserted (plan 08, Tests). */ -@RunWith(Parameterized::class) -class SqlQueryAnalyzerPathologicalTest( - @Suppress("unused") private val name: String, - private val input: Input, - private val dbSystemName: String?, -) { - - class Input( - val name: String, - val maxQueryTextLength: Int = Int.MAX_VALUE, - val build: () -> String, - ) +class SqlQueryAnalyzerPathologicalTest { @Test - fun `completes within the bound without failing, exceeding the limit or splitting surrogates`() { - val sql = input.build() - val describe = { "${input.name} (${sql.length} chars) under $dbSystemName" } + 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() - val query = - AnalyzerWorker().use { - it.analyze(sql, dbSystemName, input.maxQueryTextLength, TIME_BOUND_MILLIS, describe) - } + 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) + } - assertHasText(query, describe) - assertWithinLimit(query, input.maxQueryTextLength, describe) - assertNoLoneSurrogate(sql, query, describe) + assertWithMessage("no text, so the analyzer failed internally (R5); %s", describe) + .that(query.queryText) + .isNotNull() + } + } + } finally { + executor.shutdownNow() + } } - companion object { + private companion object { /** Bound recorded in plan 01, step 6. */ const val TIME_BOUND_MILLIS = 2_000L - private const val KIB = 1024 - private const val D5_JDBC_LIMIT = 32 * KIB + /** Below the default for Android background threads and HotSpot (both about 1 MiB). */ + const val STACK_SIZE_BYTES = 512L * 1024 - private val DIGITS = (0 until 10_000).joinToString("") + const val MIB = 1024 * 1024 - private val INPUTS = - listOf( - Input("10k nested parens") { "SELECT " + "(".repeat(10_000) + "1" + ")".repeat(10_000) }, - Input("1 MiB of statements") { - val statement = "SELECT a, b FROM t WHERE c = 'Zq9xK7' AND d IN (1, 2, 3) /* Zq9xK7 */; " - // Just under 1 MiB: longer input is not analyzed at all (D66). - statement.repeat(KIB * KIB / statement.length) - }, - // An even count closes the literal (`''` is an escaped quote); an odd count leaves it - // unterminated. - Input("64 KiB of single quotes, closed") { "SELECT " + "'".repeat(64 * KIB) }, - Input("64 KiB of single quotes, unterminated") { "SELECT " + "'".repeat(64 * KIB + 1) }, - Input("64 KiB of comment openers") { "/*".repeat(32 * KIB) }, - // OTel .NET SqlProcessorTests#…RepeatedUnterminatedEscapedIdentifiersInFromClause… - Input("4096 unterminated brackets") { - "SELECT * FROM " + - "[".repeat(4096) + - " WHERE CustomerName = 'secret-name' AND Id = 123 AND Token = 0xDEADBEEF" - }, - Input("128 KiB of opening brackets, closed") { "SELECT " + "[".repeat(128 * KIB) + "]" }, - Input("128 KiB of opening brackets, unterminated") { "SELECT " + "[".repeat(128 * KIB) }, - Input("128 KiB of hash signs on one line") { "SELECT 1 " + "#".repeat(128 * KIB) }, - Input("128 KiB of double slashes on one line") { "SELECT 1 " + "//".repeat(64 * KIB) }, - Input("128 KiB of --a on one line") { "SELECT 1 " + "--a".repeat(128 * KIB / 3) }, - Input("128 KiB of q'[ on one line") { "SELECT 1 " + "q'[".repeat(128 * KIB / 3) }, - Input("128 KiB of dollar signs") { "SELECT " + "$".repeat(128 * KIB) }, - // OTel Java SqlQueryAnalyzerTest#longInStatementDoesntCauseStackOverflow - Input("10001-item IN list") { - "select col from table where col in (" + "?,".repeat(10_000) + "?)" - }, - // OTel Java SqlQueryAnalyzerTest#veryLongNumbersAreOk - Input("39k-digit number") { "SELECT $DIGITS" }, - // OTel Java SqlQueryAnalyzerTest#veryLongNumbersAtEndOfTableAreOk - Input("39k-character identifier") { "SELECT A$DIGITS" }, - // OTel Java SqlQueryAnalyzerTest#test32kTruncation - Input("10k statements at the 32 KiB limit", maxQueryTextLength = D5_JDBC_LIMIT) { - "SELECT * FROM TABLE WHERE FIELD = 1234 AND ".repeat(10_000) - }, - // OTel Java SqlQueryAnalyzerTest#queryTextTruncationDoesNotSplitSurrogatePair: the limit - // falls between the two halves of U+1D49C, a letter outside the BMP. - Input("surrogate pair at the 32 KiB limit", maxQueryTextLength = D5_JDBC_LIMIT) { - // The high surrogate is the limit's last character. - "SELECT " + "A".repeat(D5_JDBC_LIMIT - "SELECT ".length - 1) + "\uD835\uDC9C FROM t" - }, - // As above, without whitespace, so the wrapper cuts at the limit itself. - Input( - "surrogate pair at the 32 KiB limit, no whitespace", - maxQueryTextLength = D5_JDBC_LIMIT, - ) { - "A".repeat(D5_JDBC_LIMIT - 1) + "\uD835\uDC9C" - }, + 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 (D66). + "1 MiB string literal" to "SELECT '" + "x".repeat(MIB - "SELECT ''".length) + "'", ) - - @JvmStatic - @Parameterized.Parameters(name = "{0}") - fun parameters(): List> = INPUTS.flatMap { input -> - DIALECTS.map { dbSystemName -> - arrayOf(input.name + " / " + dbSystemName, input, dbSystemName) - } - } } } diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt index 8392656939d..78017e4070f 100644 --- a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt @@ -105,6 +105,13 @@ class SqlQueryAnalyzerTest { } } + 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) diff --git a/sentry/src/test/resources/sql/analyzer-cases.json b/sentry/src/test/resources/sql/analyzer-cases.json index a593b5ac05d..c34a3e7d438 100644 --- a/sentry/src/test/resources/sql/analyzer-cases.json +++ b/sentry/src/test/resources/sql/analyzer-cases.json @@ -28,14 +28,6 @@ "secrets": ["Zq9xK7secret"], "source": "sentry" }, - { - "id": "size.limit.over", - "dialect": "postgresql", - "input": "SELECT name FROM users WHERE email = 'Zq9xK7@example.com'", - "maxQueryTextLength": 25, - "secrets": ["Zq9xK7@example.com"], - "source": "sentry" - }, { "id": "literal.string.doubled_quote", "dialect": "CONSERVATIVE", @@ -43,12 +35,6 @@ "secrets": ["Zq9xK7a"], "source": "sentry" }, - { - "id": "literal.string.empty", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users WHERE name = ''", - "source": "sentry" - }, { "id": "literal.string.multiline", "dialect": "CONSERVATIVE", @@ -98,60 +84,6 @@ "secrets": ["Zq9xK7lc"], "source": "sentry" }, - { - "id": "literal.number.integers", - "dialect": "CONSERVATIVE", - "input": "SELECT 12, -12, +12 FROM t", - "source": "sentry" - }, - { - "id": "literal.number.decimal_exponent", - "dialect": "CONSERVATIVE", - "input": "SELECT 12.34, .5, -0.5, 1e10, 1.5E-3, -2E+9 FROM t", - "source": "sentry" - }, - { - "id": "literal.number.signed_in_expression", - "dialect": "CONSERVATIVE", - "input": "SELECT a FROM t WHERE b = 99+100 AND c=x-1 AND d = x - 1 AND e>=-5", - "source": "sentry" - }, - { - "id": "literal.number.sign_after_operand", - "dialect": "CONSERVATIVE", - "input": "SELECT a-1, a -1, 2-1, 'b'-1, ?-1, :p-1, $1-1, (c)-1, d[1]-1, `e`-1 FROM t", - "source": "sentry" - }, - { - "id": "literal.number.sign_after_keyword.clauses", - "dialect": "CONSERVATIVE", - "input": "SELECT ALL -1 FROM t JOIN u ON -2 < u.a WHERE -3 < a AND -4 < b OR NOT -5 > c GROUP BY a HAVING -6 < COUNT(*) ORDER BY -7 LIMIT -8 OFFSET -9", - "source": "sentry" - }, - { - "id": "literal.number.sign_after_keyword.expressions", - "dialect": "CONSERVATIVE", - "input": "SELECT DISTINCT CASE -1 WHEN -2 THEN -3 ELSE -4 END FROM t WHERE a BETWEEN -5 AND -6 OR b LIKE -7 ESCAPE -8 OR c = INTERVAL -9 DAY", - "source": "sentry" - }, - { - "id": "literal.number.sign_after_keyword.lists", - "dialect": "CONSERVATIVE", - "input": "SELECT TOP -1 a FROM t WHERE b IN -2 OR c > ANY -3 OR d > SOME -4; VALUES -5; UPDATE t SET -6", - "source": "sentry" - }, - { - "id": "literal.number.sign_after_keyword.ddl", - "dialect": "CONSERVATIVE", - "input": "CREATE TABLE t (a INT DEFAULT -1); CREATE PROCEDURE p AS RETURN -2; CREATE SEQUENCE s START WITH -3 INCREMENT BY -4 MINVALUE -5", - "source": "sentry" - }, - { - "id": "literal.number.in_identifier", - "dialect": "CONSERVATIVE", - "input": "SELECT c3po, r2d2 FROM covid19 WHERE n1h1 = 1234", - "source": "sentry" - }, { "id": "literal.hex", "dialect": "CONSERVATIVE", @@ -159,12 +91,6 @@ "secrets": ["DEADBEEF"], "source": "sentry" }, - { - "id": "literal.binary", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t WHERE a = B'1011' AND b = 0b1011", - "source": "sentry" - }, { "id": "literal.number.word_suffix.postgresql", "dialect": "postgresql", @@ -382,12 +308,6 @@ "secrets": ["Zq9xK7sg"], "source": "sentry" }, - { - "id": "literal.boolean_null_kept", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t WHERE a = TRUE AND b = false AND c IS NULL AND d IS NOT NULL", - "source": "sentry" - }, { "id": "literal.in_list.collapse", "dialect": "CONSERVATIVE", @@ -479,24 +399,6 @@ "secrets": ["Zq9xK7al"], "source": "sentry" }, - { - "id": "comment.hash.empty_lines.mysql", - "dialect": "mysql", - "input": "SELECT a #\nFROM t #", - "source": "sentry" - }, - { - "id": "comment.hash.postgresql", - "dialect": "postgresql", - "input": "SELECT a # b FROM t", - "source": "sentry" - }, - { - "id": "comment.hash.sqlserver_temp_table", - "dialect": "sqlserver", - "input": "SELECT * FROM #orders WHERE id = 1", - "source": "sentry" - }, { "id": "comment.hash.conservative", "dialect": "CONSERVATIVE", @@ -532,12 +434,6 @@ "secrets": ["Zq9xK7aq"], "source": "sentry" }, - { - "id": "comment.dash_dash.mysql", - "dialect": "mysql", - "input": "SELECT 1--1 FROM t", - "source": "sentry" - }, { "id": "comment.dash_dash.before_comment.mysql", "dialect": "mysql", @@ -545,12 +441,6 @@ "secrets": ["Zq9xK7sf"], "source": "sentry" }, - { - "id": "comment.dash_dash.postgresql", - "dialect": "postgresql", - "input": "SELECT 1--1\nFROM t", - "source": "sentry" - }, { "id": "comment.dash_dash.conservative", "dialect": "CONSERVATIVE", @@ -593,12 +483,6 @@ "secrets": ["Zq9xK7at"], "source": "sentry" }, - { - "id": "comment.double_slash.postgresql", - "dialect": "postgresql", - "input": "SELECT 8 // 2 FROM t", - "source": "sentry" - }, { "id": "comment.double_slash.conservative", "dialect": "CONSERVATIVE", @@ -683,60 +567,6 @@ "secrets": ["Zq9xK7sb"], "source": "sentry" }, - { - "id": "param.question", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t WHERE a = ? AND b = ?", - "source": "sentry" - }, - { - "id": "param.numbered", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t WHERE a = ?1 AND b = ?2", - "source": "sentry" - }, - { - "id": "param.named_colon", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t WHERE a = :email AND b = :id", - "source": "sentry" - }, - { - "id": "param.named_at.sqlserver", - "dialect": "sqlserver", - "input": "SELECT * FROM t WHERE a = @email AND b = @p1", - "source": "sentry" - }, - { - "id": "param.dollar_positional.postgresql", - "dialect": "postgresql", - "input": "SELECT * FROM t WHERE a = $1 AND b = $2", - "source": "sentry" - }, - { - "id": "param.dollar_named.sqlite", - "dialect": "sqlite", - "input": "SELECT * FROM t WHERE a = $email", - "source": "sentry" - }, - { - "id": "param.dollar_positional.conservative", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t WHERE a = $1", - "source": "sentry" - }, - { - "id": "param.cast_not_marker.postgresql", - "dialect": "postgresql", - "input": "SELECT a::text FROM t WHERE b = '5'::int", - "source": "sentry" - }, - { - "id": "jdbc.call", - "dialect": "CONSERVATIVE", - "input": "{call get_user(?)}", - "source": "sentry" - }, { "id": "jdbc.call_return", "dialect": "CONSERVATIVE", @@ -758,30 +588,6 @@ "secrets": ["Zq9xK7aw"], "source": "sentry" }, - { - "id": "room.select", - "dialect": "sqlite", - "input": "SELECT * FROM `users` WHERE `id` = ? LIMIT 1", - "source": "sentry" - }, - { - "id": "room.insert_or_replace", - "dialect": "sqlite", - "input": "INSERT OR REPLACE INTO `users` (`id`,`name`) VALUES (?,?)", - "source": "sentry" - }, - { - "id": "room.update_or_abort", - "dialect": "sqlite", - "input": "UPDATE OR ABORT `users` SET `id` = ?,`name` = ? WHERE `id` = ?", - "source": "sentry" - }, - { - "id": "room.delete", - "dialect": "sqlite", - "input": "DELETE FROM `users` WHERE `id` = ?", - "source": "sentry" - }, { "id": "prepared.mixed_constant", "dialect": "CONSERVATIVE", @@ -1006,12 +812,6 @@ "secrets": ["Zq9xK7pb"], "source": "sentry" }, - { - "id": "credentials.identified_by.comment_before_glued_by.postgresql", - "dialect": "postgresql", - "input": "UPDATE t SET a = 1 IDENTIFIED/**/BYpw", - "source": "sentry" - }, { "id": "credentials.password_stop.double_quoted.postgresql", "dialect": "postgresql", @@ -1026,36 +826,6 @@ "secrets": ["Zq9xK7nm", "Zq9xK7nn"], "source": "sentry" }, - { - "id": "credentials.password_stop.before_punctuation.postgresql", - "dialect": "postgresql", - "input": "CREATE STATISTICS user_stats ON password, email FROM users", - "source": "sentry" - }, - { - "id": "credentials.password_stop.after_object_kind", - "dialect": "CONSERVATIVE", - "input": "CREATE SCHEMA password AUTHORIZATION app_owner", - "source": "sentry" - }, - { - "id": "credentials.password_kept.safe_kinds", - "dialect": "CONSERVATIVE", - "input": "CREATE INDEX idx_pw ON users (password DESC); CREATE VIEW v AS SELECT password FROM users; CREATE PROCEDURE p AS SELECT password FROM users", - "source": "sentry" - }, - { - "id": "credentials.password_kept.modifiers.postgresql", - "dialect": "postgresql", - "input": "CREATE OR REPLACE TEMP VIEW v AS SELECT password FROM users; CREATE UNLOGGED TABLE t (password TEXT); CREATE GLOBAL TEMPORARY TABLE g (password TEXT); CREATE LOCAL TEMPORARY TABLE l (password TEXT); CREATE UNIQUE INDEX i ON users (password DESC); CREATE MATERIALIZED VIEW m AS SELECT password FROM users", - "source": "sentry" - }, - { - "id": "credentials.password_kept.modifiers.sqlserver", - "dialect": "sqlserver", - "input": "CREATE CLUSTERED INDEX i ON users (password DESC); CREATE NONCLUSTERED INDEX j ON users (password ASC)", - "source": "sentry" - }, { "id": "credentials.connect_not_allowlisted", "dialect": "CONSERVATIVE", @@ -1063,18 +833,6 @@ "secrets": ["Zq9xK7bu", "Zq9xK7bv"], "source": "sentry" }, - { - "id": "credentials.password_column", - "dialect": "CONSERVATIVE", - "input": "SELECT password FROM users WHERE id = 1", - "source": "sentry" - }, - { - "id": "credentials.password_column_ddl", - "dialect": "CONSERVATIVE", - "input": "CREATE TABLE users (password VARCHAR(255))", - "source": "sentry" - }, { "id": "credentials.password_update", "dialect": "CONSERVATIVE", @@ -1082,12 +840,6 @@ "secrets": ["Zq9xK7bx"], "source": "sentry" }, - { - "id": "shape.select.lowercase", - "dialect": "CONSERVATIVE", - "input": "select id from users where id = 1", - "source": "sentry" - }, { "id": "shape.insert", "dialect": "CONSERVATIVE", @@ -1102,18 +854,6 @@ "secrets": ["Zq9xK7cb"], "source": "sentry" }, - { - "id": "shape.delete", - "dialect": "CONSERVATIVE", - "input": "DELETE FROM users WHERE id IN (1, 2, 3)", - "source": "sentry" - }, - { - "id": "shape.merge", - "dialect": "CONSERVATIVE", - "input": "MERGE INTO users USING staging ON users.id = staging.id WHEN MATCHED THEN UPDATE SET name = staging.name", - "source": "sentry" - }, { "id": "shape.upsert", "dialect": "CONSERVATIVE", @@ -1143,385 +883,115 @@ "source": "sentry" }, { - "id": "shape.create_table.modifier_word_as_name", + "id": "shape.call", "dialect": "CONSERVATIVE", - "input": "CREATE TABLE temp (id INT)", + "input": "CALL update_stats(1, 'Zq9xK7cg')", + "secrets": ["Zq9xK7cg"], "source": "sentry" }, { - "id": "shape.alter_table", + "id": "shape.execute.lowercase", "dialect": "CONSERVATIVE", - "input": "ALTER TABLE orders ADD COLUMN note TEXT", + "input": "execute sp_refresh 'Zq9xK7ch'", + "secrets": ["Zq9xK7ch"], "source": "sentry" }, { - "id": "shape.drop_table_if_exists", - "dialect": "CONSERVATIVE", - "input": "DROP TABLE IF EXISTS orders", + "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": "shape.create_index", - "dialect": "CONSERVATIVE", - "input": "CREATE INDEX idx_orders_status ON orders (status)", + "id": "allowlist.copy.postgresql", + "dialect": "postgresql", + "input": "COPY users (id, email) FROM '/srv/import/Zq9xK7mb.csv' WITH (FORMAT csv)", + "secrets": ["Zq9xK7mb"], "source": "sentry" }, { - "id": "shape.drop_index", - "dialect": "CONSERVATIVE", - "input": "DROP INDEX idx_orders_status", + "id": "allowlist.copy_query.postgresql", + "dialect": "postgresql", + "input": "COPY (SELECT * FROM users WHERE tenant = 'Zq9xK7mc') TO STDOUT", + "secrets": ["Zq9xK7mc"], "source": "sentry" }, { - "id": "shape.create_view", - "dialect": "CONSERVATIVE", - "input": "CREATE VIEW open_orders AS SELECT * FROM orders WHERE status = 'open'", + "id": "allowlist.kill.mysql", + "dialect": "mysql", + "input": "KILL QUERY 48213", + "secrets": ["48213"], "source": "sentry" }, { - "id": "shape.drop_view", - "dialect": "CONSERVATIVE", - "input": "DROP VIEW open_orders", + "id": "allowlist.xa.mysql", + "dialect": "mysql", + "input": "XA START 'Zq9xK7md'", + "secrets": ["Zq9xK7md"], "source": "sentry" }, { - "id": "shape.call", - "dialect": "CONSERVATIVE", - "input": "CALL update_stats(1, 'Zq9xK7cg')", - "secrets": ["Zq9xK7cg"], + "id": "dialect.double_quotes.hsqldb", + "dialect": "hsqldb", + "input": "SELECT \"Name\" FROM \"PUBLIC\".\"Users\" WHERE \"Id\" = 'Zq9xK7da'", + "secrets": ["Zq9xK7da"], "source": "sentry" }, { - "id": "shape.exec.sqlserver", - "dialect": "sqlserver", - "input": "EXEC dbo.cleanup @days = 30", + "id": "dialect.double_quotes.derby", + "dialect": "derby", + "input": "INSERT INTO \"Users\" (\"Name\") VALUES ('Zq9xK7db')", + "secrets": ["Zq9xK7db"], "source": "sentry" }, { - "id": "shape.execute.lowercase", - "dialect": "CONSERVATIVE", - "input": "execute sp_refresh 'Zq9xK7ch'", - "secrets": ["Zq9xK7ch"], + "id": "dialect.double_quotes.mysql", + "dialect": "mysql", + "input": "SELECT * FROM users WHERE name = \"Zq9xK7dc\"", + "secrets": ["Zq9xK7dc"], "source": "sentry" }, { - "id": "shape.with_cte", - "dialect": "CONSERVATIVE", - "input": "WITH recent AS (SELECT * FROM orders WHERE created > '2024-01-01') SELECT * FROM recent JOIN users ON users.id = recent.user_id", + "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": "shape.subquery_in", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users WHERE id IN (SELECT user_id FROM orders WHERE total > 100)", + "id": "dialect.double_quotes.backslash.mysql", + "dialect": "mysql", + "input": "SELECT * FROM t WHERE a = \"x\\\" AND b = 'Zq9xK7dd'", + "secrets": ["Zq9xK7dd"], "source": "sentry" }, { - "id": "shape.derived_table", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (SELECT * FROM orders) o", + "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": "shape.join", - "dialect": "CONSERVATIVE", - "input": "SELECT u.name, o.total FROM users u JOIN orders o ON o.user_id = u.id LEFT JOIN payments p ON p.order_id = o.id", + "id": "dialect.brackets.quote_inside.sqlserver", + "dialect": "sqlserver", + "input": "SELECT [O'Brien] FROM [Users] WHERE [Note] = N'Zq9xK7de'", + "secrets": ["Zq9xK7de"], "source": "sentry" }, { - "id": "shape.implicit_join", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users u, orders o WHERE o.user_id = u.id", + "id": "dialect.brackets.bracket_inside.sqlserver", + "dialect": "sqlserver", + "input": "SELECT [a[b] FROM t WHERE c = 'Zq9xK7sh'", + "secrets": ["Zq9xK7sh"], "source": "sentry" }, { - "id": "shape.union", - "dialect": "CONSERVATIVE", - "input": "SELECT id FROM users UNION ALL SELECT id FROM admins", - "source": "sentry" - }, - { - "id": "shape.parenthesized_union", - "dialect": "CONSERVATIVE", - "input": "(SELECT id FROM users) UNION (SELECT id FROM admins)", - "source": "sentry" - }, - { - "id": "shape.multi_statement", - "dialect": "CONSERVATIVE", - "input": "INSERT INTO a VALUES (1); UPDATE b SET x = 2", - "source": "sentry" - }, - { - "id": "shape.hql.lowercase", - "dialect": "CONSERVATIVE", - "input": "from User u where u.email = :email", - "source": "sentry" - }, - { - "id": "shape.hql.uppercase", - "dialect": "CONSERVATIVE", - "input": "FROM Order WHERE total > 100", - "source": "sentry" - }, - { - "id": "shape.explain", - "dialect": "CONSERVATIVE", - "input": "EXPLAIN SELECT * FROM users WHERE id = 1", - "source": "sentry" - }, - { - "id": "shape.begin_transaction", - "dialect": "CONSERVATIVE", - "input": "BEGIN TRANSACTION", - "source": "sentry" - }, - { - "id": "shape.commit", - "dialect": "CONSERVATIVE", - "input": "COMMIT", - "source": "sentry" - }, - { - "id": "shape.rollback", - "dialect": "CONSERVATIVE", - "input": "ROLLBACK", - "source": "sentry" - }, - { - "id": "shape.savepoint.sqlite", - "dialect": "sqlite", - "input": "SAVEPOINT sp_1", - "source": "sentry" - }, - { - "id": "shape.release_savepoint.sqlite", - "dialect": "sqlite", - "input": "RELEASE SAVEPOINT sp_1", - "source": "sentry" - }, - { - "id": "shape.operation_keyword_as_table.postgresql", - "dialect": "postgresql", - "input": "INSERT INTO checkpoint (id) VALUES (1)", - "source": "sentry" - }, - { - "id": "shape.pragma.sqlite", - "dialect": "sqlite", - "input": "PRAGMA foreign_keys = ON", - "source": "sentry" - }, - { - "id": "shape.pragma_value.sqlite", - "dialect": "sqlite", - "input": "PRAGMA user_version = 3", - "source": "sentry" - }, - { - "id": "shape.pragma_optimize.sqlite", - "dialect": "sqlite", - "input": "PRAGMA optimize", - "source": "sentry" - }, - { - "id": "shape.empty_statements", - "dialect": "CONSERVATIVE", - "input": ";; SELECT * FROM t;;", - "source": "sentry" - }, - { - "id": "shape.semicolon_only", - "dialect": "CONSERVATIVE", - "input": ";", - "source": "sentry" - }, - { - "id": "allowlist.fetch.postgresql", - "dialect": "postgresql", - "input": "FETCH FORWARD 10 FROM order_cursor", - "source": "sentry" - }, - { - "id": "allowlist.close.postgresql", - "dialect": "postgresql", - "input": "CLOSE order_cursor", - "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.deallocate.postgresql", - "dialect": "postgresql", - "input": "DEALLOCATE PREPARE find_user", - "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.refresh.postgresql", - "dialect": "postgresql", - "input": "REFRESH MATERIALIZED VIEW order_totals", - "source": "sentry" - }, - { - "id": "allowlist.refresh_concurrently.postgresql", - "dialect": "postgresql", - "input": "REFRESH MATERIALIZED VIEW CONCURRENTLY order_totals", - "source": "sentry" - }, - { - "id": "allowlist.optimize.mysql", - "dialect": "mysql", - "input": "OPTIMIZE TABLE orders", - "source": "sentry" - }, - { - "id": "allowlist.checkpoint.postgresql", - "dialect": "postgresql", - "input": "CHECKPOINT", - "source": "sentry" - }, - { - "id": "allowlist.kill.mysql", - "dialect": "mysql", - "input": "KILL QUERY 48213", - "secrets": ["48213"], - "source": "sentry" - }, - { - "id": "allowlist.flush.mysql", - "dialect": "mysql", - "input": "FLUSH PRIVILEGES", - "source": "sentry" - }, - { - "id": "allowlist.reset.postgresql", - "dialect": "postgresql", - "input": "RESET search_path", - "source": "sentry" - }, - { - "id": "allowlist.discard.postgresql", - "dialect": "postgresql", - "input": "DISCARD ALL", - "source": "sentry" - }, - { - "id": "allowlist.abort.postgresql", - "dialect": "postgresql", - "input": "ABORT", - "source": "sentry" - }, - { - "id": "allowlist.xa.mysql", - "dialect": "mysql", - "input": "XA START 'Zq9xK7md'", - "secrets": ["Zq9xK7md"], - "source": "sentry" - }, - { - "id": "dialect.double_quotes.postgresql", - "dialect": "postgresql", - "input": "SELECT \"first name\" FROM \"Users\" WHERE \"id\" = 1", - "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", - "dialect": "mysql", - "input": "SELECT * FROM \"Users\"", - "source": "sentry" - }, - { - "id": "dialect.double_quotes.unknown_procedure", - "dialect": "CONSERVATIVE", - "input": "CALL \"get_user\"(?)", - "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.sqlserver", - "dialect": "sqlserver", - "input": "SELECT [first name] FROM [dbo].[Users] WHERE [id] = 1", - "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"], + "id": "dialect.brackets.escaped_close.sqlserver", + "dialect": "sqlserver", + "input": "SELECT [a]]'x] FROM t WHERE p = 'Zq9xK7sm'", + "secrets": ["Zq9xK7sm"], "source": "sentry" }, { @@ -1545,12 +1015,6 @@ "secrets": ["Zq9xK7sp"], "source": "sentry" }, - { - "id": "dialect.brackets.sqlite", - "dialect": "sqlite", - "input": "SELECT [name] FROM [users] WHERE [id] = 1", - "source": "sentry" - }, { "id": "dialect.brackets.postgresql", "dialect": "postgresql", @@ -1558,12 +1022,6 @@ "secrets": ["Zq9xK7df"], "source": "sentry" }, - { - "id": "dialect.brackets.h2", - "dialect": "h2", - "input": "SELECT [name] FROM t WHERE a = 1", - "source": "sentry" - }, { "id": "dialect.brackets.quote_inside.conservative", "dialect": "CONSERVATIVE", @@ -1606,12 +1064,6 @@ "secrets": ["Zq9xK7sd"], "source": "sentry" }, - { - "id": "dialect.brackets.number.conservative", - "dialect": "CONSERVATIVE", - "input": "SELECT a[1] FROM t", - "source": "sentry" - }, { "id": "bracket.array_literal.postgresql", "dialect": "postgresql", @@ -1689,24 +1141,6 @@ "secrets": ["Zq9xK7eg"], "source": "sentry" }, - { - "id": "malformed.unbalanced.close_paren", - "dialect": "CONSERVATIVE", - "input": "SELECT a FROM t WHERE (b = 1))", - "source": "sentry" - }, - { - "id": "malformed.empty", - "dialect": "CONSERVATIVE", - "input": "", - "source": "sentry" - }, - { - "id": "malformed.whitespace_only", - "dialect": "CONSERVATIVE", - "input": " \n\t ", - "source": "sentry" - }, { "id": "malformed.control_char", "dialect": "CONSERVATIVE", @@ -1721,12 +1155,6 @@ "secrets": ["Zq9xK7ei"], "source": "sentry" }, - { - "id": "malformed.lone_surrogate", - "dialect": "CONSERVATIVE", - "input": "SELECT a\ud800 FROM t", - "source": "sentry" - }, { "id": "malformed.lone_surrogate_in_literal", "dialect": "CONSERVATIVE", @@ -1748,12 +1176,6 @@ "secrets": ["Zq9xK7el"], "source": "sentry" }, - { - "id": "unrecognized.keyword_typo", - "dialect": "CONSERVATIVE", - "input": "SELEC * FROM users", - "source": "sentry" - }, { "id": "unrecognized.after_semicolon", "dialect": "CONSERVATIVE", @@ -1811,100 +1233,10 @@ "source": "sentry" }, { - "id": "size.limit.exact", + "id": "size.summary.over_255", "dialect": "CONSERVATIVE", - "input": "SELECT a FROM t WHERE b = 'Zq9xK7fa'", - "maxQueryTextLength": 27, - "secrets": ["Zq9xK7fa"], - "source": "sentry" - }, - { - "id": "size.limit.under", - "dialect": "CONSERVATIVE", - "input": "SELECT a FROM t WHERE b = 'Zq9xK7fa'", - "maxQueryTextLength": 28, - "secrets": ["Zq9xK7fa"], - "source": "sentry" - }, - { - "id": "size.limit.one_over", - "dialect": "CONSERVATIVE", - "input": "SELECT a FROM t WHERE b = 'Zq9xK7fa'", - "maxQueryTextLength": 26, - "secrets": ["Zq9xK7fa"], - "source": "sentry" - }, - { - "id": "size.limit.first_token", - "dialect": "CONSERVATIVE", - "input": "SELECT 1", - "maxQueryTextLength": 4, - "source": "sentry" - }, - { - "id": "size.limit.stop_over_limit", - "dialect": "CONSERVATIVE", - "input": "SELECT a FROM t WHERE b IN ('Zq9xK7fb", - "maxQueryTextLength": 28, - "secrets": ["Zq9xK7fb"], - "source": "sentry" - }, - { - "id": "size.limit.dcl_before_credential.postgresql", - "dialect": "postgresql", - "input": "CREATE USER Zq9xK7oa IDENTIFIED BY 'Zq9xK7ob'", - "maxQueryTextLength": 20, - "secrets": ["Zq9xK7oa", "Zq9xK7ob"], - "source": "sentry" - }, - { - "id": "size.limit.before_first_keyword", - "dialect": "CONSERVATIVE", - "input": "{? = call calc_total(?, ?)}", - "maxQueryTextLength": 4, - "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.insert_entity", - "dialect": "sqlite", - "input": "INSERT OR ABORT INTO `song` (`id`,`title`,`artist`) VALUES (nullif(?, 0),?,?)", - "source": "sentry" - }, - { - "id": "workload.room.insert_batch", - "dialect": "sqlite", - "input": "INSERT INTO song(title, artist) VALUES (?, ?), (?, ?), (?, ?)", - "source": "sentry" - }, - { - "id": "workload.room.count", - "dialect": "sqlite", - "input": "SELECT count(*) FROM song", - "source": "sentry" - }, - { - "id": "workload.room.prime_writer", - "dialect": "sqlite", - "input": "DELETE FROM song WHERE id < 0", - "source": "sentry" - }, - { - "id": "workload.room.query_in_list", - "dialect": "sqlite", - "input": "SELECT * FROM song WHERE id IN (?,?,?) ORDER BY title COLLATE NOCASE LIMIT 20", - "source": "sentry" - }, - { - "id": "workload.room.master_table_create", - "dialect": "sqlite", - "input": "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "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" }, { @@ -1914,66 +1246,6 @@ "secrets": ["Zq9xK7va"], "source": "sentry" }, - { - "id": "workload.room.modification_log_create", - "dialect": "sqlite", - "input": "CREATE TEMP TABLE room_table_modification_log (table_id INTEGER PRIMARY KEY, invalidated INTEGER NOT NULL DEFAULT 0)", - "source": "sentry" - }, - { - "id": "workload.room.invalidation_trigger", - "dialect": "sqlite", - "input": "CREATE TEMP TRIGGER IF NOT EXISTS `room_table_modification_trigger_song_INSERT` AFTER INSERT ON `song` BEGIN UPDATE room_table_modification_log SET invalidated = 1 WHERE table_id = 0 AND invalidated = 0; END", - "source": "sentry" - }, - { - "id": "workload.room.modification_log_reset", - "dialect": "sqlite", - "input": "UPDATE room_table_modification_log SET invalidated = 0 WHERE invalidated = 1", - "source": "sentry" - }, - { - "id": "workload.room.pragma_temp_store", - "dialect": "sqlite", - "input": "PRAGMA temp_store = MEMORY;", - "source": "sentry" - }, - { - "id": "workload.room.begin_immediate", - "dialect": "sqlite", - "input": "BEGIN IMMEDIATE TRANSACTION", - "source": "sentry" - }, - { - "id": "workload.room.migration_double_quoted", - "dialect": "sqlite", - "input": "CREATE TABLE \"order\" (\"id\" INTEGER PRIMARY KEY, \"user\" TEXT)", - "source": "sentry" - }, - { - "id": "workload.hibernate.find_by_id_join", - "dialect": "postgresql", - "input": "select p1_0.id,p1_0.email,p1_0.first_name,a1_0.id,a1_0.city from person p1_0 left join address a1_0 on a1_0.id=p1_0.address_id where p1_0.id=?", - "source": "sentry" - }, - { - "id": "workload.hibernate.insert", - "dialect": "postgresql", - "input": "insert into person (address_id,email,first_name,version,id) values (?,?,?,?,?)", - "source": "sentry" - }, - { - "id": "workload.hibernate.update_versioned", - "dialect": "postgresql", - "input": "update person set email=?,first_name=?,version=? where id=? and version=?", - "source": "sentry" - }, - { - "id": "workload.hibernate.delete", - "dialect": "postgresql", - "input": "delete from person where id=?", - "source": "sentry" - }, { "id": "workload.hibernate.sequence", "dialect": "postgresql", @@ -1981,24 +1253,6 @@ "secrets": ["Zq9xK7vc"], "source": "sentry" }, - { - "id": "workload.hibernate.page_like", - "dialect": "postgresql", - "input": "select p1_0.id,p1_0.email from person p1_0 where p1_0.email like ? escape '' order by p1_0.id offset ? rows fetch first ? rows only", - "source": "sentry" - }, - { - "id": "workload.hibernate.in_padding", - "dialect": "postgresql", - "input": "select p1_0.id,p1_0.email from person p1_0 where p1_0.id in (?,?,?,?)", - "source": "sentry" - }, - { - "id": "workload.hibernate.count_subquery", - "dialect": "postgresql", - "input": "select count(o1_0.id) from orders o1_0 where o1_0.customer_id in (select c1_0.id from customer c1_0 where c1_0.region=?)", - "source": "sentry" - }, { "id": "workload.hibernate.hql_comment", "dialect": "postgresql", @@ -2006,30 +1260,6 @@ "secrets": ["Zq9xK7vd"], "source": "sentry" }, - { - "id": "workload.hibernate.limit.mysql", - "dialect": "mysql", - "input": "select p1_0.id,p1_0.email from person p1_0 order by p1_0.id limit ?,?", - "source": "sentry" - }, - { - "id": "workload.hibernate.quoted_reserved.mysql", - "dialect": "mysql", - "input": "insert into `order` (`customer_id`,`status`,`id`) values (?,?,?)", - "source": "sentry" - }, - { - "id": "workload.hibernate.top.sqlserver", - "dialect": "sqlserver", - "input": "select top(?) p1_0.id,p1_0.email from person p1_0 where p1_0.email=?", - "source": "sentry" - }, - { - "id": "workload.hibernate.lock_hint.sqlserver", - "dialect": "sqlserver", - "input": "select p1_0.id,p1_0.version from person p1_0 with (updlock,holdlock,rowlock) where p1_0.id=?", - "source": "sentry" - }, { "id": "workload.postgresql.upsert_jsonb", "dialect": "postgresql", @@ -2044,18 +1274,6 @@ "secrets": ["Zq9xK7vf", "Zq9xK7vg"], "source": "sentry" }, - { - "id": "workload.postgresql.cte_window", - "dialect": "postgresql", - "input": "WITH ranked AS (SELECT o.id, o.customer_id, row_number() OVER (PARTITION BY o.customer_id ORDER BY o.created_at DESC) AS rn FROM orders o WHERE o.status = ANY(?)) SELECT id, customer_id FROM ranked WHERE rn = 1", - "source": "sentry" - }, - { - "id": "workload.postgresql.search_page", - "dialect": "postgresql", - "input": "SELECT id, email FROM users WHERE email ILIKE ? AND deleted_at IS NULL ORDER BY email LIMIT 20 OFFSET 40", - "source": "sentry" - }, { "id": "workload.postgresql.job_claim", "dialect": "postgresql", @@ -2063,24 +1281,6 @@ "secrets": ["Zq9xK7vh", "Zq9xK7vi"], "source": "sentry" }, - { - "id": "workload.postgresql.advisory_lock", - "dialect": "postgresql", - "input": "SELECT pg_try_advisory_xact_lock(?)", - "source": "sentry" - }, - { - "id": "workload.postgresql.create_table", - "dialect": "postgresql", - "input": "CREATE TABLE IF NOT EXISTS orders (id BIGSERIAL PRIMARY KEY, customer_id BIGINT NOT NULL REFERENCES customers (id), total NUMERIC(12, 2) NOT NULL DEFAULT 0, created_at TIMESTAMPTZ NOT NULL DEFAULT now())", - "source": "sentry" - }, - { - "id": "workload.postgresql.create_index", - "dialect": "postgresql", - "input": "CREATE INDEX IF NOT EXISTS idx_orders_customer ON orders (customer_id, created_at DESC)", - "source": "sentry" - }, { "id": "workload.postgresql.do_block", "dialect": "postgresql", @@ -2088,24 +1288,6 @@ "secrets": ["Zq9xK7vs"], "source": "sentry" }, - { - "id": "workload.postgresql.quoted_identifiers", - "dialect": "postgresql", - "input": "SELECT \"u\".\"id\", \"u\".\"displayName\" FROM \"public\".\"User\" AS \"u\" WHERE \"u\".\"email\" = ?", - "source": "sentry" - }, - { - "id": "workload.postgresql.listen", - "dialect": "postgresql", - "input": "LISTEN order_events", - "source": "sentry" - }, - { - "id": "workload.postgresql.unlisten", - "dialect": "postgresql", - "input": "UNLISTEN order_events", - "source": "sentry" - }, { "id": "workload.postgresql.notify", "dialect": "postgresql", @@ -2113,24 +1295,6 @@ "secrets": ["Zq9xK7vj"], "source": "sentry" }, - { - "id": "workload.mysql.upsert_counter", - "dialect": "mysql", - "input": "INSERT INTO page_views (page_id, day, views) VALUES (?, CURDATE(), 1) ON DUPLICATE KEY UPDATE views = views + 1", - "source": "sentry" - }, - { - "id": "workload.mysql.backticks", - "dialect": "mysql", - "input": "SELECT `id`, `name`, `price` FROM `products` WHERE `category_id` = ? AND `price` BETWEEN 10 AND 20 ORDER BY `name` LIMIT 10", - "source": "sentry" - }, - { - "id": "workload.mysql.interval", - "dialect": "mysql", - "input": "SELECT COUNT(*) FROM orders WHERE created_at >= NOW() - INTERVAL 1 DAY", - "source": "sentry" - }, { "id": "workload.mysql.double_quoted_string", "dialect": "mysql", @@ -2145,12 +1309,6 @@ "secrets": ["Zq9xK7vr"], "source": "sentry" }, - { - "id": "workload.mysql.stock_decrement", - "dialect": "mysql", - "input": "UPDATE inventory SET stock = stock - ? WHERE sku = ? AND stock >= ?", - "source": "sentry" - }, { "id": "workload.mysql.json", "dialect": "mysql", @@ -2159,346 +1317,88 @@ "source": "sentry" }, { - "id": "workload.mysql.multi_table_delete", - "dialect": "mysql", - "input": "DELETE o FROM orders o JOIN customers c ON c.id = o.customer_id WHERE c.deleted_at IS NOT NULL", - "source": "sentry" - }, - { - "id": "workload.mysql.insert_ignore", - "dialect": "mysql", - "input": "INSERT IGNORE INTO tags (name) VALUES (?)", - "source": "sentry" - }, - { - "id": "workload.mysql.start_transaction", - "dialect": "mysql", - "input": "START TRANSACTION", + "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.mysql.set_names", - "dialect": "mysql", - "input": "SET NAMES utf8mb4", + "id": "workload.sqlserver.exec_procedure", + "dialect": "sqlserver", + "input": "EXEC [dbo].[usp_GetOrders] @CustomerId = ?, @Status = N'Zq9xK7vo'", + "secrets": ["Zq9xK7vo"], "source": "sentry" }, { - "id": "workload.mysql.call_procedure", + "id": "workload.tooling.liquibase_lock.mysql", "dialect": "mysql", - "input": "CALL refresh_daily_stats(?, ?)", + "input": "UPDATE DATABASECHANGELOGLOCK SET `LOCKED` = 1, LOCKEDBY = 'Zq9xK7vp', LOCKGRANTED = NOW() WHERE ID = 1 AND `LOCKED` = 0", + "secrets": ["Zq9xK7vp"], "source": "sentry" }, { - "id": "workload.sqlc.get_author", + "id": "workload.tooling.quartz_lock.postgresql", "dialect": "postgresql", - "input": "-- name: GetAuthor :one\nSELECT id, name, bio FROM authors\nWHERE id = ? LIMIT 1", + "input": "SELECT * FROM QRTZ_LOCKS WHERE SCHED_NAME = 'Zq9xK7vq' AND LOCK_NAME = ? FOR UPDATE", + "secrets": ["Zq9xK7vq"], "source": "sentry" }, { - "id": "workload.sqlc.list_authors", - "dialect": "postgresql", - "input": "-- name: ListAuthors :many\nSELECT id, name, bio FROM authors\nORDER BY name", - "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": "workload.sqlc.create_author", - "dialect": "postgresql", - "input": "-- name: CreateAuthor :one\nINSERT INTO authors (\n name, bio\n) VALUES (\n ?, ?\n)\nRETURNING id, name, bio", - "source": "sentry" + "id": "otel_java.sanitize_sql.002", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLE WHERE FIELD = 1234", + "secrets": ["1234"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[2]" }, { - "id": "workload.sqlc.delete_author", - "dialect": "postgresql", - "input": "-- name: DeleteAuthor :exec\nDELETE FROM authors\nWHERE id = ?", - "source": "sentry" + "id": "otel_java.sanitize_sql.003", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLE WHERE FIELD>=-1234", + "secrets": ["1234"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[3]" }, { - "id": "workload.sqlc.update_bios", - "dialect": "postgresql", - "input": "-- name: UpdateAuthorBios :execrows\nUPDATE authors SET bio = ?\nWHERE bio IS NOT NULL", - "source": "sentry" + "id": "otel_java.sanitize_sql.004", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLE WHERE FIELD<-1234", + "secrets": ["1234"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[4]" }, { - "id": "workload.sqlc.books_by_titles", - "dialect": "postgresql", - "input": "-- name: ListBooksByTitles :many\nSELECT book_id, title FROM books\nWHERE title = ANY(?::varchar[])", - "source": "sentry" + "id": "otel_java.sanitize_sql.005", + "dialect": "CONSERVATIVE", + "input": "SELECT * FROM TABLE WHERE FIELD <.1234", + "secrets": ["1234"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[5]" }, { - "id": "workload.sqlc.count_join", - "dialect": "postgresql", - "input": "-- name: CountAuthorsByCountry :one\nSELECT count(*) FROM authors a\nJOIN countries c ON c.id = a.country_id\nWHERE c.code = ?", - "source": "sentry" + "id": "otel_java.sanitize_sql.016", + "dialect": "CONSERVATIVE", + "input": "SELECT 0x0af764", + "secrets": ["0af764"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[16]" }, { - "id": "workload.sqlc.get_user.mysql", - "dialect": "mysql", - "input": "-- name: GetUserByEmail :one\nSELECT id, email FROM users\nWHERE email = ? LIMIT 1", - "source": "sentry" + "id": "otel_java.sanitize_sql.017", + "dialect": "CONSERVATIVE", + "input": "SELECT 0xdeadBEEF", + "secrets": ["deadBEEF"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[17]" }, { - "id": "workload.sqlserver.top_nolock", - "dialect": "sqlserver", - "input": "SELECT TOP (10) [o].[Id], [o].[Total] FROM [dbo].[Orders] AS [o] WITH (NOLOCK) WHERE [o].[CustomerId] = ? ORDER BY [o].[CreatedAt] DESC", - "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.update_counter", - "dialect": "sqlserver", - "input": "UPDATE [dbo].[Users] SET [LastLoginAt] = GETDATE(), [LoginCount] = [LoginCount] + 1 WHERE [Id] = ?", - "source": "sentry" - }, - { - "id": "workload.sqlserver.merge_values", - "dialect": "sqlserver", - "input": "MERGE INTO [dbo].[Inventory] AS [t] USING (VALUES (?, ?)) AS [s] ([Sku], [Qty]) ON [t].[Sku] = [s].[Sku] WHEN MATCHED THEN UPDATE SET [t].[Qty] = [s].[Qty] WHEN NOT MATCHED THEN INSERT ([Sku], [Qty]) VALUES ([s].[Sku], [s].[Qty]);", - "source": "sentry" - }, - { - "id": "workload.sqlserver.exec_procedure", - "dialect": "sqlserver", - "input": "EXEC [dbo].[usp_GetOrders] @CustomerId = ?, @Status = N'Zq9xK7vo'", - "secrets": ["Zq9xK7vo"], - "source": "sentry" - }, - { - "id": "workload.sqlserver.temp_table_insert", - "dialect": "sqlserver", - "input": "INSERT INTO #recent ([Id]) SELECT [Id] FROM [dbo].[Orders] WHERE [CreatedAt] > DATEADD(day, -7, GETDATE())", - "source": "sentry" - }, - { - "id": "workload.sqlserver.brackets_with_spaces", - "dialect": "sqlserver", - "input": "SELECT [Order Id], [Customer's Name] FROM [Sales].[Order Details] WHERE [Unit Price] > ?", - "source": "sentry" - }, - { - "id": "workload.sqlserver.set_nocount", - "dialect": "sqlserver", - "input": "SET NOCOUNT ON; SELECT [Id], [Payload] FROM [dbo].[Jobs] WHERE [State] = ?", - "source": "sentry" - }, - { - "id": "workload.tooling.flyway_history.postgresql", - "dialect": "postgresql", - "input": "SELECT \"installed_rank\",\"version\",\"description\",\"type\",\"script\",\"checksum\",\"installed_on\",\"installed_by\",\"execution_time\",\"success\" FROM \"public\".\"flyway_schema_history\" WHERE \"installed_rank\" > ? ORDER BY \"installed_rank\"", - "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": "workload.tooling.shedlock.postgresql", - "dialect": "postgresql", - "input": "INSERT INTO shedlock (name, lock_until, locked_at, locked_by) VALUES(?, ?, ?, ?) ON CONFLICT (name) DO UPDATE SET lock_until = ?, locked_at = ?, locked_by = ? WHERE shedlock.lock_until <= ?", - "source": "sentry" - }, - { - "id": "workload.tooling.hikari_test_query.mysql", - "dialect": "mysql", - "input": "SELECT 1", - "source": "sentry" - }, - { - "id": "workload.tooling.hikari_init_sql.postgresql", - "dialect": "postgresql", - "input": "SET search_path TO app, public", - "source": "sentry" - }, - { - "id": "workload.tooling.spring_sample_insert.hsqldb", - "dialect": "hsqldb", - "input": "insert into person (firstName, lastName) values (?, ?)", - "source": "sentry" - }, - { - "id": "workload.tooling.spring_sample_schema.hsqldb", - "dialect": "hsqldb", - "input": "CREATE TABLE person (\n id INTEGER IDENTITY PRIMARY KEY,\n firstName VARCHAR(50) NOT NULL,\n lastName VARCHAR(50) NOT NULL\n)", - "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.006", - "dialect": "CONSERVATIVE", - "input": "SELECT 1.2", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[6]" - }, - { - "id": "otel_java.sanitize_sql.007", - "dialect": "CONSERVATIVE", - "input": "SELECT -1.2", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[7]" - }, - { - "id": "otel_java.sanitize_sql.008", - "dialect": "CONSERVATIVE", - "input": "SELECT -1.2e-9", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[8]" - }, - { - "id": "otel_java.sanitize_sql.009", - "dialect": "CONSERVATIVE", - "input": "SELECT 2E+9", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[9]" - }, - { - "id": "otel_java.sanitize_sql.010", - "dialect": "CONSERVATIVE", - "input": "SELECT +0.2", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[10]" - }, - { - "id": "otel_java.sanitize_sql.011", - "dialect": "CONSERVATIVE", - "input": "SELECT .2", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[11]" - }, - { - "id": "otel_java.sanitize_sql.012", - "dialect": "CONSERVATIVE", - "input": "7", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[12]" - }, - { - "id": "otel_java.sanitize_sql.013", - "dialect": "CONSERVATIVE", - "input": ".7", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[13]" - }, - { - "id": "otel_java.sanitize_sql.014", - "dialect": "CONSERVATIVE", - "input": "-7", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[14]" - }, - { - "id": "otel_java.sanitize_sql.015", - "dialect": "CONSERVATIVE", - "input": "+7", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[15]" - }, - { - "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.018", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM \"TABLE\"", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[18]" - }, - { - "id": "otel_java.sanitize_sql.019", - "dialect": "CONSERVATIVE", - "input": "SELECT A + B", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[19]" - }, - { - "id": "otel_java.sanitize_sql.020", - "dialect": "CONSERVATIVE", - "input": "SELECT -- comment", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[20]" - }, - { - "id": "otel_java.sanitize_sql.021", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM TABLE123", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[21]" - }, - { - "id": "otel_java.sanitize_sql.022", - "dialect": "CONSERVATIVE", - "input": "SELECT FIELD2 FROM TABLE_123 WHERE X<>7", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[22]" - }, - { - "id": "otel_java.sanitize_sql.023", - "dialect": "CONSERVATIVE", - "input": "SELECT DEADBEEF", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[23]" - }, - { - "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.025", - "dialect": "CONSERVATIVE", - "input": "SELECT 1/2/34", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[25]" - }, - { - "id": "otel_java.sanitize_sql.026", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM TABLE WHERE FIELD = ''", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[26]" + "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", @@ -2508,2215 +1408,277 @@ "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.029", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM TABLE WHERE FIELD = '\\\\'", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[29]" - }, - { - "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.033", - "dialect": "postgresql", - "input": "SELECT * FROM TABLE WHERE FIELD = $$$$", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[33]" - }, - { - "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.037", - "dialect": "postgresql", - "input": "SELECT * FROM TABLE WHERE FIELD = $$\\\\$$", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[37]" - }, - { - "id": "otel_java.sanitize_sql.038", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM TABLE WHERE FIELD = $1", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[38]" - }, - { - "id": "otel_java.sanitize_sql.039", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM TABLEओ7 WHERE FIELD = 'ɣ'", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[39]" - }, - { - "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.001", - "dialect": "CONSERVATIVE", - "input": "SELECT x, y, z FROM schema.table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[1]" - }, - { - "id": "otel_java.simplify_sql.002", - "dialect": "CONSERVATIVE", - "input": "SELECT x, y, z FROM `schema table`", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[2]" - }, - { - "id": "otel_java.simplify_sql.003", - "dialect": "CONSERVATIVE", - "input": "SELECT x, y, z FROM `schema`.`table`", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[3]" - }, - { - "id": "otel_java.simplify_sql.004", - "dialect": "CONSERVATIVE", - "input": "SELECT x, y, z FROM \"schema table\"", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[4]" - }, - { - "id": "otel_java.simplify_sql.005", - "dialect": "CONSERVATIVE", - "input": "SELECT x, y, z FROM \"schema\".\"table\"", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[5]" - }, - { - "id": "otel_java.simplify_sql.006", - "dialect": "CONSERVATIVE", - "input": "WITH subquery as (select a from b) SELECT x, y, z FROM table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[6]" - }, - { - "id": "otel_java.simplify_sql.007", - "dialect": "CONSERVATIVE", - "input": "SELECT x, y, (select a from b) as z FROM table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[7]" - }, - { - "id": "otel_java.simplify_sql.008", - "dialect": "CONSERVATIVE", - "input": "select delete, insert into, merge, update from table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[8]" - }, - { - "id": "otel_java.simplify_sql.009", - "dialect": "CONSERVATIVE", - "input": "select col /* from table2 */ from table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[9]" - }, - { - "id": "otel_java.simplify_sql.010", - "dialect": "CONSERVATIVE", - "input": "select col from table join anotherTable", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[10]" - }, - { - "id": "otel_java.simplify_sql.011", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id JOIN t3 ON t2.x = t3.x", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[11]" - }, - { - "id": "otel_java.simplify_sql.012", - "dialect": "CONSERVATIVE", - "input": "select col from (select * from anotherTable)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[12]" - }, - { - "id": "otel_java.simplify_sql.013", - "dialect": "CONSERVATIVE", - "input": "select col from (select * from anotherTable) alias", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[13]" - }, - { - "id": "otel_java.simplify_sql.014", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (SELECT * FROM t1) sub, t3", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[14]" - }, - { - "id": "otel_java.simplify_sql.015", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (SELECT * FROM t1) s1, (SELECT * FROM t2) s2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[15]" - }, - { - "id": "otel_java.simplify_sql.016", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (SELECT * FROM t1) sub, t2 JOIN t3 ON t2.id = t3.id", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[16]" - }, - { - "id": "otel_java.simplify_sql.017", - "dialect": "CONSERVATIVE", - "input": "select col from table1 union select col from table2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[17]" - }, - { - "id": "otel_java.simplify_sql.018", - "dialect": "CONSERVATIVE", - "input": "SELECT id, name FROM employees UNION ALL SELECT id, name FROM contractors UNION SELECT id, name FROM vendors", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[18]" - }, - { - "id": "otel_java.simplify_sql.019", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (t UNION SELECT * FROM t2), t3", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[19]" - }, - { - "id": "otel_java.simplify_sql.020", - "dialect": "CONSERVATIVE", - "input": "select id, (select max(foo) from (select foo from foos union all select foo from bars)) as foo from main_table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[20]" - }, - { - "id": "otel_java.simplify_sql.021", - "dialect": "CONSERVATIVE", - "input": "select col from table where col in (select * from anotherTable)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[21]" - }, - { - "id": "otel_java.simplify_sql.022", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (SELECT * FROM inner1 JOIN inner2 ON inner1.id = inner2.id) AS sub", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[22]" - }, - { - "id": "otel_java.simplify_sql.023", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (VALUES (1,2), (3,4)) AS t(a, b)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[23]" - }, - { - "id": "otel_java.simplify_sql.024", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 CROSS APPLY t2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[24]" - }, - { - "id": "otel_java.simplify_sql.025", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 OUTER APPLY (SELECT * FROM t2 WHERE t2.id = t1.id)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[25]" - }, - { - "id": "otel_java.simplify_sql.026", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1, LATERAL (SELECT * FROM t2 WHERE t2.id = t1.id)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[26]" - }, - { - "id": "otel_java.simplify_sql.027", - "dialect": "CONSERVATIVE", - "input": "select col from table1, table2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[27]" - }, - { - "id": "otel_java.simplify_sql.028", - "dialect": "CONSERVATIVE", - "input": "select col from table1 t1, table2 t2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[28]" - }, - { - "id": "otel_java.simplify_sql.029", - "dialect": "CONSERVATIVE", - "input": "select col from table1 as t1, table2 as t2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[29]" - }, - { - "id": "otel_java.simplify_sql.030", - "dialect": "CONSERVATIVE", - "input": "select col from table where col in (1, 2, 3)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[30]" - }, - { - "id": "otel_java.simplify_sql.031", - "dialect": "CONSERVATIVE", - "input": "select 'a' IN(x, 'b') from table where col in (1) and z IN( '3', '4' )", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[31]" - }, - { - "id": "otel_java.simplify_sql.032", - "dialect": "CONSERVATIVE", - "input": "select col from table order by col, col2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[32]" - }, - { - "id": "otel_java.simplify_sql.033", - "dialect": "CONSERVATIVE", - "input": "select ąś∂ń© from źćļńĶ order by col, col2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[33]" - }, - { - "id": "otel_java.simplify_sql.034", - "dialect": "CONSERVATIVE", - "input": "select 12345678", - "secrets": ["12345678"], - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[34]" - }, - { - "id": "otel_java.simplify_sql.035", - "dialect": "CONSERVATIVE", - "input": "/* update comment */ select * from table1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[35]" - }, - { - "id": "otel_java.simplify_sql.036", - "dialect": "CONSERVATIVE", - "input": "select /*((*/abc from table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[36]" - }, - { - "id": "otel_java.simplify_sql.037", - "dialect": "CONSERVATIVE", - "input": "SeLeCT * FrOm TAblE", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[37]" - }, - { - "id": "otel_java.simplify_sql.038", - "dialect": "CONSERVATIVE", - "input": "select next value in hibernate_sequence", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[38]" - }, - { - "id": "otel_java.simplify_sql.039", - "dialect": "CONSERVATIVE", - "input": "EXPLAIN SELECT * FROM users", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[39]" - }, - { - "id": "otel_java.simplify_sql.040", - "dialect": "CONSERVATIVE", - "input": "from schema.table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[40]" - }, - { - "id": "otel_java.simplify_sql.041", - "dialect": "CONSERVATIVE", - "input": "FROM schema.table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[41]" - }, - { - "id": "otel_java.simplify_sql.042", - "dialect": "CONSERVATIVE", - "input": "/* update comment */ from table1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[42]" - }, - { - "id": "otel_java.simplify_sql.043", - "dialect": "CONSERVATIVE", - "input": " insert into table where lalala", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[43]" - }, - { - "id": "otel_java.simplify_sql.044", - "dialect": "CONSERVATIVE", - "input": "insert into metrics.users (id) values (1)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[44]" - }, - { - "id": "otel_java.simplify_sql.045", - "dialect": "CONSERVATIVE", - "input": "insert insert into table where lalala", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[45]" - }, - { - "id": "otel_java.simplify_sql.046", - "dialect": "CONSERVATIVE", - "input": "insert into db.table where lalala", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[46]" - }, - { - "id": "otel_java.simplify_sql.047", - "dialect": "CONSERVATIVE", - "input": "insert into `db table` where lalala", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[47]" - }, - { - "id": "otel_java.simplify_sql.048", - "dialect": "CONSERVATIVE", - "input": "insert into \"db table\" where lalala", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[48]" - }, - { - "id": "otel_java.simplify_sql.049", - "dialect": "CONSERVATIVE", - "input": "insert without i-n-t-o", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[49]" - }, - { - "id": "otel_java.simplify_sql.050", - "dialect": "CONSERVATIVE", - "input": "delete from table where something something", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[50]" - }, - { - "id": "otel_java.simplify_sql.051", - "dialect": "CONSERVATIVE", - "input": "delete from `my table` where something something", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[51]" - }, - { - "id": "otel_java.simplify_sql.052", - "dialect": "CONSERVATIVE", - "input": "delete from \"my table\" where something something", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[52]" - }, - { - "id": "otel_java.simplify_sql.053", - "dialect": "CONSERVATIVE", - "input": "delete from foo where x IN (1,2,3)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[53]" - }, - { - "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.055", - "dialect": "CONSERVATIVE", - "input": "delete (((", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[55]" - }, - { - "id": "otel_java.simplify_sql.056", - "dialect": "CONSERVATIVE", - "input": "update table set answer=42", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[56]" - }, - { - "id": "otel_java.simplify_sql.057", - "dialect": "CONSERVATIVE", - "input": "update `my table` set answer=42", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[57]" - }, - { - "id": "otel_java.simplify_sql.058", - "dialect": "CONSERVATIVE", - "input": "update `my table` set answer=42 where x IN('a', 'b') AND y In ('a', 'b')", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[58]" - }, - { - "id": "otel_java.simplify_sql.059", - "dialect": "CONSERVATIVE", - "input": "update \"my table\" set answer=42", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[59]" - }, - { - "id": "otel_java.simplify_sql.060", - "dialect": "CONSERVATIVE", - "input": "update /*table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[60]" - }, - { - "id": "otel_java.simplify_sql.061", - "dialect": "CONSERVATIVE", - "input": "call test_proc()", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[61]" - }, - { - "id": "otel_java.simplify_sql.062", - "dialect": "CONSERVATIVE", - "input": "call test_proc", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[62]" - }, - { - "id": "otel_java.simplify_sql.063", - "dialect": "CONSERVATIVE", - "input": "call next value for hibernate_sequence", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[63]" - }, - { - "id": "otel_java.simplify_sql.064", - "dialect": "CONSERVATIVE", - "input": "call db.test_proc", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[64]" - }, - { - "id": "otel_java.simplify_sql.065", - "dialect": "CONSERVATIVE", - "input": "merge into table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[65]" - }, - { - "id": "otel_java.simplify_sql.066", - "dialect": "CONSERVATIVE", - "input": "merge into `my table`", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[66]" - }, - { - "id": "otel_java.simplify_sql.067", - "dialect": "CONSERVATIVE", - "input": "merge into \"my table\"", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[67]" - }, - { - "id": "otel_java.simplify_sql.068", - "dialect": "CONSERVATIVE", - "input": "merge table (into is optional in some dbs)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[68]" - }, - { - "id": "otel_java.simplify_sql.069", - "dialect": "CONSERVATIVE", - "input": "merge (into )))", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[69]" - }, - { - "id": "otel_java.simplify_sql.070", - "dialect": "CONSERVATIVE", - "input": "and now for something completely different", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[70]" - }, - { - "id": "otel_java.simplify_sql.073", - "dialect": "CONSERVATIVE", - "input": "INSERT INTO t1 SELECT * FROM t2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[73]" - }, - { - "id": "otel_java.simplify_sql.074", - "dialect": "CONSERVATIVE", - "input": "DELETE FROM t1 WHERE x IN (SELECT y FROM t2)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[74]" - }, - { - "id": "otel_java.simplify_sql.075", - "dialect": "CONSERVATIVE", - "input": "UPDATE t1 SET x = (SELECT y FROM t2)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[75]" - }, - { - "id": "otel_java.simplify_sql.076", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1; SELECT * FROM t2", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[76]" - }, - { - "id": "otel_java.simplify_sql.077", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1; INSERT INTO t2 VALUES (1)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[77]" - }, - { - "id": "otel_java.simplify_sql.078", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t;", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[78]" - }, - { - "id": "otel_java.simplify_sql.079", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t;;", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[79]" - }, - { - "id": "otel_java.simplify_sql.080", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM ONLY parent", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[80]" - }, - { - "id": "otel_java.simplify_sql.081", - "dialect": "CONSERVATIVE", - "input": "DELETE FROM ONLY parent WHERE id = 1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[81]" - }, - { - "id": "otel_java.simplify_sql.082", - "dialect": "CONSERVATIVE", - "input": "UPDATE ONLY parent SET x = 1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[82]" - }, - { - "id": "otel_java.simplify_sql.083", - "dialect": "CONSERVATIVE", - "input": "VALUES (1)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[83]" - }, - { - "id": "otel_java.simplify_sql.084", - "dialect": "CONSERVATIVE", - "input": "VALUES (1, 'a'), (2, 'b')", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[84]" - }, - { - "id": "otel_java.simplify_sql.085", - "dialect": "CONSERVATIVE", - "input": "EXEC my_procedure", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[85]" - }, - { - "id": "otel_java.simplify_sql.086", - "dialect": "CONSERVATIVE", - "input": "EXECUTE db.my_procedure @param=1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[86]" - }, - { - "id": "otel_java.simplify_sql.087", - "dialect": "sqlserver", - "input": "SELECT * FROM [my table]", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[87]" - }, - { - "id": "otel_java.simplify_sql.088", - "dialect": "sqlserver", - "input": "SELECT * FROM [schema].[table]", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[88]" - }, - { - "id": "otel_java.simplify_sql.089", - "dialect": "sqlserver", - "input": "SELECT [column] FROM [table] WHERE [field] = 1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[89]" - }, - { - "id": "otel_java.simplify_sql.090", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM `my``table`", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[90]" - }, - { - "id": "otel_java.simplify_sql.091", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM `table` WHERE `col``name` = 1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[91]" - }, - { - "id": "otel_java.simplify_sql.093", - "dialect": "CONSERVATIVE", - "input": ";;", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[93]" - }, - { - "id": "otel_java.simplify_sql.094", - "dialect": "CONSERVATIVE", - "input": " ; ", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[94]" - }, - { - "id": "otel_java.simplify_sql.095", - "dialect": "CONSERVATIVE", - "input": "/* comment only */", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[95]" - }, - { - "id": "otel_java.simplify_sql.096", - "dialect": "CONSERVATIVE", - "input": " ", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[96]" - }, - { - "id": "otel_java.simplify_sql.098", - "dialect": "CONSERVATIVE", - "input": "-- This query will DELETE old records\nSELECT * FROM users WHERE active = 1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[98]" - }, - { - "id": "otel_java.simplify_sql.099", - "dialect": "postgresql", - "input": "--This query will DELETE old records\nSELECT * FROM users WHERE active = 1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[99]" - }, - { - "id": "otel_java.simplify_sql.100", - "dialect": "postgresql", - "input": "SELECT --83", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[100]" - }, - { - "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.103", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM a, (SELECT * FROM b), c", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[103]" - }, - { - "id": "otel_java.simplify_sql.104", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (SELECT * FROM inner1), (SELECT * FROM inner2), outer_table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[104]" - }, - { - "id": "otel_java.simplify_sql.105", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (TABLE)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[105]" - }, - { - "id": "otel_java.simplify_sql.106", - "dialect": "CONSERVATIVE", - "input": "TRUNCATE TABLE users", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[106]" - }, - { - "id": "otel_java.simplify_sql.107", - "dialect": "CONSERVATIVE", - "input": "TRUNCATE users", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[107]" - }, - { - "id": "otel_java.simplify_sql.108", - "dialect": "CONSERVATIVE", - "input": "TRUNCATE TABLE schema.table", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[108]" - }, - { - "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.110", - "dialect": "CONSERVATIVE", - "input": "REPLACE users SET name = 'foo'", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[110]" - }, - { - "id": "otel_java.simplify_sql.111", - "dialect": "CONSERVATIVE", - "input": "REPLACE INTO db.table (col) VALUES (1)", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[111]" - }, - { - "id": "otel_java.simplify_sql.112", - "dialect": "CONSERVATIVE", - "input": "BEGIN", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[112]" - }, - { - "id": "otel_java.simplify_sql.115", - "dialect": "CONSERVATIVE", - "input": "COMMIT TRANSACTION", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[115]" - }, - { - "id": "otel_java.simplify_sql.117", - "dialect": "CONSERVATIVE", - "input": "ROLLBACK TRANSACTION", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[117]" - }, - { - "id": "otel_java.simplify_sql.118", - "dialect": "CONSERVATIVE", - "input": "LOCK TABLE users", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[118]" - }, - { - "id": "otel_java.simplify_sql.119", - "dialect": "CONSERVATIVE", - "input": "LOCK TABLE users IN EXCLUSIVE MODE", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[119]" - }, - { - "id": "otel_java.simplify_sql.120", - "dialect": "CONSERVATIVE", - "input": "LOCK TABLES users WRITE, orders READ", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[120]" - }, - { - "id": "otel_java.simplify_sql.121", - "dialect": "CONSERVATIVE", - "input": "USE mydb", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[121]" - }, - { - "id": "otel_java.simplify_sql.122", - "dialect": "CONSERVATIVE", - "input": "USE `my database`", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[122]" - }, - { - "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.simplify_sql.127", - "dialect": "CONSERVATIVE", - "input": "SHOW TABLES", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[127]" - }, - { - "id": "otel_java.simplify_sql.128", - "dialect": "CONSERVATIVE", - "input": "SHOW CREATE TABLE users", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[128]" - }, - { - "id": "otel_java.simplify_sql.129", - "dialect": "CONSERVATIVE", - "input": "SHOW DATABASES", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[129]" - }, - { - "id": "otel_java.simplify_sql.130", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM insert WHERE x = 1", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[130]" - }, - { - "id": "otel_java.simplify_sql.131", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM update", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[131]" - }, - { - "id": "otel_java.simplify_sql.132", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM delete", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[132]" - }, - { - "id": "otel_java.simplify_sql.133", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM call", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[133]" - }, - { - "id": "otel_java.simplify_sql.134", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM merge", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[134]" - }, - { - "id": "otel_java.simplify_sql.135", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM create", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[135]" - }, - { - "id": "otel_java.simplify_sql.136", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM drop", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[136]" - }, - { - "id": "otel_java.simplify_sql.137", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM alter", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[137]" - }, - { - "id": "otel_java.simplify_sql.138", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM exec", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[138]" - }, - { - "id": "otel_java.simplify_sql.139", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM execute", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[139]" - }, - { - "id": "otel_java.simplify_sql.140", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users@remote_db", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[140]" - }, - { - "id": "otel_java.simplify_sql.141", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM schema.users@remote_db", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[141]" - }, - { - "id": "otel_java.simplify_sql.142", - "dialect": "CONSERVATIVE", - "input": "SELECT insert, update FROM mytable", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[142]" - }, - { - "id": "otel_java.simplify_sql.143", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM mytable insert", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[143]" - }, - { - "id": "otel_java.simplify_sql.144", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM mytable AS update", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[144]" - }, - { - "id": "otel_java.simplify_sql.145", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM user", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[145]" - }, - { - "id": "otel_java.simplify_sql.146", - "dialect": "CONSERVATIVE", - "input": "WITH cte AS (SELECT a FROM b) SELECT * FROM cte", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[146]" - }, - { - "id": "otel_java.simplify_sql.147", - "dialect": "CONSERVATIVE", - "input": "WITH cte AS (VALUES (1, 'a'), (2, 'b')) SELECT * FROM cte", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[147]" - }, - { - "id": "otel_java.simplify_sql.148", - "dialect": "CONSERVATIVE", - "input": "WITH a AS (SELECT * FROM t1), b AS (SELECT * FROM t2) SELECT * FROM a JOIN b ON a.id = b.id", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[148]" - }, - { - "id": "otel_java.simplify_sql.149", - "dialect": "CONSERVATIVE", - "input": "WITH RECURSIVE cte AS (SELECT id FROM t WHERE parent IS NULL UNION ALL SELECT t.id FROM t JOIN cte ON t.parent = cte.id) SELECT * FROM cte", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[149]" - }, - { - "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.015", - "dialect": "CONSERVATIVE", - "input": "GRANT SELECT ON users TO admin; SELECT password FROM users", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[15]" - }, - { - "id": "otel_java.sanitize_sensitive.016", - "dialect": "CONSERVATIVE", - "input": "SELECT connect FROM TABLE", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[16]" - }, - { - "id": "otel_java.sanitize_sensitive.017", - "dialect": "CONSERVATIVE", - "input": "SELECT grant, password FROM users", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[17]" - }, - { - "id": "otel_java.sanitize_sensitive.018", - "dialect": "CONSERVATIVE", - "input": "SELECT password FROM users", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[18]" - }, - { - "id": "otel_java.sanitize_sensitive.019", - "dialect": "CONSERVATIVE", - "input": "SELECT identified_by FROM users", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[19]" - }, - { - "id": "otel_java.sanitize_sensitive.020", - "dialect": "CONSERVATIVE", - "input": "TRUNCATE TABLE password", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[20]" - }, - { - "id": "otel_java.sanitize_sensitive.021", - "dialect": "CONSERVATIVE", - "input": "REPLACE password VALUES (1)", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[21]" - }, - { - "id": "otel_java.sanitize_sensitive.022", - "dialect": "CONSERVATIVE", - "input": "VALUES (password)", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[22]" - }, - { - "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_object_named_password.001", - "dialect": "CONSERVATIVE", - "input": "GRANT SELECT ON password TO admin", - "source": "otel-java:SqlQueryAnalyzerTest#sanitizeGrantObjectNamedPassword[1]" - }, - { - "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.query_summary_is_truncated.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM very_long_table_name_0, very_long_table_name_1, very_long_table_name_2, very_long_table_name_3, very_long_table_name_4, very_long_table_name_5, very_long_table_name_6, very_long_table_name_7, very_long_table_name_8, very_long_table_name_9, very_long_table_name_10, very_long_table_name_11, very_long_table_name_12, very_long_table_name_13, very_long_table_name_14, very_long_table_name_15, very_long_table_name_16, very_long_table_name_17, very_long_table_name_18, very_long_table_name_19, very_long_table_name_20, very_long_table_name_21, very_long_table_name_22, very_long_table_name_23, very_long_table_name_24, very_long_table_name_25, very_long_table_name_26, very_long_table_name_27, very_long_table_name_28, very_long_table_name_29, very_long_table_name_30, very_long_table_name_31, very_long_table_name_32, very_long_table_name_33, very_long_table_name_34, very_long_table_name_35, very_long_table_name_36, very_long_table_name_37, very_long_table_name_38, very_long_table_name_39, very_long_table_name_40, very_long_table_name_41, very_long_table_name_42, very_long_table_name_43, very_long_table_name_44, very_long_table_name_45, very_long_table_name_46, very_long_table_name_47, very_long_table_name_48, very_long_table_name_49", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryIsTruncated[1]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.001", - "dialect": "CONSERVATIVE", - "input": "select * from users", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[1]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.002", - "dialect": "CONSERVATIVE", - "input": "SeLeCT * FrOm users", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[2]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.003", - "dialect": "CONSERVATIVE", - "input": "insert into users values (1)", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[3]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.004", - "dialect": "CONSERVATIVE", - "input": "delete from users where id = 1", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[4]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.005", - "dialect": "CONSERVATIVE", - "input": "update users set id = 1", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[5]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.006", - "dialect": "CONSERVATIVE", - "input": "call do_work()", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[6]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.007", - "dialect": "CONSERVATIVE", - "input": "merge into users", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[7]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.008", - "dialect": "CONSERVATIVE", - "input": "create table users (id int)", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[8]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.009", - "dialect": "CONSERVATIVE", - "input": "drop table users", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[9]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.010", - "dialect": "CONSERVATIVE", - "input": "alter table users add column id int", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[10]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.011", - "dialect": "CONSERVATIVE", - "input": "values (1)", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[11]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.012", - "dialect": "CONSERVATIVE", - "input": "exec do_work", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[12]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.013", - "dialect": "CONSERVATIVE", - "input": "execute db.do_work @param=1", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[13]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.014", - "dialect": "CONSERVATIVE", - "input": "truncate table users", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[14]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.015", - "dialect": "CONSERVATIVE", - "input": "replace into users values (1)", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[15]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.016", - "dialect": "CONSERVATIVE", - "input": "lock table users", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[16]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.017", - "dialect": "CONSERVATIVE", - "input": "use mydb", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[17]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.018", - "dialect": "CONSERVATIVE", - "input": "begin transaction", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[18]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.019", - "dialect": "CONSERVATIVE", - "input": "commit transaction", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[19]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.020", - "dialect": "CONSERVATIVE", - "input": "rollback transaction", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[20]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.021", - "dialect": "CONSERVATIVE", - "input": "grant select on users to admin", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[21]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.022", - "dialect": "CONSERVATIVE", - "input": "revoke select on users from admin", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[22]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.023", - "dialect": "CONSERVATIVE", - "input": "show create table users", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[23]" - }, - { - "id": "otel_java.query_summary_preserves_operation_case.024", - "dialect": "CONSERVATIVE", - "input": "explain select * from users", - "source": "otel-java:SqlQueryAnalyzerTest#querySummaryPreservesOperationCase[24]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.001", - "dialect": "CONSERVATIVE", - "input": "CREATE TABLE `table`", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[1]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.002", - "dialect": "CONSERVATIVE", - "input": "CREATE TABLE ks.users ( id UUID PRIMARY KEY, name text )", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[2]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.003", - "dialect": "CONSERVATIVE", - "input": "create table ks.users ( id UUID PRIMARY KEY, name text )", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[3]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.004", - "dialect": "CONSERVATIVE", - "input": "CREATE KEYSPACE sync_test", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[4]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.005", - "dialect": "CONSERVATIVE", - "input": "CREATE TABLE IF NOT EXISTS table", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[5]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.006", - "dialect": "CONSERVATIVE", - "input": "DROP TABLE `if`", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[6]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.007", - "dialect": "CONSERVATIVE", - "input": "ALTER TABLE table ADD CONSTRAINT c FOREIGN KEY (foreign_id) REFERENCES ref (id)", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[7]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.008", - "dialect": "CONSERVATIVE", - "input": "CREATE INDEX types_name ON types (name)", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[8]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.009", - "dialect": "CONSERVATIVE", - "input": "DROP INDEX types_name ON types (name)", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[9]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.010", - "dialect": "CONSERVATIVE", - "input": "CREATE VIEW tmp AS SELECT type FROM table WHERE id = ?", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[10]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.011", - "dialect": "CONSERVATIVE", - "input": "CREATE PROCEDURE p AS SELECT * FROM table GO", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[11]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.012", - "dialect": "CONSERVATIVE", - "input": "ALTER TABLE t2 DROP COLUMN c, DROP COLUMN d", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[12]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.013", - "dialect": "CONSERVATIVE", - "input": "ALTER TABLE users ADD COLUMN email VARCHAR(255), DROP COLUMN legacy_id, MODIFY COLUMN status INT", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[13]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.015", - "dialect": "CONSERVATIVE", - "input": "create table users (password VARCHAR(255))", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[15]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.016", - "dialect": "CONSERVATIVE", - "input": "ALTER TABLE users ADD COLUMN password VARCHAR(255)", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[16]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.017", - "dialect": "CONSERVATIVE", - "input": "alter table users ADD COLUMN password VARCHAR(255)", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[17]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.018", - "dialect": "CONSERVATIVE", - "input": "ALTER TABLE user ADD COLUMN name VARCHAR(255)", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[18]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.019", - "dialect": "CONSERVATIVE", - "input": "CREATE TABLE password (id INT)", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[19]" - }, - { - "id": "otel_java.check_ddl_operation_statements_are_ok.020", - "dialect": "CONSERVATIVE", - "input": "DROP TABLE password", - "source": "otel-java:SqlQueryAnalyzerTest#checkDdlOperationStatementsAreOk[20]" - }, - { - "id": "otel_java.simplify_sql_double_quotes_as_identifiers.001", - "dialect": "postgresql", - "input": "SELECT * FROM \"TABLE\"", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[1]" - }, - { - "id": "otel_java.simplify_sql_double_quotes_as_identifiers.002", - "dialect": "postgresql", - "input": "SELECT x, y, z FROM \"schema table\"", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[2]" - }, - { - "id": "otel_java.simplify_sql_double_quotes_as_identifiers.003", - "dialect": "postgresql", - "input": "insert into \"db table\" where lalala", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[3]" - }, - { - "id": "otel_java.simplify_sql_double_quotes_as_identifiers.004", - "dialect": "postgresql", - "input": "delete from \"my table\" where something something", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[4]" - }, - { - "id": "otel_java.simplify_sql_double_quotes_as_identifiers.005", - "dialect": "postgresql", - "input": "update \"my table\" set answer=42", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[5]" - }, - { - "id": "otel_java.simplify_sql_double_quotes_as_identifiers.006", - "dialect": "postgresql", - "input": "merge into \"my table\"", - "source": "otel-java:SqlQueryAnalyzerTest#simplifySqlDoubleQuotesAsIdentifiers[6]" - }, - { - "id": "otel_java.database_specific_dml.001", - "dialect": "CONSERVATIVE", - "input": "UPDATE t1 JOIN t2 ON t1.id = t2.t1_id SET t1.col = t2.col WHERE t2.status = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#databaseSpecificDml[1]" - }, - { - "id": "otel_java.database_specific_dml.002", - "dialect": "CONSERVATIVE", - "input": "DELETE t1 FROM t1 JOIN t2 ON t1.id = t2.t1_id WHERE t2.status = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#databaseSpecificDml[2]" - }, - { - "id": "otel_java.database_specific_dml.003", - "dialect": "CONSERVATIVE", - "input": "UPDATE t1 SET col = t2.col FROM t2 WHERE t1.id = t2.t1_id AND t2.status = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#databaseSpecificDml[3]" - }, - { - "id": "otel_java.database_specific_dml.004", - "dialect": "CONSERVATIVE", - "input": "DELETE FROM t1 USING t2 WHERE t1.id = t2.t1_id AND t2.status = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#databaseSpecificDml[4]" - }, - { - "id": "otel_java.insert_variations.001", - "dialect": "CONSERVATIVE", - "input": "INSERT INTO t1 a SELECT * FROM t2 WHERE t2.id = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#insertVariations[1]" - }, - { - "id": "otel_java.insert_variations.002", - "dialect": "CONSERVATIVE", - "input": "INSERT INTO archive (id, data) SELECT o.id, c.data FROM orders o JOIN customers c ON o.cid = c.id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#insertVariations[2]" - }, - { - "id": "otel_java.insert_variations.003", - "dialect": "CONSERVATIVE", - "input": "INSERT INTO orders (product_id) SELECT id FROM products WHERE active = ? RETURNING *", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#insertVariations[3]" - }, - { - "id": "otel_java.update_delete_with_subqueries.001", - "dialect": "CONSERVATIVE", - "input": "UPDATE products SET price = price * 1.1 WHERE category_id IN (SELECT id FROM categories WHERE margin_low = ?)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[1]" - }, - { - "id": "otel_java.update_delete_with_subqueries.002", - "dialect": "CONSERVATIVE", - "input": "UPDATE employees SET salary = (SELECT AVG(salary) FROM employees WHERE department_id = ?) WHERE department_id = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[2]" - }, - { - "id": "otel_java.update_delete_with_subqueries.003", - "dialect": "CONSERVATIVE", - "input": "UPDATE products SET price = (SELECT avg_price FROM stats) WHERE category_id IN (SELECT id FROM categories WHERE active = ?)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[3]" - }, - { - "id": "otel_java.update_delete_with_subqueries.004", - "dialect": "CONSERVATIVE", - "input": "UPDATE t1 SET a = (SELECT MAX(x) FROM t2), b = (SELECT MIN(y) FROM t3), c = (SELECT AVG(z) FROM t4)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[4]" - }, - { - "id": "otel_java.update_delete_with_subqueries.005", - "dialect": "CONSERVATIVE", - "input": "DELETE FROM orders WHERE customer_id NOT IN (SELECT id FROM customers) AND product_id NOT IN (SELECT id FROM products)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#updateDeleteWithSubqueries[5]" - }, - { - "id": "otel_java.joins.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM colors CROSS JOIN sizes", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[1]" - }, - { - "id": "otel_java.joins.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 CROSS JOIN t2 CROSS JOIN t3", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[2]" - }, - { - "id": "otel_java.joins.003", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM products CROSS JOIN (SELECT * FROM categories WHERE active = ?) AS c", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[3]" - }, - { - "id": "otel_java.joins.004", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM employees NATURAL JOIN departments", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[4]" - }, - { - "id": "otel_java.joins.005", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 NATURAL LEFT JOIN t2 NATURAL RIGHT JOIN t3", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[5]" - }, - { - "id": "otel_java.joins.006", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders o INNER JOIN customers c ON o.customer_id = c.id LEFT JOIN shipping s ON o.id = s.order_id RIGHT JOIN invoices i ON o.id = i.order_id FULL OUTER JOIN payments p ON o.id = p.order_id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[6]" - }, - { - "id": "otel_java.joins.007", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 JOIN t2 USING (id) LEFT JOIN t3 USING (id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[7]" - }, - { - "id": "otel_java.joins.008", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users WHERE deleted_at IS NULL AND email IS NOT NULL", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#joins[8]" - }, - { - "id": "otel_java.lateral_joins.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 CROSS JOIN LATERAL (SELECT * FROM t2 WHERE t2.id = t1.id) AS sub", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lateralJoins[1]" - }, - { - "id": "otel_java.lateral_joins.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 LEFT JOIN LATERAL (SELECT * FROM t2 WHERE t2.fk = t1.id LIMIT 1) sub ON true", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lateralJoins[2]" - }, - { - "id": "otel_java.lateral_joins.003", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1, LATERAL (SELECT * FROM t2 WHERE t2.id = t1.id) a, LATERAL (SELECT * FROM t3 WHERE t3.id = a.id) b", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lateralJoins[3]" - }, - { - "id": "otel_java.table_functions.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM get_user_orders(?) WHERE status = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[1]" - }, - { - "id": "otel_java.table_functions.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM dbo.fn_split(?, ',')", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[2]" - }, - { - "id": "otel_java.table_functions.003", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM UNNEST(ARRAY[1,2,3]) AS t", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[3]" - }, - { - "id": "otel_java.table_functions.004", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM GENERATE_SERIES(1, 10) AS gs", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[4]" - }, - { - "id": "otel_java.table_functions.005", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM fn1(fn2(fn3(?)))", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[5]" - }, - { - "id": "otel_java.table_functions.006", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 CROSS JOIN UNNEST(t1.arr) AS e", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#tableFunctions[6]" - }, - { - "id": "otel_java.scalar_subqueries.001", - "dialect": "CONSERVATIVE", - "input": "SELECT e.name, (SELECT AVG(salary) FROM employees WHERE department_id = e.department_id) as avg_dept_salary FROM employees e", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#scalarSubqueries[1]" - }, - { - "id": "otel_java.scalar_subqueries.002", - "dialect": "CONSERVATIVE", - "input": "SELECT p.name, (SELECT MAX(price) FROM products), (SELECT MIN(price) FROM products) FROM products p", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#scalarSubqueries[2]" - }, - { - "id": "otel_java.exists_and_not_exists.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM customers WHERE EXISTS (SELECT 1 FROM orders WHERE customer_id = customers.id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#existsAndNotExists[1]" - }, - { - "id": "otel_java.exists_and_not_exists.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM products WHERE NOT EXISTS (SELECT 1 FROM order_items WHERE product_id = products.id AND quantity > 0)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#existsAndNotExists[2]" - }, - { - "id": "otel_java.exists_and_not_exists.003", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users u WHERE EXISTS (SELECT 1 FROM sessions WHERE user_id = u.id) AND NOT EXISTS (SELECT 1 FROM banned_users WHERE user_id = u.id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#existsAndNotExists[3]" - }, - { - "id": "otel_java.all_any_some_operators.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM products WHERE price > ALL (SELECT price FROM discounted_products)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#allAnySomeOperators[1]" - }, - { - "id": "otel_java.all_any_some_operators.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM employees WHERE salary >= ANY (SELECT salary FROM managers)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#allAnySomeOperators[2]" - }, - { - "id": "otel_java.all_any_some_operators.003", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders WHERE amount < SOME (SELECT amount FROM large_orders)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#allAnySomeOperators[3]" - }, - { - "id": "otel_java.in_subqueries.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders WHERE (customer_id, product_id) IN (SELECT customer_id, product_id FROM wishlists)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#inSubqueries[1]" - }, - { - "id": "otel_java.in_subqueries.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users WHERE id NOT IN (SELECT user_id FROM banned_users)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#inSubqueries[2]" - }, - { - "id": "otel_java.derived_tables.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (SELECT id, name FROM users) AS u (user_id, user_name)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#derivedTables[1]" - }, - { - "id": "otel_java.deeply_nested_subqueries.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM users WHERE active = ?) AS l1) AS l2) AS l3", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#deeplyNestedSubqueries[1]" - }, - { - "id": "otel_java.deeply_nested_subqueries.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders WHERE customer_id IN (SELECT id FROM customers WHERE region_id IN (SELECT id FROM regions WHERE country_id IN (SELECT id FROM countries WHERE code = ?)))", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#deeplyNestedSubqueries[2]" - }, - { - "id": "otel_java.subqueries_in_join_conditions.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders o JOIN customers c ON o.customer_id = c.id AND o.amount > (SELECT AVG(amount) FROM orders WHERE customer_id = c.id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[1]" - }, - { - "id": "otel_java.subqueries_in_join_conditions.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM employees e LEFT JOIN departments d ON e.dept_id = d.id AND EXISTS (SELECT 1 FROM projects WHERE dept_id = d.id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[2]" - }, - { - "id": "otel_java.subqueries_in_join_conditions.003", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders o JOIN order_items i ON o.id = i.order_id AND i.price > (SELECT AVG(price) FROM order_items WHERE order_id = o.id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[3]" - }, - { - "id": "otel_java.subqueries_in_join_conditions.004", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1 JOIN t2 ON t1.a IN (SELECT x FROM t3) AND t2.b IN (SELECT y FROM t4)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[4]" - }, - { - "id": "otel_java.subqueries_in_join_conditions.005", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM customers c JOIN orders o ON c.id = o.cust_id AND EXISTS (SELECT 1 FROM vip WHERE vip.cust_id = c.id AND vip.order_id = o.id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInJoinConditions[5]" - }, - { - "id": "otel_java.subqueries_in_clause_positions.001", - "dialect": "CONSERVATIVE", - "input": "SELECT department_id, COUNT(*) FROM employees GROUP BY department_id HAVING COUNT(*) > (SELECT AVG(cnt) FROM (SELECT COUNT(*) as cnt FROM employees GROUP BY department_id) AS dept_counts)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[1]" - }, - { - "id": "otel_java.subqueries_in_clause_positions.002", - "dialect": "CONSERVATIVE", - "input": "SELECT category, SUM(price) FROM products GROUP BY category HAVING SUM(price) > (SELECT AVG(total) FROM category_totals)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[2]" - }, - { - "id": "otel_java.subqueries_in_clause_positions.003", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM products ORDER BY (SELECT AVG(rating) FROM reviews WHERE product_id = products.id) DESC", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[3]" - }, - { - "id": "otel_java.subqueries_in_clause_positions.004", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM employees ORDER BY (SELECT COUNT(*) FROM projects WHERE manager_id = employees.id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[4]" - }, - { - "id": "otel_java.subqueries_in_clause_positions.005", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM products WHERE price BETWEEN (SELECT MIN(price) FROM products) AND (SELECT MAX(price) FROM products)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[5]" - }, - { - "id": "otel_java.subqueries_in_clause_positions.006", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users LIMIT (SELECT setting FROM config WHERE key = ?)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[6]" - }, - { - "id": "otel_java.subqueries_in_clause_positions.007", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users OFFSET (SELECT page_size FROM config) ROWS", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[7]" - }, - { - "id": "otel_java.subqueries_in_clause_positions.008", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM GENERATE_SERIES(1, (SELECT MAX(id) FROM users))", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[8]" - }, - { - "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.subqueries_in_clause_positions.010", - "dialect": "CONSERVATIVE", - "input": "SELECT COALESCE((SELECT a FROM t1), (SELECT b FROM t2), (SELECT c FROM t3)) FROM dual", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[10]" - }, - { - "id": "otel_java.ctes.001", - "dialect": "CONSERVATIVE", - "input": "WITH cte1 AS (SELECT * FROM t1), cte2 AS (SELECT * FROM cte1 JOIN t2 ON cte1.id = t2.id) SELECT * FROM cte2", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[1]" - }, - { - "id": "otel_java.ctes.002", - "dialect": "CONSERVATIVE", - "input": "WITH a AS (SELECT 1), b AS (SELECT 2), c AS (SELECT 3) SELECT * FROM a, b, c", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[2]" - }, - { - "id": "otel_java.ctes.003", - "dialect": "CONSERVATIVE", - "input": "WITH new_data AS (SELECT * FROM staging WHERE processed = ?) INSERT INTO archive SELECT * FROM new_data", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[3]" - }, - { - "id": "otel_java.ctes.004", - "dialect": "CONSERVATIVE", - "input": "WITH updates AS (SELECT id, new_value FROM temp) UPDATE target SET value = (SELECT new_value FROM updates WHERE updates.id = target.id) WHERE EXISTS (SELECT 1 FROM updates WHERE updates.id = target.id)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[4]" - }, - { - "id": "otel_java.ctes.005", - "dialect": "CONSERVATIVE", - "input": "WITH to_delete AS (SELECT id FROM old_records WHERE date < ?) DELETE FROM records WHERE id IN (SELECT id FROM to_delete)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[5]" - }, - { - "id": "otel_java.ctes.006", - "dialect": "CONSERVATIVE", - "input": "WITH a AS (SELECT 1 as x), b AS (SELECT x FROM a), c AS (SELECT x FROM b) SELECT * FROM c", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[6]" - }, - { - "id": "otel_java.ctes.007", - "dialect": "CONSERVATIVE", - "input": "WITH users AS (SELECT * FROM active_users) SELECT * FROM users", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#ctes[7]" - }, - { - "id": "otel_java.set_operations.001", - "dialect": "CONSERVATIVE", - "input": "SELECT user_id FROM premium_users INTERSECT SELECT user_id FROM active_users", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[1]" - }, - { - "id": "otel_java.set_operations.002", - "dialect": "CONSERVATIVE", - "input": "SELECT email FROM all_users EXCEPT SELECT email FROM unsubscribed", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[2]" - }, - { - "id": "otel_java.set_operations.003", - "dialect": "CONSERVATIVE", - "input": "(SELECT id FROM users) UNION (SELECT id FROM customers)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[3]" - }, - { - "id": "otel_java.set_operations.004", - "dialect": "CONSERVATIVE", - "input": "(SELECT * FROM t1 UNION SELECT * FROM t2) INTERSECT (SELECT * FROM t3 UNION SELECT * FROM t4)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[4]" - }, - { - "id": "otel_java.set_operations.005", - "dialect": "CONSERVATIVE", - "input": "SELECT id FROM t1 MINUS SELECT id FROM t2", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#setOperations[5]" - }, - { - "id": "otel_java.window_functions.001", - "dialect": "CONSERVATIVE", - "input": "SELECT name, department, salary, AVG(salary) OVER (PARTITION BY department) as avg_dept_salary FROM employees", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[1]" - }, - { - "id": "otel_java.window_functions.002", - "dialect": "CONSERVATIVE", - "input": "SELECT id, SUM(val) OVER w FROM data WINDOW w AS (PARTITION BY cat)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[2]" - }, - { - "id": "otel_java.window_functions.003", - "dialect": "CONSERVATIVE", - "input": "SELECT SUM(val) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM data", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[3]" - }, - { - "id": "otel_java.window_functions.004", - "dialect": "CONSERVATIVE", - "input": "SELECT ROW_NUMBER() OVER (ORDER BY a), RANK() OVER (PARTITION BY b ORDER BY c) FROM tbl", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[4]" - }, - { - "id": "otel_java.window_functions.005", - "dialect": "CONSERVATIVE", - "input": "SELECT SUM(amount) OVER (PARTITION BY (SELECT type FROM types WHERE types.id = sales.type_id)) FROM sales", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#windowFunctions[5]" - }, - { - "id": "otel_java.expressions.001", - "dialect": "CONSERVATIVE", - "input": "SELECT CAST(price AS DECIMAL(10,2)) FROM products", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[1]" - }, - { - "id": "otel_java.expressions.002", - "dialect": "CONSERVATIVE", - "input": "SELECT CAST((SELECT MAX(amount) FROM orders) AS INTEGER) FROM dual", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[2]" - }, - { - "id": "otel_java.expressions.003", - "dialect": "CONSERVATIVE", - "input": "SELECT name, CAST(created_at AS DATE) FROM users WHERE CAST(status AS INTEGER) = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[3]" - }, - { - "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.expressions.006", - "dialect": "CONSERVATIVE", - "input": "SELECT CASE type WHEN 'A' THEN (SELECT COUNT(*) FROM type_a) WHEN 'B' THEN (SELECT COUNT(*) FROM type_b) ELSE 0 END FROM items", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[6]" - }, - { - "id": "otel_java.expressions.007", - "dialect": "CONSERVATIVE", - "input": "SELECT CASE (SELECT type FROM config) WHEN 'A' THEN (SELECT v FROM a) WHEN 'B' THEN (SELECT v FROM b) END FROM dual", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[7]" - }, - { - "id": "otel_java.expressions.008", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders WHERE (customer_id, product_id) = (?, ?)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[8]" - }, - { - "id": "otel_java.expressions.009", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users WHERE (first_name, last_name) IN (SELECT first_name, last_name FROM vip_users)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[9]" - }, - { - "id": "otel_java.clauses.001", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users ORDER BY created_at OFFSET 10 ROWS FETCH FIRST 20 ROWS ONLY", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[1]" - }, - { - "id": "otel_java.clauses.002", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM products ORDER BY price FETCH NEXT 10 ROWS ONLY", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[2]" - }, - { - "id": "otel_java.clauses.003", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders OFFSET 5 ROWS FETCH NEXT 1 ROW ONLY", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[3]" - }, - { - "id": "otel_java.clauses.004", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users LIMIT 10 OFFSET 5", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[4]" - }, - { - "id": "otel_java.clauses.005", - "dialect": "CONSERVATIVE", - "input": "SELECT dept, SUM(salary) FROM employees GROUP BY ROLLUP(dept)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[5]" - }, - { - "id": "otel_java.clauses.006", - "dialect": "CONSERVATIVE", - "input": "SELECT dept, year, SUM(salary) FROM employees GROUP BY CUBE(dept, year)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[6]" - }, - { - "id": "otel_java.clauses.007", + "id": "otel_java.sanitize_sql.028", "dialect": "CONSERVATIVE", - "input": "SELECT dept, year, SUM(salary) FROM employees GROUP BY GROUPING SETS ((dept), (year))", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[7]" + "input": "SELECT * FROM TABLE WHERE FIELD = ' an escaped '' quote mark inside'", + "secrets": ["quote mark inside"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[28]" }, { - "id": "otel_java.clauses.008", + "id": "otel_java.sanitize_sql.030", "dialect": "CONSERVATIVE", - "input": "SELECT * INTO temp_table FROM users WHERE active = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[8]" + "input": "SELECT * FROM TABLE WHERE FIELD = '\"inside doubles\"'", + "secrets": ["inside doubles"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[30]" }, { - "id": "otel_java.clauses.009", + "id": "otel_java.sanitize_sql.031", "dialect": "CONSERVATIVE", - "input": "SELECT u.name, COUNT(o.id) INTO summary_table FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.name", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[9]" + "input": "SELECT * FROM TABLE WHERE FIELD = '\"$$$$\"'", + "secrets": ["\"$$$$\""], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[31]" }, { - "id": "otel_java.clauses.010", + "id": "otel_java.sanitize_sql.032", "dialect": "CONSERVATIVE", - "input": "INSERT INTO users (name) VALUES (?) RETURNING id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[10]" + "input": "SELECT * FROM TABLE WHERE FIELD = 'a single \" doublequote inside'", + "secrets": ["doublequote inside"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[32]" }, { - "id": "otel_java.clauses.011", - "dialect": "CONSERVATIVE", - "input": "DELETE FROM users WHERE id = ? RETURNING *", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[11]" + "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.clauses.012", - "dialect": "CONSERVATIVE", - "input": "UPDATE users SET name = ? WHERE id = ? RETURNING *", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[12]" + "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.clauses.013", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users FOR UPDATE OF users.name NOWAIT", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[13]" + "id": "otel_java.sanitize_sql.036", + "dialect": "postgresql", + "input": "SELECT * FROM TABLE WHERE FIELD = $$\"''\"$$", + "secrets": ["\"''\""], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[36]" }, { - "id": "otel_java.clauses.014", + "id": "otel_java.sanitize_sql.040", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users FOR SHARE", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[14]" + "input": "SELECT * \t\r\nFROM TABLE WHERE FIELD1 = 12344 AND FIELD2 = 5678", + "secrets": ["12344", "5678"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[40]" }, { - "id": "otel_java.clauses.015", + "id": "otel_java.sanitize_sql.041", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users FOR UPDATE SKIP LOCKED", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[15]" + "input": "from TABLE WHERE FIELD=1234", + "secrets": ["1234"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSql[41]" }, { - "id": "otel_java.clauses.016", + "id": "otel_java.simplify_sql.034", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users FETCH FIRST 10 PERCENT ROWS ONLY", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[16]" + "input": "select 12345678", + "secrets": ["12345678"], + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[34]" }, { - "id": "otel_java.clauses.017", + "id": "otel_java.simplify_sql.054", "dialect": "CONSERVATIVE", - "input": "SELECT TOP 10 PERCENT * FROM users", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[17]" + "input": "delete from 12345678", + "secrets": ["12345678"], + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[54]" }, { - "id": "otel_java.clauses.018", - "dialect": "CONSERVATIVE", - "input": "SELECT DISTINCT ON (department) * FROM employees", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#clauses[18]" + "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.values_clauses.001", - "dialect": "CONSERVATIVE", - "input": "INSERT INTO t1 (col) VALUES ((SELECT MAX(col) FROM t2))", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#valuesClauses[1]" + "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.values_clauses.002", + "id": "otel_java.simplify_sql.109", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (VALUES (1), (2)) AS t(id) JOIN users u ON t.id = u.id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#valuesClauses[2]" + "input": "REPLACE INTO users VALUES (1, 'name')", + "secrets": ["name"], + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[109]" }, { - "id": "otel_java.values_clauses.003", + "id": "otel_java.simplify_sql.123", "dialect": "CONSERVATIVE", - "input": "SELECT id FROM users UNION VALUES (1), (2)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#valuesClauses[3]" + "input": "GRANT SELECT ON users TO some_user", + "secrets": ["some_user"], + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[123]" }, { - "id": "otel_java.identifiers_and_table_references.001", + "id": "otel_java.simplify_sql.124", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM \"SELECT\" WHERE \"FROM\" = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[1]" + "input": "GRANT ALL PRIVILEGES ON database.* TO 'user'@'host'", + "secrets": ["user", "host"], + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[124]" }, { - "id": "otel_java.identifiers_and_table_references.002", + "id": "otel_java.simplify_sql.125", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM `SELECT` WHERE `FROM` = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[2]" - }, - { - "id": "otel_java.identifiers_and_table_references.003", - "dialect": "sqlserver", - "input": "SELECT * FROM [SELECT] WHERE [FROM] = ?", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[3]" + "input": "REVOKE SELECT ON users FROM some_user", + "secrets": ["some_user"], + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[125]" }, { - "id": "otel_java.identifiers_and_table_references.004", + "id": "otel_java.simplify_sql.126", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM \"table.name\"", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[4]" - }, - { - "id": "otel_java.identifiers_and_table_references.005", - "dialect": "sqlite", - "input": "SELECT * FROM \"schema\".`table` JOIN [other] ON \"schema\".`table`.id = [other].id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[5]" + "input": "REVOKE ALL PRIVILEGES ON database.* FROM 'user'@'host'", + "secrets": ["user", "host"], + "source": "otel-java:SqlQueryAnalyzerTest#simplifySql[126]" }, { - "id": "otel_java.identifiers_and_table_references.006", + "id": "otel_java.sanitize_sensitive.001", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM db.schema.table", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[6]" + "input": "CREATE USER new_user PASSWORD Password1", + "secrets": ["new_user", "Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[1]" }, { - "id": "otel_java.identifiers_and_table_references.007", + "id": "otel_java.sanitize_sensitive.002", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM schema1.t1 JOIN t2 ON schema1.t1.id = t2.id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[7]" + "input": "ALTER USER user PASSWORD Password1", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[2]" }, { - "id": "otel_java.identifiers_and_table_references.008", + "id": "otel_java.sanitize_sensitive.003", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM (t1), (t2)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[8]" + "input": "CONNECT user PASSWORD Password1", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[3]" }, { - "id": "otel_java.identifiers_and_table_references.009", + "id": "otel_java.sanitize_sensitive.004", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.t1_id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[9]" + "input": "VALIDATE USER user PASSWORD Password1", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[4]" }, { - "id": "otel_java.identifiers_and_table_references.010", + "id": "otel_java.sanitize_sensitive.005", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM t1, t2 JOIN t3 ON t2.id = t3.t2_id, t4", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[10]" + "input": "CHECK USER user PASSWORD \"Password1\"", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[5]" }, { - "id": "otel_java.identifiers_and_table_references.011", + "id": "otel_java.sanitize_sensitive.006", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users orders JOIN orders o ON orders.id = o.user_id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#identifiersAndTableReferences[11]" + "input": "CREATE DATABASE db SYSTEM USER PASSWORD Password1", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[6]" }, { - "id": "otel_java.alias_edge_cases.001", + "id": "otel_java.sanitize_sensitive.007", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users join", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#aliasEdgeCases[1]" + "input": "ALTER SYSTEM SET SECURE STORE BACKUP PASSWORD \"Password1\"", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[7]" }, { - "id": "otel_java.alias_edge_cases.002", + "id": "otel_java.sanitize_sensitive.008", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM orders users JOIN users u ON orders.user_id = u.id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#aliasEdgeCases[2]" + "input": "EXPORT table AS BINARY ENCRYPTION PASSWORD Password1", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[8]" }, { - "id": "otel_java.alias_edge_cases.003", + "id": "otel_java.sanitize_sensitive.009", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users AS this_is_a_very_long_alias_name_that_exceeds_normal_length", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#aliasEdgeCases[3]" + "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.lexical_edge_cases.001", - "dialect": "postgresql", - "input": "SELECT /* outer /* inner */ still comment */ * FROM users", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#lexicalEdgeCases[1]" + "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.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.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.statements_and_semicolons.001", + "id": "otel_java.sanitize_sensitive.012", "dialect": "CONSERVATIVE", - "input": "; SELECT * FROM users", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#statementsAndSemicolons[1]" + "input": "CREATE USER new_user IDENTIFIED BY Password1", + "secrets": ["new_user", "Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[12]" }, { - "id": "otel_java.statements_and_semicolons.002", - "dialect": "CONSERVATIVE", - "input": ";; SELECT * FROM t1", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#statementsAndSemicolons[2]" + "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.statements_and_semicolons.003", + "id": "otel_java.sanitize_sensitive.014", "dialect": "CONSERVATIVE", - "input": "; ; SELECT * FROM t1; ; SELECT * FROM t2; ;", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#statementsAndSemicolons[3]" + "input": "GRANT ALL PRIVILEGES ON database.* TO user IDENTIFIED BY Password1", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[14]" }, { - "id": "otel_java.vendor_specific_syntax.001", + "id": "otel_java.sanitize_sensitive.023", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM sales PIVOT (SUM(amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'))", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[1]" + "input": "UPDATE users SET password = \"Password1\"", + "secrets": ["ord1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeSensitive[23]" }, { - "id": "otel_java.vendor_specific_syntax.002", + "id": "otel_java.sanitize_grant_identified_by_after_previous_statement.001", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM wide_table UNPIVOT (value FOR col_name IN (col1, col2, col3))", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[2]" + "input": "SELECT 1; GRANT ALL PRIVILEGES ON database.* TO user IDENTIFIED BY Password1", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeGrantIdentifiedByAfterPreviousStatement[1]" }, { - "id": "otel_java.vendor_specific_syntax.003", + "id": "otel_java.sanitize_ddl_object_named_password.001", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM large_table TABLESAMPLE SYSTEM (10)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[3]" + "input": "CREATE USER password PASSWORD Password1", + "secrets": ["Password1"], + "source": "otel-java:SqlQueryAnalyzerTest#sanitizeDdlObjectNamedPassword[1]" }, { - "id": "otel_java.vendor_specific_syntax.004", + "id": "otel_java.subqueries_in_clause_positions.009", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM large_table TABLESAMPLE BERNOULLI (1) REPEATABLE (42)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[4]" + "input": "SELECT COALESCE((SELECT name FROM t1 WHERE id = ?), 'default') FROM dual", + "secrets": ["default"], + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#subqueriesInClausePositions[9]" }, { - "id": "otel_java.vendor_specific_syntax.005", + "id": "otel_java.expressions.004", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users FOR XML PATH", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[5]" + "input": "SELECT CASE WHEN status = ? THEN 'Active' ELSE 'Inactive' END FROM users", + "secrets": ["Active", "Inactive"], + "source": "otel-java:SqlQuerySummaryEdgeCasesTest#expressions[4]" }, { - "id": "otel_java.vendor_specific_syntax.006", + "id": "otel_java.expressions.005", "dialect": "CONSERVATIVE", - "input": "SELECT * FROM users FOR JSON AUTO", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[6]" + "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.vendor_specific_syntax.007", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM ticker MATCH_RECOGNIZE (ORDER BY tstamp MEASURES A.tstamp AS start_t PATTERN (A B* C) DEFINE A AS A.price > 10)", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[7]" + "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", @@ -4725,18 +1687,6 @@ "secrets": ["Total"], "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[8]" }, - { - "id": "otel_java.vendor_specific_syntax.009", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM employees START WITH manager_id IS NULL CONNECT BY PRIOR employee_id = manager_id", - "source": "otel-java:SqlQuerySummaryEdgeCasesTest#vendorSpecificSyntax[9]" - }, - { - "id": "otel_dotnet.json.numeric_literal_integers", - "dialect": "CONSERVATIVE", - "input": "SELECT 12, -12, +12", - "source": "otel-dotnet:SqlProcessorTestCases.json#numeric_literal_integers" - }, { "id": "otel_dotnet.json.numeric_literal_with_decimal_point", "dialect": "CONSERVATIVE", @@ -4758,12 +1708,6 @@ "secrets": ["12.34e-56"], "source": "otel-dotnet:SqlProcessorTestCases.json#numeric_literal_negative_exponential" }, - { - "id": "otel_dotnet.json.arithmetic_on_numeric_literals", - "dialect": "CONSERVATIVE", - "input": "SELECT 99+100", - "source": "otel-dotnet:SqlProcessorTestCases.json#arithmetic_on_numeric_literals" - }, { "id": "otel_dotnet.json.hex_literal", "dialect": "CONSERVATIVE", @@ -4799,12 +1743,6 @@ "secrets": ["1234"], "source": "otel-dotnet:SqlProcessorTestCases.json#numbers_in_identifiers" }, - { - "id": "otel_dotnet.json.periods_in_identifiers", - "dialect": "CONSERVATIVE", - "input": "SELECT a FROM dbo.Table JOIN dbo.AnotherTable", - "source": "otel-dotnet:SqlProcessorTestCases.json#periods_in_identifiers" - }, { "id": "otel_dotnet.json.insert_into", "dialect": "CONSERVATIVE", @@ -4819,12 +1757,6 @@ "secrets": ["01234567-89ab"], "source": "otel-dotnet:SqlProcessorTestCases.json#uuid" }, - { - "id": "otel_dotnet.json.in_clause", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM table WHERE value IN (123, 456, 'abc')", - "source": "otel-dotnet:SqlProcessorTestCases.json#in_clause" - }, { "id": "otel_dotnet.json.comments", "dialect": "CONSERVATIVE", @@ -4832,66 +1764,6 @@ "secrets": ["end of line", "block \n comment"], "source": "otel-dotnet:SqlProcessorTestCases.json#comments" }, - { - "id": "otel_dotnet.json.insert_into_select", - "dialect": "CONSERVATIVE", - "input": "INSERT INTO shipping_details\n(order_id,\naddress)\nSELECT order_id,\naddress\nFROM orders\nWHERE order_id = 1", - "source": "otel-dotnet:SqlProcessorTestCases.json#insert_into_select" - }, - { - "id": "otel_dotnet.json.select_nested_query", - "dialect": "CONSERVATIVE", - "input": "SELECT order_date\nFROM (SELECT *\nFROM orders o\nJOIN customers c\nON o.customer_id = c.customer_id)", - "source": "otel-dotnet:SqlProcessorTestCases.json#select_nested_query" - }, - { - "id": "otel_dotnet.json.select_nested_query_case_preserved", - "dialect": "CONSERVATIVE", - "input": "SELEcT order_date\nFROM (sELECT *\nFROM orders o\nJOIN customers c\nON o.customer_id = c.customer_id)", - "source": "otel-dotnet:SqlProcessorTestCases.json#select_nested_query_case_preserved" - }, - { - "id": "otel_dotnet.json.case_preserved", - "dialect": "CONSERVATIVE", - "input": "SELEcT order_date\nFROM ORders", - "source": "otel-dotnet:SqlProcessorTestCases.json#case_preserved" - }, - { - "id": "otel_dotnet.json.cross_join", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM Orders o CROSS JOIN OrderDetails od", - "source": "otel-dotnet:SqlProcessorTestCases.json#cross_join" - }, - { - "id": "otel_dotnet.json.cross_join_comma_separated_syntax", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM Orders o, OrderDetails od", - "source": "otel-dotnet:SqlProcessorTestCases.json#cross_join_comma_separated_syntax" - }, - { - "id": "otel_dotnet.json.create_table", - "dialect": "CONSERVATIVE", - "input": "CREATE TABLE MyTable (\n ID NOT NULL IDENTITY(1,1) PRIMARY KEY\n)", - "source": "otel-dotnet:SqlProcessorTestCases.json#create_table" - }, - { - "id": "otel_dotnet.json.alter_table", - "dialect": "CONSERVATIVE", - "input": "ALTER TABLE MyTable ADD Name varchar(255)", - "source": "otel-dotnet:SqlProcessorTestCases.json#alter_table" - }, - { - "id": "otel_dotnet.json.drop_table", - "dialect": "CONSERVATIVE", - "input": "DROP TABLE MyTable", - "source": "otel-dotnet:SqlProcessorTestCases.json#drop_table" - }, - { - "id": "otel_dotnet.create_table_trailing_identifier.01", - "dialect": "CONSERVATIVE", - "input": "CREATE TABLE XXX", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_CreateTableWithTrailingIdentifier_DoesNotThrow" - }, { "id": "otel_dotnet.line_comment_crlf.01", "dialect": "CONSERVATIVE", @@ -5130,24 +2002,6 @@ "secrets": ["se'cret-'name"], "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DollarQuotedString_SanitizesLiteral[2]" }, - { - "id": "otel_dotnet.lone_dollar.01", - "dialect": "CONSERVATIVE", - "input": "SELECT $IDENTITY FROM t", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoneDollarSign_IsNotTreatedAsDollarQuote[1]" - }, - { - "id": "otel_dotnet.lone_dollar.02", - "dialect": "CONSERVATIVE", - "input": "SELECT a WHERE b = $1", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoneDollarSign_IsNotTreatedAsDollarQuote[2]" - }, - { - "id": "otel_dotnet.dollar_tag_digit.01", - "dialect": "postgresql", - "input": "SELECT a WHERE b = $1$not-a-secret$1$", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DollarQuoteTagStartingWithDigit_IsNotTreatedAsDollarQuote" - }, { "id": "otel_dotnet.unterminated_dollar.01", "dialect": "postgresql", @@ -5155,12 +2009,6 @@ "secrets": ["secret-name"], "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_UnterminatedDollarQuotedString_SanitizesLiteral" }, - { - "id": "otel_dotnet.double_quoted_identifier.01", - "dialect": "postgresql", - "input": "SELECT * FROM t WHERE c = \"identifier_or_mysql_string\"", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_DoubleQuotedString_IsPreservedAsIdentifier" - }, { "id": "otel_dotnet.double_quoted_backslash_dialect.01", "dialect": "mysql", @@ -5567,12 +2415,6 @@ "secrets": ["Pa55w0rd!"], "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[8]" }, - { - "id": "otel_dotnet.login_or_user_name.09", - "dialect": "sqlserver", - "input": "CREATE USER \"\" X", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserName_IsSanitized[9]" - }, { "id": "otel_dotnet.login_escaped_brackets_max_length.01", "dialect": "sqlserver", @@ -5594,30 +2436,6 @@ "secrets": ["]]]]]]]]]]]]"], "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_LoginOrUserNameWithEscapedBracketsAtMaximumLength_IsSanitized[3]" }, - { - "id": "otel_dotnet.keyword_first_character.01", - "dialect": "CONSERVATIVE", - "input": "SELECT a Xrom b", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_WordWhichOnlyDiffersFromKeywordByFirstCharacter_IsNotKeyword[1]" - }, - { - "id": "otel_dotnet.keyword_first_character.02", - "dialect": "CONSERVATIVE", - "input": "SELECT Prom FROM Events", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_WordWhichOnlyDiffersFromKeywordByFirstCharacter_IsNotKeyword[2]" - }, - { - "id": "otel_dotnet.keyword_first_character.03", - "dialect": "CONSERVATIVE", - "input": "SELECT * FROM Orders Xoin Customers", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_WordWhichOnlyDiffersFromKeywordByFirstCharacter_IsNotKeyword[3]" - }, - { - "id": "otel_dotnet.keyword_first_character.04", - "dialect": "CONSERVATIVE", - "input": "Xelect * FROM Orders", - "source": "otel-dotnet:SqlProcessorTests.cs#GetSanitizedSql_WordWhichOnlyDiffersFromKeywordByFirstCharacter_IsNotKeyword[4]" - }, { "id": "otel_dotnet.string_after_summary_limit.01", "dialect": "CONSERVATIVE", diff --git a/sentry/src/test/resources/sql/known-leaks.txt b/sentry/src/test/resources/sql/known-leaks.txt index 505e95d725a..c1bd0cccb2b 100644 --- a/sentry/src/test/resources/sql/known-leaks.txt +++ b/sentry/src/test/resources/sql/known-leaks.txt @@ -124,7 +124,6 @@ otel_java.sanitize_sensitive.012 otel_java.simplify_sql.123 otel_java.simplify_sql.125 otel_java.vendor_specific_syntax.008 -size.limit.dcl_before_credential.postgresql unrecognized.after_semicolon unrecognized.after_semicolon.backtick_name.mysql unrecognized.after_semicolon.bracket_name.sqlserver From ef036431307e751949e2185536bbd0b2aef23029 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Fri, 27 Nov 2026 08:33:51 +0100 Subject: [PATCH 3/4] fix(sql): Map more JDBC subprotocols to db.system.name and keep the notice commit in sync --- .github/workflows/check-vendored-otel-sql.yml | 2 ++ scripts/sync-otel-sql.sh | 19 +++++++++++++++++-- sentry/build.gradle.kts | 8 ++++++-- .../java/io/sentry/util/sql/SqlSpanData.java | 10 ++++++++-- .../io/sentry/util/sql/SqlSpanDataTest.kt | 3 +++ 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-vendored-otel-sql.yml b/.github/workflows/check-vendored-otel-sql.yml index c9a11de8fd9..4b1efcf900d 100644 --- a/.github/workflows/check-vendored-otel-sql.yml +++ b/.github/workflows/check-vendored-otel-sql.yml @@ -2,6 +2,8 @@ name: 'Check vendored OpenTelemetry SQL grammar' on: pull_request: paths: + - '.github/workflows/check-vendored-otel-sql.yml' + - 'THIRD_PARTY_NOTICES.md' - 'scripts/sync-otel-sql.sh' - 'sentry/src/main/jflex/**' - 'sentry/src/main/java/io/sentry/vendor/otel/sql/**' diff --git a/scripts/sync-otel-sql.sh b/scripts/sync-otel-sql.sh index 03b0d9cd71b..09ffc1b4c8c 100755 --- a/scripts/sync-otel-sql.sh +++ b/scripts/sync-otel-sql.sh @@ -4,6 +4,7 @@ # sentry/src/main/jflex/SqlSanitizer.jflex grammar; JFlex generates AutoSqlSanitizer # sentry/src/main/java/io/sentry/vendor/otel/sql/ SqlQuery, SqlDialect, StringUtils # sentry/src/main/java/io/sentry/vendor/otel/sql/UPSTREAM repository, commit and paths +# THIRD_PARTY_NOTICES.md commit in the "SQL grammar" entry # # Usage: # scripts/sync-otel-sql.sh vendor the files at (commit, tag or branch), print @@ -23,6 +24,9 @@ repository="open-telemetry/opentelemetry-java-instrumentation" root="$(git rev-parse --show-toplevel)" vendor_dir="$root/sentry/src/main/java/io/sentry/vendor/otel/sql" meta="$vendor_dir/UPSTREAM" +notices="$root/THIRD_PARTY_NOTICES.md" +# The commit in the notice entry for the grammar; \S+ is the em dash in the heading. +notice_re='(## OpenTelemetry Java Instrumentation \S+ SQL grammar \(Apache 2\.0\)\n\n\*\*Source:\*\* \S+ \(Commit: )[0-9a-f]{40}' # Upstream path -> vendored path, relative to the repository roots. paths=( @@ -161,7 +165,8 @@ resolve() { echo "$ref" return fi - lines="$(git ls-remote "https://github.com/$repository.git")" || die "could not list refs" + lines="$(git ls-remote --heads --tags "https://github.com/$repository.git")" || + die "could not list refs" # A peeled annotated tag (^{}) names the commit; then a lightweight tag; then a branch. for name in "refs/tags/$ref^{}" "refs/tags/$ref" "refs/heads/$ref"; do awk -v name="$name" '$2 == name { print $1; found = 1 } END { exit !found }' <<<"$lines" && @@ -209,6 +214,12 @@ check() { echo "check failed: $meta differs from what the script writes" >&2 failed=1 fi + cp "$notices" "$tmp/notices" + label="THIRD_PARTY_NOTICES.md" rewrite "$tmp/notices" "s/$notice_re/\${1}$commit/" + if ! diff -u "$notices" "$tmp/notices" >&2; then + echo "check failed: the SQL grammar entry in $notices does not name commit $commit" >&2 + failed=1 + fi if ((failed)); then echo "Vendored files must only change through scripts/sync-otel-sql.sh." >&2 return 1 @@ -226,11 +237,15 @@ sync() { # shellcheck disable=SC2064 trap "rm -rf '$tmp'" EXIT derive "$commit" "$tmp" + # Rewritten in the temporary directory first, so a missing entry fails before any file changes. + cp "$notices" "$tmp/notices" + label="THIRD_PARTY_NOTICES.md" rewrite "$tmp/notices" "s/$notice_re/\${1}$commit/" for i in "${!paths[@]}"; do mkdir -p "$(dirname "$root/${targets[$i]}")" cp "$tmp/out/$i" "$root/${targets[$i]}" done cp "$tmp/out/UPSTREAM" "$meta" + cp "$tmp/notices" "$notices" echo "vendored $repository at $commit" if [[ -n "$old_commit" && "$old_commit" != "$commit" ]]; then @@ -246,7 +261,7 @@ sync() { case "${1:-}" in --check) check ;; - "" | -h | --help) sed -n '2,20p' "$0" | sed 's/^# \{0,1\}//' ;; + "" | -h | --help) sed -n '2,21p' "$0" | sed 's/^# \{0,1\}//' ;; -*) die "unknown option: $1" ;; *) sync "$1" ;; esac diff --git a/sentry/build.gradle.kts b/sentry/build.gradle.kts index 6967100d7ba..24faa84a776 100644 --- a/sentry/build.gradle.kts +++ b/sentry/build.gradle.kts @@ -20,7 +20,11 @@ tasks.named("compileKotlin") { } // Build-time only: JFlex generates the SQL lexer; the generated code has no runtime dependency. -val jflex: Configuration = configurations.create("jflex") +val jflex: Configuration = + configurations.create("jflex") { + isCanBeConsumed = false + isCanBeResolved = true + } dependencies { jflex(libs.jflex) @@ -79,7 +83,7 @@ val generateJflex = description = "Generates the SQL lexer from src/main/jflex/SqlSanitizer.jflex." classpath(jflex) mainClass.set("jflex.Main") - inputs.file(jflexSourceFile) + inputs.file(jflexSourceFile).withPathSensitivity(PathSensitivity.RELATIVE) outputs.dir(jflexOutputDir) // Locals, not the script's vals: lambdas that reference script vals capture the script object, // which the configuration cache cannot serialize. diff --git a/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java b/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java index 406dcc7764a..fe9f2b74f94 100644 --- a/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java +++ b/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java @@ -61,14 +61,16 @@ private SqlSpanData(final @NotNull SqlQuery query) { if (dbSystem == null) { return null; } - switch (dbSystem.toLowerCase(Locale.ROOT)) { + final @NotNull String system = dbSystem.toLowerCase(Locale.ROOT); + switch (system) { case "postgresql": case "mysql": case "mariadb": case "sqlite": case "hsqldb": case "derby": - return dbSystem.toLowerCase(Locale.ROOT); + case "clickhouse": + return system; case "in-memory": return "sqlite"; case "h2": @@ -77,6 +79,10 @@ private SqlSpanData(final @NotNull SqlQuery query) { return "microsoft.sql_server"; case "oracle": return "oracle.db"; + case "db2": + return "ibm.db2"; + case "sap": + return "sap.hana"; case "mongo": return "mongodb"; default: diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt index 3a576f11ffe..a48cb90e090 100644 --- a/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt +++ b/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt @@ -141,6 +141,9 @@ class SqlSpanDataTest { "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, From ccff9f44fb4dd51a004ef54c946d96a4e9df450b Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Fri, 27 Nov 2026 09:30:54 +0100 Subject: [PATCH 4/4] ref(sql): Remove planning references and restating comments --- .github/workflows/check-vendored-otel-sql.yml | 1 - scripts/sync-otel-sql.sh | 8 ++------ sentry/build.gradle.kts | 2 -- .../main/java/io/sentry/util/sql/SqlQuery.java | 1 - .../io/sentry/util/sql/SqlQueryAnalyzer.java | 10 +++++----- .../java/io/sentry/util/sql/SqlSpanData.java | 2 +- .../util/sql/SqlQueryAnalyzerKnownLeakTest.kt | 18 +++++++----------- .../sql/SqlQueryAnalyzerPathologicalTest.kt | 12 +++++------- .../io/sentry/util/sql/SqlQueryAnalyzerTest.kt | 8 +++----- .../java/io/sentry/util/sql/SqlSpanDataTest.kt | 12 ++++-------- sentry/src/test/resources/sql/known-leaks.txt | 5 ++--- 11 files changed, 29 insertions(+), 50 deletions(-) diff --git a/.github/workflows/check-vendored-otel-sql.yml b/.github/workflows/check-vendored-otel-sql.yml index 4b1efcf900d..b4854a85aad 100644 --- a/.github/workflows/check-vendored-otel-sql.yml +++ b/.github/workflows/check-vendored-otel-sql.yml @@ -26,6 +26,5 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha || github.sha }} - # Re-derives the vendored files from upstream at the recorded commit; fails on any hand edit. - name: Compare vendored files with upstream run: ./scripts/sync-otel-sql.sh --check diff --git a/scripts/sync-otel-sql.sh b/scripts/sync-otel-sql.sh index 09ffc1b4c8c..40621e62a0b 100755 --- a/scripts/sync-otel-sql.sh +++ b/scripts/sync-otel-sql.sh @@ -68,8 +68,8 @@ rewrite() { ' "$1" "$2" "${label:-$1}" || exit 1 } -# header : prepends the attribution header (AGENTS.md). -# The upstream license comment stays in place below it. +# Prepends our attribution header. Upstream's license comment stays below it: Apache 2.0 requires +# keeping the original notice. header() { local file="$1" path="$2" commit="$3" changes="$4" tmp tmp="$file.header" @@ -105,7 +105,6 @@ string_utils_import() { rewrite "$1" 's/\bio\.opentelemetry\.instrumentation\.api\.internal\.StringUtils\b/io.sentry.vendor.otel.sql.StringUtils/g' } -# transform : applies every change for upstream file to . transform() { local index="$1" file="$2" commit="$3" semconv="io.opentelemetry.instrumentation.api.incubator.semconv.db" case "$index" in @@ -175,7 +174,6 @@ resolve() { die "$ref is neither a full commit hash, a tag nor a branch" } -# fetch

: downloads the upstream files at into /. fetch() { local commit="$1" dir="$2" i for i in "${!paths[@]}"; do @@ -184,8 +182,6 @@ fetch() { done } -# derive : downloads and transforms the files at ; writes /out/ -# and /out/UPSTREAM. derive() { local commit="$1" dir="$2" i mkdir -p "$dir/new" "$dir/out" diff --git a/sentry/build.gradle.kts b/sentry/build.gradle.kts index 24faa84a776..8146b3af1be 100644 --- a/sentry/build.gradle.kts +++ b/sentry/build.gradle.kts @@ -19,7 +19,6 @@ tasks.named("compileKotlin") { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11 } -// Build-time only: JFlex generates the SQL lexer; the generated code has no runtime dependency. val jflex: Configuration = configurations.create("jflex") { isCanBeConsumed = false @@ -74,7 +73,6 @@ tasks { } } -// Generates the SQL lexer from OpenTelemetry's grammar, vendored by scripts/sync-otel-sql.sh. val jflexSourceFile = layout.projectDirectory.file("src/main/jflex/SqlSanitizer.jflex") val jflexOutputDir = layout.buildDirectory.dir("generated/sources/jflex") diff --git a/sentry/src/main/java/io/sentry/util/sql/SqlQuery.java b/sentry/src/main/java/io/sentry/util/sql/SqlQuery.java index b0f94840c6b..468e8a793ce 100644 --- a/sentry/src/main/java/io/sentry/util/sql/SqlQuery.java +++ b/sentry/src/main/java/io/sentry/util/sql/SqlQuery.java @@ -8,7 +8,6 @@ @ApiStatus.Internal public final class SqlQuery { - /** No text, summary or stored procedure: {@code null} or skipped input, or an internal error. */ static final @NotNull SqlQuery EMPTY = new SqlQuery(null, null, null); private final @Nullable String queryText; diff --git a/sentry/src/main/java/io/sentry/util/sql/SqlQueryAnalyzer.java b/sentry/src/main/java/io/sentry/util/sql/SqlQueryAnalyzer.java index 02dc2fe871f..a40ae71426c 100644 --- a/sentry/src/main/java/io/sentry/util/sql/SqlQueryAnalyzer.java +++ b/sentry/src/main/java/io/sentry/util/sql/SqlQueryAnalyzer.java @@ -20,7 +20,7 @@ public final class SqlQueryAnalyzer { /** - * Longest input that is analyzed, in characters (D66). The grammar reads a single huge literal or + * 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; @@ -57,7 +57,7 @@ private SqlQueryAnalyzer() {} result.getQuerySummary(), result.getStoredProcedureName()); } catch (RuntimeException e) { - // R5: a bug in the vendored grammar must neither crash the caller nor return unsanitized + // 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; @@ -65,9 +65,9 @@ private SqlQueryAnalyzer() {} } /** - * Cuts sanitized text to {@code maxLength} at the last whitespace within the limit (D5), 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. + * 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) { diff --git a/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java b/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java index fe9f2b74f94..a7f046768a5 100644 --- a/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java +++ b/sentry/src/main/java/io/sentry/util/sql/SqlSpanData.java @@ -38,7 +38,7 @@ private SqlSpanData(final @NotNull SqlQuery query) { 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 (D66) have no text by design and are not logged. + // 1 MiB have no text by design and are not logged. if (query.getQueryText() == null && sql != null && sql.length() <= SqlQueryAnalyzer.MAX_INPUT_LENGTH) { diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt index e11f9582a7b..55a37351bbc 100644 --- a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerKnownLeakTest.kt @@ -8,18 +8,14 @@ import java.nio.charset.StandardCharsets import kotlin.test.Test /** - * Owns the accepted leaks of the unchanged grammar (D69): a corpus case (`sql/analyzer-cases.json`) - * leaks when one of its declared secrets appears whole in the text, summary or stored procedure of - * its full input. 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. Prefixes are not analyzed: truncated input does not reach the analyzer - * (patch-inventory section 5). + * 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. The cut is owned by [SqlQueryAnalyzerTest]. - * - * Every case must also give a text: `null` text for analyzed input means an internal failure (R5), - * which would hide a leak. Other robustness of the grammar is upstream's to test (plan 08, Tests). + * 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 { @@ -42,7 +38,7 @@ class SqlQueryAnalyzerKnownLeakTest { fixed.sorted().joinToString("\n"), ) } - assertWithMessage("cases without text, so the analyzer failed internally (R5)") + assertWithMessage("cases without text, so the analyzer failed internally") .that(failed) .isEmpty() assertWithMessage("cases that leak but are not listed in %s", KNOWN_LEAKS) diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt index fa48e53ce84..49c58ded5ab 100644 --- a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerPathologicalTest.kt @@ -14,10 +14,9 @@ import java.util.concurrent.TimeoutException import kotlin.test.Test /** - * Owns what upstream's tests don't cover: deep and large input on a smaller stack than upstream - * runs on. [SqlQueryAnalyzer.analyze] must complete within [TIME_BOUND_MILLIS] on a - * [STACK_SIZE_BYTES] stack, about half of an Android background thread's, without a - * `StackOverflowError` or an internal failure. Outputs are not asserted (plan 08, Tests). + * 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 { @@ -46,7 +45,7 @@ class SqlQueryAnalyzerPathologicalTest { throw AssertionError("$describe threw ${e.cause}", e.cause) } - assertWithMessage("no text, so the analyzer failed internally (R5); %s", describe) + assertWithMessage("no text, so the analyzer failed internally; %s", describe) .that(query.queryText) .isNotNull() } @@ -57,7 +56,6 @@ class SqlQueryAnalyzerPathologicalTest { } private companion object { - /** Bound recorded in plan 01, step 6. */ const val TIME_BOUND_MILLIS = 2_000L /** Below the default for Android background threads and HotSpot (both about 1 MiB). */ @@ -70,7 +68,7 @@ class SqlQueryAnalyzerPathologicalTest { "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 (D66). + // 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 index 78017e4070f..172eebd8ae0 100644 --- a/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt +++ b/sentry/src/test/java/io/sentry/util/sql/SqlQueryAnalyzerTest.kt @@ -9,10 +9,9 @@ import org.mockito.Mockito import org.mockito.kotlin.any /** - * Owns what [SqlQueryAnalyzer] adds around the vendored grammar: `null` and oversized input, the - * length limit, the dialect choice and the error path (plan 08, Wrapper). The grammar's own output - * is not asserted: a sync must not mean re-baselining. Where a test needs a fact about that output - * (that a keyword or an identifier is kept), it checks the fact first as a precondition. + * 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 { @@ -75,7 +74,6 @@ class SqlQueryAnalyzerTest { fun `double quotes are identifiers only for databases that use them so`() { val sql = "SELECT \"Zq9xK7\" FROM t" - // R8: upstream's forDbSystemName, e.g. PostgreSQL yes, MySQL and unknown databases no. 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") diff --git a/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt b/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt index a48cb90e090..c6a7a62577a 100644 --- a/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt +++ b/sentry/src/test/java/io/sentry/util/sql/SqlSpanDataTest.kt @@ -21,9 +21,9 @@ import org.mockito.kotlin.verifyNoInteractions import org.mockito.kotlin.whenever /** - * What the JDBC and Android SQLite integrations put on a span (plan 07, D52): the analyzer's text - * as description and `db.query.text`, summary and stored procedure only when present. The values - * themselves are the analyzer's; [SqlQueryAnalyzerTest] owns those. + * 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 { @@ -90,7 +90,6 @@ class SqlSpanDataTest { @Test fun `query over 1 MiB gives no description, no query keys and no failure log`() { - // D66: skipping is not an analysis failure. val logger = mock() val sql = "SELECT '" + "x".repeat(1024 * 1024) + "'" val data = SqlSpanData.analyze(sql, "postgresql", LIMIT, logger) @@ -123,10 +122,7 @@ class SqlSpanDataTest { assertThat(message.firstValue).doesNotContain("Zq9xK7") } - /** - * D55: the integrations' `db.system` values mapped to OTel semconv `db.system.name` values - * (`semantic-conventions` `model/db/registry.yaml`). Unknown systems get no value. - */ + // Expected values: semantic-conventions model/db/registry.yaml. @Test fun `db system values map to semconv db system names`() { val expected = diff --git a/sentry/src/test/resources/sql/known-leaks.txt b/sentry/src/test/resources/sql/known-leaks.txt index c1bd0cccb2b..a493a2d3d74 100644 --- a/sentry/src/test/resources/sql/known-leaks.txt +++ b/sentry/src/test/resources/sql/known-leaks.txt @@ -1,7 +1,6 @@ # Corpus cases (sql/analyzer-cases.json) whose declared secret appears in the output of the -# unchanged OpenTelemetry grammar for the full input: accepted leaks (D69, plan 08). Owned by -# SqlQueryAnalyzerKnownLeakTest. Fixes go upstream (patch-inventory.md section 5); a case that -# no longer leaks after a sync is reported by the test and removed here. +# 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