This file is indexed.

/usr/lib/ruby/vendor_ruby/octocatalog-diff/catalog-diff/filter/json.rb is in octocatalog-diff 1.5.3-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
# frozen_string_literal: true

require_relative '../filter'

require 'json'

module OctocatalogDiff
  module CatalogDiff
    class Filter
      # Filter based on equivalence of JSON objects for file resources with named extensions.
      class JSON < OctocatalogDiff::CatalogDiff::Filter
        # Public: Actually do the comparison of JSON objects for appropriate resources.
        # Return true if the JSON objects are known to be equivalent. Return false if they
        # are not equivalent, or if equivalence cannot be determined.
        #
        # @param diff_in [OctocatalogDiff::API::V1::Diff] Difference
        # @param _options [Hash] Additional options (there are none for this filter)
        # @return [Boolean] true if this difference is a JSON file with identical objects, false otherwise
        def filtered?(diff, _options = {})
          # Skip additions or removals - focus only on changes
          return false unless diff.change?

          # Make sure we are comparing file content for a file ending in .json extension
          return false unless diff.type == 'File' && diff.structure == %w(parameters content)
          return false unless diff.title =~ /\.json\z/i

          # Attempt to convert the old value and new value into JSON objects. Assuming
          # that doesn't error out, the return value is whether or not they're equal.
          obj_old = ::JSON.parse(diff.old_value)
          obj_new = ::JSON.parse(diff.new_value)
          obj_old == obj_new
        rescue # Rescue everything - if something failed, we aren't sure what's going on, so we'll return false.
          false
        end
      end
    end
  end
end