This file is indexed.

/usr/lib/ruby/vendor_ruby/serverspec/type/package.rb is in ruby-serverspec 2.18.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
module Serverspec::Type
  class Package < Base
    def installed?(provider=nil, version=nil)
      if provider.nil?
        @inspection = Specinfra.command.get(:check_package_is_installed, @name, version)
        @runner.check_package_is_installed(@name, version)
      else
        check_method = "check_package_is_installed_by_#{provider}".to_sym
        @runner.send(check_method, @name, version)
      end
    end

    def version
      ret = @runner.get_package_version(@name).stdout.strip
      if ret.empty?
        nil
      else
        Version.new(ret)
      end
    end

    class Version
      include Comparable

      attr_reader :epoch, :version

      def initialize(val)
        matches = val.match(/^(?:(\d+):)?(\d[0-9a-zA-Z.+:~_-]*)$/)
        if matches.nil?
          raise ArgumentError, "Malformed version number string #{val}"
        end
        @epoch   = matches[1].to_i
        @version = matches[2].to_s
      end

      def <=>(other)
        other = Version.new(other) if other.is_a?(String)
        rv    = @epoch <=> other.epoch
        return rv if rv != 0

        self.ver_array <=> other.ver_array
      end

      def ver_array
        val = @version
        re  = /^(?:(\d+)|(\D+))(.*)$/
        res = []
        until val.empty?
          matches = val.match(re)
          if matches[1].nil?
            # String
            matches[2].to_s.each_byte do |b|
              code_point = defined?("~".ord) ? "~".ord : ?~
              res << ((b == code_point) ? -2 : b)
            end
          else
            # Digits
            res << matches[1].to_i
          end
          val = matches[3].to_s
        end
        res << -1
      end
    end
  end
end