Class: TingYun::Agent::Database::Obfuscator
- Inherits:
-
Object
- Object
- TingYun::Agent::Database::Obfuscator
- Includes:
- Singleton, ObfuscationHelpers
- Defined in:
- lib/ting_yun/agent/database/obfuscator.rb
Overview
混淆器
Defined Under Namespace
Modules: ObfuscationHelpers
Constant Summary collapse
- QUERY_TOO_LARGE_MESSAGE =
"Query too large (over 16k characters) to safely obfuscate"
- FAILED_TO_OBFUSCATE_MESSAGE =
"Failed to obfuscate SQL query - quote characters remained after obfuscation"
Constants included from ObfuscationHelpers
ObfuscationHelpers::CASSANDRA_COMPONENTS_REGEX, ObfuscationHelpers::CLEANUP_REGEX, ObfuscationHelpers::COMPONENTS_REGEX_MAP, ObfuscationHelpers::DIALECT_COMPONENTS, ObfuscationHelpers::FALLBACK_REGEX, ObfuscationHelpers::LABEL_LINE_REGEX, ObfuscationHelpers::MYSQL_COMPONENTS_REGEX, ObfuscationHelpers::ORACLE_COMPONENTS_REGEX, ObfuscationHelpers::PLACEHOLDER, ObfuscationHelpers::POSTGRES_COMPONENTS_REGEX, ObfuscationHelpers::QUOTED_STRINGS_REGEX, ObfuscationHelpers::SQLITE_COMPONENTS_REGEX
Instance Attribute Summary collapse
-
#obfuscator ⇒ Object
readonly
Returns the value of attribute obfuscator.
Instance Method Summary collapse
- #default_sql_obfuscator(sql) ⇒ Object
-
#initialize ⇒ Obfuscator
constructor
A new instance of Obfuscator.
- #reset ⇒ Object
Methods included from ObfuscationHelpers
#detect_unmatched_pairs, generate_regex, #obfuscate, #obfuscate_postgres_explain, #obfuscate_single_quote_literals
Constructor Details
#initialize ⇒ Obfuscator
Returns a new instance of Obfuscator.
13 14 15 |
# File 'lib/ting_yun/agent/database/obfuscator.rb', line 13 def initialize reset end |
Instance Attribute Details
#obfuscator ⇒ Object (readonly)
Returns the value of attribute obfuscator.
11 12 13 |
# File 'lib/ting_yun/agent/database/obfuscator.rb', line 11 def obfuscator @obfuscator end |
Instance Method Details
#default_sql_obfuscator(sql) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/ting_yun/agent/database/obfuscator.rb', line 24 def default_sql_obfuscator(sql) stmt = sql.kind_of?(Statement) ? sql : Statement.new(sql) if stmt.sql[-3,3] == '...' return QUERY_TOO_LARGE_MESSAGE end obfuscate(stmt.sql, stmt.adapter).to_s end |
#reset ⇒ Object
17 18 19 |
# File 'lib/ting_yun/agent/database/obfuscator.rb', line 17 def reset @obfuscator = method(:default_sql_obfuscator) end |