This file is indexed.

/usr/lib/ruby/vendor_ruby/chef_zero/rest_request.rb is in chef-zero 4.5.0-2.

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'rack/request'

module ChefZero
  class RestRequest
    def initialize(env, rest_base_prefix = [])
      @env = env
      @rest_base_prefix = rest_base_prefix
    end

    attr_reader :env
    attr_accessor :rest_base_prefix

    def base_uri
      @base_uri ||= "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}#{env['SCRIPT_NAME']}"
    end

    def base_uri=(value)
      @base_uri = value
    end

    def api_version
      @env['HTTP_X_OPS_SERVER_API_VERSION'] || 0
    end

    def requestor
      @env['HTTP_X_OPS_USERID']
    end

    def method
      @env['REQUEST_METHOD']
    end

    def rest_path
      @rest_path ||= rest_base_prefix + env['PATH_INFO'].split('/').select { |part| part != "" }
    end

    def body=(body)
      @body = body
    end

    def body
      @body ||= env['rack.input'].read
    end

    def query_params
      @query_params ||= begin
        params = Rack::Request.new(env).GET
        params.keys.each do |key|
          params[key] = URI.unescape(params[key])
        end
        params
      end
    end

    def to_s
      result = "#{method} #{rest_path.join('/')}"
      if query_params.size > 0
        result << "?#{query_params.map { |k,v| "#{k}=#{v}" }.join('&') }"
      end
      if body.chomp != ''
        result << "\n--- #{method} BODY ---\n"
        result << body
        result << "\n" if !body.end_with?("\n")
        result << "--- END #{method} BODY ---"
      end
      result
    end
  end
end