Sanitize SQL queries

未关闭
#6,019 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@lbloder 已经在做这个了。

开始于 2026年10月12日。

评估

难度
5/5
预计耗时
一周以上
新手友好度
42/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, java, kotlin, sql, sqlite

调研方向

定位 sentry-jdbc 和 sentry-android-sqlite 的 instrumentation,包括 SupportSQLiteOpenHelper 和 SQLiteDriver 入口点,并参考 OpenTelemetry Java 的 SqlSanitizerWithSummary.jflex。完成标准是所有语句都能生成安全的结构化 span 描述,同时不暴露字面量或注释,并覆盖格式错误输入、方言、secret-canary、fuzz/健壮性和性能。

由索引模型根据 Issue 内容生成。

描述

Feature Java Platform: Java Spans
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.

主要语言
Kotlin
星标
1.4k
派生
483
平均合并
2 天 2 小时
30 天内合并 PR
202

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-java 的其他 Issue

查看 getsentry/sentry-java 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。