This file is indexed.

/usr/lib/ruby/vendor_ruby/chef/resource/chef_node.rb is in ruby-cheffish 4.0.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require 'cheffish'
require 'cheffish/base_resource'
require 'chef/chef_fs/data_handler/node_data_handler'
require 'cheffish/node_properties'

class Chef
  class Resource
    class ChefNode < Cheffish::BaseResource
      resource_name :chef_node

      include Cheffish::NodeProperties

      action :create do
        differences = json_differences(current_json, new_json)

        if current_resource_exists?
          if differences.size > 0
            description = [ "update node #{new_resource.name} at #{rest.url}" ] + differences
            converge_by description do
              rest.put("nodes/#{new_resource.name}", normalize_for_put(new_json))
            end
          end
        else
          description = [ "create node #{new_resource.name} at #{rest.url}" ] + differences
          converge_by description do
            rest.post("nodes", normalize_for_post(new_json))
          end
        end
      end

      action :delete do
        if current_resource_exists?
          converge_by "delete node #{new_resource.name} at #{rest.url}" do
            rest.delete("nodes/#{new_resource.name}")
          end
        end
      end

      action_class.class_eval do
        def load_current_resource
          begin
            @current_resource = json_to_resource(rest.get("nodes/#{new_resource.name}"))
          rescue Net::HTTPServerException => e
            if e.response.code == "404"
              @current_resource = not_found_resource
            else
              raise
            end
          end
        end

        def augment_new_json(json)
          # Preserve tags even if "attributes" was overwritten directly
          json['normal']['tags'] = current_json['normal']['tags'] unless json['normal']['tags']
          # Apply modifiers
          json['run_list'] = apply_run_list_modifiers(new_resource.run_list_modifiers, new_resource.run_list_removers, json['run_list'])
          json['normal'] = apply_modifiers(new_resource.attribute_modifiers, json['normal'])
          # Preserve default/override/automatic even when "complete true"
          json['default'] = current_json['default']
          json['override'] = current_json['override']
          json['automatic'] = current_json['automatic']
          json
        end

        #
        # Helpers
        #

        def resource_class
          Chef::Resource::ChefNode
        end

        def data_handler
          Chef::ChefFS::DataHandler::NodeDataHandler.new
        end

        def keys
          {
            'name' => :name,
            'chef_environment' => :chef_environment,
            'run_list' => :run_list,
            'normal' => :attributes
          }
        end
      end
    end
  end
end