diff --git a/app/controllers/exceptionhandler_controller.rb b/app/controllers/exceptionhandler_controller.rb index b4c9260..330a5e1 100755 --- a/app/controllers/exceptionhandler_controller.rb +++ b/app/controllers/exceptionhandler_controller.rb @@ -23,7 +23,7 @@ # if not a new bug issue will be generated. class ExceptionhandlerController < ApplicationController unloadable - + helper :exceptionhandler include ExceptionhandlerHelper @@ -34,7 +34,7 @@ class ExceptionhandlerController < ApplicationController if params.size != 2 flash.now[:alert] = "Not enough args" end - + # check to see if the reported project exists elsif Project.find_by_name(params[:app]) == nil flash.now[:error] = "Project Not Found" @@ -42,6 +42,10 @@ class ExceptionhandlerController < ApplicationController else #if we get to this point, then we can try file the incomming report + + #lets deobfuscate the traces + params[:stackTrace] = deobfuscate(params[:stackTrace], params[:package], params[:version]) + params[:cause] = deobfuscate(params[:cause], params[:package], params[:version]) #check to see if the report exists # if we get a report back, then let update it diff --git a/app/helpers/exceptionhandler_helper.rb b/app/helpers/exceptionhandler_helper.rb index f8e4289..31bbd32 100755 --- a/app/helpers/exceptionhandler_helper.rb +++ b/app/helpers/exceptionhandler_helper.rb @@ -1,7 +1,7 @@ # exceptionhandler_helper.rb # @date Feb. 15, 2012 # @author ricky barrette -# @authro twenty codes +# @author twenty codes # # Copyright 2012 Rick Barrette # @@ -18,8 +18,10 @@ # limitations under the License. module ExceptionhandlerHelper + + require 'tempfile' - # Checks the database for exisiting reports + # Checks the database for existing reports # @return existing issue report if existing def check_for_existing_report bug_id = tracker.id @@ -34,8 +36,8 @@ module ExceptionhandlerHelper return nil; end - # checks a specific issue agains params - # @return true if the suppyled issue matches new report args + # checks a specific issue against parameters + # @return true if the supplied issue matches new report args def check_issue(issue) if issue.subject == params[:msg] if check_issue_custom_values(issue) @@ -111,8 +113,8 @@ module ExceptionhandlerHelper return custom_value end - # updates the provided issue with the incomming report - # @returns true if save is sucessful + # updates the provided issue with the incoming report + # @returns true if save is successful def update_report(issue) if params[:description].length > 0 description = issue.description @@ -139,8 +141,8 @@ module ExceptionhandlerHelper return issue.save end - # gets the prodived tracker - # if it doesnt exist, defualt to Bug + # gets the provided tracker + # if it doesn't exist, default to Bug def tracker if(params[:tracker]!= nil) if params[:tracker].length > 0 @@ -152,5 +154,35 @@ module ExceptionhandlerHelper end return Tracker.find_by_name("Bug") end - -end #EOF + + # de obfuscates a trace of there is a map available + def deobfuscate (stacktrace, package, build) + + map = Map.find_by_package(package) + + if map != nil + map = map.find_by_build(build) + end + + if map != nil + + # Save the stack trace to a temp file + # might need to add ruby path + tf = Tempfile.open('stacktrace') + tf.puts stacktrace + + #retrace + Dir.chdir("#{RAILS_ROOT}/vendor/plugins/redmine-exception-handler/public/proguard") do + Open3.popen3("bin/retrace.sh #{RAILS_ROOT}/public/maps/#{map} #{RAILS_ROOT}/#{tf.path}") do |stdrin, stdout, stderr| + output = stderr.read + end + end + + tf.close! + retrun output + else + return stacktrace + end + end + +end diff --git a/app/views/exceptionhandler/index.html.erb b/app/views/exceptionhandler/index.html.erb index 9d3e10a..508e25b 100755 --- a/app/views/exceptionhandler/index.html.erb +++ b/app/views/exceptionhandler/index.html.erb @@ -14,4 +14,6 @@
<%= params.inspect %> +
+ <%= @output %> diff --git a/public/proguard/bin/retrace.sh b/public/proguard/bin/retrace.sh index 85fd314..2b740d6 100755 --- a/public/proguard/bin/retrace.sh +++ b/public/proguard/bin/retrace.sh @@ -9,4 +9,4 @@ PROGUARD_HOME=`dirname "$0"`/.. -java -jar $PROGUARD_HOME/lib/retrace.jar "$@" +/opt/java/jre/bin/java -jar $PROGUARD_HOME/lib/retrace.jar "$@"