Repository navigation
Conversation
|
PR risk: mediumFor commit Main concerns: dependencies customers inherit, public contract, data sent to Sentry. Rules that block low also fired:
This label is a hint for reviewers, not an approval. |
📲 Install BuildsAndroid
|
| if (sql == null || sql.length() > MAX_INPUT_LENGTH) { | ||
| return SqlQuery.EMPTY; | ||
| } | ||
| try { |
There was a problem hiding this comment.
Open question: the try also covers cut(...), so a bug in our own cut is swallowed like a grammar failure. Concretely, a negative maxQueryTextLength throws StringIndexOutOfBoundsException in StringUtils.truncate, which ends up as "no text" plus an "analysis failed" log; 0 returns "".
Option: wrap only OtelSqlSanitizer.sanitize(...), and throw IllegalArgumentException for maxQueryTextLength <= 0. The limit is a constant in our integrations (32 KiB JDBC, 8 KiB Android), not a user setting, so only our own bug can trip it, and the integration tests would catch it immediately. Downside: analyze would no longer be "never throws", and a bad constant would fail the user's query instead of only dropping the span data.
Does narrowing + IllegalArgumentException make sense here, or keep the current fail-closed behaviour?
…otice commit in sync
PR Stack (SQL Sanitizing)
📜 Description
Adds the SQL query analyzer to
sentrycore, built on OpenTelemetry Java Instrumentation's SQL grammar with its rules unchanged. Nothing calls it yet; the JDBC and Android SQLite PRs in this stack wire it in.scripts/sync-otel-sql.sh <ref>vendorsSqlSanitizer.jflex,SqlQuery,SqlDialectandStringUtilsintoio.sentry.vendor.otel.sql. Every change (license header, package, imports, annotations, AutoValue removed,%scanerror) is applied by the script; the pinned upstream commit is inio/sentry/vendor/otel/sql/UPSTREAM.--checkre-derives the files from upstream and fails on any hand edit; a new workflow runs it on PRs that touch these paths.generateJflex); JFlex is not a runtime dependency.AutoValue_SqlQueryandAutoValue_SqlDialectreplace the annotation processor. Error Prone and NullAway now check our classes in the vendor package; the upstream files and the generated lexer stay excluded.io.sentry.util.sql:SqlQueryAnalyzer.analyze(sql, dbSystemName, maxQueryTextLength)skips input over 1 MiB, cuts the output at the last whitespace within the limit, and fails closed on aRuntimeException. PlusSqlQuery,SqlSpanDataand newSpanDataConventionkeys. All new types are@ApiStatus.Internal.💡 Motivation and Context
Maintaining a patched grammar is not viable long term; upstream changes often. Vendoring it unchanged behind a script keeps syncs mechanical, and whatever breaks on an update breaks loudly (script, compile error or test), never silently. Upstream's known leaks are accepted and listed in
sentry/src/test/resources/sql/known-leaks.txt(131 corpus cases); fixes are to be contributed upstream.💚 How did you test it?
./gradlew :sentry:check :sentry:javadoc: 3835 tests, 0 failures.SqlQueryAnalyzerTest) andSqlSpanData; a known-leak test over 361 corpus inputs with declared secrets, analyzed without a length limit, that fails on a leak not in the list and on any internal failure; and three deep or large inputs (nested parens, a 10,001-item IN list, a literal just under 1 MiB) on a 512 KiB stack with a time bound. Grammar robustness beyond that is left to upstream's test suite.scripts/sync-otel-sql.sh --checkpasses; a hand edit to a vendored file makes it fail.runtimeClasspathandruntimeElements; thesentryjar grows by 48 KB.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
JDBC integration (
[SQL Sanitizing 2]), then Android SQLite integration ([SQL Sanitizing 3]).#skip-changelog