Skip to content

Make double-quoted literal redaction dialect-aware #62

Description

@coderabbitai

Requested by @KARTIKrocks as a follow-up to PR #61.

Problem

analyzer.Redact treats every double-quoted run as an identifier. This preserves quoted identifiers in PostgreSQL and MySQL with ANSI_QUOTES, but MySQL's default sql_mode accepts double-quoted strings as literals. As a result, a value such as "alice@example.com" can remain in redacted Result.Query and Result.Fingerprint. This gap predates PR #61 and is documented in website/docs/redaction.md. Changing Redact to redact every double-quoted run would remove useful structure from PostgreSQL ORM-generated queries.

Proposed work

  • Define a dialect hint for Analyzer and pass it through the canonical analyzer.Redact / analyzer.Fingerprint path without adding a second normalizer. Keep parser-pluggable analysis and resolve the configuration once during construction, not per query.
  • Redact double-quoted strings when MySQL default-mode semantics apply. Preserve double-quoted identifiers when identifier semantics apply, including PostgreSQL and MySQL ANSI_QUOTES. Preserve backtick identifiers.
  • Update the relevant analyzer/redact.go and analyzer/analyzer.go behavior, tests in analyzer/redact_test.go, and website/docs/redaction.md. Consider integration coverage for parsers/mysqlparser.

Acceptance criteria

  • Under a MySQL default-mode dialect hint, double-quoted literal contents appear in neither redacted Result.Query nor Result.Fingerprint.
  • PostgreSQL ORM-style quoted identifiers remain readable; MySQL ANSI_QUOTES identifiers and backtick identifiers remain intact.
  • Document the behavior when the dialect is unknown, including any remaining exposure, and test the chosen default. Do not regress single-quoted, dollar-quoted, or numeric redaction.
  • Keep the analyzer dependency-light and avoid additional per-query configuration work.

References: #61
Review discussion: #61 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions