getsentry / getsentry/sentry-java

Sanitize SQL queries

Aperta
#6,019 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Feature Java Platform: Java Spans
Lingua principale
Kotlin
Stelle
1.4k
Fork
478
Merge medio
2g 23h
PR unite (30g)
67

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Locate the sentry-jdbc and sentry-android-sqlite instrumentation, including the SupportSQLiteOpenHelper and SQLiteDriver entry points, and review OpenTelemetry Java's SqlSanitizerWithSummary.jflex as prior art. Done means all statements produce safe structural span descriptions without exposing literals or comments, with malformed-input, dialect, secret-canary, fuzz/robustness, and performance coverage.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
android, java, kotlin, sql, sqlite
Ambito
databases, observability, security
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.