MCPcopy Create free account
hub / github.com/DataDog/datadog-agent / ObfuscateSQLStringWithOptions

Method ObfuscateSQLStringWithOptions

pkg/obfuscate/sql.go:300–316  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
300func (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
318func (o *Obfuscator) obfuscateSQLString(in string, opts *SQLConfig) (*ObfuscatedQuery, error) {
319 lesc := o.useSQLLiteralEscapes()

Callers 5

ObfuscateSQLStringMethod · 0.95
TestSQLReplaceDigitsFunction · 0.80
ObfuscateSQLFunction · 0.80

Calls 5

ObfuscateWithSQLLexerMethod · 0.95
obfuscateSQLStringMethod · 0.95
CostMethod · 0.80
GetMethod · 0.65
SetMethod · 0.65

Tested by 3

TestSQLReplaceDigitsFunction · 0.64