Class: Datadog::DI::EL::Compiler Private
- Inherits:
-
Object
- Object
- Datadog::DI::EL::Compiler
- Defined in:
- lib/datadog/di/el/compiler.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
DI Expression Language compiler.
Converts AST in probe definitions into Expression objects.
WARNING: this class produces strings that are then eval'd as Ruby code. Input ASTs are user-controlled. As such the compiler must sanitize and escape all input to avoid injection.
Besides quotes and backslashes we must also escape # which is starting string interpolation (#...).
Instance Method Summary collapse
-
#compile(ast) ⇒ Array(String, Array<Regexp>)
private
Compiles
astinto eval'able Ruby source. -
#redaction_identifier(ast) ⇒ String?
private
Returns the identifier that
astdirectly references at its top level, so the message path can redact direct references the same way snapshots redact by name.
Instance Method Details
#compile(ast) ⇒ Array(String, Array<Regexp>)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Compiles ast into eval'able Ruby source.
Returns the compiled source and companion compiled Regexp objects.
28 29 30 31 32 |
# File 'lib/datadog/di/el/compiler.rb', line 28 def compile(ast) regexps = [] code = compile_partial(ast, regexps) [code, regexps] end |
#redaction_identifier(ast) ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the identifier that ast directly references at its top
level, so the message path can redact direct references the same
way snapshots redact by name.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/datadog/di/el/compiler.rb', line 42 def redaction_identifier(ast) return nil unless Hash === ast && ast.length == 1 entry = ast.first return nil if entry.nil? op, target = entry case op when "ref" target if String === target when "getmember", "index" target[1] if Array === target && target.length == 2 && String === target[1] end end |