Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError isn't caught when parsing parameter hashes (via eval) #175

Closed
searlm opened this issue Oct 29, 2014 · 1 comment · Fixed by #176
Closed

SyntaxError isn't caught when parsing parameter hashes (via eval) #175

searlm opened this issue Oct 29, 2014 · 1 comment · Fixed by #176

Comments

@searlm
Copy link

searlm commented Oct 29, 2014

If a parameter hash is truncated in a rails log, or is otherwise malformed, the resulting SyntaxError doesn't get caught by convert_eval, and request-log-analyzer crashes.

Example log entry:

2014-09-08T23:37:03+00:00 blah blah[foo]: [ID blah user.info] Parameters: {"foo"=>{"bar"=>"baz

I'm not sure what other exceptions are possible/expected here, so I just rescued Exception, as seen in the diff below.

diff --git a/lib/request_log_analyzer/request.rb b/lib/request_log_analyzer/request.rb
index 06bf46b..9cb6a81 100644
--- a/lib/request_log_analyzer/request.rb
+++ b/lib/request_log_analyzer/request.rb
@@ -58,7 +58,7 @@ module RequestLogAnalyzer
       # Converts :eval field, which should evaluate to a hash.
       def convert_eval(value, _capture_definition)
         eval(sanitize_parameters(value)).reduce({}) { |h, (k, v)| h[k.to_sym] = v; h }
-      rescue
+      rescue Exception
         nil
       end
@wvanbergen
Copy link
Owner

I don't really like this solution. This will also catch OutOfMemory exceptions, Interrupt exceptions, and a whole bunch of stuff that we shouldn't catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants