Module: NewRelic::Security::Instrumentation::Rails::Engine
- Included in:
- Prepend
- Defined in:
- lib/newrelic_security/instrumentation-security/rails/chain.rb,
lib/newrelic_security/instrumentation-security/rails/prepend.rb,
lib/newrelic_security/instrumentation-security/rails/instrumentation.rb
Defined Under Namespace
Instance Method Summary collapse
-
#call_on_enter(env) ⇒ Object
TODO: Revisit this hook for more base level hook which can support any framework by default.
- #call_on_exit(event, retval) ⇒ Object
Instance Method Details
#call_on_enter(env) ⇒ Object
TODO: Revisit this hook for more base level hook which can support any framework by default.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/newrelic_security/instrumentation-security/rails/instrumentation.rb', line 8 def call_on_enter(env) event = nil NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}" return unless NewRelic::Security::Agent.config[:enabled] NewRelic::Security::Agent.config.update_port = NewRelic::Security::Agent::Utils.app_port(env) unless NewRelic::Security::Agent.config[:listen_port] NewRelic::Security::Agent::Utils.get_app_routes(:rails) if NewRelic::Security::Agent.agent.route_map.empty? NewRelic::Security::Agent::Control::HTTPContext.set_context(env) NewRelic::Security::Agent::Utils.parse_fuzz_header(NewRelic::Security::Agent::Control::HTTPContext.get_context) rescue => exception NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}" ensure yield return event end |
#call_on_exit(event, retval) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/newrelic_security/instrumentation-security/rails/instrumentation.rb', line 23 def call_on_exit(event, retval) NewRelic::Security::Agent.logger.debug "OnExit : #{self.class}.#{__method__}" # NewRelic::Security::Agent.logger.debug "\n\nHTTP Context : #{::NewRelic::Agent::Tracer.current_transaction.instance_variable_get(:@security_context_data).inspect}\n\n" NewRelic::Security::Agent::Control::ReflectedXSS.check_xss(NewRelic::Security::Agent::Control::HTTPContext.get_context, retval) if NewRelic::Security::Agent.config[:'security.detection.rxss.enabled'] NewRelic::Security::Agent::Utils.delete_created_files(NewRelic::Security::Agent::Control::HTTPContext.get_context) NewRelic::Security::Agent.agent.error_reporting&.report_unhandled_or_5xx_exceptions(NewRelic::Security::Agent::Control::HTTPContext.get_current_transaction, NewRelic::Security::Agent::Control::HTTPContext.get_context, retval[0]) NewRelic::Security::Agent::Control::HTTPContext.reset_context NewRelic::Security::Agent.logger.debug "Exit event : #{event}" rescue => exception NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}" ensure yield end |