This file is indexed.

/usr/lib/ruby/vendor_ruby/serverspec/type/x509_private_key.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
require 'time'

module Serverspec::Type
  class X509PrivateKey < Base
    def valid?
      runner_res = @runner.run_command("openssl rsa -in #{name} -check -noout")
      ( runner_res.exit_status == 0 && runner_res.stdout.chomp == 'RSA key ok' )
    end

    def encrypted?
      @runner.run_command("grep -wq \"^Proc-Type.*ENCRYPTED$\" #{name}").exit_status == 0
    end

    def has_matching_certificate?(cert_file)
      mac_op = "openssl sha -sha512"
      h1 = @runner.run_command("openssl x509 -noout -modulus -in #{cert_file} | #{mac_op}")
      h2 = @runner.run_command("openssl rsa -noout -modulus -in #{name} | #{mac_op}")
      (h1.stdout == h2.stdout) && (h1.exit_status == 0) && (h2.exit_status == 0)
    end
  end
end