This file is indexed.

/usr/lib/ruby/vendor_ruby/octocatalog-diff/util/puppetversion.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
39
40
41
42
# frozen_string_literal: true

# Helper to determine the version of Puppet

require_relative 'scriptrunner'

module OctocatalogDiff
  module Util
    # This is a utility class to determine the version of Puppet.
    class PuppetVersion
      # Determine the version of Puppet.
      # @param puppet [String] Path to Puppet binary
      # @param options [Hash] Options hash as defined in OctocatalogDiff::Catalog::Computed
      # @return [String] Puppet version number
      def self.puppet_version(puppet, options = {})
        raise ArgumentError, 'Puppet binary was not supplied' if puppet.nil?
        raise Errno::ENOENT, "Puppet binary #{puppet} doesn't exist" unless File.file?(puppet)

        sr_opts = {
          default_script: 'puppet/puppet.sh',
          override_script_path: options[:override_script_path]
        }

        script = OctocatalogDiff::Util::ScriptRunner.new(sr_opts)

        sr_run_opts = {
          :logger             => options[:logger],
          :working_dir        => File.dirname(puppet),
          :pass_env_vars      => options[:pass_env_vars],
          :argv               => '--version',
          'OCD_PUPPET_BINARY' => puppet
        }

        output = script.run(sr_run_opts)
        return Regexp.last_match(1) if output =~ /^([\d\.]+)\s*$/
        # :nocov:
        raise "Unable to determine Puppet version: #{script.output}"
        # :nocov:
      end
    end
  end
end