Sha256: d48774d249b5cc59df81d3a387d1df4ad33414a524a0efb3eac46c190acbe114

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

module FastlaneCore
  class CrashReportSanitizer
    class << self
      def sanitize_backtrace(backtrace: nil, type: :unknown)
        if type == :user_error || type == :crash
          # If the crash is from `UI` we only want to include the stack trace
          # up to the point where the crash was initiated.
          # The two stack frames we are dropping are `method_missing` and
          # the call to `crash!` or `user_error!`.
          stack = backtrace.drop(2)
        else
          stack = backtrace
        end

        stack.map do |frame|
          sanitize_string(string: frame)
        end
      end

      def sanitize_string(string: nil)
        string = sanitize_fastlane_gem_path(string: string)
        string = sanitize_gem_home(string: string)
        sanitize_home_dir(string: string)
      end

      private

      def sanitize_home_dir(string: nil)
        string.gsub(Dir.home, '~')
      end

      def sanitize_fastlane_gem_path(string: nil)
        fastlane_path = Gem.loaded_specs['fastlane'].full_gem_path
        return string unless fastlane_path
        string.gsub(fastlane_path, '[fastlane_path]')
      end

      def sanitize_gem_home(string: nil)
        return string unless Gem.dir
        string.gsub(Gem.dir, '[gem_home]')
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fastlane-2.31.0.beta.20170517010031 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_sanitizer.rb
fastlane-2.31.0.beta.20170516010048 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_sanitizer.rb
fastlane-2.31.0.beta.20170515010044 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_sanitizer.rb
fastlane-2.31.0.beta.20170514010036 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_sanitizer.rb
fastlane-2.31.0.beta.20170513010043 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_sanitizer.rb
fastlane-2.30.2 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_sanitizer.rb
fastlane-2.31.0.beta.20170512010054 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_sanitizer.rb
fastlane-2.30.1 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_sanitizer.rb