This file is indexed.

/usr/lib/ruby/vendor_ruby/grape/msgpack.rb is in ruby-grape-msgpack 0.2.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
require 'msgpack'
require 'grape'
require 'grape/msgpack/version'

module Grape
  # Message pack formatter for Grape
  module Msgpack
    module Formatter
      class << self
        def call(obj, env)
          return obj.to_msgpack if obj.respond_to?(:to_msgpack)
          MessagePack.pack(obj)
        end
      end
    end

    module ErrorFormatter
      class << self
        def call(message, backtrace, options = {}, env = nil)
          result = message.is_a?(Hash) ? message : { error: message }
          if (options[:rescue_options] || {})[:backtrace] && backtrace && !backtrace.empty?
            result = result.merge(backtrace: backtrace)
          end
          MessagePack.pack(result)
        end
      end
    end

    module Parser
      class << self
        def call(object, env)
          MessagePack.unpack(object)
        end
      end
    end
  end
end

Grape::Formatter.register(:msgpack, Grape::Msgpack::Formatter)
Grape::ErrorFormatter.register(:msgpack, Grape::Msgpack::ErrorFormatter)
Grape::Parser.register(:msgpack, Grape::Msgpack::Parser)

Grape::ContentTypes::CONTENT_TYPES[:msgpack] = 'application/x-msgpack'

if defined?(Grape::Entity)
  class Grape::Entity
    def to_msgpack(pack = nil)
      if pack
        pack.write(serializable_hash)
      else
        MessagePack.pack(serializable_hash)
      end
    end
  end
end