Module: Rollbar::RequestDataExtractor
- Included in:
- Middleware::Js, Middleware::Rack, Middleware::Rack::Builder, Middleware::Rails::RollbarMiddleware, Rollbar::Rails::ControllerMethods
- Defined in:
- lib/rollbar/request_data_extractor.rb
Constant Summary collapse
- ALLOWED_HEADERS_REGEX =
/^HTTP_|^CONTENT_TYPE$|^CONTENT_LENGTH$/.freeze
- ALLOWED_BODY_PARSEABLE_METHODS =
%w[POST PUT PATCH DELETE].freeze
Instance Method Summary collapse
- #extract_person_data_from_controller(env) ⇒ Object
- #extract_request_data_from_rack(env) ⇒ Object
- #scrub_params(params, sensitive_params) ⇒ Object
- #scrub_url(url, sensitive_params) ⇒ Object
Instance Method Details
#extract_person_data_from_controller(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rollbar/request_data_extractor.rb', line 16 def extract_person_data_from_controller(env) if env.key?('rollbar.person_data') person_data = env['rollbar.person_data'] || {} else controller = env['action_controller.instance'] person_data = begin controller. rescue StandardError {} end end person_data end |
#extract_request_data_from_rack(env) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rollbar/request_data_extractor.rb', line 31 def extract_request_data_from_rack(env) rack_req = ::Rack::Request.new(env) sensitive_params = sensitive_params_list(env) get_params = scrub_params((rack_req), sensitive_params) post_params = scrub_params((rack_req), sensitive_params) raw_body_params = scrub_params(mergeable_raw_body_params(rack_req), sensitive_params) = scrub_params((rack_req), sensitive_params) session = scrub_params((env), sensitive_params) route_params = scrub_params((env), sensitive_params) url = scrub_url((env), sensitive_params) data = { :url => url, :params => route_params, :GET => get_params, :POST => post_params, :body => Rollbar::JSON.dump(raw_body_params), :user_ip => (env), :headers => (env), :cookies => , :session => session, :method => (env) } if env['action_dispatch.request_id'] data[:request_id] = env['action_dispatch.request_id'] end data end |
#scrub_params(params, sensitive_params) ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/rollbar/request_data_extractor.rb', line 79 def scrub_params(params, sensitive_params) = { :params => params, :config => Rollbar.configuration.scrub_fields, :extra_fields => sensitive_params, :whitelist => Rollbar.configuration.scrub_whitelist } Rollbar::Scrubbers::Params.call() end |
#scrub_url(url, sensitive_params) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rollbar/request_data_extractor.rb', line 66 def scrub_url(url, sensitive_params) = { :url => url, :scrub_fields => Array(Rollbar.configuration.scrub_fields) + sensitive_params, :scrub_user => Rollbar.configuration.scrub_user, :scrub_password => Rollbar.configuration.scrub_password, :randomize_scrub_length => Rollbar.configuration.randomize_scrub_length, :whitelist => Rollbar.configuration.scrub_whitelist } Rollbar::Scrubbers::URL.call() end |