SqlRedactor
in package
Redacts user-provided data from SQL strings before they are exported to Application Insights.
The intent is to keep query shape (table names, joins, where-clauses, structural literals) recognizable while removing values that might be personally identifiable: bound parameter values, free-form string literals, emails, IP addresses, and long hex/token-like sequences.
Order matters: pattern-based redactions (emails, IPs, hex) must run before generic string/number masking, otherwise they will already have been collapsed to "?".
Table of Contents
Methods
- redact() : string
- Idempotent redaction. Calling this on already-redacted SQL is a no-op for the value-removal step (a "?" placeholder stays a "?").
Methods
redact()
Idempotent redaction. Calling this on already-redacted SQL is a no-op for the value-removal step (a "?" placeholder stays a "?").
public
static redact(string $sql) : string
Parameters
- $sql : string
-
Raw SQL message (may include bound-param dump)
Return values
string —SQL with literal values replaced by typed placeholders