ObfuscateSQLStringWithOptions accepts an optional SQLOptions to change the behavior of the obfuscator to quantize and obfuscate the given input SQL query string. Quantization removes some elements such as comments and aliases and obfuscation attempts to hide sensitive information in strings and numb
(in string, opts *SQLConfig)
| 298 | // to quantize and obfuscate the given input SQL query string. Quantization removes some elements such as comments |
| 299 | // and aliases and obfuscation attempts to hide sensitive information in strings and numbers by redacting them. |
| 300 | func (o *Obfuscator) ObfuscateSQLStringWithOptions(in string, opts *SQLConfig) (*ObfuscatedQuery, error) { |
| 301 | if opts.ObfuscationMode != "" { |
| 302 | // If obfuscation mode is specified, we will use go-sqllexer pkg |
| 303 | // to obfuscate (and normalize) the query. |
| 304 | return o.ObfuscateWithSQLLexer(in, opts) |
| 305 | } |
| 306 | |
| 307 | if v, ok := o.queryCache.Get(in); ok { |
| 308 | return v.(*ObfuscatedQuery), nil |
| 309 | } |
| 310 | oq, err := o.obfuscateSQLString(in, opts) |
| 311 | if err != nil { |
| 312 | return oq, err |
| 313 | } |
| 314 | o.queryCache.Set(in, oq, oq.Cost()) |
| 315 | return oq, nil |
| 316 | } |
| 317 | |
| 318 | func (o *Obfuscator) obfuscateSQLString(in string, opts *SQLConfig) (*ObfuscatedQuery, error) { |
| 319 | lesc := o.useSQLLiteralEscapes() |