This file is indexed.

/usr/lib/ruby/vendor_ruby/chef_zero/endpoints/data_bag_endpoint.rb is in chef-zero 2.0.1-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
require 'json'
require 'chef_zero/endpoints/rest_list_endpoint'
require 'chef_zero/endpoints/data_bag_item_endpoint'
require 'chef_zero/rest_error_response'

module ChefZero
  module Endpoints
    # /data/NAME
    class DataBagEndpoint < RestListEndpoint
      def initialize(server)
        super(server, 'id')
      end

      def post(request)
        key = JSON.parse(request.body, :create_additions => false)[identity_key]
        response = super(request)
        if response[0] == 201
          already_json_response(201, DataBagItemEndpoint::populate_defaults(request, request.body, request.rest_path[1], key))
        else
          response
        end
      end

      def get_key(contents)
        data_bag_item = JSON.parse(contents, :create_additions => false)
        if data_bag_item['json_class'] == 'Chef::DataBagItem' && data_bag_item['raw_data']
          data_bag_item['raw_data']['id']
        else
          data_bag_item['id']
        end
      end

      def delete(request)
        key = request.rest_path[1]
        delete_data_dir(request, request.rest_path, :recursive)
        json_response(200, {
          'chef_type' => 'data_bag',
          'json_class' => 'Chef::DataBag',
          'name' => key
        })
      end
    end
  end
end