getsentry / getsentry/sentry-java
Sanitize SQL queries
- 主要語言
- Kotlin
- 星號
- 1.4k
- 分支
- 478
- 平均合併
- 3 天 4 小時
- 30 天內合併 PR
- 72
描述
### Problem Statement
Our JDBC and Android SQLite integrations currently use caller-provided SQL directly as the span description. If a customer interpolates values instead of using placeholders, literals and comments can contain PII, credentials, or other sensitive data and are sent to Sentry. The Java SDK has no SQL sanitizer today.
### Solution Brainstorm
Introduce a shared internal SQL analyzer used by sentry-jdbc and sentry-android-sqlite.
Requirements:
- Sanitize every statement, including prepared-statement text.
- Replace literal values with placeholders while preserving SQL structure and existing parameter markers.
- Remove or redact line and block comments.
- Handle database dialect differences conservatively.
- Never fall back to, attach, or log the original query if analysis fails; fail closed to safe structural metadata.
- Use sanitized query text as the transaction-based span description.
- Cover JDBC, SupportSQLiteOpenHelper, and SQLiteDriver instrumentation.
- Add malformed-input, dialect, secret-canary, fuzz/robustness, and performance tests.
OpenTelemetry Java's Apache-2.0 JFlex `SqlSanitizerWithSummary.jflex` is strong prior art and can likely be adapted, but should not be vendored unchanged: OTel preserves comments, may skip sanitization for prepared statements, and preserves unknown fragments. Vendoring requires source attribution and a THIRD_PARTY_NOTICES.md entry.
貢獻指南
研究方向
定位 sentry-jdbc 和 sentry-android-sqlite 的 instrumentation,包括 SupportSQLiteOpenHelper 和 SQLiteDriver 入口點,並參考 OpenTelemetry Java 的 SqlSanitizerWithSummary.jflex。完成標準是所有語句都能產生安全的結構化 span 描述,同時不暴露字面值或註解,並涵蓋格式錯誤輸入、方言、secret-canary、fuzz/穩健性和效能。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- android, java, kotlin, sql, sqlite
- 領域
- databases, observability, security
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 活躍
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100